var offsetfromcursorX=12; //Customize x offset of tooltip
var offsetfromcursorY=10; //Customize y offset of tooltip

var offsetdivfrompointerX=12; //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=14; //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

document.write('<div id="dhtmltooltip">tooltip</div>'); //write out tooltip DIV

//write out divs to hold pointers
document.write('<img id="upper_left_arrow" src="http://shiasource.com.s25867.gridserver.com/images/tooltip_top_left.gif">');
document.write('<img id="upper_right_arrow" src="http://shiasource.com.s25867.gridserver.com/images/tooltip_top_right.gif">');
document.write('<img id="lower_left_arrow" src="http://shiasource.com.s25867.gridserver.com/images/tooltip_btm_left.gif">');
document.write('<img id="lower_right_arrow" src="http://shiasource.com.s25867.gridserver.com/images/tooltip_btm_right.gif">');
//getting ie and ns6 variables
var ie=document.all;
var ns6=document.getElementById && !document.all;

//initially don't want to show
var enabletip=false;
if (ie||ns6) { var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""; }
var pointerobj;

function ietruebody(){ return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body; }
//function that actually enables the tooltip
function tip(thetext, thewidth){
if (ns6||ie){
if (typeof thewidth!="undefined") {
tipobj.style.width=thewidth+"px";
}
tipobj.innerHTML=thetext;
enabletip=true;
return false;
}
}
//event called on mouse movement
function positiontip(e){

//if tip is enabled
if (enabletip){

//hide old arrow
pointerobj.style.visibility="hidden";

//get current position
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;

//Find out how close the mouse is to the corner of the window
var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20;
var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20;

//get edge information
var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX;
var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY;
var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000;

//variable to see if right edge has been reached
var right=false;

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth){

//move the horizontal position of the menu to the left by it's width
tipobj.style.left=curX-tipobj.offsetWidth+"px";
right = true;

//place on right side of tip object
pointerobj.style.left=curX-offsetfromcursorX-(2*offsetdivfrompointerX)+"px";

}
else if (curX<leftedge) {
tipobj.style.left="5px";
}
else{
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px";

//place on left side of tip object
pointerobj.style.left=curX+offsetfromcursorX+"px";
}

//if bottom needs to be displayed
if (bottomedge<tipobj.offsetHeight){

//initial height for tip object
tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px";

//if right display lower right, otherwise display left
if(right) {
pointerobj=document.all? document.all["lower_right_arrow"] : document.getElementById? document.getElementById("lower_right_arrow") : "";
}
else {
pointerobj=document.all? document.all["lower_left_arrow"] : document.getElementById? document.getElementById("lower_left_arrow") : "";
}

pointerobj.style.top=curY-offsetdivfrompointerY+3+"px";
}

//otherwise display upper ones
else{

//initial height for tip object
tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px";

//if right, display upper right, if not, display left
if(right) {
pointerobj=document.all? document.all["upper_right_arrow"] : document.getElementById? document.getElementById("upper_right_arrow") : "";
}
else {
pointerobj=document.all? document.all["upper_left_arrow"] : document.getElementById? document.getElementById("upper_left_arrow") : "";
}

//upper position of pointer object
pointerobj.style.top=curY+offsetfromcursorY+"px";

}


//set all to visible
tipobj.style.visibility="visible";
shimit(tipobj);
pointerobj.style.visibility="visible";
}
}

//hides tooltip
function hide_tip(){
if (ns6||ie){

//disable tip
enabletip=false;

//hide all objects
tipobj.style.visibility="hidden";
noshim();
pointerobj.style.visibility="hidden";
}
}
//function initially draws arrows using only CSS
function draw_arrows() {
//initially select upper left
pointerobj=document.all? document.all["upper_left_arrow"] : document.getElementById? document.getElementById("upper_left_arrow") : ""
}
//initially draw out arrows
draw_arrows();

//set onmousemove event to position tip
document.onmousemove=positiontip;

function shimit(obj){
var shimobj=document.getElementById('shim').style;
shimobj.height=obj.offsetHeight+'px'
shimobj.width=obj.offsetWidth+'px'
var obj=obj.style
shimobj.left=obj.left
shimobj.top=obj.top
shimobj.zIndex=99
shimobj.display='block'
}

function noshim(){
document.getElementById('shim').style.display='none';
}

document.write('<iframe id="shim" src="" style="position:absolute;display:none;" scrolling="no" frameborder="0"></iframe>')