<!--
	// jQuery
	$(document).ajaxStop($.unblockUI);
	
	$(document).ready(function(){
		$("#header, #main, #matches, #scores, #footer").corner();
		$("#main_sponsor").corner("bottom 5px");
		$(".main_contents, .last_matches").corner("5px");
		
		$("#list_menu").lavaLamp({
			fx: "backout", 
			speed: 700
		});
		
		$("#slideshow").cycle({
			fx: "blindY", 
			timeout:  5000, 
			pause: 1, 
			before: onBefore
		});
		
		function onBefore(){
			if(this.name != "")
				$("#urls").addClass("abled").html('<a href="' + this.name + '" target="_blank">&nbsp;</a>');
			else
				$("#urls").removeClass("abled").html("");
		};
		
		$("#main_left").jqFancyTransitions({
			width: 590, 
			height: 450, 
			effect: "wave", 
			delay: 10000
		});
		
		$(".a_ajax").livequery("click", function(event){
			var url_rel = $(this).attr("rel");
			
			if(trim(url_rel) != ""){
				$.blockUI.defaults.applyPlatformOpacityRules = false;
				
				$.blockUI({
					message: $("#loader")
				});
				
				$.ajax({
					url: url_rel, 
					cache: false, 
					success: function(html){
						$("#spot_agenda, #matches, #scores").remove();
						$("#main").html(html);
					}
				});
			}
		});
		
		$(".a_ajax_new").livequery("click", function(event){
			var url_rel = $(this).attr("rel");
			var sid_rel = $.url.setUrl(url_rel).param("sid");
			
			if(trim(url_rel) != "" && trim(sid_rel) != ""){
				$.blockUI.defaults.applyPlatformOpacityRules = false;
				
				$.blockUI({
					message: $("#loader")
				});
				
				$.ajax({
					url: url_rel, 
					cache: false, 
					success: function(html){
						$("#spot_agenda, #matches, #scores").remove();
						$("#list_menu li.back").css({
							"width": "57px", 
							"left": "159px", 
							"display": "block", 
							"overflow": "hidden"
						});
						$("#list_menu li").removeClass("current");
						$("#list_menu li:eq(2)").addClass("current");
						$("#main").html(html);
						$(".accordion_content:eq(2)").load("_new.php?sid=" + sid_rel + "", function(){
							$(".accordion_button:eq(2)").trigger("click");
						});
					}
				});
			}
		});
		
		$(".a_ajax_match, .a_ajax_match_d").livequery("click", function(event){
			var url_rel = $(this).attr("rel");
			var giornata_rel = $.url.setUrl(url_rel).param("giornata");
			
			if($(this).attr("class") == "a_ajax_match"){
				var index = 0;
				var serie = "C2";
			}
			else{
				var index = 1;
				var serie = "D";
			}
			
			if(trim(url_rel) != "" && trim(giornata_rel) != ""){
				$.blockUI.defaults.applyPlatformOpacityRules = false;
				
				$.blockUI({
					message: $("#loader")
				});
				
				$.ajax({
					url: url_rel, 
					cache: false, 
					success: function(html){
						$("#spot_agenda, #matches, #scores").remove();
						$("#list_menu li.back").css({
							"width": "57px", 
							"left": "159px", 
							"display": "block", 
							"overflow": "hidden"
						});
						$("#list_menu li").removeClass("current");
						$("#list_menu li:eq(" + index + ")").addClass("current");
						$("#main").html(html);
						$(".accordion_content:eq(" + index + ")").load("_match.php?giornata=" + giornata_rel + "&serie=" + serie, function(){
							$(".accordion_button:eq(" + index + ")").trigger("click");
						});
					}
				});
			}
		});
		
		$(".a_ajax_back").livequery("click", function(event){
			var url_rel = $(this).attr("rel");
			var what_rel = $.url.setUrl(url_rel).param("what");
			
			if(trim(url_rel) != "" && trim(what_rel) != ""){
				$.blockUI.defaults.applyPlatformOpacityRules = false;
				
				$.blockUI({
					message: $("#loader")
				});
				
				$.ajax({
					url: url_rel, 
					cache: false, 
					success: function(html){
						$("#spot_agenda, #matches, #scores").remove();
						$("#main").html(html);
						$(".accordion_button:eq(" + what_rel + ")").trigger("click");
					}
				});
			}
		});
		
		$(".a_thumb").fancybox({
			titlePosition: "over"
		});
	});
	
	// Mail antispam
	function mailNoSpam(user, dominio){
		document.location.href = "mailto:" + user + "@" + dominio;
	}
	
	// Controlla gli spazi vuoti nella compilazione dei campi di testo
	function trim(stringa){
		while(stringa.substring(0, 1) == " ")
			stringa = stringa.substring(1, stringa.length);
		
		while(stringa.substring(stringa.length-1, stringa.length) == " ")
			stringa = stringa.substring(0, stringa.length-1);
		
		return stringa;
	}
	
	// Submit per la paginazione tramite select
	function passPage(cmd, what, page){
		var url_rel = "content.php?cmd=" + cmd + "&what=" + what + "&page=" + page;
		
		if(trim(url_rel) != ""){
			$.blockUI.defaults.applyPlatformOpacityRules = false;
			
			$.blockUI({
				message: $("#loader")
			});
			
			$.ajax({
				url: url_rel, 
				cache: false, 
				success: function(html){
					$("#main").html(html);
				}
			});
		}
	}
	
	// Scroll automatico all'ancora nella pagina
	function goToByScroll(id){
     	$("html, body").animate({
			scrollTop: $("#" + id).offset().top
		}, "slow");
	}
	
	// Controlla la compilazione della form in CONTATTI
	function checkForm(){
		var goodEmail = document.forms[0].mail.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
		
		if(trim(document.forms[0].nome.value) == ""){
			alert("Attenzione!\nIl campo NOME non è stato compilato correttamente.");
			document.forms[0].nome.focus();
		}
		else if(trim(document.forms[0].cognome.value) == ""){
			alert("Attenzione!\nIl campo COGNOME non è stato compilato correttamente.");
			document.forms[0].cognome.focus();
		}
		else if(!goodEmail){
			alert("Attenzione!\nIl campo E-MAIL non è stato compilato correttamente.");
			document.forms[0].mail.focus();
		}
		else if(trim(document.forms[0].richiesta.value) == ""){
			alert("Attenzione!\nIl campo RICHIESTA non è stato compilato correttamente.");
			document.forms[0].richiesta.focus();
		}
		else{
			$(document).ajaxStop($.unblockUI);
			
			$.blockUI.defaults.applyPlatformOpacityRules = false;
			
			$.blockUI({
				message: $("#loader")
			});
			
			$.ajax({
				url: "_mail.php",
				type: "POST",
				data: "nome=" + document.forms[0].nome.value + "&cognome=" + document.forms[0].cognome.value + "&mail=" + document.forms[0].mail.value + "&richiesta=" + document.forms[0].richiesta.value,
				cache: false,
				success: function(html){
					$("#content_mail").html(html);
				}
			});
		}
	}
//-->
