// JavaScript Document
function invia_mail()
{		
	$("#invio_ok").hide();
	$("#errore_invio").hide();
	$("#invio_in_corso").fadeIn();
	$("#invio_in_corso").html("  Invio in corso");
	var data = new Date();
	if ($("#spam").val()=='')//se non sono un bot spam
	{
		if (($("#nome").val()=='')||($("#email").val()=='')||($("#telefono").val()==''))//campi non compilati
		{
			$("#invio_ok").hide();
			$("#invio_in_corso").hide();
			$("#errore_invio").fadeIn();			
			$("#errore_invio").html("<img src='img/Alert-32.png'/> Compila i campi obbligatori*");
			valido=false;
		}else{
				var nome=$("#nome").val();
				var email=$("#email").val();
				var tel=$("#telefono").val();
				var num_pers=$("#num_pers").val();
				var anno=data.getFullYear();				
				var arrivo=$("#arrivo-giorno").val()+'/'+$("#arrivo-mese").val()+'/'+anno;
				var partenza=$("#partenza-giorno").val()+'/'+$("#partenza-mese").val()+'/'+anno;
				var note=$("#note").val();				
				$.ajax({	
					type: 'POST',
					url: 'ajax.php',
					data: 'nome='+nome+'&email='+email+'&num_pers='+num_pers+'&tel='+tel+'&arrivo='+arrivo+'&partenza='+partenza+'&note='+note,					
					success: function(html){
						if (html=='inviata')
						{
							$("#errore_invio").hide();
							$("#invio_in_corso").hide();
							$("#invio_ok").fadeIn();
							$("#invio_ok").html("<img src='img/Check-icon.png'/> Email correttamente inviata");
						}
						else{
							$("#invio_in_corso").hide();
							$("#invio_ok").hide();
							$("#errore_invio").fadeIn();							
							$("#errore_invio").html("<img src='img/Alert-32.png'/> Errore invio email");
						}
					
					}
				});			
		}
	}	
}

//inizializzazioni plugin

		
//fancybox
$(document).ready(function() {		
			$("a[rel=galleria]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',				
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			});
			$(".tour").fancybox({
				'width'				: 850,
				'height'			: 650,
				'autoScale'			: false,
				'transitionIn'		: 'fade',
				'transitionOut'		: 'fade',					
				'type'				: 'iframe'
			});			
			$("#various4").fancybox({
				'padding'			: 0,
				'autoScale'			: false,
				'transitionIn'		: 'fade',
				'transitionOut'		: 'fade',	
				'width': 320,
				'height': 240	
			});
		});

