function Menu()
{
	this.categories = new Array();
	this.currentSubmenu = '';
}

Menu.prototype._mouseOver = function(categoryId, iteration, totalItems)
{
	this.currentSubmenu = categoryId;
	oMenu.show(categoryId, true, iteration, totalItems);
}

Menu.prototype._mouseOut = function(categoryId, iteration, totalItems)
{
	this.currentSubmenu = '';
	//setTimeout('oMenu.show(\''+categoryId+'\', false, \''+iteration+'\', \''+totalItems+'\')', 0);
	oMenu.show(categoryId, false, iteration, totalItems);
}

Menu.prototype.show = function(categoryId, show, iteration, totalItems)
{
	var menuId = 'liCategory_'+categoryId;
	var menuObj = document.getElementById(menuId);
	
	if(show)
	{
		if(categoryId && categoryId != 'Home')
		{
			var subMenuObj = document.getElementById('content_'+categoryId);
			subMenuObj.style.display = '';
			var subMenuBorder = document.getElementById('border_'+categoryId);
			subMenuBorder.style.display = '';
			var divObj = document.getElementById('subcategoriesContent');
			divObj.style.position = 'absolute';
			divObj.style.left = this.getMenuLeftPosition(menuObj);
			
			if(oBrowser.isWindows())
			{
				divObj.style.top = '154px';
			}
			else if(!oBrowser.isWindows())
			{
				divObj.style.top = '153px';
			}
			
			if(oBrowser.isIE())
			{
				divObj.style.top = '149px';
			}
		}
		menuObj.className = 'menuHover';
		document.getElementById("categoryLink_"+categoryId).style.color = "#FFFFFF";
		
		//IEs hack
		menuObj.style.background = 'url(\'/images/bgMenu.gif\') repeat-x 1px -30px';
		
		//document.getElementById("debug").innerHTML = iteration+" "+totalItems;
		
		if(typeof(iteration)!="undefined" && typeof(totalItems)!="undefined")
		{
			if(iteration=="1")
			{
				document.getElementById("borderMenuLeft").style.backgroundPosition = "7px 0";
			}
			else if(iteration==totalItems)
			{
				document.getElementById("borderMenuRight").style.backgroundPosition = "7px 0";
			}
		}
	}
	else
	{
		if(this.currentSubmenu != categoryId)
		{
			var subMenuObj = document.getElementById('content_'+categoryId);
			subMenuObj.style.display = 'none';
			var subMenuBorder = document.getElementById('border_'+categoryId);
			subMenuBorder.style.display = 'none';
			menuObj.className = 'menu';
			menuObj.style.background = '';
			menuObj.style.margin = '0px';
			
			document.getElementById("categoryLink_"+categoryId).style.color = "#b5bcc2";
			
			if(typeof(iteration)!="undefined" && typeof(totalItems)!="undefined")
			{
				if(iteration=="1")
				{
					document.getElementById("borderMenuLeft").style.backgroundPosition = "0 0";
				}
				else if(iteration==totalItems)
				{
					document.getElementById("borderMenuRight").style.backgroundPosition = "0 0";
				}
			}
		}
	}
}

Menu.prototype.getMenuLeftPosition = function(menuObj)
{
	var i = 0;
	var menus = document.getElementById('menu').getElementsByTagName('li');
	var widths = 0;
	
	while(menus[i].getAttribute('id') != menuObj.getAttribute('id') && i < menus.length)
	{
		widths += (menus[i].offsetWidth);
		i++;
	}

	var body = document.getElementsByTagName('body')[0];
	var width = body.clientWidth;
	
	var offsetLeft = widths+23;
	
	if(oBrowser.isIE())
	{
		offsetLeft = offsetLeft+0;
	}
	
	var x = ((width - document.getElementById('linksTop').offsetWidth) / 2)  + offsetLeft;
	return x+'px';
}

Menu.prototype.mouseClick = function()
{
	
}

Menu.prototype.sessionCategory = function(categoryId)
{
	this.categories.push(categoryId);
}

Menu.prototype.formRegister = function(obj)
{
	var formRegister = document.getElementById('formRegister');
	var msg = document.getElementById("msgLogin");
	
	if(msg)
	{
		msg.style.display = "none";	
	}	
	
	if(formRegister.style.display == "none")
	{
		formRegister.style.display = 'block';
		var divLogin = document.getElementById('divLogin');
		divLogin.style.display = 'none';
	}
	else
	{
		formRegister.style.display = 'none';
		var divLogin = document.getElementById('divLogin');
		divLogin.style.display = 'block';
	}
}


var oMenu = new Menu();
