
// MOSNE FUNCTIONS

$(document).ready(function(){
    if ($.browser.msie) {
        
            if (parseInt($.browser.version)<=6){
            
            alert("Attenzione! \n Il tuo browser è veramente obsoleto!  \n Per rendere la tua esperienza online più sicura e piacevole \n dedica 5 minuti del tuo tempo a questo aggiornamento!");
            location = "http://www.browserchoice.eu/";
            
          
        } //if ie6
       } //if ie*

    /*
    Cufon.replace('#roll h2');
    Cufon.replace('#menu li a',{hover:true});
    Cufon.replace('.box a, .schedalink a, a.goto',{hover:true});
    Cufon.replace('#roll h1, .titlebox h1, .navi h1, .pad h1,');
    Cufon.replace('.titlebox h2, .navi h2');
    Cufon.replace('ul.dati li');
    Cufon.replace('#roll h3, .titlebox h3, .navi h3, .box span.red');
    Cufon.replace('.dona a,.navi a, ul.more, h2.hometitle',{hover:true});
    */
     
    $('#opendona').click(function(){
    
            $("#donashow").slideDown("slow");
            $(this).hide();
    
    });
    
    /*
    var rc = $('.pics li').length;
    var rcn = 10*Math.random(rc);
    var okn = parseInt(rcn);
    
   
    $('.pics').cycle({
       pause:1,
       fx:'scrollHorz',
	   startingSlide: okn,
       timeout: 7000,
	   next:"#next",
	   prev:"#prev"
	   });
	*/
	
	$('.pics').cycle({
       pause:1,
       fx:'scrollHorz',
	   startingSlide: 0,
       timeout: 0,
	   next:"#next",
	   prev:"#prev"
	   });
	
	
   
   $(".oohembed").oembed(null, { 
			embedMethod: "replace", 
			vimeo: {autoplay:true, color: "ff0000", portrait:false, width: 622, height: 409, title:false, byline:false}});




 $(".oohembedhd").oembed(null, { 
			embedMethod: "replace", 
			vimeo: {autoplay:true, color: "ff0000", portrait:false, width: 622, height: 350, title:false, byline:false}});

   	   
   $('.gallery ul').cycle({
       fx:'fade',
	   timeout: 0,
	   next:"#next",
	   prev:"#prev"
	   });
	   
	   
	   
       
	setTimeout(function(){ 
	/* top  
	    $('.fb_share_count_inner').css({background:"white"});
	    $('.fb_share_count_top').css({border:"2px solid red"});
        $('.fb_share_count_nub_top').css({backgroundImage:"url()"});
        */
        
        $('.fb_share_count_inner, .fb_share_count').css({background:"red",color:"white"});
	    $('.fb_share_count_right .fb_share_count_inner').css({border:"0px solid red"});
        $('.fb_share_count_nub_right').css({backgroundImage:"url()"});
       
        
    },300);
  
   $('a.go').hover(function(){
        
    $(this).find('h2').css({color:'#fff'});
    //Cufon.refresh('#roll h2');
    $(this).find('h3').show();
    $(this).parent().find('.due').find('img').show();
    $(this).parent().find('.uno').find('img').hide();
         
        
   },function(){
    
    $(this).find('h3').hide();
    $(this).find('h2').css({color:'#111'});
   // Cufon.refresh('#roll h2');
    $(this).parent().find('.due').find('img').hide();
    $(this).parent().find('.uno').find('img').show();

   }); 
   
   
   
   /*
   $('#next').hover(function(){
        
        $('#prev').hide();      
        
   },function(){
   
        $('#prev').show();
    
   }); 
   
   $('#prev').hover(function(){
        
        $('#next').hide();      
        
   },function(){
   
        $('#next').show();
    
   });
   */
   
   $("#bd img").each(function(i){
		
		var curr = $(this).parents("a");
		var currimg = $(this);
		var the_src= $(currimg).attr("src");
		var img = new Image();					
		
		$(curr).addClass("imgloading");
							
		$(img).load(function () {
	       
	        $(currimg).css({"opacity":0}).css("visibility","visible");
	        $(currimg).attr("src", the_src);
	        
			$(currimg).animate({"opacity":1},3000,function(){
	        	
				$(curr).removeClass("imgloading");
	        
			});
	    
	    }).attr("src",the_src);	
	    
	
	});	
    
    $(".carto").each(function(){
    
        $(this).attr("href","javascript:void(0);");
   
    });
    $(".carto").click(function(){
    
        $(this).parent().find("input[type=radio]").attr("checked","checked");
   
    });
    
    function fisz(){
	   var hh =  20+$(this).height();
   	   $('#m_slideshow').cycle('pause').animate({height:hh}).cycle('resume');		   
	   };
	   
	   
      $('#m_slideshow').cycle({
       fx:'scrollHorz',
	   timeout: 0,
	   before:fisz
	   });
	
	$('#m_slideshow .fbshare a').click(function(){
	   
	   var imago = $(this).parent().parent().find(".thumb img");
	   var hi = $(imago).attr("rel");
	   $(imago).attr({src:hi});
	   
	});
	
	$('#m_slideshow .thumb img').click(function(){
	       $(this).parent().parent().find(".fbshare a").trigger("click");
    });
	
	 
	$("#fillme").html($("#geo").html());
	$("#geo").empty();
	
	$('#ga').click(function(){   
        $('#m_slideshow').cycle(1);
	   
	}); 
	
	$('#gb').click(function(){   
        $('#m_slideshow').cycle(2);
    }); 
	
	$('.gz').click(function(){   
        $('#m_slideshow').cycle(0);
    });
    
    setTimeout(function(){
        if (location.hash=="#formBuilderCSSIDAdotta"){
            $('#m_slideshow').cycle(1);
        }
    },900);   
    
   
    
}); //scope 
