/*

*/
function setD(b,n)
{
	var smenu  = document.getElementById("submenu");	
	var ssmenu = document.getElementById("subsubmenuid");
	var sssid  = document.getElementById("ssid");
	var frm    = document.getElementById("form_container");
	var gal    = document.getElementById('myGallery');

	if (b)
	{
		if (n==1)
		{
			if (smenu) {smenu.style.display = 'none';}
			if (ssmenu) ssmenu.style.display = 'none';
		}
		if (n==2)
		{
			if (ssmenu) ssmenu.style.display = 'none';
		}
		if (sssid) sssid.style.display = 'none';
		if (frm) frm.style.zIndex = '-1';
		if (gal) gal.style.zIndex = '-1';
	}
	else
	{
		if (smenu) {smenu.style.display = 'block';}
		if (ssmenu) ssmenu.style.display = 'block';
		if (sssid) sssid.style.display = 'block';
		if (frm) {frm.style.zIndex = '5';frm.style.display='block';}
		if (gal) gal.style.zIndex = '5';		
	}
}

var hopen = false;

function hoofdmenu()
{
	var hmenu = document.getElementById("hoofdmenu");
	var smenu2  = document.getElementById("submenu2");

	for (var i=0; i<hmenu.childNodes.length;i++)
	{
		node = hmenu.childNodes[i];
		if (node.nodeName == "LI")
		{
			node.onmouseover=function()
			{
				setD(1,1);
				if (this.childNodes.length > 2)
				{
					this.childNodes[2].style.display = 'block';
					if (smenu2) smenu2.style.zIndex = '-1';
				}
			}
			node.onmouseout=function()
			{
				this.childNodes[2].style.display = 'none';
				if (smenu2) smenu2.style.zIndex = '1';
				setD(0,1)
			}
		}
	}
}

function submenu()
{
	var smenu = document.getElementById("submenuid");
	if (smenu)
	{
		for (var i=0;i<smenu.childNodes.length;i++)
		{
			node = smenu.childNodes[i];
			if (node.nodeName == "LI")
			{
				node.onmouseover=function()
				{
					if (this.childNodes[2].childNodes.length < 1) return
					setD(1,2);
					this.childNodes[2].style.display = 'block';
				}
				node.onmouseout=function()
				{
					if (this.childNodes[2].childNodes.length < 1) return
					this.childNodes[2].style.display = 'none';
					setD(0,2);
				}
			}
		}
	}	
}

function subsubmenu()
{
	var smenu = document.getElementById("subsubmenuid");
	var st = document.getElementById("ssid");
	if (smenu)
	{
		for (var i=0;i<smenu.childNodes.length;i++)
		{
			node = smenu.childNodes[i];
			if (node.nodeName == "LI")
			{
				node.onmouseover=function()
				{
					if (this.childNodes[2].childNodes.length < 1) return
					if (st) st.style.display = 'none';
					this.childNodes[2].style.display = 'block';
				}
				node.onmouseout=function()
				{
					if (this.childNodes[2].childNodes.length < 1) return
					if (st) st.style.display = 'block';
					this.childNodes[2].style.display = 'none';
				}
			}
		}
	}
}

function setbalkheight()
{
	var r1 = document.getElementById("balk_submenu");
	var r2 = document.getElementById("balk_submenu2");

	if (r1)
	{
		r1.style.height = '75px';
		
	}
	if (r2)
		r2.style.height = '75px';
}

function vertical_align()
{

	if (!document.getElementById("absolute_text"))
		return
	var height = $('#absolute_text span').height();

	if (height > 0 && height < 75)
	{
		margin = parseInt((75 - height)/2);
		$('#absolute_text span').css({'padding-top':margin});
	}
}

function setPageTitle(title)
{
	if (title != '')
	{
		document.getElementById("paginatitel").innerHTML = title;
	}
}

$(document).ready(function(){vertical_align();})

function init()
{
	hoofdmenu();
	submenu();
	subsubmenu();
}


var ts = '';
var ms = '';

function set_image(obj)
{
	var target = document.getElementById('suite_image');

	if (target)
	{
		ts = target.src.replace('/images/', '/images/small_');
		ms = obj.src.replace('small_', '');

		$(obj).fadeOut(500, function() {this.src=ts});
		$(target).fadeOut(500, function() {this.src=ms});

		$(obj).fadeIn(500);
		$(target).fadeIn(500);
	}
}

function findPos(obj)
{
	var curleft = curtop = 0;
	if (obj.parentNode)
	{
		var old = obj;
		obj.parentNode.style.display = 'block';
	}

	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	if (old)
		old.parentNode.style.display = old.parentNode.style.display;
	return {left : curleft, top: curtop};
}

function nm(obj)
{

	if (obj.childNodes.length >=1)
	{
		obj.childNodes[1].style.position = 'absolute';
		obj.childNodes[1].style.display = 'block';
		if (obj.childNodes[1].style.top == ''){
//			document.title = findPos(obj).top;
			obj.childNodes[1].style.top = findPos(obj).top-130+'px';
		}
		obj.childNodes[1].style.backgroundColor = '#fff';
		obj.childNodes[1].style.left = '170px';
		obj.className = 'nmo';
	}
}

function nmu(obj)
{
	obj.childNodes[1].style.display = 'none';
	obj.className = '';
}
// Events koppelen
if (window.attachEvent)
{
	// hoofdmenu
	window.attachEvent("onload", init);
}
else
{
	window.addEventListener("load", init, false);
}