function MM_jumpMenu_1(targ,selObj,restore)
{ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenu_2(targ,selObj,restore)
{ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenu_3(targ,selObj,restore)
{ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}

function MM_openBrWindow(theURL,winName,features) 
{ //v2.0
  window.open(theURL,winName,features);
}
function apriInGrande(pagina)
	{
		msg=open(
			pagina,
			'SOP',
			'toolbar=no,directories=no,menubar=no,hotkeys=no,location=no,scrollbars=yes,width=550,height=600,top=0,left=0'
		);
	}

function apriMenu(pagina)
{
	msg=open(
		pagina,
		'SOP',
		'toolbar=no,directories=no,menubar=no,hotkeys=no,location=no,scrollbars=yes,width=550,height=600,top=0,left=0'
	);
}
	
function apriRivenditore(pagina)
	{
		msg=open(
			pagina,
			'SOP',
			'toolbar=no,directories=no,menubar=no,hotkeys=no,location=no,scrollbars=yes,width=500,height=500,top=0,left=0'
		);
	}
	
function indirizzoEmailValido(indirizzo) {
  if (window.RegExp) {
    var nonvalido = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
    var valido = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
    var regnv = new RegExp(nonvalido);
    var regv = new RegExp(valido);
    if (!regnv.test(indirizzo) && regv.test(indirizzo))
      return true;
    return false;
	}
  else {
    if(indirizzo.indexOf("@") >= 0)
      return true;
    return false;
  	}
  };
  
	
function controllaDati(modulo) {
	if (!indirizzoEmailValido(modulo.email.value)) {
		 	modulo.email.select();
			alert("Si prega di inserire un indirizzo email valido");
			return false;
		 	}

	if(modulo.remove.checked == false){	
		if( modulo.privacy.checked != true ) {
			alert ("Prima di registrarsi leggere l'informativa sulla privacy e selezionare SI nell'opzione relativa!");
			modulo.privacy.focus();
			return false;
			}
	 	}
		else
			return true;		
};
   
function searchCode_Validator(theForm){
	   if (theForm.codice.value == "")
  		{
			alert("Specificare un codice articolo valido.");
			theForm.codice.focus();
			return (false);
  		}
};


function login_validator() {
	//controlla che venga inserito un valore nello username
	if (frmLogin.txtUsername.value == "") 
	{
		frmLogin.txtUsername.select();
			alert("Si prega di inserire uno username valido, utilizzare l'indirizzo email usato nella registrazione");
			return false;
	}

	//controlla che venga inserito un valore per la password
	if (frmLogin.txtPassword.value == "") 
	{
	frmLogin.txtPassword.select();
	alert("Si prega di inserire una password valida");
		return false;
	}
	else
	return true;
};

function ControllaPIVA(pi)
{
    if( pi == '' )  return '';
    if( pi.length != 11 )
        return "La lunghezza della partita IVA non ?" +
            "corretta: la partita IVA dovrebbe essere lunga\n" +
            "esattamente 11 caratteri.\n";
    validi = "0123456789";
    for( i = 0; i < 11; i++ ){
        if( validi.indexOf( pi.charAt(i) ) == -1 )
            return "La partita IVA contiene un carattere non valido `" +
                pi.charAt(i) + "'.\nI caratteri validi sono le cifre.\n";
    }
    s = 0;
    for( i = 0; i <= 9; i += 2 )
        s += pi.charCodeAt(i) - '0'.charCodeAt(0);
    for( i = 1; i <= 9; i += 2 ){
        c = 2*( pi.charCodeAt(i) - '0'.charCodeAt(0) );
        if( c > 9 )  c = c - 9;
        s += c;
    }
    if( ( 10 - s%10 )%10 != pi.charCodeAt(10) - '0'.charCodeAt(0) )
        return "La partita IVA non ?alida:\n" +
            "il codice di controllo non corrisponde.\n";
    return '';
}

function ControllaCF(cf)
{
    var validi, i, s, set1, set2, setpari, setdisp;
    if( cf == '' )  return '';
    cf = cf.toUpperCase();
    if( cf.length != 16 )
        return "La lunghezza del codice fiscale non ?"
        +"corretta: il codice fiscale dovrebbe essere lungo\n"
        +"esattamente 16 caratteri.\n";
    validi = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    for( i = 0; i < 16; i++ ){
        if( validi.indexOf( cf.charAt(i) ) == -1 )
            return "Il codice fiscale contiene un carattere non valido `" +
                cf.charAt(i) +
                "'.\nI caratteri validi sono le lettere e le cifre.\n";
    }
    set1 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    set2 = "ABCDEFGHIJABCDEFGHIJKLMNOPQRSTUVWXYZ";
    setpari = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    setdisp = "BAKPLCQDREVOSFTGUHMINJWZYX";
    s = 0;
    for( i = 1; i <= 13; i += 2 )
        s += setpari.indexOf( set2.charAt( set1.indexOf( cf.charAt(i) )));
    for( i = 0; i <= 14; i += 2 )
        s += setdisp.indexOf( set2.charAt( set1.indexOf( cf.charAt(i) )));
    if( s%26 != cf.charCodeAt(15)-'A'.charCodeAt(0) )
        return "Il codice fiscale non ?orretto:\n"+
            "il codice di controllo non corrisponde.\n";
    return "";
}

					
function registrazione_utente_Form_Validator(theForm)
{
  if( theForm.privacy.checked != true ) 
  {
	alert ("Prima di registrarsi leggere l'informativa sulla privacy e selezionare la check al suo fianco!");
	theForm.privacy.focus();
	return false;
  }
  
   if (theForm.codice_fiscale.disabled == false){
		if (theForm.codice_fiscale.value != ""){   
		  err = ControllaCF(theForm.codice_fiscale.value);
		  if( err > '' ){
			alert("Il codice fiscale inserito non è corretto!");
			theForm.codice_fiscale.focus();
			return (false);
		  }
		}
		if (theForm.codice_fiscale.value == "")
		{
			alert("Inserire un valore per il codice fiscale");
			theForm.codice_fiscale.focus();
			return (false);
		}
	}
	
	//if (theForm.partita_iva.disabled == false){
		if (theForm.partita_iva.value != "")
		{   
		  err = ControllaPIVA(theForm.partita_iva.value);
		  if( err > '' ){
			alert("La partita iva inserita non è corretta!");
			theForm.partita_iva.focus();
			return (false);
		  }
		}
		/*if (theForm.partita_iva.value == "")
		{
		alert("Inserire un valore per la partita iva");
		theForm.partita_iva.focus();
		return (false);
		}*/
	//}	  
    
  if (theForm.ragione_Sociale.value.length > 39)
  {
    alert("Inserire al massimo 16 caratteri per il campo Ragione Sociale");
    theForm.ragione_Sociale.focus();
    return (false);
  }

  var checkOK = "-_.,:;'^?£$%&/\|*éèìòàABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆ`ÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0123456789- \t\r\n\f";
  var checkStr = theForm.ragione_Sociale.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Inserire solo lettera, cifra e spazio caratteri nel campo Ragione sociale");
    theForm.ragione_Sociale.focus();
    return (false);
  }
  
   if (theForm.nome_referente.value == "")
  {
    alert("Inserire un valore per il campo Nome referente");
    theForm.nome_referente.focus();
    return (false);
  }
  
     if (theForm.cognome_referente.value == "")
  {
    alert("Inserire un valore per il campo Cognome referente");
    theForm.cognome_referente.focus();
    return (false);
  }
  	
   if (theForm.indirizzo.value == "")
	  {
		alert("Inserire un valore per il campo Indirizzo");
		theForm.indirizzo.focus();
		return (false);
	  } 
  
  if (theForm.citta.value == "")
	  {
		alert("Inserire un valore per il campo Città");
		theForm.citta.focus();
		return (false);
	  }
  
  if (theForm.cap.value == "")
	  {
		alert("Inserire il Codice di Avviamento Postale");
		theForm.cap.focus();
		return (false);
	  }
  
  if (theForm.cap.value.length < 5 )
	  {
		alert("Inserire 5 numeri nel campo Codice di Avviamento Postale");
		theForm.cap.focus();
		return (false);
	  }

  if (theForm.cap.value.length > 5)
	  {
		alert("Inserire al massimo 5 caratteri nel campo Cap");
		theForm.cap.focus();
		return (false);
	  }

  var checkOK = "0123456789-.";
  var checkStr = theForm.cap.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch != ".")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Inserire solo cifra caratteri nel campo Cap");
    theForm.cap.focus();
    return (false);
  }
   
   if (theForm.cap_consegna.value.length > 5)
  {
    alert("Inserire al massimo 5 caratteri nel campo Cap per la consegna");
    theForm.cap_consegna.focus();
    return (false);
  }
  
    if (theForm.cap_consegna.value.length > 5)
  {
    alert("Inserire al massimo 5 caratteri nel campo Cp per la consegna");
    theForm.cap_consegna.focus();
    return (false);
  }

  var checkOK = "0123456789-.";
  var checkStr = theForm.cap_consegna.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch != ".")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Inserire solo cifra caratteri nel campo Cap per la consegna");
    theForm.cap_consegna.focus();
    return (false);
  }
    if (theForm.indirizzo.value.length > 50)
  {
    alert("Inserire al massimo 50 caratteri nel campo Indirizzo");
    theForm.indirizzo.focus();
    return (false);
  }

  var checkOK = "-_.,:;'^?£$%&/\|*éèìòàABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0123456789- \t\r\n\f";
  var checkStr = theForm.indirizzo.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
     for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Inserire solo lettera, cifra, spazio e \"-/\\,.\" caratteri nel campo Indirizzo");
    theForm.indirizzo.focus();
    return (false);
  }

  if (theForm.citta.value.length > 25)
  {
    alert("Inserire al massimo 25 caratteri nel campo Città");
    theForm.citta.focus();
    return (false);
  }

  var checkOK = "-_.,:;'^?£$%&/\|*éèìòàABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0123456789- \t\r\n\f";
  var checkStr = theForm.citta.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Inserire solo lettera, cifra, spazio e \"-\\/\" caratteri nel campo Città");
    theForm.citta.focus();
    return (false);
  }

  if (theForm.telefono.value.length > 16)
  {
    alert("Inserire al massimo 16 caratteri nel campo Telefono`");
    theForm.telefono.focus();
    return (false);
  }

  var checkOK = "0123456789-+";
  var checkStr = theForm.telefono.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    allNum += ch;
  }
  if (!allValid)
  {
    alert("Inserire solo cifra caratteri nel campo Telefono");
    theForm.telefono.focus();
    return (false);
  }
  
    if (theForm.telefono.value == "")
	  {
		alert("Inserire almeno un numero di telefono per eventuali contatti.");
		theForm.telefono.focus();
		return (false);
	  }
  
  if (theForm.telefono_consegna.value.length > 16)
  {
    alert("Inserire al massimo 16 caratteri nel campo Telefono consegna`");
    theForm.telefono_consegna.focus();
    return (false);
  }

  var checkOK = "0123456789-+";
  var checkStr = theForm.telefono_consegna.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    allNum += ch;
  }
  if (!allValid)
  {
    alert("Inserire solo cifra caratteri nel campo Telefono consegna");
    theForm.telefono_consegna.focus();
    return (false);
  }
   
   if (theForm.txtUsername.value == "")
  {
    alert("Inserire una email per il campo relativo allo Username");
    theForm.txtUsername.focus();
    return (false);
  }
  
   if (theForm.txtUsername.value.length > 35)
  {
    alert("Inserire al massimo 35 caratteri nel campo email per lo Username");
    theForm.txtUsername.focus();
    return (false);
  }
		
  if(!isEmail(theForm.txtUsername.value))
  return false;
  
  if (theForm.nuova_password.value == "")
  {
    alert("Inserire una Password per accedere da utente registrato");
    theForm.nuova_password.focus();
    return (false);
  }
  if (theForm.nuova_password.value.length > 12)
  {
    alert("Inserire al massimo 12 caratteri nel campo Password");
    theForm.nuova_password.focus();
    return (false);
  }
  if (theForm.conferma_password.value == "")
  {
    alert("Ripetere la password per sicurezza");
    theForm.conferma_password.focus();
    return (false);
  }
  
