// JavaScript Document Pasveer Korpsen

function showMenu(inx)
{
		menuItems 	= new Array("homeLink", "hundredLink", "webshopLink");
		subMenus = new Array("homeMenu", "hundredMenu", "webshopMenu");
		for (i=0; i<subMenus.length; i++)
		{
			document.getElementById(subMenus[i]).style.display = "none";
			document.getElementById(menuItems[i]).className = "";
		}
		document.getElementById(subMenus[inx]).style.display = "block";
		document.getElementById(menuItems[inx]).className = "active";
		dropDownPosition();		
}





function hasClassName(el, name){
var re = new RegExp("(^| )" + name + "( |$)");
if(re.test(el.className)){
return true;
}
return false;
}


  function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }


function allDropDowns(){
allDivs = document.getElementsByTagName("ul");
allDrops = new Array();
  for (i=0; i<allDivs.length; i++)
  {
	 		if (hasClassName(allDivs[i], "subsub")){
	 	  allDrops.push(allDivs[i]);
			}
  }
return allDrops;
}


function dropDownPosition(){
col = allDropDowns();
  for (i=0; i<col.length; i++)
	{
	 		col[i].style.position="absolute";
			col[i].style.left = (findPosX(col[i].parentNode))+"px";
			col[i].style.top = (findPosY(col[i].parentNode)+30)+"px";
	}
}




// Javascript originally by Patrick Griffiths and Dan Webb.
// http://htmldog.com/articles/suckerfish/dropdowns/

sfHover = function(targ) {
	var target = String(targ);
	var sfEls = document.getElementById(target).getElementsByTagName("li");
//	var sfEls = document.getElementById("homeMenu").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" hover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" hover\\b"), "");
			if (window.addEventListener) {this.className="";}
		}
	}
}


// end of Suckerfish


function toggleFollow(inx)
{
		hetMenu = document.getElementById("followMenu");
		hetMenu.style.left = ((findPosX(hetMenu.parentNode))-37)+"px";
		if (inx == 0){
			hetMenu.style.display = 'none'
		//argu = "hetMenu.style.display = 'none'";
		//setTimeout(argu, 2500);
		}
		if (inx == 1){
		hetMenu.style.display = "block";
		}
}

function appendLinkje(){
		hetMenu = document.getElementById("followMenu");
		//bladiebla = document.createElement("<div><a onclick='toggleFollow(0)'>Menu sluiten</a></div>");
		//hetMenu.appendChild(bladiebla);
		hetMenu.innerHTML += "<div><a onclick='toggleFollow(0)' style='background-color: #ffffff; color: #666; margin-left: 40px; margin-right: 20px; cursor: pointer;'>Menu sluiten</a></div>";
}

function init() {
	sfHover("homeMenu");
	sfHover("hundredMenu");
	sfHover("webshopMenu");
	dropDownPosition();
	appendLinkje();	
}





if (window.attachEvent) window.attachEvent("onload", init);
if(window.addEventListener)
{
window.addEventListener('load', init, false);
}


