
var offsetfrommouse=[15,15]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var displayduration=0; //duration in seconds image should remain visible. 0 for always.
var help_box_height = 270;	// maximum image size.

if (document.getElementById || document.all){
	document.write('<div id="help_box">');
	document.write('</div>');
}

function gethelpobj(){
if (document.getElementById)
return document.getElementById("help_box").style
else if (document.all)
return document.all.help_box.style
}

function gethelpobjnostyle(){
if (document.getElementById)
return document.getElementById("help_box")
else if (document.all)
return document.all.help_box
}


function truebody(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function show_help(table,field,alias,description){

	document.onmousemove=followmouse;

	newHTML = '<div style="padding: 5px; background-color: #FFF; border: 1px solid #888;" id="trailInnerDiv">';
	if(string_trim(alias)!='')
	{
		newHTML = newHTML + '<h2 style="font-size:14px;">' + alias + '</h2>';
	}else
	{
		newHTML = newHTML + '<h2 style="font-size:14px;>' + table + ' :: ' + field + '</h2>';
	}
	
	newHTML = newHTML + description+ '<br/>';
	newHTML = newHTML + '</div>';
	gethelpobjnostyle().innerHTML = newHTML;
	gethelpobj().display="inline";
}



function hide_help(){
	gethelpobj().innerHTML = " ";
	gethelpobj().display="none"
	document.onmousemove=""
	gethelpobj().left="-500px"

}

function followmouse(e){var xcoord=offsetfrommouse[0]
var ycoord=offsetfrommouse[1]
var docwidth=document.all?truebody().scrollLeft+truebody().clientWidth:pageXOffset+window.innerWidth-15
var docheight=document.all?Math.min(truebody().scrollHeight,truebody().clientHeight):Math.min(window.innerHeight)
if(typeof e!="undefined"){if(docwidth-e.pageX<380){xcoord=e.pageX-xcoord-400;}else{xcoord+=e.pageX;}
if(docheight-e.pageY<(help_box_height+110)){if(document.body){scrollTop=Math.max(truebody().scrollTop,document.body.scrollTop);}else{scrollTop=truebody().scrollTop;}
ycoord+=e.pageY-Math.max(0,(110+help_box_height+e.pageY-docheight-scrollTop));}else{ycoord+=e.pageY;}}else if(typeof window.event!="undefined"){if(docwidth-event.clientX<380){xcoord=event.clientX+truebody().scrollLeft-xcoord-400;}else{xcoord+=truebody().scrollLeft+event.clientX}
if(docheight-event.clientY<(help_box_height+110)){ycoord+=event.clientY+truebody().scrollTop-Math.max(0,(110+help_box_height+event.clientY-docheight));}else{ycoord+=truebody().scrollTop+event.clientY;}}
if(ycoord<0){ycoord=ycoord*-1;}
gethelpobj().left=xcoord+"px"
gethelpobj().top=ycoord+"px"}
function followmouseBatch(e){var xcoord=offsetfrommouse[0]
var ycoord=offsetfrommouse[1]
var docwidth=document.all?truebody().scrollLeft+truebody().clientWidth:pageXOffset+window.innerWidth-15
var docheight=document.all?Math.min(truebody().scrollHeight,truebody().clientHeight):Math.min(window.innerHeight)
var trailInnerDiv=$('trailInnerDiv');var currentimageheight=trailInnerDiv.offsetHeight;var help_box_height=trailInnerDiv.offsetWidth;scrollPos=Position.realOffset(truebody());if(typeof e!="undefined"){if(docwidth-e.pageX<380){xcoord=e.pageX-xcoord-400;}else{xcoord+=e.pageX;}
if((e.pageY-scrollPos[1])+currentimageheight>docheight){ycoord=-ycoord+(e.pageY-currentimageheight);}else{ycoord+=e.pageY;}}else if(typeof window.event!="undefined"){if(event.clientX+help_box_height>docwidth){xcoord=-xcoord+((event.clientX+scrollPos[0])-help_box_height);}else{xcoord+=(event.clientX+scrollPos[0]);}
if(event.clientY+currentimageheight>docheight){ycoord=-ycoord+((event.clientY+scrollPos[1])-currentimageheight);}else{ycoord+=(event.clientY+scrollPos[1]);}}
if(ycoord<0){ycoord=ycoord*-1;}
gethelpobj().left=xcoord+"px"
gethelpobj().top=ycoord+"px"}