if (theForm.conferma_password.value != theForm.nuova_password.value){
    alert ("attenzione la password di conferma è diversa da quella inserita");
    theForm.conferma_password.value = "";
    theForm.conferma_password.focus()
    return (false);
}

   if (theForm.email.value == "")
  {
    alert("Inserire un valore per il campo email");
    theForm.email.focus();
    return (false);
  }
  
  
 if(!isEmail(theForm.email.value)) 
		return false;

  if (theForm.email.value.length > 80)
  {
    alert("Inserire al massimo 80 caratteri nel campo email");
    theForm.email.focus();
    return (false);
  }
  
  var checkOK = "ç@-_.,:;'^?£$%&/\|*éèìòàABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0123456789- \t\r\n\f";
  var checkStr = theForm.email.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Inserire solo lettera, cifra e \"@.-\" caratteri nel campo email");
    theForm.email.focus();
    return (false);
  }

  if (theForm.nome_referente.value.length > 16)
  {
    alert("Inserire al massimo 16 caratteri per il campo Nome referente");
    theForm.nome_referente.focus();
    return (false);
  }

  var checkOK = "-_.,:;'^?£$%&/\|*éèìòàABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0123456789- \t\`r\n\f";
  var checkStr = theForm.nome_referente.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  
  if (!allValid)
  {
    alert("Inserire solo lettera, cifra e spazio caratteri nel campo Nome referente");
    theForm.nome_referente.focus();
    return (false);
  }
  
  if (theForm.cognome_referente.value.length > 16)
  {
    alert("Inserire al massimo 16 caratteri per il campo Cognome referente");
    theForm.cognome_referente.focus();
    return (false);
  }

  var checkOK = "-_.,:;'^?£$%&/\|*éèìòàABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0123456789- \t\r\n\f";
  var checkStr = theForm.cognome_referente.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  
  if (!allValid)
  {
    alert("Inserire solo lettera, cifra e spazio caratteri nel campo Cognome referente");
    theForm.cognome_referente.focus();
    return (false);
  }
  
  
  if (theForm.telefono_cellulare.value.length > 15)
  {
    alert("Inserire al massimo 15 caratteri nel campo Telefono cellulare");
    theForm.telefono_cellulare.focus();
    return (false);
  }
  
  var checkOK = "0123456789-+";
  var checkStr = theForm.telefono_cellulare.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
     }
    allNum += ch;
  }
  if (!allValid)
  {
    alert("Inserire solo cifra caratteri nel campo Telefono cellulare");
    theForm.telefono_cellulare.focus();
    return (false);
  }

  if (theForm.fax.value.length > 15)
  {
    alert("Inserire al massimo 15 caratteri nel campo Fax");
    theForm.fax.focus();
    return (false);
  }
 
  var checkOK = "0123456789-.+";
  var checkStr = theForm.fax.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch != ".")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Inserire solo cifra caratteri nel campo Fax");
    theForm.fax.focus();
    return (false);
  }
  return (true);
}

