var offsetfromcursorX=12 //Customize x offset of tooltip
var offsetfromcursorY=10 //Customize y offset of tooltip

var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=4 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

var X;
var Y;
//var X = Array(445, 800);
//var Y = Array(304, 731);

document.write('<div id="dhtmltooltipAd"></div>') //write out another tooltip DIV
document.write('<div id="dhtmltooltip"></div>') //write out tooltip DIV
document.write('<img id="dhtmlpointer" src="arrow2.gif" style="visibility: hidden;">') //write out pointer image

var ie = document.all;
var ns6 = document.getElementById && !document.all;
var enabletip = false;
if (ie||ns6) {
    var tipobjReg = document.all ? 
            document.all["dhtmltooltip"] : 
            document.getElementById? document.getElementById("dhtmltooltip") : "";
    var tipobjAd = document.all ? 
            document.all["dhtmltooltipAd"] : 
            document.getElementById? document.getElementById("dhtmltooltipAd") : "";
}
//var pointerobj=document.all? document.all["dhtmlpointer"] : document.getElementById? document.getElementById("dhtmlpointer") : ""

function ietruebody(){
    return (document.compatMode && document.compatMode!="BackCompat")? 
            document.documentElement : document.body;
}

function showToolTip(tipobj, thetext, thewidth, Xstring, Ystring, thecolor) {
    if (ns6||ie) {
        if (typeof thewidth != "undefined") 
            tipobj.style.width = thewidth + "px";
        if (typeof thecolor != "undefined" && thecolor != "") 
            tipobj.style.backgroundColor = thecolor;
        tipobj.innerHTML = thetext;
        tipobj.style.textAlign="left";

        if (tipobj.id == "dhtmltooltipAd")
            tipobj.style.visibility="visible";
        else {
            enabletip=true;
            X = Xstring.split(",");
            Y = Ystring.split(",");
        }
        return false;
    }
}

function hideToolTip(tipobj) {
    if (ns6||ie) {
        tipobj.style.visibility = "hidden";
        if (tipobj == "dhtmltooltip") {
            enabletip = false;
            tipobj.style.visibility = "hidden";
            tipobj.style.left = "-1000px";
            tipobj.style.backgroundColor = '';
            tipobj.style.width = '';
        }
    }
}

document.onmousemove = positiontip;

function positiontip(e) {
    if (enabletip) {
        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;
        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;
            a = curX + offsetfromcursorX - offsetdivfrompointerX;
            i = X.length;
            b = 0;
            while ( (--i >= 0) && (b == 0) ) {
                if (a > X[i])
                    b = X[i];
            }
            tipobjReg.style.left = b + "px";
            aa = Y[Y.length-1];
            if (aa < 0) {
                aa = (-1) * aa;
                i = Y.length-1;
            } else {
                aa = 200;
                i = Y.length;
            }
            a = curY + aa; // + offsetfromcursorY + offsetdivfrompointerY + aa;
            b = 0;
            while ( (--i >= 0) && (b == 0) ) {
                if (a > Y[i])
                    b = Y[i];
            tipobjReg.style.top = b + "px";
        }
    }
}

function ddrivetip(thetext, thewidth, Xstring, Ystring, thecolor) {
    showToolTip(tipobjReg, thetext, thewidth, Xstring, Ystring, thecolor);
    tipobjReg.style.visibility = "visible";
}
function hideddrivetip(){
    hideToolTip(tipobjReg);
    tipobjReg.style.visibility = "hidden";
}

function showAd(thetext) {
    showToolTip(tipobjAd, thetext, 370);
}
function hideAd() {
    hideToolTip(tipobjAd);
}