//File di funzioni JS comuni

//Ottiene una stirnga da un canmpo form
function get_string(objText) {
	if (!objText || objText.value=="") {return "";}
	var str = new String(objText.value);
	//alert(objText.value);
	str = trim(str);
	//alert("str: "+str);
	return str;
}


//Trimma una stringa
function trim(stringa)
{
	while (stringa.substring(0,1) == ' ')
	{
		stringa = stringa.substring(1, stringa.length);
	}
	while (stringa.substring(stringa.length-1, stringa.length) == ' ')
	{
		stringa = stringa.substring(0,stringa.length-1);
	}
	return stringa;
}

//Controlla il formato di un indirizzo email
function parse_email(string) {
	//alert("aooo");
	if (string.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) != -1)
		return 1;
	else
		return 0;
}

//Colora una riga di una tabella al passaggio del mouse
function colora_riga(idriga, azione) {
	var colore = "";
	var riga = document.getElementById(idriga);
	
	switch (azione) {
		//case 1: colore = "#E9F3F9"; break;
		case 1: colore = "#FFEAF9"; break;
		case 0:	colore = "#FFFFFF";	break;
	}
	//alert("mo coloro....");
	if (riga) {
		//alert("ho colorato");
		riga.style.backgroundColor = colore;
	}
}

//Fuzione per la form di ricerca
function cerca(rand, qs) {

	var frm = document.getElementById("frmCerca");
	var txt = document.getElementById("txtCerca");
	var uri = "";
	
	//alert(txt);
	//alert(txt.value);
	
	if (txt.value == "") {
		uri = "?p=1";
	} else {
		var stxt = get_string(txt);
		uri = "?p=1&f="+stxt;
	}
	/*
	if (qs && qs != "") {
		uri += "&"+qs;
	}
	*/
	
	document.location.href = uri+rand;
	
}


//Submit della form su pagina faq.php, per creazione nuova faq
function controlla_form_faq() {
	
	var txt_domanda = document.getElementById("txt_domanda");
	var txt_inviata = document.getElementById("txt_inviata");
	var codice_controllo = document.getElementById("codice_controllo");
	var msg = "Conferma invio della domanda?";
	
	if (txt_domanda.value == "") {
		alert("Inserire nella casella di testo la domanda che si vuole inviare.");
		txt_domanda.focus();
		void(0);
		return false;
	}
	if (txt_inviata.value != "") {
		//Controllo la mail valida
		var semail = get_string(txt_inviata);
		var parsemail = parse_email(semail);
		if (parsemail == 0) {
			alert("Indirizzo e-mail non valido. Inserire una e-mail in formato corretto: nome@dominio.it");
			txt_inviata.value="";
			txt_inviata.focus();
			void(0);
			return false;
		}
	}
	if (codice_controllo.value == "") {
		alert("Scrivere nella casella \'codice di verifica\' il codice che si vede nell\'immagine.");
		codice_controllo.focus();
		void(0);
		return false;
	}
	
	return confirm(msg);
	
}


