﻿


var currentTip = null;
var xOffset = 2;
var yOffset = 2;
var tipShowing = false;
var oTip = null;
 
var sX = window.screenLeft;
var sY = window.screenTop;
var left;
var top;
var right;
var bottom;
    

function clearTimer()
{
  if(currentTip != null)
   {
       window.clearTimeout(currentTip);
       currentTip = null; 
   } 
}

function hideTip()
{
   clearTimer();
   tipOpen = false;
   tipShowing = false;
   oTip.style.visibility ="hidden";
   oTip.style.left = "-5000px";
   oTip.style.bgColor = ""; 
   oTip.style.border = "";  
   oTip.style.width = "";
   
   return false;
}



function loadTipHtml(tipHtml, tipWidth, tipColorClass, tipBorder)
{
    if (oTip == null)
        return;
        
    if(typeof tipWidth != "undefined" && tipWidth != null)
        oTip.style.width = tipWidth = "px";
           
    if(typeof tipColorClass != "undefined" && tipColorClass != null)    
        oTip.className = tipColorClass;
        //oTip.style.bgColor = tipColor;
        
    if(typeof tipBorder != "undefined" && tipBorder != null)
        oTip.style.border = tipBorder;

    oTip.innerHTML = tipHtml;
    tipShowing = true;
    setTipPosition();
   
    return false;   
   
}

var ems_row;
var ems_low;
var ems_bow;
var ems_mouseX;
var ems_mouseY;
var ems_clientX;
var ems_clientY;
var ems_winHt;

function setTipPosition() {
    if(oTip)
    { 
        var realBody = (document.compatMode && document.compatMode!="BackCompat") ? document.documentElement : document.body
        if(tipShowing)
       {
           oTip.style.visibility = "hidden";
           if(ems_row < oTip.offsetWidth) {
             oTip.style.left = isIE 
                 ? realBody.scrollLeft + ems_mouseX - oTip.offsetWidth + "px" 
                 : window.pageXOffset + ems_clientX - oTip.offsetWidth + "px";
           }
          var tipWidth = oTip.offsetWidth;
          
          if (ems_mouseX < ems_low) {
                oTip.style.left = "5px";
          }
          else {
            oTip.style.left = ems_mouseX + xOffset + "px"; 
          }
        
          if((xOffset + tipWidth) > ems_row) {
            oTip.style.left = ems_mouseX - xOffset - tipWidth + "px"
          }

          if(ems_bow < oTip.offsetHeight)
          {
            oTip.style.top = ems_winHt - oTip.offsetHeight + "px";
          } 
          else
          {
             oTip.style.top = ems_mouseY + yOffset + "px"; 
          }


          oTip.style.visibility = "visible";
       }
    }
}




function setTip()
{
    oTip = Dea.Get("mcTip");
}


function displayTip(itemId, router) {
    loadTipHtml(mc_PauseToLoadMsg, null, "", "2px solid black");
    currentTip = window.setTimeout("getTip(" + itemId + ", '" + router + "')", 1000);
    return;
}

function getTip(itemId, router) {
   Dea.setEmsData(true);
   Dea.emsData.tipItemId = itemId;
   Dea.makeCallback(router, Dea.emsData);  
   return;
}

function showDetails(page, qs, w, h) {
    var link = PathToRoot + page + "?" + qs;
    var width = w || 500;
    var height = h || 550;
    showPopWin(link, width, height, null, true);
    return false; 
}


function setDivPosition()
{   
    left = parseInt(oTip.style.left, 10);  //-sX;
    top = parseInt(oTip.style.top, 10);
    right = left + oTip.offsetWidth;
    bottom = parseInt(oTip.style.top, 10) + oTip.offsetHeight;
   
}

function OverDivPosition(x, y) {
    
    setDivPosition();
    //alert('x ' + x + ' y ' + y + ' left ' + left + ' top ' + top + ' right ' + right + ' bottom ' + bottom);
    if ((x > left && x < right) && (y > top && y < bottom))
        tipOpen = true;
    else {
        tipOpen = false;
    }
            
   
}


document.write("<div id='mcTip'></div>");
Dea.browser.addEvent(window, "load", setTip);



