function controlloForm(){
	errore=0;
    messaggio="";
	thisForm=document.prenota;
	thisForm.action="invia.php";
	thisForm.target="_self";
	if(thisForm.nome.value==''){
		errore=1
        messaggio= messaggio+ "Inserire il nome\n";
	}
	if(thisForm.cognome.value==''){
		errore=1
        messaggio= messaggio+ "Inserire il cognome\n";
	}
	if(thisForm.email.value==''){
		errore=1
        messaggio= messaggio+ "Inserire un email valida\n";
	}
	if((thisForm.gg_arrivo.value=='') || (thisForm.mm_arrivo.value=='') || (thisForm.aaaa_arrivo.value=='')){
		errore=1
        messaggio= messaggio+ "Inserire un giorno di arrivo\n";
	}
	if((thisForm.gg_partenza.value=='') || (thisForm.mm_partenza.value=='') || (thisForm.aaaa_partenza.value=='')){
		errore=1
        messaggio= messaggio+ "Inserire un giorno di partenza\n";
	}
	if(thisForm.adulti.value==''){
		errore=1
        messaggio= messaggio+ "Inserire il numero di adulti\n";
	}
	if(thisForm.bambini.value==''){
		errore=1
        messaggio= messaggio+ "Inserire il numero di bambini\n";
	}
	if(thisForm.accetto.checked==false){
		errore=1
        messaggio= messaggio+ "Bisogna accettare le condizioni sulla privacy prima di proseguire\n";
	}
    if (errore > 0){
        alert (messaggio);
    }
	else {
        thisForm.submit();
    }
}

function controlloForm2(){
	errore=0;
    messaggio="";
	thisForm=document.form_contattaci;
	thisForm.action="_class/classAzioni.php";
	thisForm.target="_self";
	if(thisForm.nome.value==''){
		errore=1;
        messaggio= messaggio+ "Riempire il campo nome\n";
	}
	if(thisForm.email.value==''){
		errore=1;
        messaggio= messaggio+ "Inserire un email valida\n";
	}
	if(thisForm.messaggio.value==''){
		errore=1;
        messaggio= messaggio+ "Riempire il campo messaggio\n";
	}
	if(thisForm.accetto.checked==false){
		errore=1;
        messaggio= messaggio+ "Bisogna autorizzare la pubblicazione prima di proseguire\n";
	}
    if (errore > 0){
        alert (messaggio);
    }
	else {
        thisForm.submit();
    }
}

function show(id){ 
    obj = document.getElementById(id); 
    obj.style.visibility = "visible"; 
} 

function hide(id){ 
    obj = document.getElementById(id); 
    obj.style.visibility = "hidden"; 
}

function openMassaggi(w, h){
	var left=(screen.width - w)/2;
	var top=(screen.height- h)/2
	miaFin=window.open("massaggi.php", "massaggi", "width=" + w + ",height=" + h + ", left="+left+", top="+top+", directories=no, location=no, menubar=no, resizable=no, status=no, toolbar=no, scrollbars=yes");
	miaFin.focus();
}

function roundedBox(label, submenu){
	if(submenu==1)
		document.write('<div class="rounded1"><div class="rounded2"><div class="rounded3"><div class="rounded4_sub">' + label + '</div></div></div></div>');
	else
		document.write('<div class="rounded1"><div class="rounded2"><div class="rounded3"><div class="rounded4">' + label + '</div></div></div></div>');
}

function roundedBoxInput(inputname, inputsize, width, cols, rows){
	document.write('<div class="rounded1_input" style="width: '+width+'px;"><div class="rounded2_input"><div class="rounded3_input"><div class="rounded4_input"><input type="Text" name="'+inputname+'" size="'+inputsize+'" value="" class="input_commento" /></div></div></div></div>');
	
}
function roundedBoxTextarea(inputname, width, cols, rows){
	document.write('<div class="rounded1_input" style="width: '+width+'px;"><div class="rounded2_input"><div class="rounded3_input"><div class="rounded4_input"><textarea name="'+inputname+'" cols="'+cols+'" rows="'+rows+'" class="input_commento"></textarea></div></div></div></div>');
}

function switchZoom(src, thumb){
	document.images[thumb].src = document.images['zoom_prodotto'].src;
	document.images['zoom_prodotto'].src = src;
}

function showDisciplinaHome(sel){
	for (var i=0; i<totalDiscipline; i++){
		document.getElementById('disciplina_'+i).style.display='none';
	}
	document.getElementById('disciplina_'+sel).style.display='block';
	
	//document.getElementById('box_discipline_select').innerHTML = titoliDiscipline[sel];
}

function controlMemoForm(){
	errore=0;
    messaggio="";
	thisForm=document.memo_iscrizione;
	thisForm.action="_class/classAzioni.php";
	thisForm.target="_self";
	if(thisForm.nome.value==''){
		errore=1;
        messaggio= messaggio+ "Inserire il nome\n";
	}
	
	if( (thisForm.email.value=='') || (!checkEmail(thisForm, "1")) ){
		errore=1;
        messaggio= messaggio+ "Inserire un email valida\n";
	}
	
	if(thisForm.privacy.checked==false){
		errore=1;
        messaggio= messaggio+ "Bisogna accettare le condizioni sulla privacy prima di proseguire\n";
	}
    if (errore > 0){
        alert (messaggio);
    }
	else {
        thisForm.submit();
    }
}

