jQuery(document).ready(function() {
var hoverColour = "#FFF";

jQuery(function(){
	/*jQuery(".nav li a").show("fast", function() {
		//jQuery(this).wrap("<div class=\"hoverBtn\">");
		jQuery(this).attr("class", "");
	});*/
	
	//display the hover div
	jQuery(".nav li").show("fast", function() {
		//append the background div
		jQuery(this).append("<div class=\"hoverBtn \"></div>");
		
		//get link's size
		var wid = String(parseInt(jQuery(this).children("a").width())+(parseInt(jQuery(this).css("padding-left"))*2));
		var hei = jQuery(this).children("a").height();
		
		//set div's size
		jQuery(this).width(wid);
		jQuery(this).height(hei);
		jQuery(this).children("div").width(wid);
		jQuery(this).children("div").height(hei);
		
		//on link hover
		jQuery(this).children("a").hover(function(){
			//store initial link colour
			if (jQuery(this).attr("rel") == "") {
				jQuery(this).attr("rel", jQuery(this).css("color"));
			}
			//fade in the background
			jQuery(this).parent().children("div")
				.stop()
				.css({"display": "none", "opacity": "1"})
				.fadeIn("fast");
			//fade the colour
			jQuery(this).children("strong").stop()
				.css({"color": jQuery(this).attr("rel")})
				.animate({"color": hoverColour}, 350);
		},function(){
			if (!jQuery(this).parent().hasClass("current-menu-item") && !jQuery(this).parent().hasClass("current-menu-parent")) {
				//fade out the background
				jQuery(this).parent().children("div")
					.stop()
					.fadeOut("slow");
				//fade the colour
				jQuery(this).children("strong").stop()
					.animate({"color": jQuery(this).css("color")}, 250);
			}
		});
	});
});
});
