function getposOffset(what, offsettype){
   var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
   var parentEl=what.offsetParent;
    while (parentEl!=null){
      totaloffset = (offsettype == "left")? totaloffset + parentEl.offsetLeft : totaloffset + parentEl.offsetTop;
      parentEl=parentEl.offsetParent;
   }
   return totaloffset;
}

function HideScreenTip() {

   var screentipobj = document.getElementById('screentip');
   screentipobj.style.visibility = 'hidden';

}

function ShowScreenTip(screentiptext, what, screentipwidth)   {

    if (screentiptext == '')
       return;
    
    var SenderWidth = what.offsetWidth;
    var SenderHeight = what.offsetHeight;
    var ScreenTipObj = document.getElementById("screentip");

    //ScreenTipObj.style.height = '1px';
    ScreenTipObj.innerHTML = screentiptext;
    ScreenTipObj.style.width=screentipwidth;

    var HorizontalPoint = SenderWidth + getposOffset(what, 'left') + 5;
	var PageWidth = document.body.offsetWidth;
    if (HorizontalPoint + ScreenTipObj.offsetWidth + 30 > PageWidth)  
        ScreenTipObj.style.width = Math.max(PageWidth - HorizontalPoint - 30, 200);

    ScreenTipObj.style.left = HorizontalPoint;

    var VerticalPoint = getposOffset(what, 'top');
	var PageHeight = document.body.offsetHeight;
    if (VerticalPoint + ScreenTipObj.offsetHeight + 4 - document.body.scrollTop > PageHeight)
        ScreenTipObj.style.top = VerticalPoint - ScreenTipObj.offsetHeight + SenderHeight;
    else
        ScreenTipObj.style.top = VerticalPoint;
		
    ScreenTipObj.style.visibility = "visible";
}
