/*
Image w/ description tooltip- By Dynamic Web Coding (www.dyn-web.com)
Copyright 2002 by Sharon Paine
Visit http://www.dynamicdrive.com for this script
*/

/* IMPORTANT: Put script after tooltip div or
	 put tooltip div just before </BODY>. */

var tn_map_dom = (document.getElementById) ? true : false;
var tn_map_ns5 = ((navigator.userAgent.indexOf("Gecko")>-1) && tn_map_dom) ? true: false;
var tn_map_ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && tn_map_dom) ? true : false;
var tn_map_ns4 = (document.layers && !tn_map_dom) ? true : false;
var tn_map_ie4 = (document.all && !tn_map_dom) ? true : false;
var tn_map_nodyn = (!tn_map_ns5 && !tn_map_ns4 && !tn_map_ie4 && !tn_map_ie5) ? true : false;

// resize fix for ns4
var tn_map_origWidth, tn_map_origHeight;
if (tn_map_ns4) {
	tn_map_origWidth = window.innerWidth; tn_map_origHeight = window.innerHeight;
	window.onresize = function() { if (window.innerWidth != tn_map_origWidth || window.innerHeight != tn_map_origHeight) history.go(0); }
}

// avoid error of passing event object in older browsers
if (tn_map_nodyn) { event = "nope" }

///////////////////////  CUSTOMIZE HERE   ////////////////////
// settings for tooltip
// Do you want tip to move when mouse moves over link?
var tn_map_tipFollowMouse= true;
// Be sure to set tipWidth wide enough for widest image
var tn_map_tipWidth= 100;
var tn_map_offX= -28;	// how far from mouse to show tip
var tn_map_offY= 18;
var tn_map_tipFontFamily= "Tahoma";
var tn_map_tipFontSize= "6pt";
// 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 tn_map_tipFontColor= "#205A62";
var tn_map_tipBgColor= "transparent";
var tn_map_tipBorderColor= "transparent";
var tn_map_tipBorderWidth= 1;
var tn_map_tipBorderStyle= "none";
var tn_map_tipPadding= 0;

// tooltip content goes here (image, description, optional bgColor, optional textcolor)
var tn_map_messages = new Array();
// multi-dimensional arrays containing:
// image and text for tooltip
// optional: bgColor and color to be sent to tooltip

tn_map_messages[0] = new Array('Knox','','');
tn_map_messages[1] = new Array('Cocke','','');
tn_map_messages[2] = new Array('Dickson','','');
tn_map_messages[3] = new Array('Gibson','','');
tn_map_messages[4] = new Array('Chester','','');
tn_map_messages[5] = new Array('Fentress','','');
tn_map_messages[6] = new Array('Fayette','','');
tn_map_messages[7] = new Array('Hickman','','');


////////////////////  END OF CUSTOMIZATION AREA  ///////////////////

// to layout image and text, 2-row table, image centered in top cell
// these go in var tip in doTooltip function
// startStr goes before image, midStr goes between image and text
var tn_map_startStr = '<table width="' + tn_map_tipWidth + '"><tr><td align="center" width="100%"><font size="2"><b>';
var tn_map_midStr = '</b></font></td></tr><tr><td valign="top">';
var tn_map_endStr = '</td></tr></table>';

////////////////////////////////////////////////////////////
//  initTip	- initialization for tooltip.
//		Global variables for tooltip.
//		Set styles for all but ns4.
//		Set up mousemove capture if tipFollowMouse set true.
////////////////////////////////////////////////////////////
var tn_map_tooltip, tn_map_tipcss;
function tn_map_initTip() {
	if (tn_map_nodyn) return;
	tn_map_tooltip = (ns4)? document.tn_map_tipDiv.document: (ie4)? document.all['tn_map_tipDiv']: (ie5||ns5)? document.getElementById('tn_map_tipDiv'): null;
	tn_map_tipcss = (ns4)? document.tn_map_tipDiv: tn_map_tooltip.style;
	if (ie4||ie5||ns5) {	// ns4 would lose all this on rewrites
		tn_map_tipcss.width = tn_map_tipWidth+"px";
		tn_map_tipcss.fontFamily = tn_map_tipFontFamily;
		tn_map_tipcss.fontSize = tn_map_tipFontSize;
		tn_map_tipcss.color = tn_map_tipFontColor;
		tn_map_tipcss.backgroundColor = tn_map_tipBgColor;
		tn_map_tipcss.borderColor = tn_map_tipBorderColor;
		tn_map_tipcss.borderWidth = tn_map_tipBorderWidth+"px";
		tn_map_tipcss.padding = tn_map_tipPadding+"px";
		tn_map_tipcss.borderStyle = tn_map_tipBorderStyle;
	}
	if (tn_map_tooltip&&tn_map_tipFollowMouse) {
		if (tn_map_ns4) document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove = trackMouse;
	}
}

window.onload = tn_map_initTip;