//Controllo form pagina contatti
function controlla_form_contatti() {
	
	var nome = document.getElementById("nome");
	var cognome = document.getElementById("cognome");
	var azienda = document.getElementById("azienda");
	var settore = document.getElementById("settore");
	var email = document.getElementById("email");
	var telefono = document.getElementById("telefono");
	var richiesta = document.getElementById("richiesta");
	var codice_controllo = document.getElementById("codice_controllo");
	var privacy = document.getElementById("privacy");
	var msg = "Confermi l\'invio dei dati?";
	
	var snome =get_string(nome);
	var scognome = get_string(cognome);
	var sazienda = get_string(azienda);
	var ssettore = get_string(settore);
	var semail = get_string(email);
	var stelefono = get_string(telefono);
	var srichiesta = get_string(richiesta);
	var scodice_controllo = get_string(codice_controllo);
	
	if (snome == "") {
		alert("Inserisci il tuo nome nella casella.");
		nome.focus();
		return false;
	}
	if (scognome == "") {
		alert("Inserisci il tuo cognome nella casella.");
		cognome.focus();
		return false;
	}
	if (sazienda == "") {
		alert("Inserisci il nome della tua azienda.");
		azienda.focus();
		return false;
	}
	if (ssettore == "") {
		alert("Inserisci un settore per la tua azienda, ad esempio 'Commercio'.");
		settore.focus();
		return false;
	}
	if (semail == "") {
		alert("Inserisci il tuo indirizzo e-mail nella casella.");
		email.focus();
		return false;
	}
	if (parse_email(semail) == 0) {
		alert("Indirizzo e-mail non valido. Inserisci un indirizzo del tipo 'nome@dominio.it'.");
		email.value = "";
		email.focus();
		return false;
	}
	if (stelefono == "") {
		alert("Inserisci un numero di telefono nella casella.");
		telefono.focus();
		return false;
	}
	if (srichiesta == "") {
		alert("Non hai inserito alcuna richiesta. Per inviare i dati devi inserire una richiesta.");
		richiesta.focus();
		return false;
	}
	if (scodice_controllo == "") {
		alert("ATTENZIONE: Devi inserire il codice di verifica.");
		codice_controllo.focus();
		return false;
	}
	if (privacy.value == "0") {
		alert("ATTENZIONE: Per inviare i dati devi autorizzare il trattamento dei dati personali.");
		return false;
	}
	return confirm(msg);

}


//Form di iscrizione ai corsi
function controlla_form_corso() {
	
	var nome = document.getElementById("nome");
	var cognome = document.getElementById("cognome");
	//var azienda = document.getElementById("azienda");
	//var partitaiva = document.getElementById("partitaiva");
	var indirizzo = document.getElementById("indirizzo");
	//var cap = document.getElementById("cap");
	var citta = document.getElementById("citta");
	//var provincia = document.getElementById("provincia");
	var email = document.getElementById("email");
	var telefono = document.getElementById("telefono");
	//var fax = document.getElementById("fax");
	var codice_controllo = document.getElementById("codice_controllo");
	var privacy = document.getElementById("privacy");
	/*
	var nome2 = document.getElementById("nome2");
	var cognome2 = document.getElementById("cognome2");
	var azienda2 = document.getElementById("azienda2");
	var partitaiva2 = document.getElementById("partitaiva2");
	var indirizzo2 = document.getElementById("indirizzo2");
	var cap2 = document.getElementById("cap2");
	var citta2 = document.getElementById("citta2");
	var provincia2 = document.getElementById("provincia2");
	var msg = "Confermi l\'invio dei dati?";
	*/
	
	var msg = "Confermi l\'invio dei dati per la tua iscrizione al corso di formazione?";
	
	
	var snome = get_string(nome);
	var scognome = get_string(cognome);
	//var sazienda = get_string(azienda);
	//var spartitaiva = get_string(partitaiva);
	var sindirizzo = get_string(indirizzo);
	var scitta = get_string(citta);
	//var scap = get_string(cap);
	//var sprovincia = get_string(provincia);
	var semail = get_string(email);
	var stelefono = get_string(telefono);
	//var sfax = get_string(fax);
	var scodice_controllo = get_string(codice_controllo);
	
	if (snome == "") {
		alert("Inserisci il tuo nome nella casella.");
		nome.focus();
		return false;
	}
	if (scognome == "") {
		alert("Inserisci il tuo cognome nella casella.");
		cognome.focus();
		return false;
	}
	if (sindirizzo == "") {
		alert("Inserisci il tuo indirizzo nella casella.");
		indirizzo.focus();
		return false;
	}
	if (scitta == "") {
		alert("Inserisci la tua citta\' nella casella.");
		citta.focus();
		return false;
	}
	if (stelefono == "") {
		alert("Inserisci un numero di telefono nella casella.");
		telefono.focus();
		return false;
	}
	if (semail == "") {
		alert("Inserisci il tuo indirizzo e-mail nella casella.");
		email.focus();
		return false;
	}
	if (parse_email(semail) == 0) {
		alert("Indirizzo e-mail non valido. Inserisci un indirizzo del tipo 'nome@dominio.it'.");
		email.value = "";
		email.focus();
		return false;
	}
	if (scodice_controllo == "") {
		alert("ATTENZIONE: Devi inserire il codice di verifica.");
		codice_controllo.focus();
		return false;
	}
	if (privacy.value == "0") {
		alert("ATTENZIONE: Per inviare i dati devi autorizzare il trattamento dei dati personali.");
		return false;
	}
	return confirm(msg);

}


