var index=-1;
var mainmenuItem=-1;
var submenuitem=-1;
var subsubmenuitem=-1;

function FindParent(id){

for(var i=0;i<M.length;i++){
	if(M[i][0]==id)
		return i;
	}
return false;
}

function MakeSubmenu(parent){

var D='';
var E='';

for(var i=0;i<M.length;i++){
	if(M[i][1]==parent){
		D += "<td class=menu onmouseover=\"document.getElementById('smenustr"+M[i][0]+"').className='menuover';\" onmouseout=\"document.getElementById('smenustr"+M[i][0]+"').className='menuout';\"><a href='" + M[i][3] + "'>" + M[i][2] + "</a></td><td width=30></td>";
		E += "<td id=smenustr"+M[i][0]+"></td><td width=30></td>";
		}
	}

document.getElementById('sbmnu').innerHTML = "<table align=left class=submenulink cellpadding=0 cellspacing=0 border=0><tr><td width=19 height=31></td>" + D + "</tr><tr><td width=19 height=3></td>" + E + "</tr></table>";
}

var subsub='';

function Subsubmenu(parent,depth){

subsub='';


for(var i=0;i<M.length;i++){
	var teller=0;
	var tekst = M[i][2];

	if(tekst.length > 28)
		tekst = tekst.substring(0, 26) + '..';

	if(M[i][1]==parent){


		if(i==submenuitem && i==index){
				subsub+="<tr><td colspan=2 title='"+M[i][2]+"' style='color:#005bbb'><b>"+tekst+"</b></td></tr>";
			}
		else	{
if(subsubmenuitem!=-1 && M[i][0]==M[subsubmenuitem][1])
				subsub+="<tr><td colspan=2><a href='"+M[i][3]+"'><span style='color: #005bbb;font-weight:bold'>"+tekst+"</span></a></td></tr>";
else				subsub+="<tr><td colspan=2><a href='"+M[i][3]+"'>"+tekst+"</a></td></tr>";
			}

		subsub += "<tr><td colspan=2 height=5></td></tr> \
			<tr><td colspan=2 height=1 bgcolor=#cbcfd0></td></tr> \
			<tr><td colspan=2 height=5></td></tr>";

		if(subsubmenuitem!=-1 && M[i][0]==M[subsubmenuitem][1] || index==i){

			teller=0;
			var ssub='';

			for(var j=0;j<M.length;j++){

				if(M[j][1]==M[submenuitem][0]){

					teller++;

					var tekst2 = M[j][2];

					if(tekst2.length > 28)
						tekst2 = tekst2;

					if(j==subsubmenuitem && j==index)
						ssub+="<li>"+tekst2+"</li>";
					else
						ssub+="<li style='list-style-image: url(\"images/listcyaan.gif\");'><a href='"+M[j][3]+"'>"+tekst2+"</a></li>";
					}
				}

			if(teller)
				subsub += "<tr><td class=ssmenu colspan=2><ul>"+ssub+ "</ul></td></tr> \
				<tr><td colspan=2 height=5></td></tr> \
				<tr><td colspan=2 height=1 bgcolor=#cbcfd0></td></tr> \
				<tr><td colspan=2 height=5></td></tr>";

			}

		}
	}

if(subsub.length)
	subsub = '<tr><td colspan=2 height=1 bgcolor=#cbcfd0></td></tr> \
	<tr><td colspan=2 height=5></td></tr>' + subsub;
}

function Submenu(parent){

var D='';

for(var i=0;i<M.length;i++){
	if(M[i][1]==parent)
		D += M[i][2];
	}
return D;
}

function makebreadcrump(){

var bcrump = '';

if(mainmenuitem!=0)
	bcrump += "<a href='/'>Home</a> > <a href='" + M[mainmenuitem][3] + "'>" + M[mainmenuitem][2] + "</a>";

if(submenuitem!=-1)
	bcrump += " > " + "<a href='"+M[submenuitem][3]+"'>" + M[submenuitem][2] + "</a>";

if(subsubmenuitem!=-1)
	bcrump += " > " + "<a href='"+M[subsubmenuitem][3]+"'>" + M[subsubmenuitem][2] + "</a>";
if(document.getElementById("breadcrumb"))
	document.getElementById("breadcrumb").innerHTML = bcrump;
}

var days = "1";

function getCookie(c_name)
{
if (document.cookie.length>0)
{
c_start=document.cookie.indexOf(c_name + "=");
if (c_start!=-1)
{ 
c_start=c_start + c_name.length+1; 
c_end=document.cookie.indexOf(";",c_start);
if (c_end==-1) c_end=document.cookie.length;
return unescape(document.cookie.substring(c_start,c_end));
} 
}
return "";
}

function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function checkCookie()
{
username=getCookie('popup');

var expiredays=1;
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);

if (username!=null && username!=""){
	}
else	{
	GeneratePopup();
	document.cookie="popup" + "=" +1+ ";expires="+exdate.toGMTString();
	}
}

function GeneratePopup(){

DocHeight();
var w=document.body.offsetWidth;
var h=pageHeight;

var div=document.createIdElement("div","popuptransparant");
div.className="transparent_class";
div.style.left=0;
div.style.top=0;
div.style.position="absolute";
div.style.width=w+"px";
div.style.height=h+"px";
div.style.backgroundColor="#000000";
div.style.zIndex="100";
document.body.appendChild(div);

div2=document.getElementById("popup");
div2.style.position="absolute";
div2.style.left=(w/2)-225;
div2.style.top=280+'px';
div2.style.width="450px";
div2.style.backgroundColor="#ffffff";
div2.style.zIndex="101";
div2.style.display="block";
}

