//Simple Image Rollover Plugin for jQuery
//Give the <img> tag a class of roll_image ex. <img class="roll_image" src="images/image1.jpg" OR class="rollover" hover="images/image2.jpg" />
//Make sure the rollover image is the same name with _roll at the end.
$(document).ready(function(){
	function reverse_str(str){
		str = str.split("");
		str = str.reverse();
		str = str.join("");
		return str;
	}	
	$(".roll_image").mouseover(function(){
		var img_src = $(this).attr("src");
		img_src = reverse_str(img_src);
		img_src = img_src.split(".");
		img_src_new = img_src[0]+'.llor_'+img_src[1]+'.'+img_src[2];
		img_src_new = reverse_str(img_src_new);
		$(this).attr({src:img_src_new});
	});
	$(".roll_image").mouseout(function(){
		var img_src = $(this).attr("src");
		img_src = reverse_str(img_src);
		img_src = img_src.split(".");
		img_src[1] = img_src[1].replace(/llor_/, "");
		img_src_new = img_src[0]+'.'+img_src[1]+'.'+img_src[2];
		img_src_new = reverse_str(img_src_new);
		$(this).attr({src:img_src_new});
	});
});

$(document).ready(function() {
 $('.rollover').hover(function() {
		var currentImg = $(this).attr('src');
		$(this).attr('src', $(this).attr('hover'));
		$(this).attr('hover', currentImg);
	}, function() {
		var currentImg = $(this).attr('src');
		$(this).attr('src', $(this).attr('hover'));
		$(this).attr('hover', currentImg);
	});
});
