function ShowPopup(index){
  divPopup.innerHTML = index;
  divPopup.style.display = "inline";

  showDiv = true;
}
  
function HidePopup(){
  showDiv = false;
  if (divPopup != null){
    divPopup.style.display = "none";
    divPopup.style.display = "none";
    divPopup.style.top = -1000 + "px";;
    divPopup.style.left = -1000 + "px";;
    if (document.all){
      selects = document.getElementsByTagName("SELECT");
      for (i = 0; i < selects.length; i++){
        selects[i].style.visibility="visible";
      }
    }
  }
}

var divPopup = null;
var offsetX = 20;
var offsetY = -15;
var showDiv = false;

if (window.addEventListener)
  window.addEventListener("load", PopupInit, false);
else if (window.attachEvent)
  window.attachEvent("onload", PopupInit);
else if (document.getElementById)
  document.body.onload = PopupInit;


function PopupInit(){
  document.onmousemove = MouseTip;
  divPopup = document.getElementById("DivPopup");
}

function MouseTip(e){
  if (divPopup != null && showDiv){
  	x = 0;
  	y = 0;
    if (e == null){
      x = event.x + document.documentElement.scrollLeft + offsetX;
      y = event.y + document.documentElement.scrollTop + offsetY;
    }
    else{
      x = e.pageX + offsetX;
      y = e.pageY + offsetY;
    }
	
    if (x + divPopup.clientWidth >= document.body.clientWidth){
    	x = x - offsetX * 2 - divPopup.clientWidth;
    	if (x <= 0)
    		x = 5;
    }
    if (y + divPopup.clientHeight >= document.body.clientHeight){
    	y = y - offsetY * 2 - divPopup.clientHeight;
    	if (y <= 0)
    		y = 5;
    }
    divPopup.style.left = x + "px";
    divPopup.style.top = y + "px";
  }
}


