

var activeMenus = new Array();
var timerId = false;




function menu_mouseOver()
{
	if(timerId){
		window.clearTimeout(timerId);
		timerId = false;
	}
	document.getElementById("menuBlock").style.display = "block";
}


function menu_mouseOut()
{
	
	if(timerId){
		window.clearTimeout(timerId);
		timerId = false;
	}
	timerId = window.setTimeout("menuHideAll()",500);
}






function mouseOver()
{
	var child = false;
	
	this.style.color = 'white';
	this.style.backgroundColor = '#3366CC';
	
	if(this.childNodes.length > 0 && this.childNodes[0].tagName == "A"){
		this.childNodes[0].style.color = 'white';
	}
	
	
	for(var i=0;i<this.childNodes.length; i++){
		if(this.childNodes[i].className == "menuChild"){
			child = this.childNodes[i];
			break;
		}
	}
	if(child != false){
		menuDisplay(child);
	}else{
	
	if(timerId){
		window.clearTimeout(timerId);
		timerId = false;
	}
	
		for(var i=activeMenus.length - 1; 0<=i; i--){
			if(activeMenus[i] != this.parentNode){
				menuHide(activeMenus[i]);
			}else{
				break;
			}
		}
	}
	
}






function mouseOut()
{
	this.style.color = 'black';
	this.style.backgroundColor = 'white';
	
	if(this.childNodes.length > 0 && this.childNodes[0].tagName == "A"){
		this.childNodes[0].style.color = 'black';
	}
	
	
	if(timerId){
		window.clearTimeout(timerId);
		timerId = false;
	}
	timerId = window.setTimeout("menuHideAll()",500);
}


function menuDisplay(obj)
{
	if(timerId){
		window.clearTimeout(timerId);
		timerId = false;
	}
	if(obj.style.display == "block"){
		return; 
	}
	for(var i=activeMenus.length - 1; 0<=i; i--){
		if(activeMenus[i] != obj.parentNode.parentNode){
			menuHide(activeMenus[i]);
		}else{
			break;
		}
	}
	

	
	var parent = obj.parentNode;
	
	obj.style.display = "block";
	obj.style.zIndex = parent.style.zIndex;
	obj.style.left = parent.clientWidth - 10;
	obj.style.top = parent.clientHeight - 15;
//	obj.style.color = 'white';
	activeMenus.push(obj);
	
	for(var i=0;i<obj.childNodes.length; i++){
		if(obj.childNodes[i].className == "menuObj" || obj.childNodes[i].className == "menuObj bgimg"){
			obj.childNodes[i].style.zIndex = parent.style.zIndex + "0";
			obj.childNodes[i].style.zIndex -= i;
		}
	}
}


function menuHideAll()
{
	if(activeMenus.length == "0"){
		document.getElementById("menuBlock").style.display = "none";
	}else{
		menuHide(activeMenus[0]);
		document.getElementById("menuBlock").style.display = "none";
	}
}


function menuHide(obj)
{
	if(obj.style.display == "none"){
		return;
	}
	obj.style.display = "none";
	
	
	for(var i=activeMenus.length - 1; 0<=i; i--){
		if(activeMenus[i] == obj){
			activeMenus.splice(i,1);
			break;
		}
	}
	for(var i=0;i<obj.childNodes.length; i++){
		if(obj.childNodes[i].className == "menuChild"){
			menuHide(obj.childNodes[i]);
			break;
		}
	}
}

var func = function ()
	{
		nodes = document.getElementsByTagName("div");
		for(var i=0; i<nodes.length; i++){
			if(nodes[i].className == "menuObj" || nodes[i].className == "menuObj bgimg"){
				nodes[i].onmouseover = mouseOver;
				nodes[i].onmouseout = mouseOut;
			}
		}
	}
;

if(window.attachEvent){
	window.attachEvent("onload", func);
}else{
	window.addEventListener("load", func ,true);
}