// modulo contatti
function isEmail(what){
	var i=new RegExp("^.*\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	if(!i.test(what)) 
	{ 
		alert("Il campo email specificato non è valido."); 
			return false
	}   
	return true;
}
		
function frmContatti_Validator(theForm){
if (theForm.nome.value == "")
  {
	alert("Inserire un valore per il campo Nome");
	theForm.nome.focus();
	return (false);
	}
	
if (theForm.cognome.value == "")
  {
	alert("Inserire un valore per il campo Cognome");
	theForm.cognome.focus();
	return (false);
	}

if(!isEmail(theForm.email.value)) 
return false;

if (theForm.messaggio.value == "")
  {
	alert("Inserire un valore per il campo messaggio");
	theForm.messaggio.focus();
	return (false);
	}
	}
	
function frmPreventivi_Validator(theForm){
if (theForm.nome.value == "")
  {
	alert("Inserire un valore per il campo Nome");
	theForm.nome.focus();
	return (false);
	}

if (theForm.cognome.value == "")
  {
	alert("Inserire un valore per il campo Cognome");
	theForm.cognome.focus();
	return (false);
	}
	
if (theForm.citta.value == "")
 {
	alert("Inserire un valore per il campo Città");
	theForm.citta.focus();
	return (false);
  }
	
if (theForm.nomeAzienda.value == "")
  {
	alert("Inserire un valore per il campo Azienda o inserire Privato.");
	theForm.nomeAzienda.focus();
	return (false);
  }
 
 if (theForm.telefono.value.length > 16)
  {
    alert("Inserire al massimo 16 caratteri nel campo Telefono`");
    theForm.telefono.focus();
    return (false);
  }

  var checkOK = "0123456789-+";
  var checkStr = theForm.telefono.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    allNum += ch;
  }
  if (!allValid)
  {
    alert("Inserire solo cifra caratteri nel campo Telefono");
    theForm.telefono.focus();
    return (false);
  }
  
    if (theForm.telefono.value == "")
	  {
		alert("Inserire almeno un numero di telefono per eventuali contatti.");
		theForm.telefono.focus();
		return (false);
	  }
  
  if (theForm.telefono.value.length > 16)
  {
    alert("Inserire al massimo 16 caratteri nel campo Telefono consegna`");
    theForm.telefono.focus();
    return (false);
  }
  
  if (theForm.PIva.disabled == false){
		if (theForm.PIva.value != "")
		{   
		  err = ControllaPIVA(theForm.PIva.value);
		  if( err > '' ){
			alert("La partita iva inserita non è corretta!");
			theForm.PIva.focus();
			return (false);
		  }
		}
	}	  
	
	if( theForm.privacy.checked != true ) 
  	{
	alert ("Prima di registrarsi leggere l'informativa sulla privacy e selezionare la check al suo fianco!");
	theForm.privacy.focus();
	return false;
  	}

if(!isEmail(theForm.email.value)) 
return false;

if (theForm.messaggio.value == "")
  {
	alert("Inserire un valore per il campo messaggio");
	theForm.messaggio.focus();
	return (false);
  }

}

