/* live site configuration for images */
var mosconfig_live_site;

/* prefix for the menu in the list-elements class e.g. <li class="prefix"> */
var sqillsMenuPrefix='menulevel';

/* variable for the timeout, to hide the menu*/
var sqillsMenuTimeOut;


/* Menu open or closed */
var sqillsMenuOpen = false;

/** Function: sqillsMenuActivate :: controls the menu
 * @param node aelement : This function is called from this a-element
 * Description: this function builds the menu according to the current element.
 * 			First: determine current level and stop timer (timer is used to close menu)
 * 			Second: close all higher levels (higher number is lower in the tree)
 * 			Third: If needed, setup up the menu space
 * 			Fourth: Make this element the current element == active highlighting 
 * 			Last: Open the actual sub menu that corresponds with this element
 */
 
//var sqillsMenuLI = new Array();
var sqillsMenucLI = new Array();


function sqillsMenuActivate(aelement,live_site){

	/* set mosconfig_live_site for images */
	mosconfig_live_site = live_site;

	/* break current counter*/
	clearTimeout(sqillsMenuTimeOut);
	
	/* first detect which level we are one*/
	var level=0;

	/* parent of a-element == li-element */
	var parNode = $(aelement.parentNode);

	/* Find level of li element */
	for (var a=1; a<5; a++) 
	{
		if (parNode.hasClassName(sqillsMenuPrefix+a))
		{
		    level=a;
		    break;
		}
	}

	/* if level == 1 then show the menu ! */
	if(level==1)
	{
		sqillsLeftMenuChange(aelement);
		$('navigation').setStyle("height: 200px; display: block");
		$('subnavigationbg').show();
		sqillsMenuOpen = true;
	}
		
	/* make current item the active/current item! */
	sqillsMenuCurrent(aelement,level);
	
	
	
	
}





/** Function sqillsMenuCurrent :: makes the current item on this level active
 * @param node aelement : the node that has to be active
 * @param int level : the current level
 * @require csscode for the id eg currentlevel1, currentlevel2 etc
 * Description: makes the curren element active
 * 		Case 1: no headline menu (level != 1)
 * 			First: search if any element is set active on this element
 * 			Second: delete this attribute
 * 			Last: put an id on this element
 * 		Case 2: element is headline (level == 1)
 * 			First: remove styles of the current element that is selected
 * 			Last: put styles on the current element
 */
function sqillsMenuCurrent(aelement , level)
{
	sqillsCloseMenu(level);
	
	$(aelement.parentNode).addClassName('currentli');
	sqillsMenucLI[level] = aelement.parentNode;
	
}


/**
 * Function sqillsLeftMenuChange :: changes the text on the left side of the menu
 * @param node aelement : the link corresponding with the current text
 * Description: overwrites the context of the id's
 */
function sqillsLeftMenuChange(aelement)
{
	var newicon = "over_edu_actief";
	var newtext = "Edu'actief";
	var newheader = "";
	
	/* section Nieuws */
	if(aelement.firstChild.nodeValue=="Nieuws"){
		newicon="nieuws";
		newheader="Nieuws";
		newtext="Hier vindt u het laatste nieuws van en over Uitgeverij Edu'Actief b.v.";
	}

	/* section Agenda */
	if(aelement.firstChild.nodeValue=="Agenda"){
		newicon="agenda";
		newheader="Agenda";
		newtext="Omdat u niets wilt missen, staan in deze agenda onze belangrijkste bijeenkomsten op een rij.";
	}

	/* section Onderwijstype */
	if(aelement.firstChild.nodeValue=="Onderwijstypen"){
		newicon="onderwijstype";
		newheader="Onderwijstypen";
		newtext="Hier vindt u de onderwijstypen waarvoor wij materiaal ontwikkelen.";
	}

	/* section Onderwijstype */
	if(aelement.firstChild.nodeValue=="Edu'Assist"){
		newicon="eduassist";
		newheader="Edu'Assist";
		newtext="De implementatie van nieuwe methodes vraagt inmiddels meer dan het bestuderen van de docentenhandleiding. Hier leest u daar alles over.";
	}

	/* section Onderwijstype */
	if(aelement.firstChild.nodeValue=="Methodesites"){
		newicon="methodesites";
		newheader="Methodesites";
		newtext="Hier kunt u terecht voor meer informatie over de methodesites. Ook vraagt u hier uw docentencode aan.";
	}

	/* section Help */
	if(aelement.firstChild.nodeValue=="Catalogus"){
		newicon="online_catalogus";
		newheader="Catalogus";
		newtext="In deze online catalogus vindt u actuele informatie over onze nieuwe en bestaande uitgaven. ";
	}

	/* section Help */
	if(aelement.firstChild.nodeValue=="Over Edu'Actief"){
		newicon="over_edu_actief";
		newheader="Over Edu'Actief";
		newtext="Hier vindt u informatie over de uitgeverij, zoals onze contactgegevens, vacatures en onze leveringsvoorwaarden.";
	}

	//document.write( mosconfig_live_site+"/templates/static/gfx/iconen/subnav_"+aelement.firstChild.nodeValue.toLowerCase()+".png" );
	
	$('introtextimage').src = mosconfig_live_site+"/templates/static/gfx/iconen/subnav_"+newicon+".png";
	$('introtextheader').firstChild.nodeValue = newheader;
	$('introtextshorttext').firstChild.nodeValue = newtext;
}
/** Function sqillsCloseMenu :: close all sub-menus with higher levels
 * @param int level : the current level, higher number == lower in subtree (lower in submenu)
 * Description: closes the lists with higher classes (on the UL element)
 * 		First: get all UL - elements
 * 		Second: Check if the current UL element has a higher level (deeper in menu structure)
 * 		Last: set display on none
 */
function sqillsCloseMenu(level)
{
	for (var i = (level); i < 5; i++)
		if (sqillsMenucLI[i])
				sqillsMenucLI[i].removeClassName('currentli');
}

/** Function sqillsMenuToClose :: Initiating the closing procedure
 * Description: Initiates a timer-countdown to close the current menu 
 */
function sqillsMenuToClose()
{
	if(sqillsMenuTimeOut!=null){
		clearTimeout(sqillsMenuTimeOut);
		sqillsMenuTimeOut=null;
	}
	sqillsMenuTimeOut=setTimeout("sqillsDeactivateMenu()",1);
}

/** Function sqillsDeactivateMenu :: closes the menu
 * Description :: closes menu structure
 * 		First: close all submenus (ul-list)
 * 		Second: hide the background / text 
 */
function sqillsDeactivateMenu()
{
	if (sqillsMenuOpen == true)
	{
		sqillsCloseMenu(1);
		$('navigation').setStyle('height:34px');
		$('subnavigationbg').hide();
		sqillsMenuOpen = false;
	}
}