function controlMemoLogin(){
	errore=0;
    messaggio="";
	thisForm=document.memo_login;
	thisForm.action="_class/classAzioni.php";
	thisForm.target="_self";
	
	if( (thisForm.email.value=='') || (!checkEmail(thisForm, "1")) ){
		errore=1;
        messaggio= messaggio+ "Inserire un email valida\n";
	}
	if(thisForm.password.value==''){
		errore=1;
        messaggio= messaggio+ "Inserire la password\n";
	}
	
	
    if (errore > 0){
        alert (messaggio);
    }
	else {
        thisForm.submit();
    }
}

function checkEmail(myForm, lang) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.email.value)){
		return (true)
	}
	
	return (false)
}

function formAccredito(tipo){
	if(tipo==2) document.getElementById('multi_accredito').style.display='block';
	else document.getElementById('multi_accredito').style.display='none';
}

function controlloMultiAccrediti(){
	errore=0;
	thisForm=document.form_multi_accredito2;
	
	if(thisForm.nome.value==''){
		errore=1;
        alert('Inserire il nome');
		thisForm.nome.focus();
	}else if(thisForm.cognome.value==''){
		errore=1;
        alert('Inserire il cognome');
		thisForm.cognome.focus();
	}else if(thisForm.email.value==''){
		errore=1;
        alert('Inserire l\'indirizzo email');
		thisForm.email.focus();
	}
	
    if(errore==0){
		thisForm.submit();
		thisForm.nome.value=''
		thisForm.cognome.value=''
		thisForm.email.value=''
	}
}

function controlloMultiAccreditiIng(){
	errore=0;
	thisForm=document.form_multi_accredito2;
	
	if(thisForm.nome.value==''){
		errore=1;
        alert('Insert the first name');
		thisForm.nome.focus();
	}else if(thisForm.cognome.value==''){
		errore=1;
        alert('Insert the last name');
		thisForm.cognome.focus();
	}else if(thisForm.email.value==''){
		errore=1;
        alert('Insert the e-mail address');
		thisForm.email.focus();
	}
	
    if(errore==0){
		thisForm.submit();
		thisForm.nome.value=''
		thisForm.cognome.value=''
		thisForm.email.value=''
	}
}

function controlloAccredito(){
	errore=0;
	thisForm=document.form_accredito;
	
	if(thisForm.nome.value==''){
		errore=1;
        alert('Inserire il nome');
		thisForm.nome.focus();
	}else if(thisForm.cognome.value==''){
		errore=1;
        alert('Inserire il cognome');
		thisForm.cognome.focus();
	}else if(thisForm.editore.value==''){
		errore=1;
        alert('Inserire l\'editore');
		thisForm.editore.focus();
	}else if(thisForm.testata.value==''){
		errore=1;
        alert('Inserire la testata');
		thisForm.testata.focus();
	}else if(thisForm.posizione.value==''){
		errore=1;
        alert('Inserire la posizione');
		thisForm.posizione.focus();
	}else if(thisForm.telefono.value==''){
		errore=1;
        alert('Inserire il telefono');
		thisForm.telefono.focus();
	}else if(thisForm.email.value==''){
		errore=1;
        alert('Inserire l\'indirizzo email');
		thisForm.email.focus();
	}else if(thisForm.privacy.checked==false){
		errore=1;
        alert('Accettare l\'informativa sulla privacy');
		thisForm.privacy.focus();
	}
	
    if(errore==0) thisForm.submit();
}

function controlloAccreditoIng(){
	errore=0;
	thisForm=document.form_accredito;
	
	if(thisForm.nome.value==''){
		errore=1;
        alert('Insert the first name');
		thisForm.nome.focus();
	}else if(thisForm.cognome.value==''){
		errore=1;
        alert('Insert the last name');
		thisForm.cognome.focus();
	}else if(thisForm.editore.value==''){
		errore=1;
        alert('Insert the publisher');
		thisForm.editore.focus();
	}else if(thisForm.testata.value==''){
		errore=1;
        alert('Insert the publication');
		thisForm.testata.focus();
	}else if(thisForm.posizione.value==''){
		errore=1;
        alert('Insert the function');
		thisForm.posizione.focus();
	}else if(thisForm.telefono.value==''){
		errore=1;
        alert('Insert the telephone');
		thisForm.telefono.focus();
	}else if(thisForm.email.value==''){
		errore=1;
        alert('Insert the e-mail address');
		thisForm.email.focus();
	}else if(thisForm.privacy.checked==false){
		errore=1;
        alert('Accettare l\'informativa sulla privacy');
		thisForm.privacy.focus();
	}
	
    if(errore==0) thisForm.submit();
}
