$(document).ready(function(){
if (!jQuery.rollover) {

/* Normal
----------------------------------------------------------- */

	// Roll Over	
	$("img.rollover,img.js\\.rollover").mouseover(function(){
		$(this).attr("src", $(this).attr("src").replace(/^(.+)_off(\.[a-z]+)$/, "$1_on$2"));
	});

	// Roll Out
	$("img.rollover,img.js\\.rollover").mouseout(function(){
		$(this).attr("src", $(this).attr("src").replace(/^(.+)_on(\.[a-z]+)$/, "$1_off$2"));
	});

	// Preload
	$("img.rollover,img.js\\.rollover").each(function(){
		var image = new Image();
		$(image).attr("src", $(this).attr("src").replace(/^(.+)_off(\.[a-z]+)$/, "$1_on$2"));
	});



/* Normal Prev
----------------------------------------------------------- */

	// Roll Over
	$(".rollover_prev").mouseover(function(){
		$(this).prev().attr("src", $(this).prev().attr("src").replace(/^(.+)_off(\.[a-z]+)$/, "$1_on$2"));
	});

	// Roll Out
	$(".rollover_prev").mouseout(function(){
		$(this).prev().attr("src", $(this).prev().attr("src").replace(/^(.+)_on(\.[a-z]+)$/, "$1_off$2"));
	});



/* Fade
----------------------------------------------------------- */

	// Preload & Put
	$("img.rollover_fade").each(function(){
		$(this).css({ display: "block" });
		$("<img>")
		.attr("src",$(this).attr("src").replace(/^(.+)_off(\.[a-z]+)$/, "$1_on$2"))
		.css({ display: "block", opacity: "0", position:"absolute", width:$(this).width(), height:$(this).height() })
		.addClass("rollover_fade_on")
		.insertBefore($(this));
	});

	// Roll Over
	$("img.rollover_fade_on").mouseover(function(){
		$(this).animate({ opacity: 1 }, 200, "easeOutSine");
		//$(this).prev().animate({ opacity: 0 }, 0.5);
	});

	// Roll Out
	$("img.rollover_fade_on").mouseout(function(){
		$(this).animate({ opacity: 0 }, 200, "easeOutSine");
		//$(this).prev().animate({ opacity: 1 }, 0.5);
	});



/* Cousin Fade
----------------------------------------------------------- */

	// Preload & Put
	$(".rollover_fade_cousin").each(function(){
	 $(this).parent().siblings().each(function(){
			var cousin = $(this).children("img");
			cousin.css({ display: "block" });
			$("<img>")
			.attr("src",cousin.attr("src").replace(/^(.+)_off(\.[a-z]+)$/, "$1_on$2"))
			.css({ display: "block", opacity: "0", position:"absolute", width:cousin.width(), height:cousin.height() })
			.addClass("rollover_fade_cousin_on")
			.insertBefore(cousin);
		});
	});

	// Roll Over
	$(".rollover_fade_cousin").mouseover(function(){
		$(this).parent().siblings().each(function(){
			var cousin = $(this).children("img.rollover_fade_cousin_on");
			cousin.animate({ opacity: 1 }, 200, "easeOutSine");
		});
	});

	// Roll Out
	$(".rollover_fade_cousin").mouseout(function(){
		$(this).parent().siblings().each(function(){
			var cousin = $(this).children("img.rollover_fade_cousin_on");
			cousin.animate({ opacity: 0 }, 200, "easeOutSine");
		});
	});



/* Background
----------------------------------------------------------- */

	// Roll Over
	$(".rollover_bg,.bgrollover").mouseover(function(){
		$(this).css("background-image", $(this).css("background-image").replace(/^(.+)_off(\.[a-z]+)/, "$1_on$2"));		
	});

	// Roll Out
	$(".rollover_bg,.bgrollover").mouseout(function (){
		$(this).css("background-image", $(this).css("background-image").replace(/^(.+)_on(\.[a-z]+)/, "$1_off$2"));
	});

	// Preload
	$(".rollover_bg,.bgrollover").each(function(){
		var image = new Image();
		$(image).attr("src", $(this).css("background-image").replace(/^(url\(\"?)(.+)_off(\.[a-z]+)(\"?\))/, "$2_on$3"));
	});


/* Parent Background
----------------------------------------------------------- */

	// Roll Over
	$(".rollover_bg_parent").mouseover(function(){
		$(this).parent().css("background-image", $(this).parent().css("background-image").replace(/^(.+)_off(\.[a-z]+)/, "$1_on$2"));
	});

	// Roll Out
	$(".rollover_bg_parent").mouseout(function (){
		$(this).parent().css("background-image", $(this).parent().css("background-image").replace(/^(.+)_on(\.[a-z]+)/, "$1_off$2"));
	});

	// Preload
	$(".rollover_bg_parent").each(function(){
		var image = new Image();
		$(image).attr("src", $(this).parent().css("background-image").replace(/^(url\(\"?)(.+)_off(\.[a-z]+)(\"?\))/, "$2_on$3"));
	});



/* Map Image
----------------------------------------------------------- */

	$("img.rollover_map").each(function(){

		var _id = $(this).attr("usemap").replace(/^(.+)#/, "#"); // for Opera

		// Roll Over
		$(_id + " area").bind("mouseover", {_this: $(this)}, function(e){
			e.data._this.attr("src", e.data._this.attr("src").replace(/^(.+)_off(\.[a-z]+)$/, "$1_on$2"));
		});

		// Roll Out
		$(_id + " area").bind("mouseout", {_this: $(this)}, function(e){
			e.data._this.attr("src", e.data._this.attr("src").replace(/^(.+)_on(\.[a-z]+)$/, "$1_off$2"));
		});

		// Preload
		var image = new Image();
		$(image).attr("src", $(this).attr("src").replace(/^(.+)_off(\.[a-z]+)$/, "$1_on$2"));

	});



	jQuery.rollover = true;

}
});