function homepagelink (url,displayclass)
{
	if (document.all)
	{
		document.write('<a href="' + url + '" target="_top" onClick="this.style.behavior=\'url(#default#homepage)\';this.setHomePage(\'' + url + '\')">');
		document.write('<span class="' + displayclass + '">Fai di eKoo la tua Home Page</span></a>');
	}

	// If it's Netscape 6, tell user to drag link onto Home button
	else if (document.getElementById)
	{
		document.write('<a href="' + url + '"><span class="' + displayclass + '">Fai di eKoo la tua Home Page</span></a>');
	}
}
	
function bookmarklink (url,title,displayclass)
{
	var app = navigator.appName;
	var ver = parseInt(navigator.appVersion);

	if ((app == "Microsoft Internet Explorer") && (ver >= 4)) {
		document.write("<a href=\"javascript:window.external.AddFavorite('" + url + "',\'" + title + "')\"><span class=\"" + displayclass + "\">Aggiungi eKoo ai tuoi preferiti</span></a>");
	} else {
		document.write('<span class="' + displayclass + '">CTRL + D per aggiungere eKoo ai tuoi preferiti</span>');
	}
		return;
}


//controlla l'accettazione delle clausole di vendita all'invio dell'ordine
function sendorder_validator(sender){
  if(!sender.rdBuyCond.checked){
	alert ("Per procedere con l'ordine bisogna necessariamente accettare le condizioni di vendita!");
	return false;
  }
}
//controlla l'abilitazione dei campi nel modulo registrazione a seconda si tratti di azienda o privato
////////privato
function privatesubject(){
	registrazione_utente_Form.codice_fiscale.disabled 			= false;
	registrazione_utente_Form.partita_iva.disabled 				= true;
	registrazione_utente_Form.codice_fiscale.value 				= 'inserisci codice fiscale';
	registrazione_utente_Form.partita_iva.value 				= '';
	registrazione_utente_Form.ragione_Sociale.disabled 			= true;
	registrazione_utente_Form.partita_iva.style.background 		= '#cccccc'
	registrazione_utente_Form.codice_fiscale.style.background 	= '#ffffff'
	registrazione_utente_Form.ragione_Sociale.style.background 	= '#cccccc'
	}
////////azienda
function publicsubject(){
	registrazione_utente_Form.codice_fiscale.disabled 			= true;
	registrazione_utente_Form.partita_iva.disabled 				= false;
	registrazione_utente_Form.ragione_Sociale.disabled 			= false;
	registrazione_utente_Form.partita_iva.value 				= 'inserisci la partita iva';
	registrazione_utente_Form.codice_fiscale.value 				= '';
	registrazione_utente_Form.partita_iva.style.background 		= '#ffffff'
	registrazione_utente_Form.codice_fiscale.style.background 	= '#cccccc'
	registrazione_utente_Form.ragione_Sociale.style.background 	= '#ffffff'
	}
