/* Originally by Erik Bosrup (erik@bosrup.com) 31/03/99
   Modified by Alex Charlton - Click Media Inc. 26/02/02
*/

//var width = "200";
var border = "3";
var offsetx = 20;
var offsety = 2;

var fcolor = "#FFFFFF";
//var backcolor = "#333399";
var textcolor = "#000000";
var capcolor = "#FFFFFF";
var closecolor = "#FFFFFF";

function checkBrowser() {
	ns4 = (document.layers)? true:false
	ie4 = (document.all)? true:false
	ns6 = (document.getElementById)? true:false;

	// Microsoft Stupidity Check.
	if (ie4) {
		if (navigator.userAgent.indexOf('MSIE 5')>0 || (navigator.userAgent.indexOf('MSIE 6') > 0)) {
			ie5 = true;
		} else {
			ie5 = false;
		}

		if (ns6) {
			ns6 = false;
		}
	} else {
		ie5 = false;
	}

	if ( (ns4) || (ie4) || (ns6)) {
		if (ns4) over = document.overDiv
		if (ie4) over = overDiv.style
		if (ns6) over = document.getElementById("overDiv")
		document.onmousemove = mouseMove
		if (ns4) document.captureEvents(Event.MOUSEMOVE)
	}
}

var x = 0;
var y = 0;
var snow = 0;
var sw = 0;
var cnt = 0;
var dir = 1;

// Caption popup center
function ToolTip(text, title) {
	checkBrowser();
	Caption(dir,text,title);
}

function ToolTipColor(text, title, col) {
	checkBrowser();
	CaptionColor(dir,text,title, col);
}

// Clears popups if appropriate
function HideTip() {

	if ( cnt >= 1 ) { sw = 0 };
	if ( (ns4) || (ie4) || (ns6)) {
		if ( sw == 0 ) {
			hideObject(over);
			snow = 0;
		} else {
			cnt++;
		}
	}
	window.status = '';
}


// Caption popup
function CaptionColor(d,text,title, col) {
    backcolor = col;
	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(title);
}

// Caption popup
function Caption(d,text,title) {
    var backcolor = "#990099";
	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(title);
}

// Common calls
function Disp(title) {
	if ( (ns4) || (ie4) || (ns6)) {
    	if (snow == 0) 	{
			if (dir == 2) { // Center
				moveTo(over,x+offsetx-(width/2),y+offsety);
			}
			if (dir == 1) { // Right
				moveTo(over,x+offsetx,y+offsety);
			}
			if (dir == 0) { // Left
				moveTo(over,x-offsetx-width,y+offsety);
			}
			showObject(over);
			snow = 1;
		}
	}
	window.status = title;
}

// Moves the layer
function mouseMove(e) {
	if (ns4 || ns6) {x=e.pageX; y=e.pageY;}
	if (ie4) {x=event.x; y=event.y;}
	if (ie5) {x=event.x+document.body.scrollLeft; y=event.y+document.body.scrollTop;}

	if (x > (width/2)) {
		dir = 0;
	} else {
		dir = 1;
	}	
	
	if (snow) {
		if (dir == 2) { // Center
			moveTo(over,x+offsetx-(width/2),y+offsety);
		}
		if (dir == 1) { // Right
			moveTo(over,x+offsetx,y+offsety);
		}
		if (dir == 0) { // Left
			moveTo(over,x-offsetx-width,y+offsety);
		}
	}
}

// Writes to a layer
function LayerWrite(txt) {
        if (ns4) {
                var lyr = document.overDiv.document
                lyr.write(txt)
                lyr.close()
        }
        else if (ie4) document.all["overDiv"].innerHTML = txt
		else if (ns6) document.getElementById("overDiv").innerHTML = txt

}

// Make an object visible
function showObject(obj) {
        if (ns4) obj.visibility = "show"
        else if (ie4) obj.visibility = "visible"
		else if (ns6) obj.style.visibility = "visible";

}

// Make an object hidden
function hideObject(obj) {
		if (ns4) obj.visibility = "hide"
		else if (ie4) obj.visibility = "hidden"
		else if (ns6) obj.style.visibility = "hidden";
		window.status = '';
}


// Move a layer
function moveTo(obj,xL,yL) {

	obj.left = xL
	obj.top = yL

	if (ns6) {
			obj.style.left = xL + "px";
			obj.style.top = yL+ "px";
	}
}