
jquery_hover = {

	init: function(){
		this.preload();
                $('.hover').live('mouseover mouseout', function(event) {
                    if ($(this).attr('src')) { $(this).attr('src',jquery_hover.Change($(this).attr('src'),event.type)); }
                });
                $('.click').live('mousedown mouseup', function(event) {
                    if ($(this).attr('src')) { $(this).attr('src',jquery_hover.Change($(this).attr('src'),event.type,true)); }
                });
                $('.hclick').live('mousedown mouseup mouseover mouseout', function(event) {
                    if ($(this).attr('src')) { $(this).attr('src',jquery_hover.Change($(this).attr('src'),event.type)); }
                });
        },

	preload: function(){
		$().bind('load', function() {
			$('.hover').each(function(key,elm){
				$('img.hover').attr('src',jquery_hover.Change($('img.hover'),'mouseout'));
			});
			$('.click').each(function(key,elm){
				$('img.hover').attr('src',jquery_hover.Change($('img.hover'),'mouseup'));
			});
			$('.hclick').each(function(key,elm){
				$('img.hover').attr('src',jquery_hover.Change$('img.hover'),'mouseout');
			});
		});
	},

        Change: function(src,act,retorna)
        {
            switch (act) {
                case 'mouseover':
                    ext         = src.substring(src.lastIndexOf(".")).toLowerCase();
                    newImg      = src.replace(ext,'');
                    return newImg + '_hover' + ext;
                    break;
                case 'mouseout':
                    src.replace('_hover', '');
                    src.replace('_click', '');
                    return src.replace('_hover', '');
                    break;
                case 'mousedown':
                    return src.replace('_hover', '_click');
                    break;
                case 'mouseup':
                    if (retorna == true) retorna = '';
                    else retorna = '_hover';
                    return src.replace('_click', retorna);
                    break;
                default:
                    break;
            }

        }
}
