var aStack = new Array();
startList = function() {
	var nodes = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<nodes.length; i++) {
		
		nodes[i].onmouseover = function() { 

			this.className = (' ' + this.className).replace(/([ ]|[$])over/g, " ");
			this.className += " over";
			push(this);
		}
		nodes[i].onmouseout = function() {
			this.className = (' ' + this.className).replace(/([ ]|[$])over/g, " ");
			pop(this)
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", startList); 
if (window.addEventListener) window.addEventListener('load',startList,true);
//if (document.addEventListener != null) document.addEventListener('click',startList,true);
//
function push(element) {
	oPop = aStack.pop();
	if (oPop == element)
	{
		aStack.push(oPop);
	}
	aStack.push(element);
}
// Достает элемент из стека дерева
function pop(element) {
	oPop = aStack.pop();
	if (oPop != element)
	{
		aStack.push(oPop);
		
	} 
}
