function createCookie(name,value,days){
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name){
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function display_menu(expand, cat_number) 
{ // 'expand' is div id so we can target specific div. cat_number allows us to define the loop cutoff

    if (document.getElementById("nav_container_"+expand).style.display == 'none') 
	{ // If the divs already displayed, hide it!
	
		var loopIndex=1 // Set loop index
        
        for(loopIndex = 1; loopIndex <=(cat_number); loopIndex++) 
		{ // Declare for loop to display/hide relevant lists.
        
        	if(loopIndex == expand) 
			{ // If the index is the same as the current div id display the lists.
        	
			document.getElementById("nav_container_"+expand).style.display = 'block'
			createCookie('myCookie', (expand), 365)
			}
			
			/*else 
			{
			
			document.getElementById(loopIndex).style.display = 'none' // Set irrelevant divs to display 'none'.
			
			}     */
					
		}
        
	} else 
		
	{
	
        document.getElementById("nav_container_"+expand).style.display = 'none'
		eraseCookie('myCookie')
		
    }
		
		document.getElementById('navigation_menu').style.display = 'block' // Set 'sitenav' div to display using block element. We need this to elimate flicker caused by the list items expanding.
}


function load_menu() 
{
document.getElementById('navigation_menu').style.display = 'block'
}
