/*
 * @File        $RCSfile: moDIV.js,v $
 * @Version     $Revision: 1.1 $
 * @Author      $Author: heeringa $ (last checked in by)
 * @Date        $Date: 2006/03/24 15:12:38 $ (UTC date of last check in)
 */

function init() {
	setMOhandler();
	setBottomHandler();
}
      
function setDivOver(divID) {
	var d = document.getElementById(divID);
	d.style.background = '#D21206';
	d.style.color = '#FFFFFF';
	d.style.border = '1px solid #FFFFFF';
}

function setDivOut(divID) {
	var d = document.getElementById(divID);
	d.style.background = 'transparent';
	d.style.color = '#FFFFFF';
	d.style.border = '1px solid #FFFFFF';
}

function setDiv2Over(divID) {
	var d = document.getElementById(divID);
	d.style.background = '#FFFFFF';
	d.style.color = '#A00000';
	d.style.border = '1px solid #A00000';
}

function setDiv2Out(divID) {
	var d = document.getElementById(divID);
	d.style.background = 'transparent';
	d.style.color = '#F90B00';
	d.style.border = '1px solid #F90B00';
}

function toggleLinks() {
	toggle('linksdiv');
}

function toggle(divname) {
	var theDiv = document.getElementById(divname);
	var visibility = theDiv.style.visibility;
	if(visibility =='hidden') {
		theDiv.style.visibility = 'visible';
	} else {
		theDiv.style.visibility = 'hidden';
	}
	
}

var pl, pm, tijd;

function findPosX(obj)
{
  var curleft = 0;
  if (obj.offsetParent)
  {
    while (obj.offsetParent)
    {
      curleft += obj.offsetLeft;
      obj = obj.offsetParent;
    }
  }
  else if (obj.x)
  {
    curleft += obj.x;
  }
  return curleft;
}

function findPosY(obj)
{
  var curtop = 0;
  if (obj.offsetParent)
  {
    while (obj.offsetParent)
    {
      curtop += obj.offsetTop
      obj = obj.offsetParent;
    }
  }
  else if (obj.y)
  {
    curtop += obj.y;
  }
  return curtop;
}

function initPopup() {
  pl = document.getElementById("menulink");
  pm = document.getElementById("linksdiv2");

  pl.onmouseover = function(evt) {
    if (tijd) { clearTimeout(tijd); }
    if (!evt) { evt = event; }

    srcObj = evt.srcElement ? evt.srcElement : evt.target;

    var y = findPosY(srcObj) + 20;
    if (pm.offsetHeight + y + 10 > document.body.scrollHeight) { y = y - pm.offsetHeight - 5; }

    var x = findPosX(srcObj) - 156;
    if (pm.offsetWidth + x + 10 > document.body.clientWidth) { x = x - pm.offsetWidth; }

    pm.style.left = x + "px";
    pm.style.top  = y + "px";
    pm.style.visibility = "visible";
    tijd = setTimeout("closePopup()", 3000);
  }

  pm.onmouseout = function() { tijd = setTimeout("closePopup()", 500); }
  pm.onmouseover = function() { clearTimeout(tijd); }
}

function closePopup() {
  pm.style.visibility = "hidden";
  pm.style.left = "0px";
  pm.style.top = "0px";
}

function checkPopup() {
  if (document.getElementById("menulink")) { initPopup(); }
  else { setTimeout("checkPopup()", 100); }
}
checkPopup();