/**
 * Bootstraps the web site main menu.
 *
 * @return void
 */
function bootstrapMainMenu()
{
	// For each item of main menu...
	$("#divMainMenu ul li").each(function() {		
		// Gets a element child and bind a event
		$(this).find("a").bind("click", function(evt){
			// Prevents the a element click to work and animate it
			//evt.preventDefault();
			animate($(this));
		});
	});
}

/**
 * Animates the main menu.
 *
 * @param jQuery element
 * @return void
 */
function animate(element)
{
	// Setup the animation speed
	var speed = "slow";
	
	// Checks for a context active menu
	if ($("#divSubMenu .active").length) {
		// Slides up the sub menu
		$("#divSubMenu .active").slideUp(speed, function(){
			// Toggles the class "active" and changes the location
			$("#divSubMenu .active").toggleClass("active");
			
			// Checks the context a element href attribute
			if ("#" != element.attr("href")) {
				window.location.href = element.attr("href");
			}
		});
	} else	{
		// Gets the context item id and slides down the sub menu
		var parentId = element.parent("li").attr("id");
		$("#divSubMenu ." + parentId).slideDown(speed, function(){
			// Toggles the class "active"			
			$("#divSubMenu ." + parentId).toggleClass("active");
		});	
	}
}