/**
 * Plugin Rollover jQuery
 * Autor: Gustavo Michel - BiTS Business IT Solutions
 *
 * Ex.: <img src="imagem.jpg" rel="hover" />
 * Obs.: Para as imagens com 'hover' deve ser seguido o padrão de nomenclatura de imagem_hover.jpg
 *
 */

jquery_hover_img = {

	init: function(){
		this.preload();
		$('img[rel="hover"], input[rel="hover"]').mouseover(function(){
			$(this).attr('src',jquery_hover_img.hover(this));
		}).mouseout(function(){
			$(this).attr('src',jquery_hover_img.out(this));
		});
	},

	preload: function(){
		$(window).bind('load', function() {
			$("img[rel='hover'").each(function(key,elm){
				$('<img>').attr('src',jquery_hover_img.out());
			});
		});
	},

	hover: function(id){
		var img_total = '';
		src       = $(id).attr('src');
		extensao  = src.substring(src.lastIndexOf(".")).toLowerCase();
		img_nova  = src.replace(extensao, '');
		img_total = img_nova + '_hover' + extensao;
		return img_total;
	},

	out: function(id){
		src        = $(id).attr('src');
		img_antiga = src.replace('_hover', '');
		return img_antiga;
	}

}