$(function() {
	$("#DispDal").datepicker({ dateFormat: 'dd/mm/yy', dayNamesMin: ['Do', 'Lu', 'Ma', 'Me', 'Gi', 'Ve', 'Sa'], monthNames: ['Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno','Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre'] , firstDay: 1, showOtherMonths: true, selectOtherMonths: true, showWeek: true, weekHeader: '' });
	$("#DispAl").datepicker({ dateFormat: 'dd/mm/yy', dayNamesMin: ['Do', 'Lu', 'Ma', 'Me', 'Gi', 'Ve', 'Sa'], monthNames: ['Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno','Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre'], firstDay: 1, showOtherMonths: true, selectOtherMonths: true, showWeek: true, weekHeader: '' });
	$.fn.maphilight.defaults = {
		fill: true,
		fillColor: 'ffffff',
		fillOpacity: 0.1,
		stroke: true,
		strokeColor: 'e6750a',
		strokeOpacity: 1,
		strokeWidth: 1,
		fade: false,
		alwaysOn: false
	}
	$(".map").maphilight();
	$("#LangIt").simpletip({ content: '<table cellspacing="0" cellpadding="0" border="0"><tr><td><img src="imgs/_layout/flg_it.gif" border="0" /></td><td>&nbsp; italiano</td></tr></table>', fixed:false, persistent:false, offset:[0,22], showEffect:'' });
	$("#LangDe").simpletip({ content: '<table cellspacing="0" cellpadding="0" border="0"><tr><td><img src="imgs/_layout/flg_de.gif" border="0" /></td><td>&nbsp; deutsch</td></tr></table>', fixed:false, persistent:false, offset:[0,22], showEffect:''  });
	$("#LangEn").simpletip({ content: '<table cellspacing="0" cellpadding="0" border="0"><tr><td><img src="imgs/_layout/flg_en.gif" border="0" /></td><td>&nbsp; english</td></tr></table>', fixed:false, persistent:false, offset:[0,22], showEffect:''  });

	$("a[id=MapIt]").simpletip({ content: '<table cellspacing="0" cellpadding="0" border="0"><tr><td><img src="imgs/_layout/zoom_map.gif" border="0" /></td><td>&nbsp; visualizza sulla cartina</td></tr></table>', fixed:false, persistent:false, offset:[0,22], showEffect:'' });
	$("a[id=MapDe]").simpletip({ content: '<table cellspacing="0" cellpadding="0" border="0"><tr><td><img src="imgs/_layout/zoom_map.gif" border="0" /></td><td>&nbsp; auf der Karte anzeigen</td></tr></table>', fixed:false, persistent:false, offset:[0,22], showEffect:''  });
	$("a[id=MapEn]").simpletip({ content: '<table cellspacing="0" cellpadding="0" border="0"><tr><td><img src="imgs/_layout/zoom_map.gif" border="0" /></td><td>&nbsp; view on map</td></tr></table>', fixed:false, persistent:false, offset:[0,22], showEffect:''  });
});
$(document).ready(function(){
	//$("a[rel^='prettyPhoto']").prettyPhoto({theme: 'dark_rounded'});
	$('#slideshowHolder').jqFancyTransitions({width:705, height:302, direction:'fountainAlternate', effect:'wave', strips:30, delay:5000, stripDelay:20});
	mainmenu();

	$("a[rel=gmapsh]").fancybox({
		'width'				: 650,
		'height'			: 450,
		'autoScale'			: false,
		'autoDimensions'	: false,
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'fade',
		'scrolling'			: 'no',
		'type'				: 'iframe',
		'overlayOpacity'	: 0.8,
		'padding'			: 0,
		'overlayColor'		: '#000000',
		'showNavArrows'		: false
	});

	$("a[rel=webcam]").fancybox({
		'width'				: 800,
		'height'			: 600,
		'autoScale'			: false,
		'autoDimensions'	: false,
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'fade',
		'scrolling'			: 'no',
		'type'				: 'iframe',
		'overlayOpacity'	: 0.8,
		'padding'			: 0,
		'overlayColor'		: '#000000',
		'showNavArrows'		: false
	});
	
	$("a[rel=fbox]").fancybox({
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'titlePosition' 	: 'over'
		//'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {return '<span id="fancybox-title-over">'+title+'<br><span style="font-weight:100">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + '</span></span>';}
	});

});

function mainmenu(){
	$(" #nav ul ").css({display: "none"});
	$(" #nav li").hover(function(){
		$(this).find('ul:first').css({visibility: "visible",display: "none"}).show('blind', 300);
		},function(){
			$(this).find('ul:first').css({visibility: "visible"}).hide('blind', 50);
		});
}

function hp_img(nomeimg) {
	document.getElementById('himgtop').src = './imgs/b/'+nomeimg;
}


// Funzioni richiesta disp.
function Children(){
	var selection = document.Form1.Bambini.value

	if (selection == "0")
	{
	}
	else
	{
		document.Form1.Altro.value = "Inserire l\'etā dei bambini in questa casella!"
	}
}

function ValidLength(item, len) 
		{	return(item.length >=len);
		}
function ValidEmail(item)
	{	if(!ValidLength(item,5)) return false;
		if(item.indexOf('@',0) == -1) return false;
		if(item.indexOf('.',0) == -1) return false;
		if(item.indexOf(',',0) > 0) return false;
		return true;
	}
