// indicate hint visibility
var isvisible = 0;
// on load finished - set isLoaded to true
var isLoaded = 0;
function init() {
  isLoaded = 1;
}
window.onload = init; 


// Temporary variables to hold mouse x-y pos.s
var tempX = 0;
var tempY = 0;

var setx = 0;
var sety = 0;
// show hint - onmouseover
// @param string $text - content html
// !!!!!!!!!!!!!! be carefull - Convert special characters to HTML entities!!! e.g. " (double quote) becomes &quot; etc.
// !!!!!!!!!!!!!! only special symbol ' has to be converted as \'
function showHint(text, startx, starty) {
  tempX = PopupTempX;
  tempY = PopupTempY;
  setx = startx;
  sety = starty;
  /*setx = 20;
  sety = -20;*/
  if (document.getElementById("ti_hint_box")) {
    mydiv = document.getElementById("ti_hint_box");
    
    mydiv.style.display = 'block';
    dheight = mydiv.offsetHeight;
    dwidth = mydiv.offsetWidth;
    
    // find out document dimension
    if (window.XMLHttpRequest && !window.opera) {
     theWidth = document.documentElement.clientWidth;
     theHeight = document.documentElement.clientHeight;
     theScroolTop = document.documentElement.scrollTop;
     theScroolLeft = document.documentElement.scrollLeft;
    } 
    else { //ie6
     theWidth = document.documentElement.clientWidth;
     theHeight = document.documentElement.clientHeight;
     theScroolTop = document.documentElement.scrollTop;
     theScroolLeft = document.documentElement.scrollLeft;
    }
    // calculate hint position
    //if ie7
    if (IE) {
      if ((tempX+(setx)+dwidth)>theWidth) {
        setx=0-(2*setx)-dwidth+theScroolLeft;
      }
      else {
        setx=setx+theScroolLeft;
      }  
      if ((tempY+(sety)+dheight)>theHeight) {
        sety=0-sety-dheight+theScroolTop;
      }
      else {
        sety=sety+theScroolTop;
      }
    }//ie6,mozilla
    else {
      {
        if ((tempX+(setx)+dwidth)>theWidth+theScroolLeft) setx=0-(2*setx)-dwidth;
        if ((tempY+(sety)+dheight)>(theHeight+theScroolTop)) sety=0-sety-dheight;
      }
    }
    // set hint position
    mydiv.style.left = (tempX+(setx))+"px";
    mydiv.style.top = (tempY+(sety))+"px";
    // set hint content
    mycontent = document.getElementById("ti_hint_box_content");
    mycontent.innerHTML= text;
    // display hint
    mydiv.style.display = 'block';
  
  }
}

// move hint - onmousemove
function moveHint() {
  tempX = PopupTempX;
  tempY = PopupTempY;
  /*setx = 20;
  sety = -20;*/
  pomSetX = setx;
  pomSetY = sety;
  if (document.getElementById("ti_hint_box")) {
    mydiv = document.getElementById("ti_hint_box");
    
    mydiv.style.display = 'block';
    dheight = mydiv.offsetHeight;
    dwidth = mydiv.offsetWidth;
    
    // find out document dimension
    if (window.XMLHttpRequest && !window.opera) {
     theWidth = document.documentElement.clientWidth;
     theHeight = document.documentElement.clientHeight;
     theScroolTop = document.documentElement.scrollTop;
     theScroolLeft = document.documentElement.scrollLeft;
    } 
    else { //ie6
     theWidth = document.documentElement.clientWidth;
     theHeight = document.documentElement.clientHeight;
     theScroolTop = document.documentElement.scrollTop;
     theScroolLeft = document.documentElement.scrollLeft;
    }
    // calculate hint position
    //if ie7
    if (IE && !IE8) {
      //alert(theScroolTop);
      if ((tempX+(setx)+dwidth)>theWidth) {
        pomSetX = setx=0-(2*setx)-dwidth+theScroolLeft;
      }
      else {
        pomSetX=setx+theScroolLeft;
      }  
      if ((tempY+(sety)+dheight)>theHeight) {
        pomSetY=0-sety-dheight+theScroolTop;
      }
      else {
        pomSetY=sety;//+theScroolTop;
        
      }
    }//ie6,mozilla
    else {
      if ((tempX+(setx)+dwidth)>theWidth+theScroolLeft) {
        pomSetX=0-(2*setx)-dwidth;
      } else {
        
      }  
      if ((tempY+(sety)+dheight)>(theHeight+theScroolTop)) {
        pomSetY=0-sety-dheight;
      } else {

      }  
    }
    // set hint position
    mydiv.style.left = (tempX+(pomSetX))+"px";
    mydiv.style.top = (tempY+(pomSetY))+"px";
    // display hint
    mydiv.style.display = 'block';
  
  }
}
// hide hint - onmouseout
function hideHint() {
  if (document.getElementById("ti_hint_box")) {
    mydiv = document.getElementById("ti_hint_box");
    mydiv.style.display = 'none';
  }  
}

