function getWindowHeight()
{
   var myWidth = 0, myHeight = 0;
   if( typeof( window.innerWidth ) == 'number' )
   { //Non-IE
      myHeight = window.innerHeight;
   }
   else
   {
      if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
      { //IE 6+ in 'standards compliant mode'
        myHeight = document.documentElement.clientHeight;
      }
      else
      {
        if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
        { //IE 4 compatible
          myHeight = document.body.clientHeight;
        }
      }
  }
  return myHeight;
}

function getElementLeft(elemId) {
  var elem = getElementById(elemId);
	xPos = elem.offsetLeft;
	tempEl = elem.offsetParent;
  while (tempEl != null) {
  	xPos += tempEl.offsetLeft;
	  tempEl = tempEl.offsetParent;
  }
  return xPos;
}


function getElementTop(elemId) {
  var elem = getElementById(elemId);
	yPos = elem.offsetTop;
	tempEl = elem.offsetParent;
	while (tempEl != null) {
  	yPos += tempEl.offsetTop;
	  tempEl = tempEl.offsetParent;
  }
	return yPos;
}

function getElementById(elemId) {
	if (document.getElementById)
		return document.getElementById(elemId);
	else
	  if (document.all)
		  return document.all[elemId];
		else
		  return null;
}

function set100PercentHeight(elemId)
{
  var control = getElementById(elemId);
  var wh = getWindowHeight();
  var ch = control.offsetHeight;
  var ct = getElementTop(elemId);
  var h  = wh - ct - 1;
  control.style.height = String(h) + "px";
}

function toggleImage(elem, imageurl)
{
  elem.src = imageurl;
}

function getEventTarget(e)
{
	var targ;
	if (!e) e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) // defeat Safari bug
		targ = targ.parentNode;
  return targ;
}

var tooltip;
function createToolTip()
{
  if (!tooltip)
  {
    tooltip = document.createElement('DIV');
    tooltip.className = 'tooltip';
    tooltip.style.top = '0px';
    tooltip.style.left = '0px';
    tooltip.style.visibility = 'hidden';
    tooltip.style.whitespace = 'nowrap';
    //document.body.appendChild(tooltip);
    document.all['TooltipContainerDiv'].appendChild(tooltip);
  }
}

function tooltipMouseOver(text)
{
  createToolTip();
  tooltip.innerHTML = text;
  tooltip.style.top = event.y - tooltip.offsetHeight;
  tooltip.style.left = event.x;
  tooltip.style.visibility = "visible";
}

function tooltipMouseOut()
{
  if (tooltip)
  {
    tooltip.style.visibility = 'hidden';
    //document.body.removeChild(tooltip);
    //tooltip = null;
  }
}

function openPopup(url)
{
  return window.open(url, "popup", "width=550,height=400,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no");
}