function sendit()
{

	if ((document.Form1.NrCamereHotel.value == "0") &&
		(document.Form1.NrCamereGarni.value  == "0") &&
		(document.Form1.NrAppartamenti.value  == "0") &&
		(document.Form1.TxtCamping.value  == "0") &&
		(document.Form1.TxtRifugio.value  == "0"))
	{
		alert("Per proseguire č necessario scegliere almeno un tipo di alloggio.");
		return false;
	}
	else if ((document.Form1["5Stelle"].checked == 0) &&
		(document.Form1["4Stelle"].checked  == 0) &&
		(document.Form1["3Stelle"].checked  == 0) &&
		(document.Form1["2Stelle"].checked  == 0) &&
		(document.Form1["1Stelle"].checked  == 0))
	{
		alert("Per proseguire č necessario selezionare almeno una categoria..");
		return false;
	}
	else if ((document.Form1.SrcLuogo01.checked == 0) &&
		(document.Form1.SrcLuogo02.checked  == 0) &&
		(document.Form1.SrcLuogo03.checked  == 0) &&
		(document.Form1.SrcLuogo04.checked  == 0) &&
		(document.Form1.SrcLuogo05.checked  == 0) &&
		(document.Form1.SrcLuogo06.checked  == 0) &&
		(document.Form1.SrcLuogo07.checked  == 0) &&
		(document.Form1.SrcLuogo08.checked  == 0) &&
		(document.Form1.SrcLuogo09.checked  == 0) &&
		(document.Form1.SrcLuogo10.checked  == 0) &&
		(document.Form1.SrcLuogo11.checked  == 0) &&
		(document.Form1.SrcLuogo12.checked  == 0) &&
		(document.Form1.SrcLuogo13.checked  == 0) &&
		(document.Form1.SrcLuogo14.checked  == 0) &&
		(document.Form1.SrcLuogo15.checked  == 0) &&
		(document.Form1.SrcLuogo16.checked  == 0) &&
		(document.Form1.SrcLuogo17.checked  == 0) &&
		(document.Form1.SrcLuogo18.checked  == 0) &&
		(document.Form1.SrcLuogo19.checked  == 0) &&
		(document.Form1.SrcLuogo20.checked  == 0) &&
		(document.Form1.SrcLuogo21.checked  == 0) &&
		(document.Form1.SrcLuogo22.checked  == 0) &&
		(document.Form1.SrcLuogo23.checked  == 0) &&
		(document.Form1.SrcLuogo24.checked  == 0))  
	{
		alert("Pre proseguire č necessario scegliere almeno una localitā.");
		return false;
	}
	else 
		Control2()
}
function Control2()
	{	errfound = false;
		if (!ValidLength(document.Form1.Nome.value,3))
			error(document.Form1.Nome,"Inserire il proprio nome.");
		if (!ValidLength(document.Form1.Cognome.value,3))
			error(document.Form1.Cognome,"Inserire il proprio cognome.");
		if (!ValidLength(document.Form1.Indirizzo.value,3))
			error(document.Form1.Indirizzo,"Inserire il propio indirizzo di residenza.");
		if (!ValidLength(document.Form1.CAP.value,3))
			error(document.Form1.CAP,"Inserire il proprio CAP.");
		if (!ValidLength(document.Form1.Citta.value,3))
			error(document.Form1.Citta,"Inserire il nome della cittā di residenza.");
		if (!ValidEmail(document.Form1.Email.value))
			error(document.Form1.Email, "Inserire il proprio indirizzo e-mail.");
		if (document.Form1.TxtPrivacy.checked == 0)
			error(document.Form1.TxtPrivacy,"Per proseguire č neccessario acconsentire al trattamento dei dati personali \n come stabilito dalla legge 675/96.");
		if (errfound == false)
			{
			document.Form1.TxtCheck03.value = 'validato'
			document.Form1.BtnSend.disabled = true;
			document.Form1.BtnSend.value = 'Attendere prego...\nLa richiesta sta per essere inviata.';
			document.Form1.submit();
			}
			
}
function error(elem, text)
	{	if (errfound) return;
		window.alert(text)
		elem.select();
		elem.focus;
		errfound = true;
	}



// richiesta diretta
function diretta()
	{	errfound = false;
		if (!ValidLength(document.Form1.Nome.value,3))
			error(document.Form1.Nome,"Inserire il proprio nome.");
		if (!ValidLength(document.Form1.Cognome.value,3))
			error(document.Form1.Cognome,"Inserire il proprio cognome.");
		if (!ValidLength(document.Form1.Indirizzo.value,3))
			error(document.Form1.Indirizzo,"Inserire il propio indirizzo di residenza.");
		if (!ValidLength(document.Form1.CAP.value,3))
			error(document.Form1.CAP,"Inserire il proprio CAP.");
		if (!ValidLength(document.Form1.Citta.value,3))
			error(document.Form1.Citta,"Inserire il nome della cittā di residenza.");
		if (!ValidEmail(document.Form1.Email.value))
			error(document.Form1.Email, "Inserire il proprio indirizzo e-mail.");
		if (document.Form1.TxtPrivacy.checked == 0)
			error(document.Form1.TxtPrivacy,"Per proseguire č neccessario acconsentire al trattamento dei dati personali \n come stabilito dalla legge 675/96.");
		if (errfound == false)
			{
			document.Form1.TxtCheck03.value = 'validato'
			document.Form1.BtnSend.disabled = true;
			document.Form1.BtnSend.value = 'Attendere prego...\nLa richiesta sta per essere inviata.';
			document.Form1.submit();
			}		
}
