var hoverColour = "#FFF";

jQuery(function(){
	jQuery("a.hoverBtn").show("fast", function() {
		jQuery(this).wrap("<div class=\"hoverBtn\">");
		jQuery(this).attr("class", "");
	});
	
	//display the hover div
	jQuery("div.hoverBtn").show("fast", function() {
		//append the background div
		jQuery(this).append("<div></div>");
		
		//get link's size
		var wid = jQuery(this).children("a").width();
		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)	.stop()
				.css({"color": jQuery(this).attr("rel")})
				.animate({"color": hoverColour}, 350);
		},function(){
			//fade out the background
			jQuery(this).parent().children("div")
				.stop()
				.fadeOut("slow");
			//fade the colour
			jQuery(this)	.stop()
				.animate({"color": jQuery(this).attr("rel")}, 250);
		});
	});
});

