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;
	  //alert(parentEl.id);
      parentEl=parentEl.offsetParent;
   }
   //totaloffset = (offsettype == "left")? 125 : totaloffset;
   return totaloffset;
}

function HideScreenTip() {

   var screentipobj = document.getElementById('screentip');
   screentipobj.style.visibility = 'hidden';

}

function HideLongToolTip() {

   var screentipobj = document.getElementById('longtooltip');
   screentipobj.style.visibility = 'hidden';

}

function ShowScreenTip(screentiptextobj, what, screentipwidth)   {

    var screentiptext = screentiptextobj.innerHTML;
	
	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 = getWinSize().width;
    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 = getWinSize().height;
	var test = VerticalPoint + ScreenTipObj.offsetHeight + 4;
	
    if (VerticalPoint + ScreenTipObj.offsetHeight + 4 > PageHeight)
        ScreenTipObj.style.top = VerticalPoint - ScreenTipObj.offsetHeight + SenderHeight;
    else
        ScreenTipObj.style.top = VerticalPoint;

    
    ScreenTipObj.style.visibility = "visible";
}

function ShowLongToolTip(tooltiptext, what, screentipwidth)   {

	if (tooltiptext == '')
       return;
    
	var SenderWidth = what.offsetWidth;
    var SenderHeight = what.offsetHeight;
    var ScreenTipObj = document.getElementById("longtooltip");

    //ScreenTipObj.style.height = '1px';
    ScreenTipObj.innerHTML = tooltiptext;
    ScreenTipObj.style.width=screentipwidth;

    //var HorizontalPoint = SenderWidth + getposOffset(what, 'left') + 5;
	//var PageWidth = getWinSize().width;
    //if (HorizontalPoint + ScreenTipObj.offsetWidth + 30 > PageWidth)  
    //    ScreenTipObj.style.width = Math.max(PageWidth - HorizontalPoint - 30, 200);

    var HorizontalPoint = mouseX(event);

	ScreenTipObj.style.left = HorizontalPoint;

    //var VerticalPoint = getposOffset(what, 'top');
	//var PageHeight = getWinSize().height;
	//var test = VerticalPoint + ScreenTipObj.offsetHeight + 4;
	
    var VerticalPoint = mouseY(event) + 20;

	//if (VerticalPoint + ScreenTipObj.offsetHeight + 4 > PageHeight)
    //    ScreenTipObj.style.top = VerticalPoint - ScreenTipObj.offsetHeight + SenderHeight;
    //else
    //    ScreenTipObj.style.top = VerticalPoint;

	ScreenTipObj.style.top = VerticalPoint;
    
    ScreenTipObj.style.visibility = "visible";
}

function getWinSize(){
	var iWidth = 0, iHeight = 0;

	if (document.documentElement && document.documentElement.clientHeight){
		iWidth = parseInt(document.documentElement.offsetWidth,10);
		iHeight = parseInt(document.documentElement.offsetHeight,10);
	}
	else if (document.body){
		iWidth = parseInt(document.body.offsetWidth,10);
		iHeight = parseInt(document.body.offsetHeight,10);
	}

	return {width:iWidth, height:iHeight};
}

function mouseX(evt) 
{
	if (evt.pageX) 
		return evt.pageX;
	else if (evt.clientX)
		return evt.clientX //+ (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
	else 
		return null;
}

function mouseY(evt) 
{
	if (evt.pageY) 
		return evt.pageY;
	else if (evt.clientY)
		return evt.clientY //+ (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
	else 
		return null;
}