//Form di invio contributi attivita'
function controlla_form_contributi() {
	
	var nome = document.getElementById("nome");
	var cognome = document.getElementById("cognome");
	var indirizzo = document.getElementById("indirizzo");
	var cap = document.getElementById("cap");
	var citta = document.getElementById("citta");
	var provincia = document.getElementById("provincia");
	var email = document.getElementById("email");
	var telefono = document.getElementById("telefono");
	//var fax = document.getElementById("fax");
	var codice_controllo = document.getElementById("codice_controllo");
	var privacy = document.getElementById("privacy");
	
	var msg = "Confermi l\'invio dei contributi scientifici per questa attivita\'?";
	
	var snome = get_string(nome);
	var scognome = get_string(cognome);
	var sindirizzo = get_string(indirizzo);
	var scitta = get_string(citta);
	var scap = get_string(cap);
	var sprovincia = get_string(provincia);
	var semail = get_string(email);
	var stelefono = get_string(telefono);
	//var sfax = get_string(fax);
	var scodice_controllo = get_string(codice_controllo);
	
	if (snome == "") {
		alert("Inserisci il tuo nome nella casella.");
		nome.focus();
		return false;
	}
	if (scognome == "") {
		alert("Inserisci il tuo cognome nella casella.");
		cognome.focus();
		return false;
	}
	if (semail == "") {
		alert("Inserisci il tuo indirizzo e-mail nella casella.");
		email.focus();
		return false;
	}
	if (parse_email(semail) == 0) {
		alert("Indirizzo e-mail non valido. Inserisci un indirizzo del tipo 'nome@dominio.it'.");
		email.value = "";
		email.focus();
		return false;
	}
	if (sindirizzo == "") {
		alert("Inserisci il tuo indirizzo nella casella.");
		indirizzo.focus();
		return false;
	}
	if (scitta == "") {
		alert("Inserisci la tua citta\' nella casella.");
		citta.focus();
		return false;
	}
	if (scap =="") {
		alert("Inserisci il codice avviamento postale (CAP).");
		cap.focus();
		return false;
	}
	if (sprovincia =="") {
		alert("Inserisci la tua provincia.");
		provincia.focus();
		return false;
	}
	if (stelefono == "") {
		alert("Inserisci un numero di telefono nella casella.");
		telefono.focus();
		return false;
	}
	if (scodice_controllo == "") {
		alert("ATTENZIONE: Devi inserire il codice di verifica.");
		codice_controllo.focus();
		return false;
	}
	if (privacy.value == "0") {
		alert("ATTENZIONE: Per inviare i dati devi autorizzare il trattamento dei dati personali.");
		return false;
	}
	
	return confirm(msg);

}

