var menu = new function() {
	this.animate_delay = 500;
	this.close_delay = 3000;
	this.container = '#menu-main-menu';

	this.setup = function() {
		jQuery(this.container).children('li').each(function() {
			jQuery(this).hover(
				function() {
					menu.toggle_item(jQuery(this), true);
				},
				function() {
					menu.toggle_item(jQuery(this), false);					
				}
			);
		});
	};

	this.toggle_item = function(jq, bShow) {
		if (!jq.hasClass('active')) {
			var child_ul = jq.children('ul');
			
			child_ul.stop(true, true);
			if (bShow)
				child_ul.slideDown(menu.animate_delay);
			else
				child_ul.delay(menu.close_delay).slideUp(menu.animate_delay);
		}
	}

};

jQuery(document).ready(function(){
	menu.setup();
});
