var hidetimeout=0;
var showtimeout=0;
var minsubwidth=200;
var minmenuwidth=200;

var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;

if (checkIt('konqueror'))
{
	browser = "konqueror";
	OS = "linux";
}
else if (checkIt('safari')) browser = "safari"
else if (checkIt('omniweb')) browser = "omniWeb"
else if (checkIt('opera')) browser = "opera"
else if (checkIt('webtv')) browser = "webtv";
else if (checkIt('icab')) browser = "icab"
else if (checkIt('msie')) browser = "ie"
else if (!checkIt('compatible'))
{
	browser = "Netscape Navigator"
	version = detect.charAt(8);
}
else browser = "?";

if (!version) version = detect.charAt(place + thestring.length);

if (!OS)
{
	if (checkIt('linux')) OS = "linux";
	else if (checkIt('x11')) OS = "unix";
	else if (checkIt('mac')) OS = "mac"
	else if (checkIt('win')) OS = "windows"
	else OS = "?";
}

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

function getAbsoluteLeft(objectId){
  o=document.getElementById(objectId);
  oLeft=o.offsetLeft;
  while(o.offsetParent!=null){
    oParent=o.offsetParent;
    oLeft+=oParent.offsetLeft;
    o=oParent;
  }
  return oLeft;
}

function getAbsoluteTop(objectId){
  o=document.getElementById(objectId);
  oTop=o.offsetTop;
  while(o.offsetParent!=null){
    oParent=o.offsetParent;
    oTop+=oParent.offsetTop;
    o=oParent;
  }
  return oTop;
}

function getAbsoluteWidth(objectId){
  o=document.getElementById(objectId);
  return o.offsetWidth;
}


function showMenu(Menu){
  eval('div'+ Menu).style.display='block';
  eval('div'+ Menu).style.left=getAbsoluteLeft(Menu)+4;
  eval('div'+ Menu).style.top=getAbsoluteTop(Menu)+20;
  eval('div'+ Menu).style.index=99;
  if(getAbsoluteWidth('div'+ Menu)<minmenuwidth){
    tbl=document.getElementById('div'+ Menu);
    tds=tbl.getElementsByTagName('td');
    for(var i=0; i<tds.length; i++){
      tds[i].width=minmenuwidth;
    }
  }
  WCH.Apply('div'+ Menu);
}

function showSubMenu(Menu,Submenu){
 eval('div'+ Submenu).style.display='block';
  if(browser=='ie'||browser=='?'){
    eval('div'+ Submenu).style.left=getAbsoluteLeft('div'+ Menu)+getAbsoluteWidth('div'+ Menu)-2;
    eval('div'+ Submenu).style.top=getAbsoluteTop(Submenu);
  }else if(browser=='safari'){
    eval('div'+ Submenu).style.left=getAbsoluteLeft('div'+ Menu)+getAbsoluteWidth('div'+ Menu)-10;
    eval('div'+ Submenu).style.top=getAbsoluteTop(Submenu)-25;
  }else{
    eval('div'+ Submenu).style.left=getAbsoluteLeft('div'+ Menu)+getAbsoluteWidth('div'+ Menu)-2;
    eval('div'+ Submenu).style.top=getAbsoluteTop(Submenu);
  }
  eval('div'+ Submenu).style.index=98;
  if(getAbsoluteWidth('div'+ Submenu)<minsubwidth){
    tbl=document.getElementById('div'+ Submenu);
    tds=tbl.getElementsByTagName('td');
    for(var i=0; i<tds.length; i++){
      tds[i].width=minsubwidth;
    }
  }
  WCH.Apply('div'+ Submenu);
}

function hideMenu(MenuId){
  if(eval('hide'+MenuId)){
    eval(MenuId).style.left=-999;
    //eval(MenuId).style.display='';
    WCH.Discard(MenuId);
  }
}



function hoofdMenuOver(sender,id){
  for(var t=0; t<SubmenuItems.length; t++){
    hideMenu(SubmenuItems[t]);
  }
  for(var t=0; t<MenuItems.length; t++){
    hideMenu(MenuItems[t]);
  }
  if(id==null){
    sender.style.cursor='pointer';
  }
  else window.setTimeout('showMenu(\''+id+'\')', showtimeout);
}

function hoofdMenuOut(sender,id){
  if(id==null){
    sender.style.cursor='';
  }
  else window.setTimeout('hideMenu(\''+id+'\')', hidetimeout);
}

function menuOver(sender,menu,submenu){
  for(var t=0; t<SubmenuItems.length; t++){
    hideMenu(SubmenuItems[t]);
  }
  if(menu==null||submenu==null){
    sender.style.cursor='pointer';
  }
  else{
    sender.style.cursor='default';
    window.setTimeout('showSubMenu(\''+menu+'\',\''+submenu+'\')', showtimeout);
  }
  tbl=document.getElementById('inner'+ submenu);
  tbl.className='menu_over';
  //sender.className='menu_over';
}

function menuOut(sender,menu,submenu){
  if(menu==null||submenu==null){
    sender.style.cursor='';
  }
  else{
    window.setTimeout('hideMenu(\'div'+submenu+'\')', hidetimeout); 
    window.setTimeout('hideMenu(\'div'+menu+'\')', hidetimeout);
  }
  tbl=document.getElementById('inner'+ submenu);
  tbl.className='menu_out';
  //sender.className='menu_out';
}

function subMenuOver(sender,submenu){
   sender.style.cursor='pointer';
   tbl=document.getElementById(submenu);
   tbl.className='submenu_over';
   //sender.className='submenu_over';
}

function subMenuOut(sender,submenu){
   sender.style.cursor='';
   tbl=document.getElementById(submenu);
   tbl.className='submenu_out';
   //sender.className='submenu_out';
}
