/*
	This menuinit function will not work well once it is running on a the hosting.
	
	You wont see this now but once this is uploaded there will be a delay in setting these to display none using javascript. 
	This will cause the submenus to show for a moment and then be hidden.

	The image src should be defined in the code otherwise it is not valid and may show an empty image while the icons are loading.  

function menuinit() {
	

	
    document.getElementById('m1').style.display = 'none';
    document.getElementById('m2').style.display = 'none';
    document.getElementById('m3').style.display = 'none';
	document.getElementById('m4').style.display = 'none';
	document.getElementById('m5').style.display = 'none';
	document.getElementById('m6').style.display = 'none';
	 
	document.getElementById('pm1').src = 'plus.png';
	document.getElementById('pm2').src = 'plus.png';
	document.getElementById('pm3').src = 'plus.png';
	document.getElementById('pm4').src = 'plus.png';
	document.getElementById('pm5').src = 'plus.png';
	document.getElementById('pm6').src = 'plus.png';
	
}
*/
function menuexpand (i) {
	 /* defined variables so that the script is quicker. 
	 document.getElementById (and all dom related functions) is relatively slow so it's best to run it as few times as possible */
	 var arrImages = document.getElementById('nav').getElementsByTagName('img');
	 var arrULs = document.getElementById('nav').getElementsByTagName('ul');
	 var objUl = document.getElementById(i);
	 var objImage = document.getElementById('p' + i);
	 

	 
	
	 /* changed the condition to check whether the menu is open or not based on what style is applied */
     if (objUl.style.display == 'block') {
		objImage.src = 'images/plus.png';
		objUl.style.display = 'none';
	} else {
		objImage.src = 'images/minus.png';
		objUl.style.display = 'block';
	}
	for (var i in arrImages){
		if(arrImages[i].id!=objImage.id){
		 arrImages[i].src = 'images/plus.png';
		}
	}
	for (var i in arrULs){
		if(arrULs[i].id!=objUl.id){
			if(typeof(arrULs[i].style)!='undefined'){
			 arrULs[i].style.display = 'none';
			}
		}
	}	 
	return false;
}
