jQuery.fn.imghover = function () {
	this.each(function() {	
		var n = this.src ? this.src : $(this).css('background-image'); // our normal image			
		$("<img>").attr("src", n); // preload the image
	
		// store the name of the normal and hover image in element
		$(this)
			.data('img-normal', n)	
			.data('img-hover', n.substring(0, n.lastIndexOf('.')) + '-hover.' + n.substring(n.lastIndexOf('.') + 1));	
	})
	.hover(
		function () {	
			if (this.src) {
				this.src = $(this).data('img-hover');
			} else {
				$(this).css('background-image', $(this).data('img-hover'));
			}
		}, 
		function () {	
			if (this.src) {
				this.src = $(this).data('img-normal');
			} else {
				$(this).css('background-image', $(this).data('img-normal'));			
			}
		}	
	);
};

$(function () {	
	$('.imghover').imghover();		
});