//Declarations
var cssMouseOver = ""
var cssMouseOut = ""
var subNavId = new Array()
var subNavCount = 0;
var subULCount = 0;


//Insert mouse event function in UL Lists
function menuEvent(id){
	obj = document.getElementById(id);
	objName = document.getElementById(id).id
	if (obj != null){	
	    for (c=0; c < obj.childNodes.length; c++){	    
	    objNode = obj.childNodes[c];	    
		    if(objNode.nodeName == "LI"){
				if(objName =="nav"){
	            	mouseEvent(objNode,id);}
				else{
					mouseEvent1(objNode,id);}
			    if (objNode.childNodes.length > 1){  
			        subMenu(objNode,c);
				
			    }			    
		    }
	    }
	    if (subULCount < subNavCount){	                
            subULCount++;
            menuEvent(subNavId[subULCount-1]);            
	    }
	}	
}

function footerLogoOver(name){
	 document.getElementById('fImage').src = 'images/footerLogo_over.jpg';
}

function footerLogoOut(name){
	 document.getElementById('fImage').src = 'images/footerLogo.jpg';
}


//If sub UL is present, assign an ID.
function subMenu(obj,c){
    subObjNode = obj;    
    for(b=0; b < subObjNode.childNodes.length; b++){
        objSubNode = objNode.childNodes[b];        
        if(objSubNode.nodeName == "UL"){		                            
            subNavId[subNavCount] = "subnav" + (subNavCount + c);
            objSubNode.id = subNavId[subNavCount];              
            subNavCount++;                  
        }
    }        
}

//Mouse event function
function mouseEvent(obj,id){ 
    objNode.onmouseover = function(){

			if(this.className =="homeOut"){
				this.className= id == "nav" ? "homeOver" : "";}
			else{
				this.className= id == "nav" ? "over" : "liOverBG";}
	}
    objNode.onmouseout = function(){
			
			if(this.className =="over" || this.className =="out" ){
				this.className= id == "nav" ? "out" : "";}
			else{
				this.className= id == "nav" ? "homeOut" : "";}
		
	
	}

}


function mouseEvent1(obj,id){
	
    objNode.onmouseover = function(){

			if(this.className =="noBorderImg" || this.className =="outnoBorderImg"){
				this.className= id == "nav1" ? "noBorderoverTop" : "liOverBG";}
			else{
				this.className= id == "nav1" ? "overTop" : "liOverBG";}
	}
    objNode.onmouseout = function(){
			
			if(this.className =="overTop" || this.className =="out" ){
				this.className= id == "nav1" ? "out" : "";}
			else{
				this.className= id == "nav1" ? "outnoBorderImg" : "";}
		
	
	}
	

}

//Initiate script after page load
window.onload = function() {
menuEvent("nav");}

