/*===========================
CREATED BY: Drew Bolton | dbolton@protravelnetwork.com | icomeinpeace@sbcglobal.net
THIS WILL POP UP A DIV 'TOOLTIP' ON AN EVENT OF CHOICE;
USAGE:
    onmouseover="tip(1,this,event,150,100,'hello');"
        1 = display of 'block' (1), 'none' (0)
        this = reference to itself (leave as is since javascript needs to know what object called the function)
        event = reference for an event listener (leave as is)
        150 = an integer specifying width of tooltip box (div)
        100 = an integer or string specifying height of tooltip. If string, use 'auto'... which is a valid css parameter
        hello = a string value for the tooltip verbage.
============================*/
isDiv=0;
function tip(d,t,e,w,h,v) {
	if(t) {
		try{
			t.style.cursor="pointer";
		}catch(er) {
			//
		}
	}else{
		try{
    		document.getElementById('tipDiv').style.display="none";
    		return false;
		}catch(er) {
            return false;
        }
	}
	var winX=document.body.clientWidth;
	var winY=document.body.clientHeight;
	var isTipDiv=document.getElementById('tipDiv');
	if(isDiv==0 && !isTipDiv) {
        try {
            try{
                var createDiv=document.createElement('<div id=\"tipDiv\" style=\"position: absolute; display: none; background: url(\'images/bg_0.gif\') #efefef; color: #000099; border: solid 4px #000099; padding: 3px; left: 0px; top: 0px; z-index: 11000; text-align: left;\">');//background-color: #6699cc; color: #ffffff; border: solid 2px #000000;
            }catch(err) {
                var createDiv=document.createElement('div');
                createDiv.setAttribute('id','tipDiv');
                createDiv.setAttribute('style','position: absolute; display: none; background: url(\'images/bg_0.gif\') #efefef; color: #000099; border: solid 4px #000099; padding: 3px; left: 0px; top: 0px; z-index: 11000; text-align: left;');
            }
        	document.body.appendChild(createDiv);
        }catch(er) {
            //alert("Javascript could not create a Unique Div for the Tooltip.\nTo use the tooltip functions,\nsimply add a Div to the body with an ID of 'tipDiv'");
            alert("Sorry, could not pull the definition for this.");
            return false;
        }
        isDiv=1;
    }
	if(d==0) {
        try{
    		document.getElementById('tipDiv').style.display="none";
    		return false;
		}catch(er) {
            return false;
        }
	}
	e=(e ? e : window.event);
	var isX=0;
	var findX=t;
	while(findX!=null) {
        isX+=findX.offsetLeft;
		findX=findX.offsetParent;
	}
	var isY=0;
	var findY=t;
	while(findY!=null) {
		isY+=findY.offsetTop;
		findY=findY.offsetParent;
	}
	isX=(e.clientX+15);//isX*1;
		isX=((isX+(w*1))>winX || (isX>(winX/2)) ? (isX-(w+30)) : isX);
	isY=(isY*1)+15;//isY*1;
		isY=((isY+h)>winY ? (isY+(winY-(isY+h+15))) : isY);
	//var gotXY=mousexy(e,isX,isY,w,h);
	/*
	if(!isNaN(v)) {//->IF IS INTEGER, THEN PULL FROM TOOLTIP ARRAY
		try{
			v=tooltip[v];
		}catch(er) {
			alert("There is no Tool Tip Array set.");
			return false;
		}
	}
	*/
	if(createDiv) {
    	document.getElementById('tipDiv').style.width=w+"px";
    	document.getElementById('tipDiv').style.height=(h=="auto" ? h : h+"px");
    	//document.getElementById('tipDiv').style.left=gotXY[0];
    	//document.getElementById('tipDiv').style.top=(gotXY[2]==0 ? (isY+15)+"px" : gotXY[2]+"px");
    	document.getElementById('tipDiv').style.left=isX+"px";
    	document.getElementById('tipDiv').style.top=isY+"px";
    	document.getElementById('tipDiv').innerHTML=unescape(v);
    	document.getElementById('tipDiv').style.display="block";
	}else{
        try{
            document.getElementById('tipDiv').style.width=w+"px";
        	document.getElementById('tipDiv').style.height=(h=="auto" ? h : h+"px");
        	//document.getElementById('tipDiv').style.left=gotXY[0];
        	//document.getElementById('tipDiv').style.top=(gotXY[2]==0 ? (isY+15)+"px" : gotXY[2]+"px");
        	document.getElementById('tipDiv').style.left=isX+"px";
        	document.getElementById('tipDiv').style.top=isY+"px";
        	document.getElementById('tipDiv').innerHTML=unescape(v);
        	document.getElementById('tipDiv').style.display="block";
        }catch(er) {
            return false;
        }
    }
}
