/***********************************************
* Image w/ description tooltip- By Dynamic Web Coding (www.dyn-web.com)
* Copyright 2002-2007 by Sharon Paine
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

/* IMPORTANT: Put script after tooltip div or 
	 put tooltip div just before </BODY>. */

var Tip_dom = (document.getElementById) ? true : false;
var Tip_ns5 = (!document.all && Tip_dom || window.opera) ? true: false;
var Tip_ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && Tip_dom) ? true : false;
var Tip_ie4 = (document.all && !Tip_dom) ? true : false;
var Tip_nodyn = (!Tip_ns5 && !Tip_ie4 && !Tip_ie5 && !Tip_dom) ? true : false;

var origWidth, origHeight;

// avoid error of passing event object in older browsers
if (Tip_nodyn) { event = "nope" }

///////////////////////  CUSTOMIZE HERE   ////////////////////
// settings for tooltip 
// Do you want tip to move when mouse moves over link?
var tip_FollowMouse= true;	
// Be sure to set tip_Width wide enough for widest image
var tip_Width= 200;
var Tip_offX= 20;	// how far from mouse to show tip
var Tip_offY= 12; 
var Tip_tipFontFamily= "Verdana, arial, helvetica, sans-serif";
var tip_FontSize= "8pt";
// set default text color and background color for tooltip here
// individual tooltips can have their own (set in messages arrays)
// but don't have to
var tip_FontColor= "#000000";
var tip_BgColor= "#DDECFF"; 
var tip_BorderColor= "#000080";
var tip_BorderWidth= 3;
var tip_BorderStyle= "ridge";
var tip_Padding= 4;

// tooltip content goes here (image, description, optional bgColor, optional textcolor)
var messages = new Array();
////////////////////  END OF CUSTOMIZATION AREA  ///////////////////

// preload images that are to appear in tooltip
// from arrays above
if (document.images) {
	var theImgs = new Array();
	for (var i=0; i<messages.length; i++) {
  	theImgs[i] = new Image();
		theImgs[i].src = messages[i][0];
  }
}

// to layout image and text, 2-row table, image centered in top cell
// these go in var tip in doTool_tip function
// startStr goes before image, midStr goes between image and text
var startStr = '<table width="' + tip_Width + '"><tr><td align="center" width="100%"><img src="';
var midStr = '" border="0"></td></tr><tr><td valign="top">';
var endStr = '</td></tr></table>';

////////////////////////////////////////////////////////////
//  initTip	- initialization for tooltip.
//		Global variables for tooltip. 
//		Set styles
//		Set up mousemove capture if tip_FollowMouse set true.
////////////////////////////////////////////////////////////
var tooltip, tipcss;
function initTip() {
	if (Tip_nodyn) return;
	tooltip = (Tip_ie4)? document.all['tip_Div']: (Tip_ie5||Tip_ns5)? document.getElementById('tip_Div'): null;
	tipcss = tooltip.style;
	if (Tip_ie4||Tip_ie5||Tip_ns5) {	// ns4 would lose all this on rewrites
		tipcss.width = tip_Width+"px";
		tipcss.fontFamily = Tip_tipFontFamily;
		tipcss.fontSize = tip_FontSize;
		tipcss.color = tip_FontColor;
		tipcss.backgroundColor = tip_BgColor;
		tipcss.borderColor = tip_BorderColor;
		tipcss.borderWidth = tip_BorderWidth+"px";
		tipcss.padding = tip_Padding+"px";
		tipcss.borderStyle = tip_BorderStyle;
	}
	if (tooltip&&tip_FollowMouse) {
		document.onmousemove = track_Mouse;
	}
}

window.onload = initTip;

/////////////////////////////////////////////////
//  doTool_tip function
//			Assembles content for tooltip and writes 
//			it to tip_Div
/////////////////////////////////////////////////
var t1,t2;	// for setTimeouts
var tipOn = false;	// check if over tooltip link
function doTool_tip(evt,num) {
	if (!tooltip) return;
	if (t1) clearTimeout(t1);	if (t2) clearTimeout(t2);
	tipOn = true;
	// set colors if included in messages array
	if (messages[num][2])	var curBgColor = messages[num][2];
	else curBgColor = tip_BgColor;
	if (messages[num][3])	var curFontColor = messages[num][3];
	else curFontColor = tip_FontColor;
	if (Tip_ie4||Tip_ie5||Tip_ns5) {
		var tip = startStr + messages[num][0] + midStr + '<span style="font-family:' + Tip_tipFontFamily + '; font-size:' + tip_FontSize + '; color:' + curFontColor + ';">' + messages[num][1] + '</span>' + endStr;
		tipcss.backgroundColor = curBgColor;
	 	tooltip.innerHTML = tip;
	}
	if (!tip_FollowMouse) position_Tip(evt);
	else t1=setTimeout("tipcss.visibility='visible'",100);
}

var mouseX, mouseY;
function track_Mouse(evt) {
	standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body //create reference to common "body" across doctypes
	mouseX = (Tip_ns5)? evt.pageX: window.event.clientX + standardbody.scrollLeft;
	mouseY = (Tip_ns5)? evt.pageY: window.event.clientY + standardbody.scrollTop;
	if (tipOn) position_Tip(evt);
}

/////////////////////////////////////////////////////////////
//  position_Tip function
//		If tip_FollowMouse set false, so track_Mouse function
//		not being used, get position of mouseover event.
//		Calculations use mouseover event position, 
//		offset amounts and tooltip width to position
//		tooltip within window.
/////////////////////////////////////////////////////////////
function position_Tip(evt) {
	if (!tip_FollowMouse) {
		standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
		mouseX = (Tip_ns5)? evt.pageX: window.event.clientX + standardbody.scrollLeft;
		mouseY = (Tip_ns5)? evt.pageY: window.event.clientY + standardbody.scrollTop;
	}
	// tooltip width and height
	var tpWd = (Tip_ie4||Tip_ie5)? tooltip.clientWidth: tooltip.offsetWidth;
	var tpHt = (Tip_ie4||Tip_ie5)? tooltip.clientHeight: tooltip.offsetHeight;
	// document area in view (subtract scrollbar width for ns)
	var winWd = (Tip_ns5)? window.innerWidth-20+window.pageXOffset: standardbody.clientWidth+standardbody.scrollLeft;
	var winHt = (Tip_ns5)? window.innerHeight-20+window.pageYOffset: standardbody.clientHeight+standardbody.scrollTop;
	// check mouse position against tip and window dimensions
	// and position the tooltip 
	if ((mouseX+Tip_offX+tpWd)>winWd) 
		tipcss.left = mouseX-(tpWd+Tip_offX)+"px";
	else tipcss.left = mouseX+Tip_offX+"px";
	if ((mouseY+Tip_offY+tpHt)>winHt) 
		tipcss.top = winHt-(tpHt+Tip_offY)+"px";
	else tipcss.top = mouseY+Tip_offY+"px";
	if (!tip_FollowMouse) t1=setTimeout("tipcss.visibility='visible'",100);
}

function hide_Tip() {
	if (!tooltip) return;
	t2=setTimeout("tipcss.visibility='hidden'",100);
	tipOn = false;
}
document.write('<div id="tip_Div" style="position:absolute; visibility:hidden; z-index:300"></div>')