﻿//ONMOUSEMOVE
document.onmousemove = mM;
var newX = '';
var newY = '';
var offsetX = '';
var offsetY = '';
	
//HANDLER FOR MOUSEPOSITIONS
function mM(e)
{
    if (window.event) e=window.event;
	newX = e.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft); //e.clientX - offsetX;
	newY = e.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop :  document.body.scrollTop);//e.clientY - offsetY;
}

//SHOW TOOLTIP
function showTip(sender,type,ID,URL,width,div_ID,loading)
{
    //var div2 = document.getElementById(div_ID);
    var div = document.createElement("div");
    var newLeft = newX - 250;
    var newTop = newY + 20; 
    div.id = div_ID + "_tooltip";
    div.style.position = "absolute";
    div.style.left = newLeft + 'px';
    div.style.top = newTop + 'px';
    
    div.innerHTML = '<div style=\'width:' + width + 'px;text-align:center;background-color:#fff;border:1px solid #ccc;padding:10px;\'><img src=\'' + loading + '\'></div>';
    //GET TOOLTIP
    var xmlHttp
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    } 
    var http = new XMLHttpRequest();
    var params = 'type=' + type + '&ID=' + ID + '&width=' + width + '';
    http.open("POST", URL, true);

    //Send the proper header information along with the request
    http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http.setRequestHeader("Content-length", params.length);
    http.setRequestHeader("Connection", "close");
    http.onreadystatechange = function() {//Call a function when the state changes.
	    if(http.readyState == 4 && http.status == 200) 
	    {
	        div.innerHTML = http.responseText;
	    }
    }
    http.send(params);
            
    document.getElementsByTagName("body")[0].appendChild(div);
}

//HIDE-TOOLTIP
function hideTip(div_ID)
{
    var div = '';
    if(document.getElementById(div_ID + "_tooltip")) {
        div = document.getElementById(div_ID + "_tooltip");
        document.getElementsByTagName("body")[0].removeChild(div);
    }
}


//AJAX OBJECT
function GetXmlHttpObject()
{
    var xmlHttp=null;
    try
    {
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
    }
    catch (e)
    {
        // Internet Explorer
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
}