$(window).unload( function () { } );



(function ($) {
	$.event.special.load = {
		add: function (hollaback) {
			if ( this.nodeType === 1 && this.tagName.toLowerCase() === 'img' && this.src !== '' ) {
				// Image is already complete, fire the hollaback (fixes browser issues were cached
				// images isn't triggering the load event)
				if ( this.complete || this.readyState === 4 ) {
					hollaback.handler.apply(this);
				}

				// Check if data URI images is supported, fire 'error' event if not
				else if ( this.readyState === 'uninitialized' && this.src.indexOf('data:') === 0 ) {
					$(this).trigger('error');
				}
				
				else {
					$(this).bind('load', hollaback.handler);
				}
			}
		}
	};
}(jQuery));




$(document).ready(function() {


jQuery.easing.easeOutQuart = function (x, t, b, c, d) {
	return -c * ((t=t/d-1)*t*t*t - 1) + b;
};


	//MENU AZIENDALI
	if($("body").attr("id")=="aziende"){
	$("#aziende #content #menus").load("aziende_speciali.html");
	}
	
	$("#aziende a#speciali").click(function(){	
			$("#aziende a").removeClass('attivo');
			$(this).addClass('attivo');
		$("#aziende #content #menus").load("aziende_speciali.html", function() {
			$("html, body").animate({scrollTop:200, easing: "swing"}, 800);
		 	$("#maschera").animate({ height: $("#aziende #content #menus").height()+350, easing: "swing" }, 800);
	});
	 });
	
	$("#aziende a#lavoro").click(function(){
		$("#aziende a").removeClass('attivo');
		$(this).addClass('attivo');
		$("#aziende #content #menus").load("aziende_lavoro.html", function() {
			$("html, body").animate({scrollTop:200, easing: "swing"}, 800);
		 	$("#maschera").animate({ height: $("#aziende #content #menus").height()+350, easing: "swing" }, 800);
		});
	 });
	
	$("#aziende a#buffet").click(function(){	
		$("#aziende a").removeClass('attivo');
		$(this).addClass('attivo');
		$("#aziende #content #menus").load("aziende_buffet.html", function() {
			$("html, body").animate({scrollTop:200, easing: "swing"}, 800);
		 	$("#maschera").animate({ height: $("#aziende #content #menus").height()+350, easing: "swing" }, 800);
	});
	 });



	
	
	//FUNZIONI PER MOVIMENTO ELEMENTI ASSOCIATI AI TASTI DI NAVIGAZIONE
	$(".linkinterno").click(function(){	
			$("#navigation li a").parent().siblings().removeClass('attivo');
			$("#navigation li a#"+ $(this).attr("id")).parent().addClass('attivo');
		});
	
		$("#navigation li a").click(function(){	
			$(this).parent().siblings().removeClass('attivo');
			$(this).parent().addClass('attivo');
			var altezza= ($($(this).attr("href")).height()+60);
			var altezzatotale= altezza + $("#navigation").height();
			$("html, body").animate({scrollTop:0, easing: "swing"}, 800);
			$("#maschera").animate({ height: altezzatotale, easing: "swing" }, 800);	
		});
		
		
	
		$("#show #agenda li a").click(function(){	
			var altezza= ($($(this).attr("href")).height()+60);
			var altezzatotale= altezza + $("#navigation").height()+ $("#agenda").height()+60;
			$(this).parent().siblings().removeClass('attivo');
			$(this).parent().addClass('attivo');
			$("html, body").animate({scrollTop:0, easing: "swing"}, 800);
			$("#maschera").animate({ height: altezzatotale, easing: "swing" }, 800);
		});
		
		$("#index #agenda li a").click(function(event) {
			event.preventDefault();
		});
		$("#index #agenda li a").click(function(){	
			var url = $(this).attr('href');
			$('#body-background').fadeOut('fast',function(){
				$("#footer").animate({ scrollLeft:0, easing: "swing" }, 1000);
				$("#generale").animate({ left: 800, easing: "swing" }, 1000, function(){ 
					$(location).attr('href',url);  
				});
				
			});
				
				
		});

		$("#menu li.interno").click(function(){	
			var project= $(this).attr("id"); 
			$('#body-background').fadeOut('fast',function(){
				$("#footer").animate({ scrollLeft:0, easing: "swing" }, 1000);
				$("#generale").animate({ left: 800, easing: "swing" }, 1000, function(){ 
					window.location = project  + ".php"   
				});
			});
		});
		
		$("#banner a.interno").click(function(){	
			var project= $(this).attr("id"); 
			$('#body-background').fadeOut('fast',function(){
				$("#footer").animate({ scrollLeft:0, easing: "swing" }, 1000);
				$("#generale").animate({ left: 800, easing: "swing" }, 1000, function(){ 
					window.location = project  + ".php"   
				});
			});
		});
		
		$("#qualcosa.sezione #content a").click(function(){	
			var project= $(this).attr("id"); 
			$('#body-background').fadeOut('fast',function(){
				$("#footer").animate({ scrollLeft:0, easing: "swing" }, 1000);
				$("#generale").animate({ left: 800, easing: "swing" }, 1000, function(){ 
					window.location = project  + ".php"   
				});
			});
		});
		
		$("#qualcosa.interna #back").click(function(){	
			var project= $(this).attr("id"); 
			$('#body-background').fadeOut('fast',function(){
				$("#footer").animate({ scrollLeft:0, easing: "swing" }, 1000);
				$("#generale").animate({ left: 800, easing: "swing" }, 1000, function(){ 
					window.location = "qualcosa.php"   
				});
			});
		});
	
		$("#footer #prenota").click(function(){		
			$("#footer #content").animate({ left: 800, easing: "swing" }, 1000);
			$("#generale").animate({ left: 800, easing: "swing" }, 1000, function(){ 
				window.location = "prenota.php"   
			});
		});
		
		$("#footer #mail").click(function(){		
			$("#footer #content").animate({ left: 800, easing: "swing" }, 1000);
			$("#generale").animate({ left: 800, easing: "swing" }, 1000, function(){ 
				window.location = "prenota.php"   
			});
		});
	
		$("#menu #contattaci").click(function(){	
			$("html, body").scrollTo( $('#footer'), 800)		  
			$("#footer #espandibile").animate({ height: 260, easing: "swing" }, 800);
			$("#footer #full").addClass('attivo');
		});
	
		$("#footer #full").click(function(){	
			$("html, body").scrollTo( $('#footer'), 800)		  
			$("#footer #espandibile").animate({ height: 260, easing: "swing" }, 800);
			$(this).addClass('attivo');
		});
		
		
		
		
	
	// DISABILITA IL LINK DEGLI HREF DEL MENU PRINCIPALE
		$("#menu li.interno a").click(function(event) {
			event.preventDefault();
		});
	
	// DISABILITA IL LINK DEGLI HREF DELLA NAVIGAZIONE DEI MENU DELLA SEZIONE AZIENDE
		$("#aziende #nav_menu a").click(function(event) {
			event.preventDefault();
		});
	
	// DISABILITA IL LINK DEGLI HREF DELLA NAVIGAZIONE 
		$("#navigation li a").click(function(event) {
			event.preventDefault();
		});
		
	// DISABILITA IL LINK DEllE CARTOLINE DI QUALCOSA IN PIù
		$("#qualcosa #content a").click(function(event) {
			event.preventDefault();
		});
		
	// DISABILITA IL LINK DEI BACK DELLE PAGINE INTERNE DI QUALCOSA IN PIù
		$("#qualcosa.interna a#back").click(function(event) {
			event.preventDefault();
		});
		
	// DISABILITA IL LINK DEI BANNER DELLA HOME CON LINK INTERNI
		$("#banner a.interno").click(function(event) {
			event.preventDefault();
		});
		
		
		
		// AGGIUNGE LA CLASSE ATTIVO AL TASTO DEL MENU CORRISPONDENTE ALL'ID DELLA PAGINA CARICATA (uso class e non id perchè IE7 non vede l'id)
				$("#menu li." + $("body").attr("id")).addClass('attivo');

		
		
		
		
		
		
	// FUNZIONI PER L'ENTRATA DEGLI ELEMENTI AL LOAD DELLA PAGINA
					   		
		// SE NON C'è UN ANCORA NELL'URL	
		if(!window.location.hash ){		
			
				
				// SE SIAMO NELLA PAGINA SHOW O INDEX
				if($("body").attr("id")=="index"){
					var altezza= $(".primo").height() +60;
					var altezzatotale= altezza + $("#navigation").height()+ $("#agenda").height()+45;
					}
				else if($("body").attr("id")=="show"){
					var altezza= $(".primo").height() +60;
					var altezzatotale= altezza + $("#navigation").height()+ $("#agenda").height()+45;
					
					
					var primoevento = $('#agenda ul li a:first').attr('rel');
			
					$.post('evento.php',{ ev: primoevento},function(data){
						$('#descr_evento').html(data); 
						
						var altezza= $('#descr_evento li').height() +60;
						var altezza2= altezza + $("#navigation").height()+ $("#agenda").height()+60;
		
						$("#maschera").animate({ height: altezza2, easing: "swing" }, 800, function(){$('#body-background').fadeIn('slow');});
						$("[title]").mbTooltip({opacity : .97, wait:200,  cssClass:"default", timePerWord:70, hasArrow:false, hasShadow:true, imgPath:"images/", ancor:"parent",  shadowColor:"black",  mb_fade:200  });
									
					
						});
					
					
					
					}
				// SE NON SIAMO NELLA PAGINA SHOW O INDEX
				else{
					var altezza= $(".primo").height() +60;
					var altezzatotale= altezza + $("#navigation").height();	
					}
					
				$("#maschera").css('height', altezzatotale);
				$('#body-background').hide();
				$("#maschera").animate({ scrollLeft:740, easing: "swing" }, 1000);	
				$("#footer").animate({ scrollLeft:740, easing: "swing" }, 1000, function(){
					
					
					$('#body-background img').bind('load', function (e) {

						
						$('#body-background').fadeIn('slow');	
						$("#body-background").ezBgResize();

					});
					
					
					
					
				});
		/*}else if(window.location.hash && window.location.hash=="#fatto"){
			
			
			alert('no animation');*/
			
			
		}else if(window.location.hash && ($("body").attr("id")=="show" || $("body").attr("id")=="index")){
			
			//alert('hashed!?');
			
			if($("body").attr("id")=="show"){
				var ancora= window.location.hash;
				var theid = $('#agenda ul li a[href$="'+ancora+'"]').attr('rel');
				$('#agenda ul li').removeClass('attivo');
				$('#agenda ul li a[href$="'+ancora+'"]').parent('li').addClass('attivo');
				
				
				
				$.post('evento.php',{ ev: theid},function(data){
								$('#descr_evento').html(data); 
								
								var altezza= $('#descr_evento li').height()+60;
								var altezza2= altezza + $("#navigation").height()+ $("#agenda").height()+60;			
								$("#maschera").animate({ height: altezza2, easing: "swing" }, 800, function(){$('#body-background').fadeIn('slow');});
								$("[title]").mbTooltip({opacity : .97, wait:200,  cssClass:"default", timePerWord:70, hasArrow:false, hasShadow:true, imgPath:"images/", ancor:"parent",  shadowColor:"black",  mb_fade:200  });
							
							
							});
				
				
					$("#maschera").css('height', altezzatotale);
					$('#body-background').hide();
					$("#maschera").animate({ scrollLeft:740, easing: "swing" }, 1000);	
					$("#footer").animate({ scrollLeft:740, easing: "swing" }, 1000, function(){
					$('#body-background img').bind('load', function (e) {

						
						$('#body-background').fadeIn('slow');	
						$("#body-background").ezBgResize();

					});
					
					
				});
				
								
				}else if($("body").attr("id")=="index"){
					
					var altezza= $(".primo").height() +60;
					var altezzatotale= altezza + $("#navigation").height()+ $("#agenda").height()+45;
					
					var ancora= window.location.hash;
					var theid = $('#agenda ul li a[href$="'+ancora+'"]').attr('rel');
					$('#agenda ul li').removeClass('attivo');
					$('#agenda ul li a[href$="'+ancora+'"]').parent('li').addClass('attivo');
				
					
					$("#maschera").css('height', altezzatotale);
					$('#body-background').hide();
					$("#maschera").animate({ scrollLeft:740, easing: "swing" }, 1000);	
					$("#footer").animate({ scrollLeft:740, easing: "swing" }, 1000, function(){
					$('#body-background img').bind('load', function (e) {

						
						$('#body-background').fadeIn('slow');	
						$("#body-background").ezBgResize();

					});
					
				});
				
				
				
			};
									
				
			
			};
		
		
		
		
		
		
	/////////////////
	//LOCAL SCROLL//
	////////////////
	$.localScroll.defaults.axis = 'x';
	
	
	
	//escludo con questa if la pagina FATTO, dopo l'invio del form di prenotazione
	
	if(window.location.hash && window.location.hash=="#fatto"){
		
			//alert('no animation');
			$.localScroll.hash({	
				
				onBefore:function(){
						var ancora= window.location.hash;
						var altezza= $(ancora).height() +60;
						var altezzatotale= altezza + $("#navigation").height();	
						$("#maschera").css('height', altezzatotale);
						$('#body-background').hide();
						$("html, body").animate({scrollTop:0, easing: "none"}, 1);
						
						$("#maschera").animate({ scrollTop:0, easing: "swing" }, 1);
						$("#maschera").animate({ scrollLeft:0, easing: "swing" }, 1, function(){																 
							$("#maschera").animate({ scrollLeft:740, easing: "swing" }, 0)
						$("#footer").animate({ scrollLeft:0, easing: "swing" }, 1, function(){
							$("#footer").animate({ scrollLeft:740, easing: "swing" }, 0, function(){
											$('#body-background img').bind('load', function (e) {
		
												$('#body-background').show();	
												$("#body-background").ezBgResize();
		
											});
							
							});
						});
						
						});
						
						
					// AGGIUNGE LA CLASSE ATTIVO AL TASTO DEL MENU CORRISPONDENTE ALL'ID DELL'ANCORA NELL'URL
					$("#navigation li a#prenotazioni_t").parent().siblings().removeClass('attivo');
					$("#navigation li a#prenotazioni_t").parent().addClass('attivo');
						},
				
				target: '#content',
				queue:false,
				duration:10
				
				
			});
		



	
	}else{
		
		// SE C'E' UN ANCORA NELL'URL
			$.localScroll.hash({	
				
				onBefore:function(){
						var ancora= window.location.hash;
						var altezza= $(ancora).height() +60;
						var altezzatotale= altezza + $("#navigation").height();	
						$("#maschera").css('height', altezzatotale);
						$('#body-background').hide();
						$("html, body").animate({scrollTop:0, easing: "none"}, 1);
						
						$("#maschera").animate({ scrollTop:0, easing: "swing" }, 1);
						$("#maschera").animate({ scrollLeft:0, easing: "swing" }, 1, function(){																 
							$("#maschera").animate({ scrollLeft:740, easing: "swing" }, 1000)
						$("#footer").animate({ scrollLeft:0, easing: "swing" }, 1, function(){
							$("#footer").animate({ scrollLeft:740, easing: "swing" }, 1000, function(){
											$('#body-background img').bind('load', function (e) {
												$('#body-background').fadeIn('slow');	
												$("#body-background").ezBgResize();
		
											});
							
							});
						});
						
						});
						
						
						// AGGIUNGE LA CLASSE ATTIVO AL TASTO DEL MENU CORRISPONDENTE ALL'ID DELL'ANCORA NELL'URL
					$("#navigation li a#" + window.location.hash +"_t").parent().siblings().removeClass('attivo');
					$("#navigation li a#" + window.location.hash+"_t").parent().addClass('attivo');
						},
				
				target: '#content',
				queue:false,
				duration:1000
				
				
			});
		
		
		}
	
	
	
	// SE SIAMO NELLA PAGINA SHOW
	 if($("body").attr("id")=="show"){
		$.localScroll({
			target: '#sections', // could be a selector or a jQuery object too.		  
			queue:true,
			duration:1000,
			hash:true
	});}
	
	
	// SE NON SIAMO NELLA PAGINA SHOW
	else if($("body").attr("id")=="prenota2"){
		 var ancora= window.location.hash;
		 //alert(ancora);
		 if(ancora=='#dovesiamo'){
		 	
		 	//alert('contact');
		 	$("#contactform").validate({
		   		submitHandler: function(form) {
		   			var dati= $("#contactform").serialize();
		   			//alert(dati);
		   			$.post('sendcontact.php',dati,function(data){
	   					$("#contactform *").fadeOut(600);
	   					$("#contactform").delay(300).html('<div style="padding:50px 0;">'+data+'</div>');
	   				});
		   		}
		 	});
			
		 	}
		 else if(ancora =='' || ancora=='#prenotazioni'){
		 	
			//alert('prenota');
			$("#prenotaform input").keyup(function(){
				
				var regemail = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
				var regenum = /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/;
				var regedate = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/;
			
				//tolgo i mess di errore di prima (eventuali)
				$('label.error').remove();

				if(
					(!regemail.test($('#prenotaform #f_email').val())) ||
					//(!regenum.test($('#prenotaform #f_telefono').val()) && $('#prenotaform #f_telefono').val()!='Telefono fisso') ||
					(!regenum.test($('#prenotaform #f_cellulare').val()) && $('#prenotaform #f_cellulare').val()!='Telefono cellulare') ||
					(!regedate.test($('#prenotaform #f_data_evento').val()) && $('#prenotaform #f_data_evento').val()!='Data evento') //||
					//(!regedate.test($('#prenotaform #f_data_nascita').val()) && $('#prenotaform #f_data_nascita').val()!='Nato/a il gg/mm/aaaa')
					
					){
							if(!regemail.test($('#prenotaform #f_email').val())){$('#prenotaform #f_email').parent('.wrap').append('<label for="f_email" generated="true" class="error">Inserisci un indirizzo email valido.</label>');}
							//if(!regenum.test($('#prenotaform #f_telefono').val()) && $('#prenotaform #f_telefono').val()!='Telefono fisso'){$('#prenotaform #f_telefono').parent('.wrap').append('<label for="f_email" generated="true" class="error">Inserisci un numero valido.</label>');}
							if(!regenum.test($('#prenotaform #f_cellulare').val()) && $('#prenotaform #f_cellulare').val()!='Telefono cellulare'){$('#prenotaform #f_cellulare').parent('.wrap').append('<label for="f_email" generated="true" class="error">Inserisci un numero valido.</label>');}
							if(!regedate.test($('#prenotaform #f_data_evento').val()) && $('#prenotaform #f_data_evento').val()!='Data evento'){$('#prenotaform #f_data_evento').parent('.wrap').append('<label for="f_email" generated="true" class="error">Questo campo è obbligatorio.</label>');};
							//if(!regedate.test($('#prenotaform #f_data_nascita').val()) && $('#prenotaform #f_data_nascita').val()!='Nato/a il gg/mm/aaaa'){$('#prenotaform #f_data_nascita').parent('.wrap').append('<label for="f_email" generated="true" class="error">Inserisci una data corretta.</label>');};
							return false;

					
				}else{

						return true;
				};
								
			});	//fine onkeyup
			
			
			$("#prenotaform #inviare").click(function(){
				
				var regemail = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
				var regenum = /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/;
				var regedate = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/;
			
				//tolgo i mess di errore di prima (eventuali)
				$('label.error').remove();

				if(
					(!regemail.test($('#prenotaform #f_email').val())) ||
					//(!regenum.test($('#prenotaform #f_telefono').val()) && $('#prenotaform #f_telefono').val()!='Telefono fisso') ||
					(!regenum.test($('#prenotaform #f_cellulare').val()) && $('#prenotaform #f_cellulare').val()!='Telefono cellulare') ||
					(!regedate.test($('#prenotaform #f_data_evento').val()) && $('#prenotaform #f_data_evento').val()!='Data evento') //||
					//(!regedate.test($('#prenotaform #f_data_nascita').val()) && $('#prenotaform #f_data_nascita').val()!='Nato/a il gg/mm/aaaa')
					
					){
							if (!regemail.test($('#prenotaform #f_email').val())){$('#prenotaform #f_email').parent('.wrap').append('<label for="f_email" generated="true" class="error">Inserisci un indirizzo email valido.</label>');}
							//if(!regenum.test($('#prenotaform #f_telefono').val()) && $('#prenotaform #f_telefono').val()!='Telefono fisso'){$('#prenotaform #f_telefono').parent('.wrap').append('<label for="f_email" generated="true" class="error">Inserisci un numero valido.</label>');}
							if(!regenum.test($('#prenotaform #f_cellulare').val()) && $('#prenotaform #f_cellulare').val()!='Telefono cellulare'){$('#prenotaform #f_cellulare').parent('.wrap').append('<label for="f_email" generated="true" class="error">Inserisci un numero valido.</label>');}
							if(!regedate.test($('#prenotaform #f_data_evento').val()) && $('#prenotaform #f_data_evento').val()!='Data evento'){$('#prenotaform #f_data_evento').parent('.wrap').append('<label for="f_email" generated="true" class="error">Questo campo è obbligatorio.</label>');};
							//if(!regedate.test($('#prenotaform #f_data_nascita').val()) && $('#prenotaform #f_data_nascita').val()!='Nato/a il gg/mm/aaaa'){$('#prenotaform #f_data_nascita').parent('.wrap').append('<label for="f_email" generated="true" class="error">Inserisci una data corretta.</label>');};
							return false;

					
				}else{

						return true;
				};
								
			});	//fine onclick
			
			
		
			
			
			
			
				
		 }
			//else if(ancora=='#fatto'){
		 	//alert('fatto');
		 	//	};
		 
		
		$.localScroll({
			target: '#content', // could be a selector or a jQuery object too.		  
			queue:true,
			duration:1000,
			hash:true,
			onAfter:function( anchor, settings ){
				$(this).parent().siblings().removeClass('attivo');
				$(this).parent().addClass('attivo');
				var ancora= window.location.hash;
				
				if(ancora=='#dovesiamo'){
					
					$("#contactform").validate({
				   		submitHandler: function(form) {
				   			var dati= $("#contactform").serialize();
				   			$.post('sendcontact.php',dati,function(data){
			   					$("#contactform *").fadeOut(600);
			   					$("#contactform").delay(300).html('<div style="padding:50px 0;">'+data+'</div>');
			   				});
				   		
				   			}
					});
				}
				else if(ancora=='#prenotazioni'){
					
					
					$("#prenotaform input").keyup(function(){
				
					var regemail = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
					//var regenum = /^([0-9])/;
					var regenum = /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/;
					var regedate = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/;
				
					//tolgo i mess di errore di prima (eventuali)
					$('.error').remove();
	
					if(
						(!regemail.test($('#prenotaform #f_email').val())) ||
						(!regenum.test($('#prenotaform #f_telefono').val()) && $('#prenotaform #f_telefono').val()!='Telefono fisso') ||
						(!regenum.test($('#prenotaform #f_cellulare').val()) && $('#prenotaform #f_cellulare').val()!='Telefono cellulare') ||
						(!regedate.test($('#prenotaform #f_data_evento').val()) && $('#prenotaform #f_data_evento').val()!='Data evento') ||
						(!regedate.test($('#prenotaform #f_data_nascita').val()) && $('#prenotaform #f_data_nascita').val()!='Nato/a il gg/mm/aaaa')
						
						){
								if(!regemail.test($('#prenotaform #f_email').val())){$('#prenotaform #f_email').parent('.wrap').append('<label for="f_email" generated="true" class="error">Inserisci un indirizzo email valido.</label>');}
								if(!regenum.test($('#prenotaform #f_telefono').val()) && $('#prenotaform #f_telefono').val()!='Telefono fisso'){$('#prenotaform #f_telefono').parent('.wrap').append('<label for="f_email" generated="true" class="error">Inserisci un numero valido.</label>');}
								if(!regenum.test($('#prenotaform #f_cellulare').val()) && $('#prenotaform #f_cellulare').val()!='Telefono cellulare'){$('#prenotaform #f_cellulare').parent('.wrap').append('<label for="f_email" generated="true" class="error">Inserisci un numero valido.</label>');}
								if(!regedate.test($('#prenotaform #f_data_evento').val()) && $('#prenotaform #f_data_evento').val()!='Data evento'){$('#prenotaform #f_data_evento').parent('.wrap').append('<label for="f_email" generated="true" class="error">Inserisci una data corretta.</label>');}
								if(!regedate.test($('#prenotaform #f_data_nascita').val()) && $('#prenotaform #f_data_nascita').val()!='Nato/a il gg/mm/aaaa'){$('#prenotaform #f_data_nascita').parent('.wrap').append('<label for="f_email" generated="true" class="error">Inserisci una data corretta.</label>');};

								return false;
	
						
					}else{
	
							return true;
					};
									
				});	//fine onclick
					
					
				$("#prenotaform #inviare").click(function(){
				
				var regemail = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
				var regenum = /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/;
				var regedate = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/;
			
				//tolgo i mess di errore di prima (eventuali)
				$('.error').remove();

				if(
					(!regemail.test($('#prenotaform #f_email').val())) ||
					(!regenum.test($('#prenotaform #f_telefono').val()) && $('#prenotaform #f_telefono').val()!='Telefono fisso') ||
					(!regenum.test($('#prenotaform #f_cellulare').val()) && $('#prenotaform #f_cellulare').val()!='Telefono cellulare') ||
					(!regedate.test($('#prenotaform #f_data_evento').val()) && $('#prenotaform #f_data_evento').val()!='Data evento') ||
					(!regedate.test($('#prenotaform #f_data_nascita').val()) && $('#prenotaform #f_data_nascita').val()!='Nato/a il gg/mm/aaaa')
					
					){
							if(!regemail.test($('#prenotaform #f_email').val())){$('#prenotaform #f_email').parent('.wrap').append('<label for="f_email" generated="true" class="error">Inserisci un indirizzo email valido.</label>');}
							if(!regenum.test($('#prenotaform #f_telefono').val()) && $('#prenotaform #f_telefono').val()!='Telefono fisso'){$('#prenotaform #f_telefono').parent('.wrap').append('<label for="f_email" generated="true" class="error">Inserisci un numero valido.</label>');}
							if(!regenum.test($('#prenotaform #f_cellulare').val()) && $('#prenotaform #f_cellulare').val()!='Telefono cellulare'){$('#prenotaform #f_cellulare').parent('.wrap').append('<label for="f_email" generated="true" class="error">Inserisci un numero valido.</label>');}
							if(!regedate.test($('#prenotaform #f_data_evento').val()) && $('#prenotaform #f_data_evento').val()!='Data evento'){$('#prenotaform #f_data_evento').parent('.wrap').append('<label for="f_email" generated="true" class="error">Questo campo è obbligatorio.</label>');};
							if(!regedate.test($('#prenotaform #f_data_nascita').val()) && $('#prenotaform #f_data_nascita').val()!='Nato/a il gg/mm/aaaa'){$('#prenotaform #f_data_nascita').parent('.wrap').append('<label for="f_email" generated="true" class="error">Inserisci una data corretta.</label>');};
							return false;

					
				}else{

						return true;
				};
								
			});	//fine onclick	
					
					
					
					
					
					
					
					
					
					
					
					
				}
				
				
			}
		});}
	
	else{
	$.localScroll({
		target: '#content', // could be a selector or a jQuery object too.		  
		queue:true,
		duration:1000,
		hash:true,
		onAfter:function( anchor, settings ){
			$(this).parent().siblings().removeClass('attivo');
			$(this).parent().addClass('attivo');
			
		}
	});};
	
	
	/////////////////
	//SERIAL SCROLL//
	////////////////
	if(location.hash){
			var ancora= window.location.hash;
			var startid1 = $('#agenda ul li a[href$="'+ancora+'"]').attr('id');
			}else{
				startid1=0;
				};		
				
				
$('#agenda').serialScroll({
		target:'#sections',
		items:'li', 
		prev:'a.prev',
		next:'a.next',
		axis:'xy',
		navigation:'#navigation li a',
		force:true,
		cycle:false,
		start:startid1,
		duration:700,
		force:true			
	});
	

//PAGINA SHOW: Funzioni di Ale

		$("#ilcalendario").hide();
		
		
		
		$('#agenda ul li').click(function(){
				var theid =$(this).find('a').attr('rel');
				$(this).siblings().removeClass('attivo');
				$(this).addClass('attivo');
				
				
				
				var startid = $(this).find('a').attr('id');
				$('#agenda').serialScroll({
								target:'#sections',
								items:'li', 
								prev:'a.prev',
								next:'a.next',
								axis:'xy',
								navigation:'#navigation li a',
								start:startid,
								cycle:false,
								duration:700,
								force:true
							});
				$.post('evento.php',{ ev: theid},function(data){
								$('#descr_evento').html(data); 
								
								var altezza= $('#show #descr_evento li').height()+60;
								var altezza2= altezza + $("#show #navigation").height()+ $("#agenda").height()+60;			
								$("#show  #maschera").animate({ height: altezza2, easing: "swing" }, 800, function(){$('#body-background').fadeIn('slow');});
								$("[title]").mbTooltip({opacity : .97, wait:200,  cssClass:"default", timePerWord:70, hasArrow:false, hasShadow:true, imgPath:"images/", ancor:"parent",  shadowColor:"black",  mb_fade:200  });
							
							
							});
				});


		$("#sceglidata").hover(function(){
				$("#ilcalendario").show();
				$("#ilcalendario").load('calendar.php','', function(){
						
						
						$(this).find('a').click(function(){
							var startid = $(this).attr('rel');
							var evento = $(this).attr('id');
							//$('#descr_evento').html('<h1>loading...</h1>');
							if($('body').attr('id')=="show"){
							var altezza3= $("#navigation").height()+ $("#agenda").height()+60;
							$("#maschera").animate({ height: altezza3, easing: "swing" }, 800, function(){$('#body-background').fadeIn('slow');});
							
							var altezza= $('#descr_evento li').height() +60;
							var altezza2= altezza + $("#navigation").height()+ $("#agenda").height()+60;
							
							$("#maschera").animate({ height: altezza2, easing: "swing" }, 800, function(){$('#body-background').fadeIn('slow');});
							$("[title]").mbTooltip({opacity : .97, wait:200,  cssClass:"default", timePerWord:70, hasArrow:false, hasShadow:true, imgPath:"images/", ancor:"parent",  shadowColor:"black",  mb_fade:200  });
							}
									
							$('#ilcalendario').hide();
							$('#agenda').serialScroll({
								target:'#sections',
								items:'li', 
								prev:'a.prev',
								next:'a.next',
								axis:'xy',
								cycle:false,
								navigation:'#navigation li a',
								start:startid,
								duration:700,
								force:true
							});
							
							
				
							
							if($('body').attr('id')=="show"){
								$('#agenda ul li').removeClass('attivo');
								$('#agenda ul li a[id$="'+startid+'"]').parent('li').addClass('attivo');
								$.post('evento.php',{ ev: evento},function(data){
									$('#descr_evento').html(data); 
									var altezza= $('#descr_evento li').height() +60;
									var altezza2= altezza + $("#navigation").height()+ $("#agenda").height()+60;
									$("#maschera").animate({ height: altezza2, easing: "swing" }, 800, function(){$('#body-background').fadeIn('slow');});
									$("[title]").mbTooltip({opacity : .97, wait:200,  cssClass:"default", timePerWord:70, hasArrow:false, hasShadow:true, imgPath:"images/", ancor:"parent",  shadowColor:"black",  mb_fade:200  });
									});
								
							}else if($('body').attr('id')=="index"){
								
								$('#agenda ul li').removeClass('attivo');
								var ancora= window.location.hash;
								var prova = $(this).attr('href');
								//alert(prova);
								$('#agenda ul li a[href$="show.php'+prova+'"]').parent('li').addClass('attivo');
								
								}
								
								
								
														
							});	
							$(this).find('table.month').hide();
							$(this).find('table#the1').show();	
							$(this).find('span.to1').click(function(){$('table.month').hide();$('table#the1').show();})
							$(this).find('span.to2').click(function(){$('table.month').hide();$('table#the2').show();})
							$(this).find('span.to3').click(function(){$('table.month').hide();$('table#the3').show();})
							$(this).find('span.to4').click(function(){$('table.month').hide();$('table#the4').show();})
							$(this).find('span.to5').click(function(){$('table.month').hide();$('table#the5').show();})
							$(this).find('span.to6').click(function(){$('table.month').hide();$('table#the6').show();})
							$(this).find('span.to7').click(function(){$('table.month').hide();$('table#the7').show();})
							$(this).find('span.to8').click(function(){$('table.month').hide();$('table#the8').show();})
							$(this).find('span.to9').click(function(){$('table.month').hide();$('table#the9').show();})
							$(this).find('span.to10').click(function(){$('table.month').hide();$('table#the10').show();})
							$(this).find('span.to11').click(function(){$('table.month').hide();$('table#the11').show();})
							$(this).find('span.to12').click(function(){$('table.month').hide();$('table#the12').show();})
							$(this).find('span.to13').click(function(){$('table.month').hide();$('table#the13').show();})
							$(this).find('span.to14').click(function(){$('table.month').hide();$('table#the14').show();})
							$(this).find('span.to15').click(function(){$('table.month').hide();$('table#the15').show();})
							$(this).find('span.to16').click(function(){$('table.month').hide();$('table#the16').show();})
							$(this).find('span.to17').click(function(){$('table.month').hide();$('table#the17').show();})
							$(this).find('span.to18').click(function(){$('table.month').hide();$('table#the18').show();})
							$(this).find('span.to19').click(function(){$('table.month').hide();$('table#the19').show();})
							$(this).find('span.to20').click(function(){$('table.month').hide();$('table#the20').show();})
							$(this).find('span.to21').click(function(){$('table.month').hide();$('table#the21').show();})
							$(this).find('span.to22').click(function(){$('table.month').hide();$('table#the22').show();})
							$(this).find('span.to23').click(function(){$('table.month').hide();$('table#the23').show();})
							$(this).find('span.to24').click(function(){$('table.month').hide();$('table#the24').show();})
						
					});

				},function(){
				$("#ilcalendario").hover(function(){$(this).show();},function(){$(this).hide();});
			});



});	






//$("#body-background img").load(function() {
  // Handler for .load() called.
  	//$("#body-background").ezBgResize();
  	
	$(window).resize(function(){
		$("#body-background").ezBgResize();
	});
  
//});
