////////////////////////////////////////////////////////////////////////////////////
//
//  Pop messenger  Ver 1.0
//  By Hiroyuki Nakamoto (nakamoto@hyogo-kg.go.jp) Last modified 2000-09-24
//
////////////////////////////////////////////////////////////////////////////////////

// ================================================================
// ----- Configuration -----

// Main background color (the large area)
   if (typeof fcolor == 'undefined') { var fcolor = "#EEEEEE";}
	
// Border color and color of caption
   if (typeof backcolor == 'undefined') { var backcolor = "#999999";}
	
// Text color
   if (typeof textcolor == 'undefined') { var textcolor = "#333333";}
	
// Color of the caption text
   if (typeof capcolor == 'undefined') { var capcolor = "#FFFFFF";}
	
// Color of "Close" when using Sticky
   if (typeof closecolor == 'undefined') { var closecolor = "#999999";}
	
	
// Width of the popups in pixels
   if (typeof width == 'undefined') { var width = "130";}
	
// How thick the border should be in pixels
   if (typeof border == 'undefined') { var border = "1";}
	
	
// How many pixels to the right/left of the cursor to show the popup
   if (typeof offsetx == 'undefined') { var offsetx = 10;}
	
// How many pixels to the below the cursor to show the popup
   if (typeof offsety == 'undefined') { var offsety = 10;}
	
// ----- Configuration -----
// ================================================================

// Microsoft Stupidity Check.
if (br=="ie4") {
	if (navigator.userAgent.indexOf('MSIE 5')>0) {
		ie5 = true;
	} else {
		ie5 = false; }
} else {
	ie5 = false;
}

var x = 0;
var y = 0;
var snow = 0;
var sw = 0;
var cnt = 0;
var dir = 1;
if(br=="ns4" || br=="ns6") {
   var pop = document.popper;
   document.captureEvents(Event.MOUSEMOVE);
}
if(br=="ie4") {
   var pop = popper.style;
}
document.onmousemove = mouseMove;

// Public functions to be used on pages.

// Simple popup right
function drs(text) {
	dts(1,text);
}

// Caption popup right
function drc(text, title) {
	dtc(1,text,title);
}

// Sticky caption right
function src(text,title) {
	stc(1,text,title);
}

// Simple popup left
function dls(text) {
	dts(0,text);
}

// Caption popup left
function dlc(text, title) {
	dtc(0,text,title);
}

// Sticky caption left
function slc(text,title) {
	stc(0,text,title);
}

// Simple popup center
function dcs(text) {
	dts(2,text);
}

// Caption popup center
function dcc(text, title) {
	dtc(2,text,title);
}

// Sticky caption center
function scc(text,title) {
	stc(2,text,title);
}

// Image popup right
function ipr(text) {
	dir=1;
	disp(text);
}

// Clears popups if appropriate
function nd() {
	if ( cnt >= 1 ) { sw = 0 };
	if ( br=="ns4" || br=="ie4" ) {
		if ( sw == 0 ) {
			snow = 0;
			hidePopper(pop);
		} else {
			cnt++;
		}
	}
}

// Non public functions. These are called by other functions etc.

// Simple popup
function dts(d,text) {
	txt = "<TABLE WIDTH="+width+" BORDER=0 CELLPADDING="+border+" CELLSPACING=0 BGCOLOR=\""+backcolor+"\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR=\""+fcolor+"\"><TR><TD><FONT COLOR=\""+textcolor+"\" SIZE=\"-1\">"+text+"</FONT></TD></TR></TABLE></TD></TR></TABLE>"
	layerWrite(txt);
	dir = d;
	disp(text);
}

// Caption popup
function dtc(d,text, title) {
	txt = "<TABLE WIDTH="+width+" BORDER=0 CELLPADDING="+border+" CELLSPACING=0 BGCOLOR=\""+backcolor+"\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD><SPAN ID=\"PTT\"><B><FONT COLOR=\""+capcolor+"\">"+title+"</FONT></B></SPAN></TD></TR></TABLE><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR=\""+fcolor+"\"><TR><TD><SPAN ID=\"PST\"><FONT COLOR=\""+textcolor+"\">"+text+"</FONT><SPAN></TD></TR></TABLE></TD></TR></TABLE>"
	layerWrite(txt);
	dir = d;
	disp(text);
}

// Sticky
function stc(d,text, title) {
	sw = 1;
	cnt = 0;
	txt = "<TABLE WIDTH="+width+" BORDER=0 CELLPADDING="+border+" CELLSPACING=0 BGCOLOR=\""+backcolor+"\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD><SPAN ID=\"PTT\"><B><FONT COLOR=\""+capcolor+"\">"+title+"</FONT></B></SPAN></TD><TD ALIGN=RIGHT><A HREF=\"/\" onMousePop=\"cClick();\" ID=\"PCL\"><FONT COLOR=\""+closecolor+"\">Close</FONT></A></TD></TR></TABLE><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR=\""+fcolor+"\"><TR><TD><SPAN ID=\"PST\"><FONT COLOR=\""+textcolor+"\">"+text+"</FONT><SPAN></TD></TR></TABLE></TD></TR></TABLE>"
	layerWrite(txt);
	dir = d;
	disp(text);
	snow = 0;
}

// Common calls
function disp(text) {
   if ( br=="ns4" || br=="ie4" ) {
      if (snow == 0) {
         if (dir == 2) { // Center
            moveTo(pop,x+offsetx-(width/2),y+offsety);
         }
         if (dir == 1) { // Right
            moveTo(pop,x+offsetx,y+offsety);
         }
         if (dir == 0) { // Left
            moveTo(pop,x-offsetx-width,y+offsety);
         }
         showPopper(pop);
         snow = 1;
      }
   }
// Here you can make the text goto the statusbar.
   window.status=text;
}

// Moves the layer
function mouseMove(e) {
   if (br=="ns4") {x=e.pageX; y=e.pageY;}
   if (br=="ie4" && !ie5) {x=event.x; y=event.y;}
   if (ie5) {x=event.x+document.body.scrollLeft; y=event.y+document.body.scrollTop;}
   if (snow) {
      if (dir == 2) { // Center
         moveTo(pop,x+offsetx-(width/2),y+offsety);
      }
      if (dir == 1) { // Right
         moveTo(pop,x+offsetx,y+offsety);
      }
      if (dir == 0) { // Left
         moveTo(pop,x-offsetx-width,y+offsety);
      }
   }
}

// The Close onMousePop function for Sticky
function cClick() {
   hidePopper(pop);
   sw=0;
}

// Writes to a layer
function layerWrite(txt) {
   if (br=="ns4") {
      var lyr = document.popper.document;
      lyr.write(txt);
      lyr.close();
   }
   else if (br="ie4") document.all["popper"].innerHTML = txt;
}

// Make an popper visible
function showPopper(obj) {
   if (br=="ns4") obj.visibility = "show"
   else if (br=="ie4") obj.visibility = "visible";
}

// Hides an popper
function hidePopper(obj) {
   if (br=="ns4") obj.visibility = "hide"
   else if (br=="ie4") obj.visibility = "hidden";
   window.status = "";
}

// Move a layer
function moveTo(obj,xL,yL) {
   obj.left = xL
   obj.top = yL
}

