// --------------------------------------------------------------------------------------
// Initiated when page is loaded
// --------------------------------------------------------------------------------------
var URL = "";
isMouseOver = false;
var currentparent = null;
var parentStack = new Array();
var containerStack = new Array();

// --------------------------------------------------------------------------------------
// Events that occur on mouseover events
// --------------------------------------------------------------------------------------
	
function mouseOver(containerName,level,parent,currentNode,url){
	isMouseOver = true;
	currentMouseOver = currentNode;
//	if(currentparent != null){
//		rollOn(currentparent);
//	}
	highlightParent(level,parent);
	openmouseover(containerName,level);
	changebgcolor(currentNode);
	clock.stop();
	URL = url;
}

function mouseOut(currentNode){
	isMouseOver = false;
	currentMouseOver = "";
	if(currentNode != null){
		changebgcolorback(currentNode);
	}
	
	clock.start();
	URL = "";
}

// --------------------------------------------------------------------------------------
// Clears levels above the current level
// --------------------------------------------------------------------------------------

function hideallMenus(level){
	for(var i = level ; i < containerStack.length ; i++){
		if(containerStack[level] != null){
			hideContainers(containerStack[i]);
		}
	}
	for(var j = level + 1 ; j < parentStack.length ; j++){
		if(parentStack[j] != null){
			changebgcolorback(parentStack[j]);
		}
	}
}

function hideContainers(containerName){
		if(document.all("topbar"+containerName.id[0])){
			document.all("topbar"+containerName.id[0]).style.visibility = "hidden";
		}
		for(var a = 0 ; a < containerName.id.length ; a++){
			document.all(containerName.id[a]).style.visibility = "hidden";
		}
		if(document.all("bottombar"+containerName.id[0])){
			document.all("bottombar"+containerName.id[0]).style.visibility = "hidden";
		}
}


// --------------------------------------------------------------------------------------
// Mouseover event for opening the child container on the main level
// --------------------------------------------------------------------------------------

function openMenu(containerNum,parentname){
	
	
		
	if(containerNum != null){
		openmouseover(container[containerNum][0],0);
	}else{
		hideallMenus(0);
	}
	
//	if(currentparent != null){
//		rollOff(currentparent);
//	}
//	currentparent = parentname;
//	if(currentparent != null){
//		rollOn(currentparent);
//	}
	
	clock.stop();

}

// --------------------------------------------------------------------------------------
// Click event for opening the child container on the main level
// --------------------------------------------------------------------------------------

function openClick(categoryNum){
	
		if(categoryNum != null){
			if(document.all(container[categoryNum][0].id[0]).style.visibility == "hidden"){
				rollOn(currentparent);
				hideallMenus(0);
				if(document.all("topbar"+container[categoryNum][0].id[0])){
					document.all("topbar"+container[categoryNum][0].id[0]).style.visibility = "visible";
				}
				for(var a = 0 ; a < container[categoryNum][0].id.length ; a++){
					document.all(container[categoryNum][0].id[a]).style.visibility = "visible";
				}
				if(document.all("bottombar"+container[categoryNum][0].id[0])){
					document.all("bottombar"+container[categoryNum][0].id[0]).style.visibility = "visible";
				}
			}else{
				hideallMenus(0);
//				rollOff(currentparent);
			}
		}
}

// --------------------------------------------------------------------------------------
// Opens the child container
// --------------------------------------------------------------------------------------

function openmouseover(containerName,level){
		if(containerName != null){
			hideallMenus(level);
			if(document.all("topbar"+containerName.id[0]) != null){
				document.all("topbar"+containerName.id[0]).style.visibility = "visible";
			}
			for(var a = 0 ; a < containerName.id.length ; a++){
				document.all(containerName.id[a]).style.visibility = "visible";
			}
			if(document.all("bottombar"+containerName.id[0]) != null){
				document.all("bottombar"+containerName.id[0]).style.visibility = "visible";
			}
			containerStack[level] = containerName;
		}else{
			hideallMenus(level);
		}
}

// --------------------------------------------------------------------------------------
// Highlights the parent Node
// --------------------------------------------------------------------------------------

function highlightParent(level,parent){
		if(document.all(parentStack[level]) != null){
			changebgcolorback(parentStack[level]);
		}
		if(document.all(parent) != null){
			changebgcolor(parent);
			parentStack[level] = parent;
		}	
}

// --------------------------------------------------------------------------------------
// Highlights the specified node
// --------------------------------------------------------------------------------------

function changebgcolor(nodeID){

		document.all(nodeID).style.backgroundColor = bgcolorOn;
}


// --------------------------------------------------------------------------------------
// Resets the color of current node
// --------------------------------------------------------------------------------------

function changebgcolorback(nodeID){
		document.all(nodeID).style.backgroundColor = bgcolorOff;
}


// ======================================================================================
// Netscape Specific Code
// ======================================================================================

// --------------------------------------------------------------------------------------
//	used to enable onclick events associtated to menu sys
// --------------------------------------------------------------------------------------

function beginListen(){
}

function endListen(){
}

function mousedown(){
	if(isMouseOver)	{
		location = URL;
	}
}
