function inviapass(){
	var risp_utente = document.recupera.risp_utente.value;
	var risp_data = document.recupera.risp_data.value;

	if ((risp_utente == "") || (risp_utente == "undefined")) {
           alert("Inserire la risposta per recuperare la password");
           document.recupera.risp_utente.focus();
        }
	else if(risp_utente!=risp_data){
		alert("La risposta che hai inserito non è corretta");
		document.recupera.risp_utente.focus();
		}
	else {
			document.recupera.action = "invia_pass.php";
           	document.recupera.submit();
        }
}
function smarrita(){
	var nome = document.login.nome.value;
		
	if ((nome == "") || (nome == "undefined")) {
           alert("Inserire e-mail per recuperare la password");
           document.login.nome.focus();
        }
	else {
			document.login.action = "cerca_email.php";
           	document.login.submit();
        }
	
}

function smarrita2(){
	var nome = document.fast_login.nome.value;
		
	if ((nome == "") || (nome == "undefined") || (nome == "Email")) {
           alert("Inserire e-mail per recuperare la password");
           document.fast_login.nome.focus();
        }
	else {
			document.fast_login.action = "cerca_email.php";
           	document.fast_login.submit();
        }
	
}

function modello(){
	var email = document.newmodel.email.value;
	var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	if (!email_reg_exp.test(email) || (email == "") || (email == "undefined")) {
           alert("Inserire un indirizzo email corretto!");
           document.newmodel.email.select();
    }
	else{
	document.newmodel.action = "invia_modello.php";
	document.newmodel.submit();
	}
}
function dettaglio_back(num){
	document.getElementById(num).style.visibility="hidden";
	document.getElementById("tableacc").style.visibility="visible";
}
function dettaglio(num){
	document.getElementById(num).style.visibility="visible";
	document.getElementById("tableacc").style.visibility="hidden";
}
function invia_feed(){
	document.feed.action = "invia_feed.php";
	document.feed.submit();
}
function invia_mail(){
	document.mail.action = "invia_mail.php";
	document.mail.submit();
}
function vendiamo(){
	if (document.condizioni.accetto.checked==false){
		alert("Devi accettare le condizioni contrattuali");
		return;
	}
	else if (document.vendita.scelta.value==""){
		alert("Devi scegliere una modalità di pagamento");
		return;
	}
	else if (loggato == 2){
		alert("Per completare la vendita devi essere un utente registrato e/o effettuare il login");
		window.location = "login.php";
	}
	else {
		document.vendita.action = "vendere.php";
		document.vendita.submit();
	}
}
function cancella(){
	if (document.elimina.selezionati.value=="false")
		alert("Selezionare almeno un elemento dal carrello");
	else if(confirm("Eliminare gli elementi selezionati")){
	document.elimina.action = "cancella.php";
	document.elimina.submit();
	}
}
function seleziona_elemento(){
	if (document.elimina.selezionati.value=="true")
		document.elimina.selezionati.value="false";
	else
		document.elimina.selezionati.value="true";
}
function cart(){
	if(sess==1)
		window.location = "carrello.php";
	else
		alert("Il tuo Carrello è vuoto");
}
function svuota(){
	if(confirm("Sei sicuro di voler svuotare il carrello?"))
	window.location = "svuota.php";
}
function scelta(tipo){
		if (tipo==1){
		document.getElementById("prezzo").innerHTML = document.vendita.contanti.value;
		document.vendita.scelta.value = "contanti";
		document.getElementById("imgcont").setAttribute("src","images/TASTO-a-cerchio-conferma-ok.png");
		document.getElementById("imgtot").setAttribute("src","images/TASTO-a-cerchio-conferma-ok.png");
		document.getElementById("imgvouch").setAttribute("src","images/TASTO-a-cerchio-conferma-ok-(spento).png");
		document.getElementById("font2").setAttribute("color","#666666");
		document.getElementById("font1").setAttribute("color","#000000");
		}
		else{
		document.getElementById("prezzo").innerHTML = document.vendita.voucher.value;
		document.getElementById("imgvouch").setAttribute("src","images/TASTO-a-cerchio-conferma-ok.png");
		document.getElementById("imgtot").setAttribute("src","images/TASTO-a-cerchio-conferma-ok.png");
		document.getElementById("imgcont").setAttribute("src","images/TASTO-a-cerchio-conferma-ok-(spento).png");
		document.getElementById("font1").setAttribute("color","#666666");
		document.getElementById("font2").setAttribute("color","#000000");
		document.vendita.scelta.value = "voucher";
		}
}
function aggiungi(){
	var imei = document.getElementById("imei").value;
	if ((isNaN(imei)) || (imei == "") || (imei == "undefined") || (imei.length < 15)){
		alert("IMEI deve essere un codice numerico di 15 cifre");
		document.getElementById("imei").value="";
		document.getElementById("imei").focus();
	}
	else {
	document.recupero.imeidef.value = imei;
	document.recupero.funziona.value = document.getElementById("funzionante").value;
	document.recupero.risposte.value = document.quota.acquisto.value + "|" + document.quota.condizione.value + "|" + document.quota.marcato.value + "|";
	if (document.quota.batteria.checked==true)
		document.recupero.risposte.value += "1|";
	else
		document.recupero.risposte.value += "0|";
		
	if (document.quota.caricabatt.checked==true)
		document.recupero.risposte.value += "1|";
	else
		document.recupero.risposte.value += "0|";
	
	if (document.quota.scontrino.checked==true)
		document.recupero.risposte.value += "1|";
	else
		document.recupero.risposte.value += "0|";
	
	if (document.quota.imballo.checked==true)
		document.recupero.risposte.value += "1|";
	else
		document.recupero.risposte.value += "0|";
	
	if (document.quota.garanzia.checked==true)
		document.recupero.risposte.value += "1|";
	else
		document.recupero.risposte.value += "0|";
	
	if (document.quota.assistenza.checked==true)
		document.recupero.risposte.value += "1|";
	else
		document.recupero.risposte.value += "0|";
	
	if (document.quota.manuale.checked==true)
		document.recupero.risposte.value += "1|";
	else
		document.recupero.risposte.value += "0|";
	
	if (document.quota.memory.checked==true)
		document.recupero.risposte.value += "1|";
	else
		document.recupero.risposte.value += "0|";
	
	if (document.quota.auricolare.checked==true)
		document.recupero.risposte.value += "1|";
	else
		document.recupero.risposte.value += "0|";
	
	if (document.quota.cavo.checked==true)
		document.recupero.risposte.value += "1|";
	else
		document.recupero.risposte.value += "0|";
	
	if (document.quota.cd.checked==true)
		document.recupero.risposte.value += "1|";
	else
		document.recupero.risposte.value += "0|";
		
	document.recupero.action = "aggiungi.php";
	document.recupero.submit();
	}
}
function imei(){
	document.getElementById("textf1").style.visibility="hidden";
	document.getElementById("textf2").style.visibility="hidden";
	document.getElementById("textp").style.visibility="hidden";
	document.getElementById("clicca").style.visibility="hidden";
	document.getElementById("textg3").style.visibility="hidden";
	document.getElementById("textg1").style.visibility="hidden";
	document.getElementById("textg2").style.visibility="hidden";
	document.getElementById("tasti1").style.visibility="hidden";
	document.getElementById("textIMEI").style.visibility="visible";
	document.getElementById("textIMEI2").style.visibility="visible";
	document.getElementById("textIMEI3").style.visibility="visible";
	document.getElementById("roundrectIMEI").style.visibility="visible";
	document.getElementById("textIMEI4").style.visibility="visible";
	document.getElementById("tasti3").style.visibility="visible";
	document.getElementById("funzionante").disabled=true;
	document.getElementById("imei").focus();
	
}
function indietro2(){
	document.getElementById("textf1").style.visibility="visible";
	document.getElementById("textf2").style.visibility="visible";
	document.getElementById("textp").style.visibility="visible";
	document.getElementById("clicca").style.visibility="visible";
	document.getElementById("tasti1").style.visibility="visible";
	document.getElementById("textIMEI").style.visibility="hidden";
	document.getElementById("textIMEI2").style.visibility="hidden";
	document.getElementById("textIMEI3").style.visibility="hidden";
	document.getElementById("roundrectIMEI").style.visibility="hidden";
	document.getElementById("textIMEI4").style.visibility="hidden";
	document.getElementById("tasti3").style.visibility="hidden";
	if(document.recupero.contanti.value==contanti){
	document.getElementById("funzionante").disabled=false;
	}
}

