// Tooltip support scripts 1.0 -----------------------------------------------------
// courtesy http://www.guistuff.com/

function webtooltip_init(){
// this has hardcoded colour values, we could read these from the stylesheet I think
// (or have them passed as params when this function is called)
// stu@cyberdelix added some stuff including customisable table width and border colour
	ContentInfo = "";
	topColor = "#899BCF";
	subColor = "#C0C0C0";
 tablewidth = 200;
	tablebordercolour = "#102C72";
	mouse_X=0;
	mouse_Y=0;
	tip_active = 0;
}

function update_tip_pos(){
	document.getElementById('WebToolTip').style.left = mouse_X + 20;
	document.getElementById('WebToolTip').style.top  = mouse_Y;
}

function getMouseXY(e) {
	if (ie) { // grab the x-y pos.s if browser is IE
		mouse_X = event.clientX + document.body.scrollLeft;
		mouse_Y = event.clientY + document.body.scrollTop;
	} else { // grab the x-y pos.s if browser is NS
		mouse_X = e.pageX;
		mouse_Y = e.pageY;
	}
	if (mouse_X < 0){mouse_X = 0;}
	if (mouse_Y < 0){mouse_Y = 0;}
// the below is disabled to stop constant redraws - now, the tip only redraws during a call to tip_it
//	if(tip_active){update_tip_pos();}
}

function EnterContent(TTitle, TContent){
// actually we overwrite whatever is supplied in TTitle with our own value, below
 TTitle = '<table border="0" width="100%" cellspacing="0" cellpadding="0"><tr><td align=left><img src=images/info.gif></td><td align=right class=legaltext>Information</td></tr></table>';
	ContentInfo = '<table border="0" width="' + tablewidth + '" cellspacing="0" cellpadding="0">'+
	'<tr><td width="100%" bgcolor="' + tablebordercolour + '">'+
	'<table border="0" width="100%" cellspacing="1" cellpadding="5">'+
	'<tr><td width="100%" bgcolor='+topColor+'>'+  			// this draws the titlebar
//	'<span class="tooltiptitle"> '+TTitle+'</span>'+
// the line above is commented out cos we apply our own stylesheet in TTitle so we just output it instead (line below)
	''+TTitle+''+
	'</td></tr>'+
	'<tr><td width="100%" bgcolor='+subColor+'>'+			 // this draws the content area
	'<span class="tooltipcontent">'+TContent+'</span>'+
	'</td></tr>'+
	'</table>'+
	'</td></tr>'+
	'</table>';
}

function tip_it(which, TTitle, TContent){
	if(which){
		update_tip_pos();
		tip_active = 1;
		EnterContent(TTitle, TContent);
		document.getElementById('WebToolTip').style.visibility = "visible";
//document.getElementById('WebToolTip').style.display = "inline";
		document.getElementById('WebToolTip').innerHTML = ContentInfo;
	}else{
		tip_active = 0;
		document.getElementById('WebToolTip').style.visibility = "hidden";
//document.getElementById('WebToolTip').style.display = "none";
		document.getElementById('WebToolTip').innerHTML = "";
	}
}


