// JavaScript Document
function controlla() {
	stato 		=	document.getElementById('nazione');
	tiranteria 	=	document.getElementById('Tiranteria Sterzo');
	dischi 		=	document.getElementById('Dischi Freno');
	candelette	=	document.getElementById('Candelette Incandescenza');
	sterzoM		=	document.getElementById('Scatole Sterzo Meccaniche');
	sterzoI		=	document.getElementById('Scatole Sterzo Idrauliche');
	
	acquisti = (tiranteria.checked || dischi.checked || candelette.checked || sterzoM.checked || sterzoI.checked);
	if (stato.value.length>0 && acquisti) {
		document.questionario.submit();
		window.close();
	} else {
		alert('Compila i campi obbligatori');
	}
}

//=========================================
function controllaMail() {
  	mail= document.iscrizioneMailingList.mail.value;
	email1 = mail.lastIndexOf('@');
	if (email1>=2) {
		m1 = true;
	} else {
		m1 = false;
	}
	email2 = mail.lastIndexOf('.');
	if ((email2-email1)>=2) {
		m2 = true;
	} else {
		m2 = false;
	}
	email3 = mail.substr(email2, mail.length);
	if (email3.length>=3) {
		m3 = true;
	} else {
		m3 = false;
	}

	//---invio del modulo------\\
	if(m1 & m2 & m3 ) {
		document.iscrizioneMailingList.submit();
	}else{
		lingua = document.iscrizioneMailingList.lingua.value;
		if (lingua == 'it') {
			alert('Inserisci una mail corretta');
		} else {
			alert('Insert correct email');
		}
	}
}

//=========================================
function controllaInfo() {
  	societa= document.info.Società.value;
  	nazione= document.info.Stato.value;
  	telefono= document.info.Telefono.value;
  	fax= document.info.Fax.value;
  	mail= document.info.Email.value;
  	persona= document.info.Persona_da_contattare.value;

    email1 = mail.lastIndexOf('@');
	if (email1>=2) {
		m1 = true;
	} else {
		m1 = false;
	}
	email2 = mail.lastIndexOf('.');
	if ((email2-email1)>=2) {
		m2 = true;
	} else {
		m2 = false;
	}
	email3 = mail.substr(email2, mail.length);
	if (email3.length>=3) {
		m3 = true;
	} else {
		m3 = false;
	}
	
	if(nazione.length < 0) {
		m4 = false; 
	} else {
	 	m4 = true;
	}
	
	if(societa.length < 0) {
		m5 = false;
	} else {
	 	m5 = true;
	}

	if(telefono.length < 5) {
		m6 = false;
	} else {
	 	m6 = true;
	}

	if(fax.length < 5) {
		m7 = false;
	} else {
	 	m7 = true;
	}
    
	if(persona.length < 0) {
		m8 = false;
	} else {
	 	m8 = true;
	}
	
	if (m1 && m2 && m3 && m4 && m5 && m6 && m7 && m8) {
		document.info.submit();
	} else {
		alert('Compila i campi obbligatori');
	}
}