//Form di invio pagamento quota associativa
function controlla_form_pagamento_quota(step) {
	
	var nome = document.getElementById("nome");
	var cognome = document.getElementById("cognome");
	var email = document.getElementById("email");
	var tessera = document.getElementById("tessera");
	
	var msg = "Confermi l\'invio per la richiesta di pagamento della quota associativa?";
	
	var snome = get_string(nome);
	var scognome = get_string(cognome);
	var semail = get_string(email);
	var stessera = get_string(tessera);
	
	if (step == 0) {
		if (snome == "") {
			alert("Inserisci il tuo nome nella casella.");
			nome.focus();
			return false;
		}
		if (scognome == "") {
			alert("Inserisci il tuo cognome nella casella.");
			cognome.focus();
			return false;
		}
		if (semail == "") {
			alert("Inserisci il tuo indirizzo e-mail nella casella.");
			email.focus();
			return false;
		}
		if (parse_email(semail) == 0) {
			alert("Indirizzo e-mail non valido. Inserisci un indirizzo del tipo 'nome@dominio.it'.");
			email.value = "";
			email.focus();
			return false;
		}
		if (semail == "") {
			alert("Inserisci il tuo indirizzo e-mail nella casella.");
			email.focus();
			return false;
		}
		if (stessera == "") {
			alert("Inserisci il tuo numero di tessera socio AIDII");
			tessera.focus();
			return false;
		}
		return true;
	} else {
		
		return confirm(msg);
		
	}

	

}


//Controllo form pagina pagamenti fattura
function controlla_form_pagamenti(step) {
	
	var fattura = document.getElementById("fattura");
	var email = document.getElementById("email");
	var importo = document.getElementById("importo");
	var msg = "Confermi il pagamento della fattura che stai inserendo?";
	
	var sfattura = get_string(fattura);
	var semail = get_string(email);
	var simporto = get_string(importo);
	
	if (step == 0) {
		var msg = "Confermi il pagamento della fattura che stai inserendo?";
	} else {
		var msg = "I dati sono corretti? Procedo con il pagamento?";
	}
	
	if (step == 0) {
		
		if (sfattura == "") {
			alert("Inserisci il numero fattura da pagare nella casella.");
			fattura.focus();
			return false;
		}
		if (semail == "") {
			alert("Inserisci il tuo indirizzo e-mail nella casella.");
			email.focus();
			return false;
		}
		if (parse_email(semail) == 0) {
			alert("Indirizzo e-mail non valido. Inserisci un indirizzo del tipo 'nome@dominio.it'.");
			email.value = "";
			email.focus();
			return false;
		}
		if (simporto == "") {
			alert("Inserire nella casella apposita l\'importo da pagare per la fattura.");
			importo.focus();
			return false;
		}
		if (parseInt(importo.value) <= 0) {
			alert("ATTENZIONE: Il valore importo inserito deve essere maggiore di 0 (zero).");
			importo.value = "";
			importo.focus();
			return false;
		}
		return true;
	} else {
		return confirm(msg);
	}
	
	

}




//Controllo form iscrizione socio
function controlla_form_iscrizione() {
	
	var nome = document.getElementById("nome");
	var cognome = document.getElementById("cognome");
	var indirizzo = document.getElementById("indirizzo");
	var cap = document.getElementById("cap");
	var citta = document.getElementById("citta");
	var provincia = document.getElementById("provincia");
	var email = document.getElementById("email");
	var telefono = document.getElementById("telefono");
	var codice_controllo = document.getElementById("codice_controllo");
	var privacy = document.getElementById("privacy");
	var msg = "Confermi l\'invio dei dati?";
	
	var snome =get_string(nome);
	var scognome = get_string(cognome);
	var sindirizzo = get_string(indirizzo);
	var scap = get_string(cap);
	var scitta = get_string(citta);
	var sprovincia = get_string(provincia);
	var semail = get_string(email);
	var stelefono = get_string(telefono);
	var scodice_controllo = get_string(codice_controllo);
	
	if (snome == "") {
		alert("Inserisci il tuo nome nella casella.");
		nome.focus();
		return false;
	}
	if (scognome == "") {
		alert("Inserisci il tuo cognome nella casella.");
		cognome.focus();
		return false;
	}
	if (sindirizzo == "") {
		alert("Inserisci il tuo indirizzo nella casella.");
		indirizzo.focus();
		return false;
	}
	if (scap =="") {
		alert("Inserisci il codice avviamento postale (CAP).");
		cap.focus();
		return false;
	}
	if (scitta == "") {
		alert("Inserisci la tua citta\' nella casella.");
		citta.focus();
		return false;
	}
	if (sprovincia =="") {
		alert("Inserisci la tua provincia.");
		provincia.focus();
		return false;
	}
	if (stelefono == "") {
		alert("Inserisci un numero di telefono nella casella.");
		telefono.focus();
		return false;
	}
	if (semail == "") {
		alert("Inserisci il tuo indirizzo e-mail nella casella.");
		email.focus();
		return false;
	}
	if (parse_email(semail) == 0) {
		alert("Indirizzo e-mail non valido. Inserisci un indirizzo del tipo 'nome@dominio.it'.");
		email.value = "";
		email.focus();
		return false;
	}
	if (scodice_controllo == "") {
		alert("ATTENZIONE: Devi inserire il codice di verifica.");
		codice_controllo.focus();
		return false;
	}
	if (privacy.value == "0") {
		alert("ATTENZIONE: Per inviare i dati devi autorizzare il trattamento dei dati personali.");
		return false;
	}
	return confirm(msg);

}


