var ManMenu =
{
	overUl: "humanbody",
	divList: "manlist",
	//This fuction sets up the list. It finds all li in the ul and adds listener events to them. It also hides all of them although they should already be hidden. 
	init: function()
	{	
		ManMenu.hideAll();
		$("#" + ManMenu.overUl + " li a").bind("mouseover",ManMenu.showMenuListener);
		$("#" + ManMenu.overUl + " li a").bind("mouseout",ManMenu.stopTimerListner);

	},
	//hides all div under the div list by adding a hidding class
	hideAll: function()
	
	{ 
		$("#" + ManMenu.divList + " div").addClass('menuHide');
	},
	//this function starts by hiding all the menues , then it gets the link from each element(LI) and breaks off the div id from them. it removes any hidemenu classes and adds the show menu class. 
	showMenu: function(element)
	{
		ManMenu.hideAll();
		var elementLink = element.href;
		var matchingDiv = elementLink.substring(elementLink.indexOf('#'));
		$(matchingDiv).removeClass('menuHide');
		$(matchingDiv).addClass('menuShow');
	},
	showMenuListener: function(event)
	{	
		var bodypart = this;
		this._timer=setTimeout(function(){ManMenu.showMenu(bodypart);},100);
	},
	stopTimerListner: function(event)
	{
	clearTimeout(this._timer);
	}
};
var WomenMenu =
{
	overUl: "womanhumanbody",
	divList: "womanlist",
	init: function()
	{
		WomenMenu.hideAll();
		$("#" + WomenMenu.overUl + " li a").bind("mouseover",WomenMenu.showMenuListener);
		$("#" + WomenMenu.overUl + " li a").bind("mouseout",WomenMenu.stopTimerListner);

	},
	hideAll: function()
	{
		$("#" + WomenMenu.divList + " div").addClass('menuHide');
	},
	showMenu: function(element)
	{
		WomenMenu.hideAll();
		var elementLink = element.href;
		var matchingDiv = elementLink.substring(elementLink.indexOf('#'));
		$(matchingDiv).removeClass('menuHide');
		$(matchingDiv).addClass('menuShow');
	},
	showMenuListener: function(event)
	{	
		var bodypart = this;
		this._timer=setTimeout(function(){WomenMenu.showMenu(bodypart);},100);
	},
	stopTimerListner: function(event)
	{
	clearTimeout(this._timer);
	}
};
$(document).ready(function() {
	WomenMenu.init();
	ManMenu.init();
});

