jQuery(document).ready(function($) {
	
	// hover for INPUT type IMAGE
	$("input[type=image]:not(.no-over)").hover(
			function(){
                $this = $(this);
				$this.data("originalsrc" , $this.attr("src") );
	
				// add -over to the image unless it is already -over
				if (!$this.attr("src").match(/-over/) ) {
					$this.attr( "src", $this.attr("src").replace(/\./, "-over.") );
				}
		
            },
            function(){ 
               
				// replace the original src
				$this = $(this);
				$this.attr("src", $this.data("originalsrc")	);
			
				$this.data("originalsrc", null);			   
       });
	
	
	$(".button").hover(
				// over
				function(){
					// store the original image src
					$this = $(this);
					$this.children(":first-child").data( "originalsrc" , $this.children(":first-child").attr("src") );
					
					// add -over to the image unless it is already -over
					if ($this.children(":first-child").attr("src") ) {
						if (!$this.children(":first-child").attr("src").match(/-over/) ) {
							$this.children(":first-child").attr( "src", $this.children(":first-child").attr("src").replace(/\./, "-over.") );
						}
					}
					
				},
				
				// out
				function(){
					// replace the original src
					$this = $(this);
					$this.children(":first-child").attr(
						"src", $this.children(":first-child").data("originalsrc")
					);
					
					$this.children(":first-child").data(
						"originalsrc", null
					);
				}
			);


		var classes = $('body').attr('class');

		if( classes.match(/category-home-hospitality/) ) {
			$("#home-hospitality").css("color", "#645D4E");
			$("#bannerImage, .breadcrumbs").css('background-image', 'url(/images/banner/header_home-hospitality.jpg)');
		} else if (classes.match(/category-protect-pamper/)) {
			$("#protect-pamper").css("color", "#645D4E");
			$("#bannerImage, .breadcrumbs").css('background-image', 'url(/images/banner/header_protect-pamper.jpg)');
		} else if (classes.match(/category-kids-critters/)) {
			$("#kids-critters").css("color", "#645D4E");
			$("#bannerImage, .breadcrumbs").css('background-image', 'url(/images/banner/header_kids-critters.jpg)');
		} else if (classes.match(/category-gifts-grabs/)) {
			$("#gifts-grabs").css("color", "#645D4E");
			$("#bannerImage, .breadcrumbs").css('background-image', 'url(/images/banner/header_gifts-grabs.jpg)');
		} else if (classes != '') {
			$("#bannerImage, .breadcrumbs").css('background-image', 'url(/images/banner/header_store.jpg)');
		} else {
			$("#bannerImage").css('background-image', 'url(/images/banner/header_home.jpg)');
		}
	
		
	
	
	
});

window.onload = function() {
		// preload
		jQuery(".button img, input[type=image]").each(
			function() {
				if (!jQuery(this).attr("src").match(/-over/) ) {
					jQuery("<img>").attr( "src", jQuery(this).attr("src").replace(/\./, "-over.") );
				}
			}
		);
}

