jQuery(document).ready(function(){

var adv_cookie = 'CAMON_ADV_COOKIE_'+jQuery('#adv').attr('rel');

if(jQuery.cookie(adv_cookie)==null){
	// qui commento perchè si vuole far apparire il banner finchè il visitatore non spunta la voce "non mostrare pi�" (un po' invadente)
	//jQuery.cookie(adv_cookie,1,{expires:1});
	jQuery('#adv').show(1000);//animate({top:'10px'}, 800);
}

jQuery('#adv .close').click(
	function(){
		jQuery('#adv').slideUp(200);
	}
);

jQuery('#adv .check input').click(
	function(){
		if(jQuery(this).attr('checked')){
			jQuery.cookie(adv_cookie,2,{expires:2});
		}
		else{
			//jQuery.cookie(adv_cookie,30,{expires:1});
			jQuery.cookie(adv_cookie,null);
		}
	}
);



jQuery('#immRot').each(
    function(){

	var that = this;
	var t = false;
	var l = jQuery('img',jQuery(this)).length;
	var timeout = 4000;

	that.initFade = function(){
	    that.display(0);
	}

	that.display = function(i){

	    jQuery('img',jQuery(that)).fadeOut(500);
	    jQuery('#immRot img',jQuery(that)).load(
		function(){
		    jQuery(this).stop(false,true).fadeIn(fadespeed);
		}
		);
	    jQuery('img:eq('+i+')',jQuery(that)).fadeIn(500);

	    t = window.setTimeout(
		function(){
		    that.display((i+1)%l);
		},
		timeout
		);

	}

	jQuery('img:first',jQuery(this)).show();

	if(l>1){
	    window.setTimeout(
		function(){
		    that.initFade();
		},
		timeout
		);
	}

    }
);


});