//Controllo form iscrizione socio
function controlla_form_iscrizione_giuridica() {
	
	var ragionesociale = document.getElementById("ragionesociale");
	var riferimento = document.getElementById("riferimento");
	var indirizzo_2 = document.getElementById("indirizzo_2");
	var cap_2 = document.getElementById("cap_2");
	var citta_2 = document.getElementById("citta_2");
	var provincia_2 = document.getElementById("provincia_2");
	var email_2 = document.getElementById("email_2");
	var telefono_2 = document.getElementById("telefono_2");
	var codice_controllo2 = document.getElementById("codice_controllo2");
	var privacy = document.getElementById("privacy_2");
	
	var msg = "Confermi l\'invio dei dati per iscrizione attivita\'?";
	
	var sragionesociale = get_string(ragionesociale);
	var sriferimento = get_string(riferimento);
	var sindirizzo_2 = get_string(indirizzo_2);
	var scap_2 = get_string(cap_2);
	var scitta_2 = get_string(citta_2);
	var sprovincia_2 = get_string(provincia_2);
	var semail_2 = get_string(email_2);
	var stelefono_2 = get_string(telefono_2);
	var scodice_controllo2 = get_string(codice_controllo2);
	
	if (sragionesociale == "") {
		alert("Inserisci il tuo ragionesociale nella casella.");
		ragionesociale.focus();
		return false;
	}
	
	if (sriferimento == "") {
		alert("Inserisci il tuo riferimento nella casella.");
		riferimento.focus();
		return false;
	}
	
	if (sindirizzo_2 == "") {
		alert("Inserisci il tuo indirizzo nella casella.");
		indirizzo_2.focus();
		return false;
	}
	if (scap_2 =="") {
		alert("Inserisci il codice avviamento postale (CAP).");
		cap_2.focus();
		return false;
	}
	if (scitta_2 == "") {
		alert("Inserisci la tua citta\' nella casella.");
		citta_2.focus();
		return false;
	}
	if (sprovincia_2 =="") {
		alert("Inserisci la tua provincia.");
		provincia_2.focus();
		return false;
	}
	if (stelefono_2 == "") {
		alert("Inserisci un numero di telefono nella casella.");
		telefono_2.focus();
		return false;
	}
	if (semail_2 == "") {
		alert("Inserisci il tuo indirizzo e-mail nella casella.");
		email_2.focus();
		return false;
	}
	if (parse_email(semail_2) == 0) {
		alert("Indirizzo e-mail non valido. Inserisci un indirizzo del tipo 'nome@dominio.it'.");
		email_2.value = "";
		email_2.focus();
		return false;
	}
	if (scodice_controllo2 == "") {
		alert("ATTENZIONE: Devi inserire il codice di verifica.");
		codice_controllo2.focus();
		return false;
	}
	if ( document.formattivita.privacy[1].checked ) {
		alert("ATTENZIONE: Per inviare i dati devi autorizzare il trattamento dei dati personali.");
		return false;
	}
	return confirm(msg);

}



