// resize fix for ns4
var origWidth, origHeight;
if (at.ns4) {
	origWidth = window.innerWidth; origHeight = window.innerHeight;
	window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
}

// avoid error of passing event object in older browsers
//if (nodyn) event = "nope";

// settings for tooltip 

var tipWidth 		= 250;
var offX			= 0;	//12// how far from mouse to show tip
var offY			= 0;	//12
var tipFontFamily 	= "Verdana, arial, helvetica, sans-serif";
var tipFontSize		= "8pt";
var tipFontColor	= "#000000";
var tipBgColor 		= "#FFFFCC";
var tipBorderColor 	= "#000000";
var tipBorderWidth 	= 1;
var tipBorderStyle 	= "solid";
var tipPadding		= 4;
var tipTimer        = null;

var tipEventPageX   = 0;
var tipEventPageY   = 0;
var tipEventClientX = 0;
var tipEventClientY = 0;
var tipCancelled    = false;

var tooltip, tipcss;

function createTooltip() {

	if (nodyn) return;
	tooltip = (at.ns4)? document.tipDiv.document: (at.ie4)? document.all['tipDiv']: (at.ie5||at.ie55||at.ie6||at.ie7||at.ns5||at.ns7)? document.getElementById('tipDiv'): null;
	tipcss = (at.ns4)? document.tipDiv: tooltip.style;
	if (at.ie4||at.ie5||at.ns5||at.ie6||at.ie7||at.ns7) {	// ns4 would lose all this on rewrites
		tipcss.width = tipWidth+"px";
		tipcss.fontFamily = tipFontFamily;
		tipcss.fontSize = tipFontSize;
		tipcss.color = tipFontColor;
		tipcss.backgroundColor = tipBgColor;
		tipcss.borderColor = tipBorderColor;
		tipcss.borderWidth = tipBorderWidth+"px";
		tipcss.padding = tipPadding+"px";
		tipcss.borderStyle = tipBorderStyle;
		tipcss.zIndex= "500"
	}
}

function Tooltip_doTooltip(evt,txt) {
    
    if (evt == null) return;
    
    tipEventPageX   = evt.pageX;
    tipEventPageY   = evt.pageY;
    tipEventClientX = evt.clientX;
    tipEventClientY = evt.clientY;
    
    var cmdToolTip_show = "Tooltip_show('" + txt + "')";
    
    tipCancelled = false;
    
	tipTimer = setTimeout(cmdToolTip_show, 1500);    
}

function Tooltip_show(txt) {

	if (!tooltip) return;
	
	if (tipCancelled == false) {
		
	    if (at.ns4) {
		    tip = '<table bgcolor="' + tipBorderColor + '" width="' + tipWidth + '" cellspacing="0" cellpadding="' + tipBorderWidth + '" border="0"><tr><td><table bgcolor="' + tipBgColor + '" width="100%" cellspacing="0" cellpadding="' + tipPadding + '" border="0"><tr><td><span style="font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + tipFontColor + ';">' + txt  + '</span></td></tr></table></td></tr></table>';
		    tooltip.write(tip);
		    tooltip.close();
		    tipcss.left = tipEventPageX + offX;
		    tipcss.top = tipEventPageY + offY;
	    } else if (at.ie4||at.ie5||at.ie6||at.ie7) {
		           tip = txt;
	 	           tooltip.innerHTML = tip;
		           tipcss.pixelLeft = tipEventClientX + offX + document.body.scrollLeft;
		           tipcss.pixelTop = tipEventClientY + offY + document.body.scrollTop;
	           } else if (at.ns5||at.ns7) {
		                  tip = txt;
	 	                  tooltip.innerHTML = tip;
		                  tipcss.left = tipEventPageX + offX;
		                  tipcss.top  = tipEventPageY + offY;
	           }
	           
	    tipcss.visibility='visible';
	}
	
	tipEventPageX   = 0;
    tipEventPageY   = 0;
    tipEventClientX = 0;
    tipEventClientY = 0;
		
	clearTimeout(tipTimer);
	tipTimer = null;
}

function Tooltip_hide() {

	if (!tooltip) return;
	
	tipCancelled = true;
	
	clearTimeout(tipTimer);
	tipTimer = null;
	
	tipcss.visibility = "hidden";
}

function Tooltip_doKey(e) {
  whichASC = (at.ns4) ? e.which : event.keyCode;
  whichKey = String.fromCharCode(whichASC).toLowerCase();
  alert(whichKey);

 // switch (whichKey) {
//    case "a":
//      ...statements to execute if "a" is pressed...
//      break;
//    case "b":
//      ...statements to execute if "b" is pressed...
//      break;
//    case "1":
//      ...statements to execute if "1" is pressed...
//      break;
//    case "2":
//      ...statements to execute if "2" is pressed...
//      break;
//    case "y":
//      ...statements to execute if "y" is pressed...
//      break;
//    case "n":
//      ...statements to execute if "n" is pressed...
//      break;
//    .
//    . other alphanumeric "hot" keys
//    .
//    default:
//    ...statements to execute if no "hot" key is pressed...
//    or include the break statement:
//    break;
//  }
}

