$(document).ready(function(){
    $("a[rel=popup]").click(function() {
        var sUrl = this.href;

        if (sUrl.indexOf("javascript") < 0)
            window.open(sUrl);
        else {
            setTimeout(sUrl.replace("javascript:", ""), 0);
        }

        return false;
    });

    $("a[rel=popup]").bind("onkeydown", function() {
        if (sUrl.indexOf("javascript") < 0)
            window.open(sUrl);
        else
            setTimeout(sUrl, 0);

        return false;
    });


	/*//////// SUPERFISH ////////////////////////////*/
	
	$('ul.sf-menu').superfish({
		delay: 0
	});


	/*///////// INNERFADE ////////////////////////////*/
	
	$('ul.listaLoghi').innerfade({
		speed: 'slow',
		timeout: 3000,
		type: 'sequence',
		containerheight: '94px'
	});	
	
	$('ul.listaSquadre').innerfade({
		speed: 'slow',
		timeout: 3000,
		type: 'sequence',
		containerheight: '38px'
	});	


	/*////////////////////////////////////////////////////////*/

				
	$(".evento a").bigTarget({	   		
        clickZone : 'div:eq(0)',
        hoverClass: 'eventoOver'
    });	
	
	$(".spotNotizia a").bigTarget({	   		
        clickZone : 'div:eq(0)',
        hoverClass: 'spotNotiziaOver'
    });	

	
	
	/*///////////////// RADIOBOX CALENDARI /////////////////////////////////////////////////////////////////////////////////////////////*/
	
	
	
	$(".labelPartite").click(function(){
		if($("#inputPartite").is(':checked'))  {        
			$("#inputPartite").attr("checked", "");   
		} else {                                      
			$("#inputPartite").attr("checked", "checked");    
		}
    });
 		 
		 
	$(".labelIncontri").click(function(){
		if($("#inputIncontri").is(':checked'))  {        
			$("#inputIncontri").attr("checked", "");   
		} else {                                      
			$("#inputIncontri").attr("checked", "checked");    
		}
    });
 		

	
	/*/////////////// HOVER DELLA TABELLA //////////////////////////////////////////////////////////////////*/
	
	 $(".riga-1").click(function(){
        window.location=$(this).find("a").attr("href"); return false;
     });
			  
	$(".riga-2").click(function(){
      	window.location=$(this).find("a").attr("href"); return false;
     });	  
			  
        		
     $('.riga-1').hover(function() {
   		$(this).find("td").css('color','#2E9B31');
		$(this).find("td a").css('color','#2E9B31');
        }, function() {
        $(this).find("td").css('color','#000000');
		$(this).find("td a").css('color','#000000');
    });
   					
            
   	$('.riga-2').hover(function() {
   		$(this).find("td").css('color','#2E9B31');
		$(this).find("td a").css('color','#2E9B31');
        }, function() {
        $(this).find("td").css('color','#000000');
		$(this).find("td a").css('color','#000000');
    });
   					
 /*////////////////////////////////////////////////////////////////////////////////////////////////////*/
   


	if ($(".contenitoreThumb li a").length > 0) {
		$(".contenitoreThumb li a").overlay({         
			target: '#gallery',        
			expose: '#000000',
			preload: 'true'
		}).gallery({ 
			speed: 800,
			template: '<strong>${title}</strong> <span>Foto ${index} di ${total}</span>'
		});
		
		// <span>Immagine ${index} of ${total}</span>
		$.tools.overlay.addEffect("drop",   
			// loading animation 
			function(done) {  
				var animateProps = { 
					top: '+=55',  
					opacity: 1,  
					width: '+=20' 
				}; 
				
				this.getOverlay().animate(animateProps, "medium", 'drop', done).show(); 
			},  
			// closing animation 
			function(done) { 
				var animateProps = { 
					top: '-=55',  
					opacity: 0,  
					width: '-=20' 
				}; 
				
				this.getOverlay().animate(animateProps, "fast", 'drop', function()  { 
					$(this).hide(); 
					done.call();         
				}); 
			} 
		);
	}
});