//Controllo form iscrizione attivita formazione
function controlla_form_attivita() {
	
	var nome = document.getElementById("nome");
	var cognome = document.getElementById("cognome");
	var indirizzo = document.getElementById("indirizzo");
	var cap = document.getElementById("cap");
	var citta = document.getElementById("citta");
	var provincia = document.getElementById("provincia");
	var email = document.getElementById("email");
	var telefono = document.getElementById("telefono");
	var codice_controllo = document.getElementById("codice_controllo");
	var privacy = document.getElementById("privacy");
	var msg = "Confermi il pagamento dei prodotti nel carrello?";
	
	var snome = get_string(nome);
	var scognome = get_string(cognome);
	var sindirizzo = get_string(indirizzo);
	var scap = get_string(cap);
	var scitta = get_string(citta);
	var sprovincia = get_string(provincia);
	var semail = get_string(email);
	var stelefono = get_string(telefono);
	var scodice_controllo = get_string(codice_controllo);
	
	if (snome == "") {
		alert("Inserisci il tuo nome nella casella.");
		nome.focus();
		return false;
	}
	if (scognome == "") {
		alert("Inserisci il tuo cognome nella casella.");
		cognome.focus();
		return false;
	}
	if (sindirizzo == "") {
		alert("Inserisci il tuo indirizzo nella casella.");
		indirizzo.focus();
		return false;
	}
	if (scap =="") {
		alert("Inserisci il codice avviamento postale (CAP).");
		cap.focus();
		return false;
	}
	if (scitta == "") {
		alert("Inserisci la tua citta\' nella casella.");
		citta.focus();
		return false;
	}
	if (sprovincia =="") {
		alert("Inserisci la tua provincia.");
		provincia.focus();
		return false;
	}
	if (stelefono == "") {
		alert("Inserisci un numero di telefono nella casella.");
		telefono.focus();
		return false;
	}
	if (semail == "") {
		alert("Inserisci il tuo indirizzo e-mail nella casella.");
		email.focus();
		return false;
	}
	if (parse_email(semail) == 0) {
		alert("Indirizzo e-mail non valido. Inserisci un indirizzo del tipo 'nome@dominio.it'.");
		email.value = "";
		email.focus();
		return false;
	}
	if (scodice_controllo == "") {
		alert("ATTENZIONE: Devi inserire il codice di verifica.");
		codice_controllo.focus();
		return false;
	}
	if ( document.formattivita.privacy[1].checked ) {
		alert("ATTENZIONE: Per inviare i dati devi autorizzare il trattamento dei dati personali.");
		return false;
	}
	return confirm(msg);

}


//Controllo form iscrizione attivita formazione
function controlla_form_acquista() {
	
	var nome = document.getElementById("nome");
	var cognome = document.getElementById("cognome");
	var indirizzo = document.getElementById("indirizzo");
	var cap = document.getElementById("cap");
	var citta = document.getElementById("citta");
	var provincia = document.getElementById("provincia");
	var email = document.getElementById("email");
	var telefono = document.getElementById("telefono");
	var codice_controllo = document.getElementById("codice_controllo");
	var privacy = document.getElementById("privacy");
	var msg = "Confermi il pagamento dei prodotti nel carrello?";
	
	var snome = get_string(nome);
	var scognome = get_string(cognome);
	var sindirizzo = get_string(indirizzo);
	var scap = get_string(cap);
	var scitta = get_string(citta);
	var sprovincia = get_string(provincia);
	var semail = get_string(email);
	var stelefono = get_string(telefono);
	var scodice_controllo = get_string(codice_controllo);
	
	if (snome == "") {
		alert("Inserisci il tuo nome nella casella.");
		nome.focus();
		return false;
	}
	if (scognome == "") {
		alert("Inserisci il tuo cognome nella casella.");
		cognome.focus();
		return false;
	}
	if (semail == "") {
		alert("Inserisci il tuo indirizzo e-mail nella casella.");
		email.focus();
		return false;
	}
	if (parse_email(semail) == 0) {
		alert("Indirizzo e-mail non valido. Inserisci un indirizzo del tipo 'nome@dominio.it'.");
		email.value = "";
		email.focus();
		return false;
	}
	if (sindirizzo == "") {
		alert("Inserisci il tuo indirizzo nella casella.");
		indirizzo.focus();
		return false;
	}
	if (scap =="") {
		alert("Inserisci il codice avviamento postale (CAP).");
		cap.focus();
		return false;
	}
	if (isNaN(cap.value)==true) {
		alert("Il CAP inserito non sembra corretto. Inserisci un CAP numero, ad esempio 60100.");
		cap.value = "";
		cap.focus();
		return false;
	}
	
	if (scitta == "") {
		alert("Inserisci la tua citta\' nella casella.");
		citta.focus();
		return false;
	}
	if (sprovincia =="") {
		alert("Inserisci la tua provincia.");
		provincia.focus();
		return false;
	}
	if (stelefono == "") {
		alert("Inserisci un numero di telefono nella casella.");
		telefono.focus();
		return false;
	}
	if (scodice_controllo == "") {
		alert("ATTENZIONE: Devi inserire il codice di verifica.");
		codice_controllo.focus();
		return false;
	}
	if (document.acquista.privacy[1].checked) {
		alert("ATTENZIONE: Per proseguire devi autorizzare il trattamento dei dati personali.");
		return false;
	}

	return true;

}