function resetta(){
	document.quota.reset();
	document.getElementById("spanc").innerHTML = contanti;
	calcola_voucher(contanti);
	document.getElementById("funzionante").disabled=false;
	indietro();
}
function calcola_voucher(prezzo){
var voucher=0;
	if(contanti<100){
	 voucher = prezzo+Math.round(((prezzo*20)/100));
	}
	else if (contanti<200){
		voucher= prezzo+Math.round(((prezzo*15)/100));
	}
	else{
		voucher = prezzo+Math.round(((prezzo*10)/100));
	}
	document.recupero.voucher.value = voucher;
	document.getElementById("spanv").innerHTML = voucher;
}
function calcola(){
	nuovo = contanti;
	switch (document.quota.acquisto.value){
		case "1":
			nuovo = nuovo+Math.round(((nuovo*5)/100));
			break;
		case "2":
			nuovo = nuovo+Math.round(((nuovo*3)/100));
			break;
		case "3":
			nuovo = nuovo+Math.round(nuovo/100);
			break;
	}
	switch (document.quota.condizione.value){
		case "1":
			nuovo = nuovo+Math.round(((nuovo*10)/100));
			break;
		case "3":
			nuovo = nuovo-Math.round(((nuovo*15)/100));
			break;
	}
	if (document.quota.marcato.value == "4"){
	alert("I prodotti marcati TRE non saranno accettati");
	}
	
	if (document.quota.batteria.checked==false){
		nuovo = nuovo-Math.round(((nuovo*5)/100));
	}
	if (document.quota.caricabatt.checked==false){
		nuovo = nuovo-Math.round(((nuovo*5)/100));
	}
	
	if (document.quota.scontrino.checked==true){
		nuovo = nuovo+Math.round(((nuovo*2)/100));
	}
	
	if (document.quota.imballo.checked==true){
		nuovo = nuovo+Math.round(((nuovo*2)/100));
	}
	
	if (document.quota.garanzia.checked==true){
		nuovo = nuovo+Math.round(((nuovo*4)/100));
	}
	
	if (document.quota.assistenza.checked==true){
		nuovo = nuovo-Math.round(((nuovo*5)/100));
	}
	
	if (document.quota.manuale.checked==true){
		nuovo = nuovo+Math.round(((nuovo*2)/100));
	}
	
	if (document.quota.memory.checked==true){
		nuovo = nuovo+Math.round(((nuovo*2)/100));
	}
	
	if (document.quota.auricolare.checked==true){
		nuovo = nuovo+Math.round(nuovo/100);
	}
	
	if (document.quota.cavo.checked==true){
		nuovo = nuovo+Math.round(nuovo/100);
	}
	
	if (document.quota.cd.checked==true){
		nuovo = nuovo+Math.round(nuovo/100);
	}
	document.recupero.contanti.value = nuovo;
	document.getElementById("spanc").innerHTML = nuovo;	
	calcola_voucher(nuovo);
	indietro();
}
function perfeziona(){
	document.getElementById("textf1").style.visibility="hidden";
	document.getElementById("tasti1").style.visibility="hidden";
	document.getElementById("textf2").style.visibility="hidden";
	document.getElementById("textp").style.visibility="hidden";
	document.getElementById("clicca").style.visibility="hidden";
	document.getElementById("textg3").style.visibility="hidden";
	document.getElementById("textg1").style.visibility="hidden";
	document.getElementById("textg2").style.visibility="hidden";
	document.getElementById("carrello").style.visibility="hidden";
	document.getElementById("roundrect9").style.visibility="hidden";
	document.getElementById("quotazione").style.visibility="visible";
	document.getElementById("textquo").style.visibility="visible";
	document.getElementById("tasti2").style.visibility="visible";
	document.getElementById("textper").style.visibility="visible";
	document.getElementById("funzionante").disabled=true;
}
function indietro(){
	document.getElementById("textf1").style.visibility="visible";
	document.getElementById("tasti1").style.visibility="visible";
	document.getElementById("textf2").style.visibility="visible";
	document.getElementById("textp").style.visibility="visible";
	document.getElementById("clicca").style.visibility="visible";
	document.getElementById("textg3").style.visibility="visible";
	document.getElementById("textg1").style.visibility="visible";
	document.getElementById("textg2").style.visibility="visible";
	document.getElementById("carrello").style.visibility="visible";
	document.getElementById("roundrect9").style.visibility="visible";
	document.getElementById("quotazione").style.visibility="hidden";
	document.getElementById("textquo").style.visibility="hidden";
	document.getElementById("tasti2").style.visibility="hidden";
	document.getElementById("textg1").style.visibility="hidden";
	document.getElementById("textg2").style.visibility="hidden";
	document.getElementById("textg3").style.visibility="hidden";
	document.getElementById("textper").style.visibility="hidden";
}
function cambia(){
	if (document.getElementById("funzionante").value == "No"){
		document.getElementById("textf1").style.visibility="hidden";
		document.getElementById("textf2").style.visibility="hidden";
		document.getElementById("textp").style.visibility="hidden";
		document.getElementById("clicca").style.visibility="hidden";
		document.getElementById("textg3").style.visibility="visible";
		document.getElementById("textg1").style.visibility="visible";
		document.getElementById("textg2").style.visibility="visible";
		nuovo = contanti;
		nuovo = Math.round(((nuovo*15)/100));
		document.recupero.contanti.value = nuovo;
		document.getElementById("spanc").innerHTML = nuovo;	
		calcola_voucher(nuovo);
	}
	else if (document.getElementById("funzionante").value == "Si"){
		document.getElementById("textf1").style.visibility="visible";
		document.getElementById("textf2").style.visibility="visible";
		document.getElementById("textg1").style.visibility="hidden";
		document.getElementById("textg2").style.visibility="hidden";
		document.getElementById("textp").style.visibility="visible";
		document.getElementById("clicca").style.visibility="visible";
		document.getElementById("textg3").style.visibility="hidden";
	}
}
function trova(){
        document.ricerca.submit();	
}
function trova2(){
        document.ricerca2.submit();	
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function verifica(){
	if (document.modulo.cond.checked==false){
		alert("Per continuare devi accettare le condizioni del sito");
		return false;
	}
	else if(document.modulo.privacy.checked==false){
		alert("Per continuare devi accettare le condizioni sulla privacy");
		return false;
	}
	else {
		var email = document.modulo.email.value;
		var password = document.modulo.password.value;
		var conferma = document.modulo.conferma.value;
		var risposta = document.modulo.risposta.value;
		var nome = document.modulo.nome.value;
		var cognome = document.modulo.cognome.value;
		var codfisc = document.modulo.codfisc.value;
		var indirizzo = document.modulo.indirizzo.value;
		var civico = document.modulo.civico.value;
		var comune = document.modulo.comune.value;
		var prov = document.modulo.prov.value;
		var cap = document.modulo.cap.value;
		var tel = document.modulo.tel.value;
		
		var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
		
		if (!email_reg_exp.test(email) || (email == "") || (email == "undefined")) {
           alert("Inserire un indirizzo email corretto!");
           document.modulo.email.select();
           return false;
        }
        else if ((password == "") || (password == "undefined") || (password.length<5)) {
           alert("Il campo Password è obbligatorio e deve essere di almeno 5 cifre!");
           document.modulo.password.focus();
           return false;
        }
        else if ((conferma == "") || (conferma == "undefined")) {
           alert("Il campo Conferma password è obbligatorio!");
           document.modulo.conferma.focus();
           return false;
        }
        else if (password != conferma) {
           alert("La password confermata è diversa da quella scelta, controllare!");
           document.modulo.conferma.value = "";
           document.modulo.conferma.focus();
           return false;
        }
		else if ((risposta == "") || (risposta == "undefined")) {
           alert("Il campo risposta è obbligatorio per il recupero della password!");
           document.modulo.risposta.focus();
           return false;
        }
		else if ((nome == "") || (nome == "undefined")) {
           alert("Il campo Nome è obbligatorio!");
           document.modulo.nome.focus();
           return false;
        }
		else if ((cognome == "") || (cognome == "undefined")) {
           alert("Il campo Cognome è obbligatorio!");
           document.modulo.cognome.focus();
           return false;
        }
		else if ((codfisc == "") || (codfisc == "undefined") || (codfisc.length<16)) {
           alert("Il campo Codice Fiscale è obbligatorio ed è composto da 16 cifre alfanumerici!");
           document.modulo.codfisc.focus();
           return false;
        }
		else if ((indirizzo == "") || (indirizzo == "undefined")) {
           alert("Il campo Indirizzo è obbligatorio!");
           document.modulo.indirizzo.focus();
           return false;
        }
		else if ((civico == "") || (civico == "undefined")) {
           alert("Il campo Civico è obbligatorio!");
           document.modulo.civico.focus();
           return false;
        }
		else if ((comune == "") || (comune == "undefined")) {
           alert("Il campo Comune è obbligatorio!");
           document.modulo.comune.focus();
           return false;
        }
		else if ((prov == "") || (prov == "undefined")) {
           alert("Il campo Provincia è obbligatorio!");
           document.modulo.prov.focus();
           return false;
        }
		else if ((isNaN(cap)) || (cap == "") || (cap == "undefined")) {
           alert("Il campo CAP è numerico ed obbligatorio.");
           document.modulo.cap.value = "";
           document.modulo.cap.focus();
           return false;
        }
		else if ((isNaN(tel)) || (tel == "") || (tel == "undefined")) {
           alert("Il campo Telefono è numerico ed obbligatorio.");
           document.modulo.telefono.value = "";
           document.modulo.telefono.focus();
           return false;
        }
		else {
           document.modulo.action = "regpriv.php";
           document.modulo.submit();
        }
	}
}

function accesso(){
	var nome = document.login.nome.value;
	var password = document.login.password.value;
	
	if ((nome == "") || (nome == "undefined")) {
           alert("Inserire e-mail!");
           document.login.nome.focus();
           return false;
        }
	else if ((password == "") || (password == "undefined")) {
          alert("Inserire la password!");
          document.login.password.focus();
          return false;
	}
	else {
			document.login.action = "accesso.php";
           	document.login.submit();
        }
}

function fast_accesso(){
	var nome = document.fast_login.nome.value;
	var password = document.fast_login.password.value;
	
	if ((nome == "") || (nome == "undefined") || (nome=="Email")) {
           alert("Inserire e-mail!");
           document.fast_login.nome.focus();
    
        }
	else if ((password == "") || (password == "undefined") || (password == "Password")) {
          alert("Inserire la password!");
          document.fast_login.password.focus();
       
	}
	else {
			document.fast_login.action = "accesso.php";
           	document.fast_login.submit();
        }
}

function verificalib2(){
	
	if(confirm("Sicuro di voler modificare i dati dell'account?")){
		var email = document.modulo.email.value;
		var password = document.modulo.password.value;
		var conferma = document.modulo.conferma.value;
		var risposta = document.modulo.risposta.value;
		var nome = document.modulo.nome.value;
		var cognome = document.modulo.cognome.value;
		var IVA = document.modulo.IVA.value;
		var indirizzo = document.modulo.indirizzo.value;
		var civico = document.modulo.civico.value;
		var comune = document.modulo.comune.value;
		var prov = document.modulo.prov.value;
		var cap = document.modulo.cap.value;
		var tel = document.modulo.tel.value;
		
		var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
		
		if (!email_reg_exp.test(email) || (email == "") || (email == "undefined")) {
           alert("Inserire un indirizzo email corretto!");
           document.modulo.email.select();
           return false;
        }
        else if ((password == "") || (password == "undefined") || (password.length<5) ) {
           alert("Il campo Password è obbligatorio e deve essere di almeno 5 cifre!");
           document.modulo.password.focus();
           return false;
        }
        else if ((conferma == "") || (conferma == "undefined")) {
           alert("Il campo Conferma password è obbligatorio!");
           document.modulo.conferma.focus();
           return false;
        }
        else if (password != conferma) {
           alert("La password confermata è diversa da quella scelta, controllare!");
           document.modulo.conferma.value = "";
           document.modulo.conferma.focus();
           return false;
        }
		else if ((risposta == "") || (risposta == "undefined")) {
           alert("Il campo risposta è obbligatorio per il recupero della password!");
           document.modulo.risposta.focus();
           return false;
        }
		else if ((nome == "") || (nome == "undefined")) {
           alert("Il campo Nome è obbligatorio!");
           document.modulo.nome.focus();
           return false;
        }
		else if ((cognome == "") || (cognome == "undefined")) {
           alert("Il campo Cognome è obbligatorio!");
           document.modulo.cognome.focus();
           return false;
        }
		else if ((isNaN(IVA)) || (IVA == "") || (IVA == "undefined") || (IVA.length<11)) {
           alert("Il campo Partita IVA è obbligatorio e deve essere di 11 cifre!");
           document.modulo.IVA.focus();
           return false;
        }
		else if ((indirizzo == "") || (indirizzo == "undefined")) {
           alert("Il campo Indirizzo è obbligatorio!");
           document.modulo.indirizzo.focus();
           return false;
        }
		else if ((civico == "") || (civico == "undefined")) {
           alert("Il campo Civico è obbligatorio!");
           document.modulo.civico.focus();
           return false;
        }
		else if ((comune == "") || (comune == "undefined")) {
           alert("Il campo Comune è obbligatorio!");
           document.modulo.comune.focus();
           return false;
        }
		else if ((prov == "") || (prov == "undefined")) {
           alert("Il campo Provincia è obbligatorio!");
           document.modulo.prov.focus();
           return false;
        }
		else if ((isNaN(cap)) || (cap == "") || (cap == "undefined")) {
           alert("Il campo CAP è numerico ed obbligatorio.");
           document.modulo.cap.value = "";
           document.modulo.cap.focus();
           return false;
        }
		else if ((isNaN(tel)) || (tel == "") || (tel == "undefined")) {
           alert("Il campo Telefono è numerico ed obbligatorio.");
           document.modulo.telefono.value = "";
           document.modulo.telefono.focus();
           return false;
        }
		else {
           document.modulo.action = "modlib.php";
           document.modulo.submit();
        }
	}
}

function verificalib(){
	if (document.modulo.cond.checked==false){
		alert("Per continuare devi accettare le condizioni del sito");
		return false;
	}
	else if(document.modulo.privacy.checked==false){
		alert("Per continuare devi accettare le condizioni sulla privacy");
		return false;
	}
	else {
		var email = document.modulo.email.value;
		var password = document.modulo.password.value;
		var conferma = document.modulo.conferma.value;
		var risposta = document.modulo.risposta.value;
		var nome = document.modulo.nome.value;
		var cognome = document.modulo.cognome.value;
		var IVA = document.modulo.IVA.value;
		var indirizzo = document.modulo.indirizzo.value;
		var civico = document.modulo.civico.value;
		var comune = document.modulo.comune.value;
		var prov = document.modulo.prov.value;
		var cap = document.modulo.cap.value;
		var tel = document.modulo.tel.value;
		
		var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
		
		if (!email_reg_exp.test(email) || (email == "") || (email == "undefined")) {
           alert("Inserire un indirizzo email corretto!");
           document.modulo.email.select();
           return false;
        }
        else if ((password == "") || (password == "undefined")|| (password.length<5)) {
           alert("Il campo Password è obbligatorio e deve essere di almeno 5 cifre!");
           document.modulo.password.focus();
           return false;
        }
        else if ((conferma == "") || (conferma == "undefined")) {
           alert("Il campo Conferma password è obbligatorio!");
           document.modulo.conferma.focus();
           return false;
        }
        else if (password != conferma) {
           alert("La password confermata è diversa da quella scelta, controllare!");
           document.modulo.conferma.value = "";
           document.modulo.conferma.focus();
           return false;
        }
		else if ((risposta == "") || (risposta == "undefined")) {
           alert("Il campo risposta è obbligatorio per il recupero della password!");
           document.modulo.risposta.focus();
           return false;
        }
		else if ((nome == "") || (nome == "undefined")) {
           alert("Il campo Nome è obbligatorio!");
           document.modulo.nome.focus();
           return false;
        }
		else if ((cognome == "") || (cognome == "undefined")) {
           alert("Il campo Cognome è obbligatorio!");
           document.modulo.cognome.focus();
           return false;
        }
		else if ((isNaN(IVA)) || (IVA == "") || (IVA == "undefined") || (IVA.length<11)) {
           alert("Il campo Partita IVA è obbligatorio e deve essere di 11 cifre!");
           document.modulo.IVA.focus();
           return false;
        }
		else if ((indirizzo == "") || (indirizzo == "undefined")) {
           alert("Il campo Indirizzo è obbligatorio!");
           document.modulo.indirizzo.focus();
           return false;
        }
		else if ((civico == "") || (civico == "undefined")) {
           alert("Il campo Civico è obbligatorio!");
           document.modulo.civico.focus();
           return false;
        }
		else if ((comune == "") || (comune == "undefined")) {
           alert("Il campo Comune è obbligatorio!");
           document.modulo.comune.focus();
           return false;
        }
		else if ((prov == "") || (prov == "undefined")) {
           alert("Il campo Provincia è obbligatorio!");
           document.modulo.prov.focus();
           return false;
        }
		else if ((isNaN(cap)) || (cap == "") || (cap == "undefined")) {
           alert("Il campo CAP è numerico ed obbligatorio.");
           document.modulo.cap.value = "";
           document.modulo.cap.focus();
           return false;
        }
		else if ((isNaN(tel)) || (tel == "") || (tel == "undefined")) {
           alert("Il campo Telefono è numerico ed obbligatorio.");
           document.modulo.telefono.value = "";
           document.modulo.telefono.focus();
           return false;
        }
		else {
           document.modulo.action = "reglib.php";
           document.modulo.submit();
        }
	}
}

function verificariv(){
	if (document.modulo.cond.checked==false){
		alert("Per continuare devi accettare le condizioni del sito");
		return false;
	}
	else if(document.modulo.privacy.checked==false){
		alert("Per continuare devi accettare le condizioni sulla privacy");
		return false;
	}
	else {
		var email = document.modulo.email.value;
		var password = document.modulo.password.value;
		var conferma = document.modulo.conferma.value;
		var risposta = document.modulo.risposta.value;
		var denominazione = document.modulo.denominazione.value;
		var IVA = document.modulo.IVA.value;
		var codfisc = document.modulo.codfisc.value;
		var indirizzo = document.modulo.indirizzo.value;
		var civico = document.modulo.civico.value;
		var comune = document.modulo.comune.value;
		var prov = document.modulo.provincia.value;
		var cap = document.modulo.cap.value;
		var tel = document.modulo.tel.value;
		var nome = document.modulo.nome.value;
		var cognome = document.modulo.cognome.value;
		
		var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	
		
		if (!email_reg_exp.test(email) || (email == "") || (email == "undefined")) {
           alert("Inserire un indirizzo email corretto!");
           document.modulo.email.select();
           return false;
        }
        else if ((password == "") || (password == "undefined")|| (password.length<5)) {
           alert("Il campo Password è obbligatorio e deve essere di almeno 5 cifre!");
           document.modulo.password.focus();
           return false;
        }
        else if ((conferma == "") || (conferma == "undefined")) {
           alert("Il campo Conferma password è obbligatorio!");
           document.modulo.conferma.focus();
           return false;
        }
        else if (password != conferma) {
           alert("La password confermata è diversa da quella scelta, controllare!");
           document.modulo.conferma.value = "";
           document.modulo.conferma.focus();
           return false;
        }
		else if ((risposta == "") || (risposta == "undefined")) {
           alert("Il campo risposta è obbligatorio per il recupero della password!");
           document.modulo.risposta.focus();
           return false;
        }
		else if ((denominazione == "") || (denominazione == "undefined")) {
           alert("Il campo Denominazione è obbligatorio!");
           document.modulo.denominazione.focus();
           return false;
        }
		else if ((isNaN(IVA)) || (IVA == "") || (IVA == "undefined") || (IVA.length<11)) {
           alert("Il campo Partita IVA è obbligatorio e deve essere di 11 cifre!");
           document.modulo.IVA.focus();
           return false;
        }
		else if ((indirizzo == "") || (indirizzo == "undefined")) {
           alert("Il campo Indirizzo è obbligatorio!");
           document.modulo.indirizzo.focus();
           return false;
        }
		else if ((civico == "") || (civico == "undefined")) {
           alert("Il campo Civico è obbligatorio!");
           document.modulo.civico.focus();
           return false;
        }
		else if ((comune == "") || (comune == "undefined")) {
           alert("Il campo Comune è obbligatorio!");
           document.modulo.comune.focus();
           return false;
        }
		else if ((prov == "") || (prov == "undefined")) {
           alert("Il campo Provincia è obbligatorio!");
           document.modulo.provincia.focus();
           return false;
        }
		else if ((isNaN(cap)) || (cap == "") || (cap == "undefined")) {
           alert("Il campo CAP è numerico ed obbligatorio.");
           document.modulo.cap.value = "";
           document.modulo.cap.focus();
           return false;
        }
		else if ((isNaN(tel)) || (tel == "") || (tel == "undefined")) {
           alert("Il campo Telefono è numerico ed obbligatorio.");
           document.modulo.telefono.value = "";
           document.modulo.telefono.focus();
           return false;
        }
		else if ((nome == "") || (nome == "undefined")) {
           alert("Il campo Nome è obbligatorio!");
           document.modulo.nome.focus();
           return false;
        }
		else if ((cognome == "") || (cognome == "undefined")) {
           alert("Il campo Cognome è obbligatorio!");
           document.modulo.cognome.focus();
           return false;
		}
		else {
           document.modulo.action = "regriv.php";
           document.modulo.submit();
        }
	}
}

function verifica2(){
	
	if(confirm("Sicuro di voler modificare i dati dell'account?")){
		var email = document.modulo.email.value;
		var password = document.modulo.password.value;
		var conferma = document.modulo.conferma.value;
		var risposta = document.modulo.risposta.value;
		var nome = document.modulo.nome.value;
		var cognome = document.modulo.cognome.value;
		var codfisc = document.modulo.codfisc.value;
		var indirizzo = document.modulo.indirizzo.value;
		var civico = document.modulo.civico.value;
		var comune = document.modulo.comune.value;
		var prov = document.modulo.prov.value;
		var cap = document.modulo.cap.value;
		var tel = document.modulo.tel.value;
		
		var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
		
		if (!email_reg_exp.test(email) || (email == "") || (email == "undefined")) {
           alert("Inserire un indirizzo email corretto!");
           document.modulo.email.select();
           return false;
        }
       else if ((password == "") || (password == "undefined")|| (password.length<5)) {
           alert("Il campo Password è obbligatorio e deve essere di almeno 5 cifre!");
           document.modulo.password.focus();
           return false;
        }
        else if ((conferma == "") || (conferma == "undefined")) {
           alert("Il campo Conferma password è obbligatorio!");
           document.modulo.conferma.focus();
           return false;
        }
        else if (password != conferma) {
           alert("La password confermata è diversa da quella scelta, controllare!");
           document.modulo.conferma.value = "";
           document.modulo.conferma.focus();
           return false;
        }
		else if ((risposta == "") || (risposta == "undefined")) {
           alert("Il campo risposta è obbligatorio per il recupero della password!");
           document.modulo.risposta.focus();
           return false;
        }
		else if ((nome == "") || (nome == "undefined")) {
           alert("Il campo Nome è obbligatorio!");
           document.modulo.nome.focus();
           return false;
        }
		else if ((cognome == "") || (cognome == "undefined")) {
           alert("Il campo Cognome è obbligatorio!");
           document.modulo.cognome.focus();
           return false;
        }
		else if ((codfisc == "") || (codfisc == "undefined") || (codfisc.length<16)) {
           alert("Il campo Codice Fiscale è obbligatorio ed è composto da 16 cifre alfanumerici!");
           document.modulo.codfisc.focus();
           return false;
        }
		else if ((indirizzo == "") || (indirizzo == "undefined")) {
           alert("Il campo Indirizzo è obbligatorio!");
           document.modulo.indirizzo.focus();
           return false;
        }
		else if ((civico == "") || (civico == "undefined")) {
           alert("Il campo Civico è obbligatorio!");
           document.modulo.civico.focus();
           return false;
        }
		else if ((comune == "") || (comune == "undefined")) {
           alert("Il campo Comune è obbligatorio!");
           document.modulo.comune.focus();
           return false;
        }
		else if ((prov == "") || (prov == "undefined")) {
           alert("Il campo Provincia è obbligatorio!");
           document.modulo.prov.focus();
           return false;
        }
		else if ((isNaN(cap)) || (cap == "") || (cap == "undefined")) {
           alert("Il campo CAP è numerico ed obbligatorio.");
           document.modulo.cap.value = "";
           document.modulo.cap.focus();
           return false;
        }
		else if ((isNaN(tel)) || (tel == "") || (tel == "undefined")) {
           alert("Il campo Telefono è numerico ed obbligatorio.");
           document.modulo.telefono.value = "";
           document.modulo.telefono.focus();
           return false;
        }
		else {
           document.modulo.action = "modpriv.php";
           document.modulo.submit();
        }
	}
}

function verificariv2(){
	
	if(confirm("Sicuro di voler modificare i dati dell'account?")){
		var email = document.modulo.email.value;
		var password = document.modulo.password.value;
		var conferma = document.modulo.conferma.value;
		var risposta = document.modulo.risposta.value;
		var denominazione = document.modulo.denominazione.value;
		var IVA = document.modulo.IVA.value;
		var codfisc = document.modulo.codfisc.value;
		var indirizzo = document.modulo.indirizzo.value;
		var civico = document.modulo.civico.value;
		var comune = document.modulo.comune.value;
		var prov = document.modulo.provincia.value;
		var cap = document.modulo.cap.value;
		var tel = document.modulo.tel.value;
		var nome = document.modulo.nome.value;
		var cognome = document.modulo.cognome.value;
		
		var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	
		
		if (!email_reg_exp.test(email) || (email == "") || (email == "undefined")) {
           alert("Inserire un indirizzo email corretto!");
           document.modulo.email.select();
           return false;
        }
        else if ((password == "") || (password == "undefined")|| (password.length<5)) {
           alert("Il campo Password è obbligatorio e deve essere di almeno 5 cifre!");
           document.modulo.password.focus();
           return false;
        }
        else if ((conferma == "") || (conferma == "undefined")) {
           alert("Il campo Conferma password è obbligatorio!");
           document.modulo.conferma.focus();
           return false;
        }
        else if (password != conferma) {
           alert("La password confermata è diversa da quella scelta, controllare!");
           document.modulo.conferma.value = "";
           document.modulo.conferma.focus();
           return false;
        }
		else if ((risposta == "") || (risposta == "undefined")) {
           alert("Il campo risposta è obbligatorio per il recupero della password!");
           document.modulo.risposta.focus();
           return false;
        }
		else if ((denominazione == "") || (denominazione == "undefined")) {
           alert("Il campo Denominazione è obbligatorio!");
           document.modulo.denominazione.focus();
           return false;
        }
		else if ((isNaN(IVA)) || (IVA == "") || (IVA == "undefined") || (IVA.length<11)) {
           alert("Il campo Partita IVA è obbligatorio e deve essere di 11 cifre!");
           document.modulo.IVA.focus();
           return false;
        }
		else if ((indirizzo == "") || (indirizzo == "undefined")) {
           alert("Il campo Indirizzo è obbligatorio!");
           document.modulo.indirizzo.focus();
           return false;
        }
		else if ((civico == "") || (civico == "undefined")) {
           alert("Il campo Civico è obbligatorio!");
           document.modulo.civico.focus();
           return false;
        }
		else if ((comune == "") || (comune == "undefined")) {
           alert("Il campo Comune è obbligatorio!");
           document.modulo.comune.focus();
           return false;
        }
		else if ((prov == "") || (prov == "undefined")) {
           alert("Il campo Provincia è obbligatorio!");
           document.modulo.provincia.focus();
           return false;
        }
		else if ((isNaN(cap)) || (cap == "") || (cap == "undefined")) {
           alert("Il campo CAP è numerico ed obbligatorio.");
           document.modulo.cap.value = "";
           document.modulo.cap.focus();
           return false;
        }
		else if ((isNaN(tel)) || (tel == "") || (tel == "undefined")) {
           alert("Il campo Telefono è numerico ed obbligatorio.");
           document.modulo.telefono.value = "";
           document.modulo.telefono.focus();
           return false;
        }
		else if ((nome == "") || (nome == "undefined")) {
           alert("Il campo Nome è obbligatorio!");
           document.modulo.nome.focus();
           return false;
        }
		else if ((cognome == "") || (cognome == "undefined")) {
           alert("Il campo Cognome è obbligatorio!");
           document.modulo.cognome.focus();
           return false;
		}
		else {
           document.modulo.action = "modriv.php";
           document.modulo.submit();
        }
	}
}

function verificapag(){
	
	var banca = document.formdati.banca.value;
	var IBAN = document.formdati.IBAN.value;
	
	if ((banca == "") || (banca == "undefined")){
		alert("Il Nome della Banca è obbligatorio!");
        document.formdati.banca.focus();
	}
	else if ((IBAN == "") || (IBAN == "undefined") ) {
           alert("Il campo IBAN è obbligatorio!");
           document.formdati.IBAN.focus();
	}
	else {
           document.formdati.action = "regdati.php";
           document.formdati.submit();
    }
}