/////////////////////////////////////////////////
//  doTooltip function
//			Assembles content for tooltip and writes
//			it to tipDiv
/////////////////////////////////////////////////
var tn_map_t1,tn_map_t2;	// for setTimeouts
var tn_map_tipOn = false;	// check if over tooltip link
function tn_map_doTooltip(tn_map_evt,num) {
	if (!tn_map_tooltip) return;
	if (tn_map_t1) clearTimeout(tn_map_t1);	if (tn_map_t2) clearTimeout(tn_map_t2);
	tn_map_tipOn = true;
	// set colors if included in messages array
	if (tn_map_messages[num][2])	var curBgColor = tn_map_messages[num][2];
	else tn_map_curBgColor = tn_map_tipBgColor;
	if (tn_map_messages[num][3])	var curFontColor = tn_map_messages[num][3];
	else tn_map_curFontColor = tn_map_tipFontColor;
	if (tn_map_ns4) {
		var tn_map_tip = '<table bgcolor="' + tn_map_tipBorderColor + '" width="' + tn_map_tipWidth + '" cellspacing="0" cellpadding="' + tn_map_tipBorderWidth + '" border="0"><tr><td><table bgcolor="' + tn_map_curBgColor + '" width="100%" cellspacing="0" cellpadding="' + tn_map_tipPadding + '" border="0"><tr><td>'+ tn_map_startStr + tn_map_messages[num][0] + tn_map_midStr + '<span style="font-family:' + tn_map_tipFontFamily + '; font-size:' + tn_map_tipFontSize + '; color:' + tn_map_curFontColor + ';">' + tn_map_messages[num][1] + '</span>' + tn_map_endStr + '</td></tr></table></td></tr></table>';
		tn_map_tooltip.write(tn_map_tip);
		tn_map_tooltip.close();
	} else if (tn_map_ie4||tn_map_ie5||tn_map_ns5) {
		var tn_map_tip = tn_map_startStr + tn_map_messages[num][0] + tn_map_midStr + '<span style="font-family:' + tn_map_tipFontFamily + '; font-size:' + tn_map_tipFontSize + '; color:' + tn_map_curFontColor + ';">' + tn_map_messages[num][1] + '</span>' + tn_map_endStr;
		tn_map_tipcss.backgroundColor = tn_map_curBgColor;
	 	tn_map_tooltip.innerHTML = tn_map_tip;
	}
	if (!tn_map_tipFollowMouse) tn_map_positionTip(tn_map_evt);
	else tn_map_t1=setTimeout("tn_map_tipcss.visibility='visible'",100);
}

var tn_map_mouseX, tn_map_mouseY;
function tn_map_trackMouse(tn_map_evt) {
	tn_map_mouseX = (tn_map_ns4||tn_map_ns5)? tn_map_evt.pageX: window.event.clientX + document.body.scrollLeft;
	tn_map_mouseY = (tn_map_ns4||tn_map_ns5)? tn_map_evt.pageY: window.event.clientY + document.body.scrollTop;
	if (tn_map_tipOn) positionTip(tn_map_evt);
}

/////////////////////////////////////////////////////////////
//  positionTip function
//		If tipFollowMouse set false, so trackMouse 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 tn_map_positionTip(tn_map_evt) {
	if (!tn_map_tipFollowMouse) {
		tn_map_mouseX = (tn_map_ns4||tn_map_ns5)? tn_map_evt.pageX: window.event.clientX + document.body.scrollLeft;
		tn_map_mouseY = (tn_map_ns4||tn_map_ns5)? tn_map_evt.pageY: window.event.clientY + document.body.scrollTop;
	}
	// tooltip width and height
	var tn_map_tpWd = (tn_map_ns4)? tn_map_tooltip.width: (tn_map_ie4||tn_map_ie5)? tn_map_tooltip.clientWidth: tn_map_tooltip.offsetWidth;
	var tn_map_tpHt = (tn_map_ns4)? tn_map_tooltip.height: (tn_map_ie4||tn_map_ie5)? tn_map_tooltip.clientHeight: tn_map_tooltip.offsetHeight;
	// document area in view (subtract scrollbar width for ns)
	var tn_map_winWd = (tn_map_ns4||tn_map_ns5)? window.innerWidth-20+window.pageXOffset: document.body.clientWidth+document.body.scrollLeft;
	var tn_map_winHt = (tn_map_ns4||tn_map_ns5)? window.innerHeight-20+window.pageYOffset: document.body.clientHeight+document.body.scrollTop;
	// check mouse position against tip and window dimensions
	// and position the tooltip
	if ((tn_map_mouseX+tn_map_offX+tn_map_tpWd)>tn_map_winWd)
		tn_map_tipcss.left = (tn_map_ns4)? tn_map_mouseX-(tn_map_tpWd+tn_map_offX): tn_map_mouseX-(tn_map_tpWd+tn_map_offX)+"px";
	else tn_map_tipcss.left = (tn_map_ns4)? tn_map_mouseX+tn_map_offX: tn_map_mouseX+tn_map_offX+"px";
	if ((tn_map_mouseY+tn_map_offY+tn_map_tpHt)>tn_map_winHt)
		tn_map_tipcss.top = (tn_map_ns4)? tn_map_winHt-(tn_map_tpHt+offY): tn_map_winHt-(tn_map_tpHt+offY)+"px";
	else tn_map_tipcss.top = (tn_map_ns4)? tn_map_mouseY+tn_map_offY: tn_map_mouseY+tn_map_offY+"px";
	if (!tn_map_tipFollowMouse) tn_map_t1=setTimeout("tn_map_tipcss.visibility='visible'",100);
}

function tn_map_hideTip() {
    if (!tn_map_tooltip) return;
	tn_map_t2=setTimeout("tn_map_tipcss.visibility='hidden'",100);
	tn_map_tipOn = false;
}

