var Menu1 = new Array ();
var containerName = "tdMenuLevel";
var startIndex = 2;
var colCount = 5;
var rootPos = "";
//DIT is EEN TEST
var executeafter = "";

Menu1[0]	= new Array(0,0,"Lidmaatschap","/lid/_t0_p0_m21_i387.htm");
Menu1[1]	= new Array(0,0,"Voordelen","/lid/_t0_p0_m7_i234.htm");
Menu1[2]	= new Array(0,0,"Contributie","/lid/_t0_p0_m7_i235.htm");
Menu1[3]	= new Array(0,0,"Gegevens wijzigen","/lid/_t0_p0_m21_i1026.htm");
Menu1[4]	= new Array(0,0,"Uw privacy","/lid/_t0_p0_m7_i237.htm");
Menu1[5]	= new Array(0,0,"Algemene Voorwaarden","/lid/_t0_p0_m7_i428.htm");


//On the onload show the right submenu
window.onload = init;
function init()
{
	//Retrieve the menu to be shown from the URL
	var ditmenu = QueryString("m")
	if (!ditmenu)
	{
		ditmenu = ''
	}	
	//set current page position
	setRootPos();
	//show current menu
	showMenu(ditmenu);
	//eval(executeafter);
	
}

function setRootPos()
{
    var selIdx = -1;
    var Val;
    var qs = "";
    for(var i = 0; i < Menu1.length; i++)
    {
        if(Menu1[i][3] == document.location.pathname)
        {
            selIdx = i;
        }
    }
    if(selIdx == 0)
    {
        rootPos = "0";
    }
    else if(selIdx > 0)
    {
        Val = selIdx;
        while(Val != 0)
        {
            qs = Val + "." + qs;
            Val = Menu1[Val][1];
        }
        rootPos = qs.substring(0,qs.length-1);
    }
    else if(document.location.pathname.substr(document.location.pathname.length -1,1) == "/")
    {
       rootPos = "0";
    }
    else
    {
        rootPos = "";
    }
}

//Called from the website to write down the menu
function showMenu(menuPos)
{
    var container;
    var arrPos;
    if(!menuPos) menuPos = rootPos;
        arrPos = menuPos.split(".");
    var qs = "";
    var Val;
    
    // loop trough colums
    for( var j = 0; j < colCount - 1; j++)
    {
        if(j == 0)
            container = document.getElementById(containerName + (startIndex + j)).childNodes[0];
        else
            container = document.getElementById(containerName + (startIndex + j));
        var sb = "";
        var remId;
        //loop throught items
	    for(var i = 0; i < Menu1.length; i++)
	    {
	        qs = "";
	        //if not first column
	        if(j > 0)
	        {
	            Val = i;
	            while(Val != 0)
	            {
	                qs = Val + "." + qs;
	                Val = Menu1[Val][1];
	            }
	            
	            qs = qs.substring(0,qs.length-1);
	            
	            //if item is sub of selected item
	           if(arrPos[j-1] == Menu1[i][1])   //
	           {                                //
	                if(Menu1[i][0] == j)
	                {
	                    if(remId != Menu1[i][1])
	                    {
	                        if(remId == null)
	                            sb += "<div id='menu" + Menu1[i][1] + "body' class=menusub><div id=mnuBlock><table cellspacing=0 cellpadding=0><tr><td valign='bottom'>";
	                        else
	                            sb += "</td></tr></table></div></div><div id='menu" + Menu1[i][1] + "body' class=menusub><div id=mnuBlock><table cellspacing=0 cellpadding=0><tr><td valign='bottom'>";
	                    }
	                        
	                
	                    sb += "<div"
	                    if(arrPos[j] && arrPos[j] == i)
	                        sb += " class='selected'";
	                    sb += "><a href='" + Menu1[i][3] + "' ";
	                    //sb += "onMouseOver='openMenu(" + i + "); openMenu(" + Menu1[i][1] + ");' onMouseOut='closeMenu(" + i + ");'";
	                    sb += ">" + Menu1[i][2] + "</a></div>";
	                    
	                    remId = Menu1[i][1];
	                    
	                    if(i == Menu1.length)
	                        sb += "</td></tr></table></div></div>";
	                }
	            }//
	        }
	        else
	            if(Menu1[i][0] == j)
	            {
	                if(i==0)
	                    sb += "<div id=mnuBlock><table cellspacing=0 cellpadding=0><tr><td valign='bottom'>";
	                sb += "<div";
	                if(arrPos[j] && arrPos[j] == i)
	                    sb += " class='selected'";
	                sb += "><a href='" + Menu1[i][3] + "' ";
	                //sb += "onMouseOver='openMenu(" + i + ");' onMouseOut='closeMenu(" + i + ");'";
	                sb += ">" + Menu1[i][2] + "</a></div>";
	                
	            }
	    }
	    var classname = "";
	    if(j > 0 && sb != "")
	        container.className = "dottedline";
	    if(container && sb != "")
	    {
	        if(j == 0)
	        {
	            sb = sb + "</td></tr></table></div>";
	            container.innerHTML = sb;
	        }
	        else
	        {
	        container.innerHTML = sb;
	        }
	    }	        
	}
}

function goToUrl(url)
{
	document.location.href = url;
}

