var timecount=500;
var timerOn=false;
var timerID;

function DropDownItem(name,top,left) {
	this.name=name;
	this.top=top;
	this.left=left;
	this.hide=hide;
	this.show=show;
	this.startTime=startTime;
	this.stopTime=stopTime;

	function show() {
		document.getElementById(this.name).style.visibility="visible";
		document.getElementById(this.name).style.left=this.left+"px";
		document.getElementById(this.name).style.top=this.top+"px";
	}

	function hide() {
		document.getElementById(this.name).style.visibility="hidden";
	}

	function startTime() {
    	if (timerOn == false) {
           timerID=setTimeout("menu.hideAll()", timecount);
           timerOn=true;
		}
	}

	function stopTime() {
    	if (timerOn) {
	        clearTimeout(timerID);
            timerID=null;
            timerOn=false;
	    }
	}	
}

function DropDownMenu() {
	this.hideAll=hideAll;
	this.hideOthers=hideOthers;
	
	this.list=new Array(arguments.length);
	for(var i=0;i<arguments.length;i++) {
		this.list[i]=arguments[i];
	}

	function hideAll() {
		for(var i=0;i<this.list.length;i++) {
			this.list[i].hide();
		}
	}

	function hideOthers(current) {
		for(var i=0;i<this.list.length;i++) {
			if (this.list[i].name==current) {
				this.list[i].show();
			} else {
				this.list[i].hide();
			}
		}
	}
	
}

function init() {
	var parent1=document.getElementById('nav-dd_WW1');
	var parent5=document.getElementById('nav-dd_WW5');
	var child=parent1.getElementsByTagName('li');
	
	parent1.onmouseover=function() {dd1.stopTime();dd1.show();};
	parent1.onmouseout=function() {dd1.startTime();};
	parent5.onmouseover=function() {dd5.stopTime();dd5.show();};
	parent5.onmouseout=function() {dd5.startTime();};
	for (var i=0;i<child.length;i++) {
/*		if (child[i].childNodes[0].nodeName=='A') {
			child[i].childNodes[0].style.width=child[i].offsetWidth+'px';
			child[i].childNodes[0].style.height=child[i].offsetHeight+'px';
		}*/
//		child[i].childNodes[0].onmouseover=function() {this.style.background='#fff';};
//		child[i].childNodes[0].onmouseout=function() {this.style.background='none';};
	}
}

var dd1=new DropDownItem("nav-dd_WW1",139,69);
var dd5=new DropDownItem("nav-dd_WW5",139,803);
var menu=new DropDownMenu(dd1,dd5);
window.onload=init;