﻿function $(obj)
{
    return document.getElementById(obj);
}

function ToolTipDiv(e, title, body, width, height)
{
    var x = e.clientX;
    var y = e.clientY;
    
    var y = y + document.documentElement.scrollTop;
    
    var sTip = '\
    <div onmouseover="KeepToolTip()" style="cursor:pointer; width: ' + width + 'px; height: ' + height + 'px; border: 4px solid #0099CC; position: absolute;\
        background-color: #fff; top: ' + y + '; left: ' + x + 'px; z-index: 10000; font-size:12px;" id="toolTipDiv">\
        <div id="toolTipTitle" style="margin:1px; padding:4px; padding-top:8px; padding-left:10px; font-weight:bold; background-color:#0099CC;">' + title + '</div>\
        <div id="toolTipTitle" style="margin:1px; padding:3px; line-height:180%;">' + body + '</div>\
    </div>\
    <iframe marginheight="0" marginwidth="0" frameborder="0" style="width: ' + (width + 10) + 'px; height: ' + (height + 10) + 'px;\
        position: absolute; top: ' + y + '; left: ' + x + 'px; z-index: 9999;"\
        id="thickBoxFm"></iframe>\
    \
    </div>';
    
    this.init = function()
    {
        $('toolTipSpan') ? $('toolTipSpan').parentNode.removeChild($('toolTipSpan')) : function(){};
	    var oDiv = document.createElement('span');
	    oDiv.id = "toolTipSpan";

	    oDiv.innerHTML = '<div id="toolTipDiv" onmouseover="KeepToolTip()" onmouseout="DelToolTip()">' + sTip + '</div>';
	    document.body.appendChild(oDiv);
    }
}

function ToolTip(event, title, body, width, height)
{
    var toolTip = new   ToolTipDiv(event, title, body, width, height);
    toolTip.init();
}


function DelToolTip()
{
    //$('toolTipSpan') ? $('toolTipSpan').parentNode.removeChild($('toolTipSpan')) : function(){};
    $('toolTipSpan').style.display = 'none';
}

function KeepToolTip()
{
    $('toolTipSpan').style.display = 'block';
}