// SHOW/HIDE the Sub Navigation
Menu = {timer : null, current : null, currentClass : null, currentClassID : null};
Menu.navArray= new Array();
Menu.getStyle = function(name){
	if(document.getElementById) return document.getElementById(name).style;
	else if(document.all) return document.all[name].style;
	else if(document.layers) return document.layers[name];
}
Menu.show = function(name){
	if(this.timer) clearTimeout(this.timer);
	if (name.substring(name.length-1,name.length) == 1){//set instace of 0 in the array	
		this.navArray[0] = name.substring(0,name.length-1)+"0";	
	}
	this.navArray[name.substring(name.length-1,name.length)] = name; //set the instance position/value
	for (i= this.navArray.length-1; i>=0; i--){
		this.getStyle(this.navArray[i]).display = "inline"; //parse the array & set the visibilities
		this.main_change(name);
	}
	this.current = name;
	return false;
}
Menu.hide = function(){
	this.timer = setTimeout("Menu.doHide()",1750);
	return false;
}
Menu.doHide = function(toLayer){
	if(this.current){
		if (toLayer == null){toLayer=0;this.current = null;}
		for (i= this.navArray.length-1; i>toLayer; i--){
			this.getStyle(this.navArray[i]).display = "none";
			this.main_changeback(i, toLayer);
			this.navArray.pop();
		}
	}
	return false;
}
Menu.main_change = function(name){
	var theID = name.substring(0,name.length-1)+(name.substring(name.length-1,name.length) - 1);
	if (document.getElementById(theID).className != '' && document.getElementById(theID).className != "hovered"){
		this.currentClassID = theID;
		this.currentClass = document.getElementById(this.currentClassID).className;
	}
	document.getElementById(theID).className =  "hovered";
	return false;
}
Menu.main_changeback = function(i, toLayer){
	var theID = this.navArray[i].substring(0,this.navArray[i].length-1)+(toLayer);
	if (this.currentClassID == theID) {//matches currentpage css class
		document.getElementById(this.currentClassID).className =  this.currentClass;
		this.currentClass = '';
	} else if (document.getElementById(theID)){//has parent to switch
		document.getElementById(theID).className =  "";
	} else {//doesn't have parent so just change this
		document.getElementById(this.navArray[i].substring(0,this.navArray[i].length-1)+(toLayer + 1)).className =  "";
	}
	return false;
}
