var curr_icon_width = 0;
	var curr_drop_width = 0;
	var ary_icons = [];
	
	function init_menu ()
	{
		var icons = document.getElementsByTagName("div");
		
		for (i=0; i<icons.length; i++)
			if (icons[i].className == "_drop_icon_")
				ary_icons.push(icons[i].id);
	}
	
	function GetIndexOf (array, value)
	{
		if (array.indexOf)
			return array.indexOf(value);
		else
		{
			for(i=0; i<array.length; i++)
			{
				if (array[i] == value)
					return i;
			}
			
			return -1;
		} 
	}

	function menu_action (id, hover)
	{
		menu_hover (id, hover);	// the custom script for hover styles
		toggle_drop_down(id, hover);
	}

	function toggle_drop_down (id, hover)
	{
		var drop = document.getElementById("nav_" + id);
		
		curr_drop_width = drop.offsetWidth;
			
		if (GetIndexOf(ary_icons, id) == 0)
			drop.style.marginLeft = "0px";
		else if (GetIndexOf(ary_icons, id) == ary_icons.length-1)
			drop.style.marginLeft = "-" + (curr_drop_width - curr_icon_width) + "px";
		else if (curr_drop_width > curr_icon_width)
			drop.style.marginLeft = "-" + ((curr_drop_width - curr_icon_width) / 2) + "px";
		else if (curr_drop_width >= curr_icon_width)
			drop.style.marginLeft = ((curr_icon_width - curr_drop_width) / 2) + "px";
			
		if (hover)
			drop.style.visibility = "";
		else
			drop.style.visibility = "hidden";
	}
	
	function toggle_drop_down_2 (id, hover)
	{
		var drop = document.getElementById("nav_" + id);
		
		//alert(drop.offsetWidth);
			
		if (hover)
			drop.style.visibility = "";
		else
			drop.style.visibility = "hidden";
	}
	
	function isMouseLeaveOrEnter(e, handler)
	{		
		if (e.type != 'mouseout' && e.type != 'mouseover') return false;
		var reltg = e.relatedTarget ? e.relatedTarget :
		e.type == 'mouseout' ? e.toElement : e.fromElement;
		while (reltg && reltg != handler) reltg = reltg.parentNode;
		return (reltg != handler);
	}
	
	function menu_hover (id, hover)
	{	
		var obj = document.getElementById("menu_" + id);
		
		if (hover)
			obj.className = "nav_selected";
		else
			obj.className = null;
			
		curr_icon_width = obj.offsetWidth;
	}

	function item_hover (id, hover)
	{
		var obj = document.getElementById("item_" + id);
		
		if (hover)
			obj.style.backgroundColor = "#726A4F";
		else
			obj.style.backgroundColor = "#a39a76";
	}	
	
	function item_hover_2 (id, hover)
	{
		var obj = document.getElementById("item_" + id);
		
		if (hover)
		{
			obj.style.backgroundColor = "#726A4F";
			obj.style.color = "#ffffff";
		}
		else
		{
			obj.style.backgroundColor = "#8B8871";
			obj.style.color = "#ffffff";
		}
	}	