
/* Fade rollover */
/* Samuele Catuzzi '2008 */
/*
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(3($){$.t.u=3(e){v f.w(3(i){2 $$=$(f);2 m=$$.5("n").x(".o","y.o");2 6=$$.5("6");2 7=$$.5("7");$$.z(\'<p A="8: B;9: 0;4: 0;"></p>\').C().D(\'<E 6="\'+6+\'" 7="\'+7+\'" 4="0">\').F(\':G-H\').5(\'n\',m);a($.g.I){2 b=f.J;$$.c({\'8\':\'h\',\'j\':0,\'k\':\'\',\'b\':b,\'4\':0,\'9\':0})}l a($.g.K){$$.c({\'8\':\'h\',\'j\':0,\'k\':\'\',\'b\':0,\'4\':0,\'9\':0})}l a($.g.L){$$.c({\'M\':\'N\'})}l{$$.c({\'8\':\'h\',\'j\':0,\'k\':\'\',\'4\':0,\'9\':0})}2 d=O;a(e)d=e;$$.P(3(){$$.q().r({s:0},d)},3(){$$.q().r({s:1},d)})})}})(Q);',53,53,'||var|function|border|attr|width|height|position|margin|if|top|css|fade_time|time_option|this|browser|absolute||left|background|else|target|src|gif|span|stop|animate|opacity|fn|faderollover|return|each|replace|_active|wrap|style|relative|parent|prepend|img|find|first|child|mozilla|offsetTop|msie|opera|display|none|400|hover|jQuery'.split('|'),0,{}))
*/


// fade rollover, from an idea of http://jqueryfordesigners.com/image-cross-fade-transition/
// working version!
// Samuele Catuzzi '2008

(function ($) {
    $.fn.faderollover = function (time_option) {
        return this.each(function (i) { 
            var $$ = $(this);
            //var target = $$.css('backgroundImage').replace(/^url|[\(\)'"]/g, '');
            var target = $$.attr("src").replace(".gif","_active.gif");
            var width= $$.attr("width");
            var height= $$.attr("height");
            
            $$.wrap('<span style="position: relative;margin: 0;border: 0;"></span>')
            	.parent()
            	.prepend('<img width="'+width+'" height="'+height+'" border="0">')
            	.find(':first-child')
            	.attr('src', target);
            	
            //if ($.browser.mozilla && jQuery.browser.version.substr(0,3)=="1.9") {
            //if ($.browser.msie && $.browser.version < 7) {
            
            if ( $.browser.mozilla ) {
                var top=this.offsetTop ;
            	$$.css({
            		'position' : 'absolute',
            		'left' : 0,
            		'background' : '',
            		'top' : top,
            		'border' : 0,
            		'margin' : 0
            	});
            } else if ($.browser.msie ) {
            	
            	
            	user = navigator.userAgent;
            	//alert(user);
            	if(user.indexOf("MSIE 8.0") != "-1"){
            	$$.css({
            		'position' : 'absolute',
            		'left' : 0,
            		'background' : '',
            		'top' : -230,
            		'border' : 0,
            		'margin' : 0
            	});
            	}else
            	{
            	    $$.css({
            		'position' : 'absolute',
            		'left' : 0,
            		'background' : '',
            		'top' : 0,
            		'border' : 0,
            		'margin' : 0
            	});
            	}
            } else if ($.browser.opera) {       
            	$$.css({
            		'display' : 'none'
            	});
            } else {
            	$$.css({
            		'position' : 'absolute', 
            		'left' : 0,
            		'background' : '',
            		'border' : 0,
            		'margin' : 0
            	});
            }
            var fade_time=400;
            if ( time_option ) fade_time=time_option;
            $$.hover(function () {
            	$$.stop().animate({
            		opacity: 0
            	}, fade_time);
            	}, function () {
            		$$.stop().animate({
            			opacity: 1
            	}, fade_time);
            });
        });
    };
})(jQuery);