//Controllo form iscrizione newsletter
function controlla_form_newsletter() {
	
	var nome = document.getElementById("nome");
	var cognome = document.getElementById("cognome");
	var email = document.getElementById("email");
	var codice_socio = document.getElementById("codice_socio");
	var codice_controllo = document.getElementById("codice_controllo");
	var iscriviti = document.getElementById("iscriviti");
	var privacy = document.getElementById("privacy");
	var msg = "Confermi il pagamento dei prodotti nel carrello?";
	
	var snome = get_string(nome);
	var scognome = get_string(cognome);
	var semail = get_string(email);
	var scodice_socio = get_string(codice_socio);
	var scodice_controllo = get_string(codice_controllo);
	
	
	if (snome == "") {
		alert("Inserisci il tuo nome nella casella.");
		nome.focus();
		return false;
	}
	if (scognome == "") {
		alert("Inserisci il tuo cognome nella casella.");
		cognome.focus();
		return false;
	}
	if (semail == "") {
		alert("Inserisci il tuo indirizzo e-mail nella casella.");
		email.focus();
		return false;
	}
	if (parse_email(semail) == 0) {
		alert("Indirizzo e-mail non valido. Inserisci un indirizzo del tipo 'nome@dominio.it'.");
		email.value = "";
		email.focus();
		return false;
	}
	if (scodice_socio != "") {
		if (isNaN(scodice_socio) ) {
			alert("Il codice socio deve essere numerico. Inserisci un codice socio valido.");
			codice_socio.focus();
			return false;
		}
	}
	if (scodice_controllo == "") {
		alert("ATTENZIONE: Devi inserire il codice di verifica.");
		codice_controllo.focus();
		return false;
	}
	if (document.formnewsletter.privacy[1].checked) {
		alert("ATTENZIONE: Per proseguire devi autorizzare il trattamento dei dati personali.");
		return false;
	}

	return true;

}





//Form di login dal sito
function controlla_form_login() {
	var txt_username = document.getElementById("txt_username");
	var txt_password = document.getElementById("txt_password");
	
	var suser = get_string(txt_username);
	var spass = get_string(txt_password);
	
	if (suser == "") {
		alert("Inserire il proprio username (ragione sociale o cognome) nella casella.");
		txt_username.focus();
		return false;
	}
	if (spass == "") {
		alert("Inserire la propria password (numero tessera) nella casella.");
		txt_password.focus();
		return false;
	}
	
	return true;
	
}


//Clic su logout sito
function logout(key) {
	
	var msg = "Disconnettersi dalla sessione di lavoro ed uscire?";
	
	if (confirm(msg)==true) {
		location.href = "logout.php?logout="+key;
	}
	
}



