/*function setDateInputs()
	{
		var lang = $('body').attr('data-lang');
		if (lang != 'it' ) lang='en';


		$(':date').each(function()
		{

			$(this).dateinput(
			{
			format: 'dd/mm/yyyy',
			lang: lang,
			firstDay: 1
			});
		});
	}*/
/*****************************************************************************************/
function includeIe6Nomore()
{
	if($.browser.msie && $.browser.version.match('6.'))
		$('#ie6nomore').load('ie6nomore.html');
}
//	inizio funzioni di debug
debug_msg = false;
function toDebug(string)
{
	if (debug_msg)
	{
		if((typeof window.console=="undefined")) {alert(string);}
		else {
			console.error();
			console.group(string);
			console.trace();
			console.groupEnd();
		}
	}
}
function toConsole(string)
{
	if((typeof window.console=="undefined")) {alert(string);}
	else console.log(string);
}
//fine funzioni di debug
function $j(argument)
{
	var result = jQuery(argument);
	if (result.length == 0) return null;
	else return result;
}

$j(document).ready(function()
{
	// init per banner "browser obsoleto"
	includeIe6Nomore();

	//setDateInputs();
	$("#checkin").datepicker({option:' it', dateFormat: 'dd-mm-yy',showOn: 'both', buttonText: '', buttonImageOnly: true, numberOfMonths: 3});
	$("#checkout").datepicker({option:' it', dateFormat: 'dd-mm-yy',showOn: 'both', buttonText: '', buttonImageOnly: true, numberOfMonths: 3});

	$("#checkin").change(
		function(){
			date1 = $("#checkin").datepicker( 'getDate' );
			// devo controllare che la data sia valida
			check = false;
			dateCheck = date1;
			date2 = new Date(dateCheck);
			$("#checkout").datepicker('option', 'minDate',date2);
		}
	);

	// init per gli elementi in overlay
	$('*[rel^="lightbox"], *[rel^="prettyPhoto"]').prettyPhoto({theme:'facebook'});

	$('#offerte-slider').cycle(
	{
		fx:     'scrollLeft',
		speed: 1000,
		timeout: 5000,
		pause: 1,
		prev: '#offerte-prev',
		next: '#offerte-next'
	});

	$('.offerte-business-slider').cycle(
	{
		fx:     'scrollLeft',
		speed: 1000,
		timeout: 5000,
		pause: 1,
		prev: '#offerte-b-prev',
		next: '#offerte-b-next'
	});

	$('#gallery-slider').cycle(
	{
		fx:     'scrollLeft',
		speed: 1000,
		timeout: 5000,
		pause: 1,
		prev: '#gallery-prev',
		next: '#gallery-next'
	});

	// Newsletter signup
	$("#frmSS12").submit(function(e) {
		var mail=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;

		var iEmail = $("#frmSS12 #email");
		var iPrivacy = $("#frmSS12 #privacy");

		if( iEmail.val() == "" || !mail.test( iEmail.val())) {
			alert("La preghiamo di inseire un indirizzo email valido");
			iEmail.focus();
			return false;
		}
		else if(!iPrivacy.attr("checked")){
			alert("La preghiamo di autorizzare l'uso dei suoi dati secondo la legge sulla Privacy.(art. 13 L. 675/03)");
			iPrivacy.focus();
			return false;
		}
		else{return true;}
	});


});


$j(window).load(function()
{


});

$j(window).resize(function()
{
});


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

function cambia_bambini(n) {
	frm = document.getElementById("form_ins");
	camere = parseInt(document.getElementById("numRooms").value);
	if (n>4) n=4;
	if ((n>0)&&(camere==1))
	{
		var contenuto = "";
		var name = "";
		for (i=1; i<=n; i++){
			name="bform[reqRooms][1][childAge]["+i+"]";
			contenuto += "<select name='"+name+"' id='"+name+"'><option value='-1'>-?-</option><option value='0'>&lt;1</option><option>1</option><option>2</option><option>3</option><option>4</option><option>5</option><option>6</option><option>7</option><option>8</option><option>9</option><option>10</option><option>11</option><option>12</option></select>";
		}
		document.getElementById("bam_div").innerHTML=contenuto+"&nbsp;";
		document.getElementById("bam_div").style.visibility = "visible";
		document.getElementById("bam_div").style.display = "block";
		document.getElementById("bam_div1").style.visibility = "visible";
		document.getElementById("bam_div1").style.display = "block";
	} else {
		document.getElementById("bam_div").style.visibility = "hidden";
		document.getElementById("bam_div").style.display = "none";
		document.getElementById("bam_div1").style.visibility = "hidden";
		document.getElementById("bam_div1").style.display = "none";
	}

}

function sendCallBack() {
		if ((document.getElementById("frm_nome").value == "") || (document.getElementById("frm_nome").value == "nome*")) {
			alert('Inserisci il tuo nome');
			document.getElementById("frm_nome").focus();
			return false;
		}
		if ((document.getElementById("frm_telefono").value == "") || (document.getElementById("frm_telefono").value == "telefono*")) {
			alert('Inserisci il tuo numero di telefono');
			document.getElementById("frm_telefono").focus();
			return false;
		}
		if ((document.getElementById("frm_orario").value == "") || (document.getElementById("frm_orario").value == "orario*")) {
			alert('A che ora vuoi essere richiamato?');
			document.getElementById("frm_orario").focus();
			return false;
		}
		if (document.getElementById("frm_privacy").checked == false) {
			alert("E' necessario prendere visione delle normative della privacy");
			return false;
		}
		var dest = "back";
		document.getElementById("wrapper_form_callback").action = "call" + dest + ".php";
    	document.getElementById("wrapper_form_callback").submit();
	}
function ctrform(){
	if (document.getElementById("checkin").value==''){
		document.getElementById("checkin").focus();
		alert("Data di Arrivo obbligatoria");
		return false;
	}
	if (document.getElementById("checkout").value=='') {
		document.getElementById("checkout").focus();
		alert("Data di Partenza obbligatoria");
		return false;
	}
	document.getElementById("form_ins").submit();
}

