// JavaScript Document
function ShowAndHide(id1,id2){
if(document.getElementById){
    el1=document.getElementById(id1);
    el2=document.getElementById(id2);
    if(el1.style.display=="none"){
        el1.style.display="block";
        el2.style.display="none";
        }
    else{
        el1.style.display="none";
        el2.style.display="block";
        }
    }
} 


function validEmail(email) {
		invalidChars = " /:,;"

		if (email == "") {
			return false
		}
		for (i=0; i<invalidChars.length; i++) {
			badChar = invalidChars.charAt(i)
			if (email.indexOf(badChar,0) > -1) {
				return false
			}
		}
		atPos = email.indexOf("@",1)
		if (atPos == -1) {
			return false
		}
		if (email.indexOf("@",atPos+1) > -1) {
			return false
		}
		periodPos = email.indexOf(".",atPos)
		if (periodPos == -1) {
			return false
		}
		if (periodPos+3 > email.length)	{
			return false
		}
		return true
}		

function isNum(passedVal) {					// E' un numero?
	if (passedVal == "") {
		return false
	}
	if (passedVal.length != 10) {			//Controlla se č di 9 o 10 cifre
		if (passedVal.length != 9) {
		return false
		}
	}

	for (i=0; i<passedVal.length; i++) {
		if (passedVal.charAt(i) < "0") {
			return false
		}
		if (passedVal.charAt(i) > "9") {
			return false
		}
	}
	return true
}





function validForm(Form) {
	
		if (Form.cognome.value == "") {
		alert("Inserire il cognome")
		Form.cognome.focus()
		Form.cognome.select()
		return false
	}
	
	if (Form.nome.value == "") {
		alert("Inserire il nome")
		Form.nome.focus()
		Form.nome.select()
		return false
	}
	
	if (Form.societa.value == "") {
		alert("Inserire la societā")
		Form.societa.focus()
		Form.societa.select()
		return false
	}	
	
	if (Form.settore.value == "Selezionare Settore Aziendale") {
		alert("Selezionare il settore")
		Form.settore.focus()
		return false
	}
	
	if (Form.ruolo.value == "Selezionare Ruolo Aziendale") {
		alert("Selezionare il ruolo")
		Form.ruolo.focus()
		return false
	}	
	
	if (Form.via.value == "") {
		alert("Inserire la via")
		Form.via.focus()
		Form.via.select()
		return false
	}
	
	if (Form.numciv.value == "") {
		alert("Inserire il numero civico")
		Form.numciv.focus()
		Form.numciv.select()
		return false
	}
	
	if (Form.cap.value == "") {
		alert("Inserire il CAP")
		Form.cap.focus()
		Form.cap.select()
		return false
	}
	
	if (Form.citta.value == "") {
		alert("Inserire la cittā")
		Form.citta.focus()
		Form.citta.select()
		return false
	}

	if (Form.prov.value == "") {
		alert("Inserire la provincia")
		Form.prov.focus()
		Form.prov.select()
		return false
	}

	if (Form.tel.value == "") {
		alert("Inserire il numero di telefono")
		Form.tel.focus()
		Form.tel.select()
		return false
	}



	if (Form.futuro[0].checked || Form.futuro[1].checked) {
			if (Form.futuro[0].checked) {
				if (Form.futurosiselect.value != "nada") 
					{}
					else
						{
						alert("Indicare un termine entro il quale la Sua azienda intende adottare un magazzino automatico")
						Form.futurosiselect.focus()
						return false
						}
				}
			}
		else
		{
		alert("Indicare se la Sua azienda intende adottare un magazzino automatico")
		return false
	}

	if (Form.futuro[0].checked || Form.futuro[1].checked) {
			if (Form.futuro[1].checked) {
				if (Form.tradizionali[0].checked || Form.tradizionali[1].checked) 
					{}
					else
						{
						alert("Indicare se la Sua azienda intende adottare un magazzino tradizionale in breve termine")
						return false
						}
				}
			}
		else
		{
		alert("Indicare se la Sua azienda intende adottare un magazzino automatico")
		return false
	}


	if (Form.conoscevate[0].checked || Form.conoscevate[1].checked)
		{}
		else
			{
			alert("Indicare se conoscevate JUNGHEINRICH come fornitore di magazzini automatici")
			return false
	}

	if (Form.dati.checked) 
		{}
  	  else
		{
		alert("E' necessario consentire il trattamento dei dati")
		Form.dati.focus()		
		return false
	}
		
	if (!validEmail(Form.mail.value)) {
		alert("Inserire una email valida")
		Form.mail.focus()
		Form.mail.select()
		return false
		}

	return true
}

	
	
	
//	if ( ( (Form.atti.value=="book") || (Form.atti.value=="cd") || (Form.atti.value=="cd_book") ) && ( (Form.fatt_cf.value=="") || (Form.fatt_iva.value=="") ) ) {
//		alert("Inserire Codice Fiscale e Partita IVA")
//		Form.fatt_cf.focus()
//		Form.fatt_cf.select()

//		return false
//	}

//	return true
//}