function RemoveDiv(){

removeWithChildren(document.getElementById("popup"));
removeWithChildren(document.getElementById("popuptransparant"));

}

function RelocatePopup(){

if(initPopup && document.getElementById("popuptransparant") && document.getElementById("popup")){
	DocHeight();

	document.getElementById("popuptransparant").style.width=pageWidth;
	document.getElementById("popuptransparant").style.height=pageHeight;

	document.getElementById("popup").style.left=Math.round(document.body.offsetWidth/2)-225+'px';
	}
}

function removeWithChildren(obj){

while (obj.hasChildNodes())
	obj.removeChild(obj.firstChild);
obj.parentNode.removeChild(obj);

}

document.createIdElement = function(type, id) {
  var element;
  try {
    element = document.createElement('<'+type+' id="'+id+'">');
  } catch (e) { }
  if (!element || !element.id) { // Not in IE, then
    element = document.createElement(type)
    element.id = id;
  }
  return element;
}

var pageWidth = 0;
var pageHeight = 0;

function DocHeight(){

if( window.innerHeight && window.scrollMaxY ) {// Firefox
	pageWidth = window.innerWidth + window.scrollMaxX;
	pageHeight = window.innerHeight + window.scrollMaxY;
	}
else if( document.body.scrollHeight > document.body.offsetHeight ) // all but Explorer Mac
{
pageWidth = document.body.scrollWidth;
pageHeight = document.body.scrollHeight;
}
else // works in Explorer 6 Strict, Mozilla (not FF) and Safari
{ pageWidth = document.body.offsetWidth + document.body.offsetLeft;
pageHeight = document.body.offsetHeight + document.body.offsetTop; }

}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}
function init(){

for(var i=0;i<M.length;i++){
	if(M[i][0]==page)
		index=i;
	}

if(index==-1)
	index=0;

if(M[index][1]==0)
	mainmenuitem=index;
else	{
	p=FindParent(M[index][1]);
	if(M[p][1]==0){
		mainmenuitem=p;
		submenuitem=index;
		}
	else	{
		subsubmenuitem=index;
		p=FindParent(M[index][1]);
		submenuitem=p;
		p=FindParent(M[submenuitem][1]);
		mainmenuitem=p;
		}
	}

MakeSubmenu(M[mainmenuitem][0]);

if(mainmenuitem){
	document.getElementById('mainmenu'+M[mainmenuitem][0]).src = '/menuimages/menu' + M[mainmenuitem][0] + 'over.gif';
	document.getElementById('mainm'+M[mainmenuitem][0]).className = 'menuover';
	document.getElementById('mainmenu'+M[mainmenuitem][0]).onmouseout='';
	}

if(mainmenuitem!=0)
	Subsubmenu(M[mainmenuitem][0],0);
else if(submenuitem!=-1)
	Subsubmenu(M[submenuitem][1],0);

if(document.getElementById("divMainmenu"))
	document.getElementById("divMainmenu").innerHTML="<table width=222 align=left cellpadding=0 cellspacing=0 border=0 class=newsarchive>" + subsub + "</table>";

makebreadcrump();
if(initPopup)
	checkCookie();
}

function popitup(url,h,w) {
	newwindow=window.open(url,'name','height='+h+',width='+w);
	if (window.focus) {newwindow.focus()}
	return false;
}

function select(id){
document.getElementById('page').value=id;
document.zoekmachines.submit();
}

var currentIndex=0;
var currentCount=0;

function Thumb(index,count){
currentIndex=index;
currentCount=count;
currentPics[index]=count;
document.getElementById('thumb'+index).src=popup[index][count][4];
document.getElementById('wrap'+index+lastPics[index]).className='navrow';
document.getElementById('wrap'+index+count).className='navrowthumbselected';
lastPics[index]=count;
}

function Popup(index,count){
currentPics[index]=count;
document.getElementById('thumb'+index).src=popup[index][count][4];
popitup('/popup.php?w='+popup[index][count][1]+'&h='+popup[index][count][2]+'&img='+popup[index][count][3],popup[index][count][2],popup[index][count][1]);
}

function PreviousPopup(index){
if(currentPics[index]==0)
	currentPics[index]=popup[index].length-1;
else
	currentPics[index]--;
Thumb(index,currentPics[index])
currentIndex=index;
currentCount=currentPics[index];
}

function NextPopup(index){

currentPics[index]++;
if(popup[index].length<=currentPics[index])
	currentPics[index]=0;
Thumb(index,currentPics[index])
currentIndex=index;
currentCount=currentPics[index];
}

function ShowFloater(img,index,count){

currentIndex=index;
currentCount=count;

var pos = findPos(img);

document.getElementById("floater").style.left = pos[0] + 'px';
document.getElementById("floater").style.top  = pos[1] + 'px';
document.getElementById("floater").style.width  = img.offsetWidth + 'px';
document.getElementById("floater").style.height = img.offsetHeight + 'px';

document.getElementById("floater").style.display='block';
}

function HideFloater(img,index,count){
document.getElementById("floater").style.display='none';
}

window.onload=init;
