jQuery.fn.autoRollover = function(rolloverClass, suffix){
	return this.each(function(){
		if (suffix){
			var backgroundSrc='';
			var src=$(this).attr("src");
			backgroundSrc=src.replace(/(.*)(?=\.)/, "$1_over");
			$(this).css('background-position', '-1000px -1000px');
			$(this).css('background-repeat', 'no-repeat');
			$(this).css('background-image', 'url(' + backgroundSrc + ')');
		}
		
		$(this).hover(function(){
			if (suffix){
				var overSrc='';
				var src=$(this).attr("src");
				overSrc=src.replace(/(.*)(?=\.)/, "$1" + suffix);
				$(this).attr('src', overSrc);
			}
			if(rolloverClass) $(this).addClass(rolloverClass);
			},
			function(){

				if (suffix){
					var bgSrc=$(this).css("background-image");
					var re=new RegExp("url\\(['\"]?(.*)" + suffix + "(?=\\.)([^'\")]*).*");
					var src=bgSrc.replace(re, "$1$2");
					$(this).attr('src', src);
				}
				if(rolloverClass) $(this).removeClass(rolloverClass);
			}
		);
	});
}
