var parentNode = null;
var childNode = null;
var childChildNode = new Array();
var timer = null;
var childNodeOn = null;
var cunningvar = null;
var parentArray = new Array();

function removeEl() {
	for(var i=0;i<childChildNode.length;i++) {
		if(childChildNode[i]!=childNodeOn)
			childChildNode[i].style.left = '-999em';
	}
}

window.onload = function() {
	parentArray = document.getElementById('navbar').childNodes;
	for(var i=0;i<parentArray.length;i++) {
		var el = parentArray[i];
		el.className = 'navparent';
		if(el.getElementsByTagName('ul')[0]) {
			var myul = el.getElementsByTagName('ul')[0];
			el.myUL = myul;
			myul.state = 0;
			el.onmouseover = function() {
				this.myUL.style.left = 'auto';
				childChildNode.push(this.myUL);
				parentNode = this;
				childNodeOn = this.myUL;
				removeEl();
			}
			el.onmouseout = function() {
				timer = setTimeout(removeEl,500);
				childNodeOn = null;
			}
			el.myUL.onmouseout = function() {
				this.style.left = '-999em';
			}
			var children = new Array();
			children = el.myUL.childNodes;
			for(var a=0;a<children.length;a++) {
				var child = children[a];
				if(child.getElementsByTagName('ul')[0]) {
					var myNewUL = child.getElementsByTagName('ul')[0];
					child.myUL = myNewUL;
					child.onmouseover = function() {
						clearTimeout(timer);
						this.myUL.style.left = 'auto';
						childNode = this;
					}
					child.onmouseout = function() {
						this.myUL.style.left = '-999em';
					}
				} else {
					child.onmouseover = function() {
						clearTimeout(timer);
					}
				}
			}
		}
	}
}