
addListenner(window, "load", mainMenuRollover, true);





function mainMenuRollover()
{
	var oMenu = document.getElementById('menu');
	if (!oMenu) {
		return false;
	}
	
	for (var oN = oMenu.firstChild; oN; oN = oN.nextSibling) {
		oN.onmouseover = showMenu;
		oN.onmouseout = hideMenu;
	}
}




var intervalManager = function () {};
//window.opeActions = [];

intervalManager.prototype =
{
	interval: null,
	actions: [],
	
	add: function(fn)
	{
		var that = this;
		this.actions[this.actions.length] = fn;
		if (!this.interval) {
			//window.interval = setInterval("intervalManagerRun()", 30);
			this.interval = setInterval(function()
									    {
											if (that.actions.length <= 0) {
												return false;
											}
											for (var i = 0; i < that.actions.length; i++) {
												if (that.actions[i]) {
													that.actions[i]();
												}
											}
									    }, 30);
		}
		return this.actions.length - 1;
	},
	
	
	remove: function(id) 
	{
		this.actions.splice(id, 1);
		if (this.actions.length <= 0 && this.interval) {
			clearInterval(this.interval);
			this.interval = null;
		}
	}

} // end of "intervalManager()"


/*
function intervalManagerRun()
{
	if (!window.opeActions || window.opeActions.length <= 0) {
		return false;
	}
	for (var i = 0; i < window.opeActions.length; i++) {
		if (window.opeActions[i]) {
			window.opeActions[i]();
		}
	}
	//setTimeout("intervalManagerRun()", 30);
}*/




var OpeTimer = new intervalManager();


function showMenu()
{
	if (this.hideTimer) {
		clearTimeout(this.hideTimer);
	}
	/*if (this.hideInterval) {
		OpeTimer.remove(this.hideInterval);
		this.hideInterval = null;
	}*/
	if (this.className.indexOf('on') >= 0) {
		return false;
	}
	var ul = this.firstChild.nextSibling;
	ul.style.width = this.clientWidth + 'px';
	addClass(this, 'on');
	
	var li   = ul.getElementsByTagName('li');
	var max  = li.length;
	var that = this;
	var counter = 0;
	
	if (document.all) {
		for (var i=0; i < li.length; i++) {
			addClass(li[i], 'on');
		}
		
	} else {
		this.showTimer = OpeTimer.add(
				function()
				{ 
					if (ul.style.width) {
						ul.style.width = null;
					}
					addClass(li[counter], 'on');
					counter++;
					if (counter >= max) {
						OpeTimer.remove(that.showTimer);
						that.showTimer = null;
					}
					return true; 
				}, 30);
	}
}




function hideMenu()
{
	/*if (this.className.indexOf('on') == null) {
		return false;
	}*/
	if (this.showTimer) {
		OpeTimer.remove(this.showTimer);
		this.showTimer = null;
	}
	var that = this;
	var ul = this.firstChild.nextSibling;
	var li = ul.getElementsByTagName('li');
	var counter = li.length;
	
	function hideFn()
	{
		if (that.showTimer) {
			OpeTimer.remove(that.showTimer);
			that.showTimer = null;
		}
		//if (document.all) {
			for (var i=0; i < counter; i++) {
				removeClass(li[i], 'on');
			}
			removeClass(that, 'on');
			clearTimeout(that.hideTimer);
			
		/*} else {
			that.hideInterval = OpeTimer.add(
				function()
				{ 
					if (counter >= 0) {
						removeClass(li[counter], 'on');
					}
					counter--;
					if (counter < 0) {
						OpeTimer.remove(that.showTimer);
						removeClass(that, 'on');
					}
					return true; 
				});
		}*/
		
	};
	
	this.hideTimer = setTimeout(hideFn, 200);

}








