/********************************************************************************
*********************************************************************************

	Created: 29-04-2009
	By: Danny Siew
	Copyright (c) Evolve Creative (htttp://www.evolvecreative.com.au)

*********************************************************************************
********************************************************************************/

//execute this code once the page has finished loading
window.onload = function(){

	//target the main menu UL using it's ID
	var mainMenuItems = document.getElementById('theMenu');
	//get a list of all the LI elements within
	mainMenuItems = mainMenuItems.getElementsByTagName('li');

	//run a loop to only assign event handlers to the menu items
	for(i=0;i<mainMenuItems.length;i++){
		//sort out the main menu LI tags from the nested ones
		//by looking for the substring of 'menu' within the ID
		if(mainMenuItems[i].id.search('menu') != -1){
			//assign rollover and rollout states to the menu items
			mainMenuItems[i].onmouseover = onRollOver;
			mainMenuItems[i].onmouseout = onRollOut;
		}
	}
}

//declare rollover state
function onRollOver(){
	//checks to see if the current page's link was triggered
	if(this.className.search("selected") == -1){
		//if not, change the LI tag's class
		this.className = "li_active";
		//get the nested A tag
		getA = this.getElementsByTagName('a')[0];
		//change the A tag's class
		getA.className = "active";
	}	
}

//declare rollover state
function onRollOut(){

	//checks to see if the current page's link was triggered
	if(this.className.search("selected") == -1){
		//if not, change the LI tag's class
		this.className = "";
		//get the nested A tag
		getA = this.getElementsByTagName('a')[0];
		//change the A tag's class
		getA.className = "";
	}
}