function testComboCamMat(){
	valUsoSing = parseInt(document.getElementById('numeroStanzeCameraMatrimonialeUsoSingola').value);
	valUsoDoppia = parseInt(document.getElementById('numeroStanzeCameraMatrimonialeUsoDoppia').value);
	valNum = parseInt(document.getElementById('numeroCameraMatrimoniale').value);
	if((valUsoSing + valUsoDoppia) > valNum){
		alert("Attenzione: Possono essere selezionati al massimo " + valNum + " camere Matrimoniali")	
		diff = (valUsoSing + valUsoDoppia) - valNum;
		if(valUsoSing  > valUsoDoppia)
			document.getElementById('numeroStanzeCameraMatrimonialeUsoSingola').value = 0;
		else
			document.getElementById('numeroStanzeCameraMatrimonialeUsoDoppia').value = 0;
	} 
}

function testComboCamMatSuperior(){
	valUsoSing = parseInt(document.getElementById('numeroStanzeCameraMatrimonialeUsoSingolaSuperior').value);
	valUsoDoppia = parseInt(document.getElementById('numeroStanzeCameraMatrimonialeUsoDoppiaSuperior').value);
	valNum = parseInt(document.getElementById('numeroCameraMatrimonialeSuperior').value);
	if((valUsoSing + valUsoDoppia) > valNum){
		alert("Attenzione: Possono essere selezionati al massimo " + valNum + " camere Matrimoniali Superior")	
		diff = (valUsoSing + valUsoDoppia) - valNum;
		if(valUsoSing  > valUsoDoppia)
			document.getElementById('numeroStanzeCameraMatrimonialeUsoSingolaSuperior').value = 0;
		else
			document.getElementById('numeroStanzeCameraMatrimonialeUsoDoppiaSuperior').value = 0;
	} 
}

function showPrivacy(){
	document.getElementById('datiPersonali').display = 'block';
}

function checkForm(){
	nome = document.getElementById('Nome');
	cognome = document.getElementById('Cognome');
	email = document.getElementById('EMail');
	nCarta = document.getElementById('nrCarta');
	month = document.getElementById('month');
	year = document.getElementById('year');
	cvc = document.getElementById('cvc');
	ragSoc = document.getElementById('ragSociale');
	confermaEmail = document.getElementById('ConfermaEMail');
	numTel = document.getElementById('NumeroDiTelefono');
	checkPrivacy = document.getElementById('consenso');
	
	msg = '';
	if(nome == null || nome.value==''){
		msg += "Inserire il nome\n";
	}
	if(cognome == null || cognome.value==''){
		msg += "Inserire il cognome\n";
	}
	if(email == null || email.value==''){
		msg += "Inserire l\'EMail\n";
		email = '';
	} 
	if(confermaEmail == null || confermaEmail.value==''){
		msg += "Inserire la conferma dell\'Email\n";
		confermaEmail = '';
	}
	if(confermaEmail.value != email.value){
		msg += "Email non corrispondente\n";
	}
	if(numTel == null || numTel.value==''){
		msg += "Inserire il numero di telefono\n";
	}
	if(!checkPrivacy.checked){
		msg += "Per continuare e\' obbligatorio dare il consenso privacy\n";
	}
	if(nCarta == null || nCarta.value==''){
		msg += "Inserire il numero della carta di credito\n";
	}
	if(ragSoc == null || ragSoc.value==''){
		msg += "Inserire la ragione sociale\n";
	}
	if(cvc == null || cvc.value==''){
		msg += "Inserire il cvc\n";
	}
	
	if(msg == ''){
		document.forms[0].submit();
	} else {
		alert(msg);
	}
}


function changeCalendario(){
	document.getElementById('day2').fireEvent('onchange');
  	//window.setTimeout(simulateOnChange, 5000);
	//document.getElementById('day2').click();
}

function checkFormBook(){
	numeroStanzeCameraSingola = parseInt(document.getElementById('numeroStanzeCameraSingola').value);
	numeroStanzeCameraMatrimonialeUsoSingola = parseInt(document.getElementById('numeroStanzeCameraMatrimonialeUsoSingola').value);
	numeroStanzeCameraMatrimonialeUsoDoppia = parseInt(document.getElementById('numeroStanzeCameraMatrimonialeUsoDoppia').value);
	numeroStanzeCameraMatrimonialeUsoSingolaSuperior = parseInt(document.getElementById('numeroStanzeCameraMatrimonialeUsoSingolaSuperior').value);
	numeroStanzeCameraMatrimonialeUsoDoppiaSuperior = parseInt(document.getElementById('numeroStanzeCameraMatrimonialeUsoDoppiaSuperior').value);
	numeroStanzeCameraMatrimonialeJacuzzi = parseInt(document.getElementById('numeroStanzeCameraMatrimonialeJacuzzi').value);
	numeroStanzeCameraAntica = parseInt(document.getElementById('numeroStanzeCameraAntica').value);
	numeroStanzeCameraTripla = parseInt(document.getElementById('numeroStanzeCameraTripla').value);
	numeroStanzeCameraQuadrupla = parseInt(document.getElementById('numeroStanzeCameraQuadrupla').value);
	somma = numeroStanzeCameraSingola + numeroStanzeCameraMatrimonialeUsoSingola + numeroStanzeCameraMatrimonialeUsoDoppia + numeroStanzeCameraMatrimonialeUsoSingolaSuperior + numeroStanzeCameraMatrimonialeUsoDoppiaSuperior + numeroStanzeCameraMatrimonialeJacuzzi + numeroStanzeCameraAntica + numeroStanzeCameraTripla + numeroStanzeCameraQuadrupla;
	if(somma == 0){
		alert('Selezionare almeno una stanza ');
	} else {
		document.forms[0].submit();
	}
}

function onChangeMeseForAdminGiorniMin(value){
	var anno = document.getElementById('anno').value;
	var mese = document.getElementById('mese').value;	
	window.location = "adminNumeroGiorniMinimo.php?mese=" + mese + "&anno=" + anno;
}


function onChangeMeseForAdminpreavvisi(value){
	var anno = document.getElementById('anno').value;
	var mese = document.getElementById('mese').value;
	window.location = "adminGiorniPreavviso.php?mese=" + mese + "&anno=" + anno;
}

function onChangeMese(value){
	var anno = document.getElementById('anno').value;
	var mese = document.getElementById('mese').value;
	window.location = "adminDisponibilita.php?mese="+ mese + "&anno=" + anno;
}

function onChangeMesePrezzi(value){
	var anno = document.getElementById('anno1').value;
	var mese = document.getElementById('mese').value;
	window.location = "adminPrezzi.php?mese=" + mese + "&anno=" + anno;
}