function controllo()
{
  with(document.prodotti)
      {
        
        if(cerca.value == '')
          {
              alert("seleziona modello");
              cerca.focus();
              return false;
          }
          
          /*if(ricerca.value == ''){
              alert("inserire la chiave di ricerca");
              ricerca.focus();
              return false;
          }*/
       }
   
  document.prodotti.action="ricerca.php";
  document.prodotti.submit();
  return true;
}

function controlloagenti()
{
  with(document.prodotti)
      {
        if(ricerca.value == '')
          {
              alert("Inserire Codice Articolo");
              ricerca.focus();
              return false;
          }
       }
   
  document.prodotti.action="agenti_ricerca_cc.php";
  document.prodotti.submit();
  return true;
}


function controllocatalogo()
{
  with(document.prodotti)
      {
        if(cerca.value == '')
          {
              alert("seleziona modello desiderata");
              cerca.focus();
              return false;
          }

       }
   
  document.prodotti.action="catalogoricerca.php";
  document.prodotti.submit();
  return true;
}


function modificacliente()
{
 if(modcli.cliente.value == '')
   {
     alert("Inserire Userid del cliente desiderato");
     modcli.cliente.focus();
     return false;
   }
  document.modcli.submit();
  return true;
}

function modificaagente()
{
 if(mod_agenti.agente.value == '')
   {
     alert("Inserire Userid del Agente desiderato");
     modcli.cliente.focus();
     return false;
   }
  document.mod_agenti.action="mod_agenti.php";
  document.mod_agenti.submit();
  return true;
}

function codicerif()
{
 if(cerca.consultaordine.value == '')
   {
     alert("Inserire Codice Riferimento o selezionare la data dell'ordine");
     cerca.consultaordine.focus();
     return false;
   }
  document.cerca.action="consultord.php";
  document.cerca.submit();
  return true;
}

function admincodicerif()
{
 if(cerca.consultaordine.value == '' && cerca.filtro.value == '')
   {
     alert("Inserire Codice Riferimento o selezionare la data dell'ordine oppure utilizzare il filtro");
     cerca.consultaordine.focus();
     return false;
   }
  document.cerca.action="evasione.php";
  document.cerca.submit();
  return true;
}

function consultord_back()
{
      with(document.cerca)
      {
      parent.location=('consultord.php');
      }
      return true;
}

function adminconsultord_back(){
      parent.location=('evasione_unset.php');
      return true;
}

function admin_back_evase(){
      with(document.evase){
      parent.location=('admin.php');
      }
      return true;
}

function admin_back()
{ 
	 
      parent.location=('admin.php');
      return true;
}

function agente_back()
{ 
	 
      parent.location=('agenti.php');
      return true;
}

function execmodificacliente()
{
  with(document.execmodcli)
      {
        if(x_userid.value == '')
          {
              alert("Attenzione Inserire Userid del Cliente");
              x_userid.focus();
              return false;
          }
		if(x_codice_friend.value == '')
          {
              alert("Attenzione Inserire Codice Cliente Friend");
              x_codice_friend.focus();
              return false;
          }
        if(x_azienda.value == '')
          {
              alert("Attenzione Inserire la Ragione Sociale");
              x_azienda.focus();
              return false;
          }
       if(x_indirizzo.value == '')
          {
              alert("Attenzione Inserire L'indirizzo");
              x_indirizzo.focus();
              return false;
          }
       if(x_cap.value == '')
          {
              alert("Attenzione Inserire il Cap");
              x_cap.focus();
              return false;
          }
       if(x_citta.value == '')
          {
              alert("Attenzione Inserire la Citta");
              x_citta.focus();
              return false;
          }
       if(x_cap.value == '')
          {
              alert("Attenzione Inserire il Cap");
              x_cap.focus();
              return false;
          }
       if(x_provincia.value == '')
          {
              alert("Attenzione Inserire la Provincia");
              x_provincia.focus();
              return false;
          }
       if(x_piva.value == '')
          {
              alert("Attenzione Manca la Partita Iva");
              x_piva.focus();
              return false;
          } 
      if(x_abilitato.value == '')
          {
              alert("Attenzione Manca l'abilitazione del Cliente");
              x_abilitato.focus();
              return false;
          }
      if(x_listper.value == '')
          {
              alert("Attenzione Manca l'abilitazione del listino Cliente");
              x_listper.focus();
              return false;
          }
      if(x_cpag.value == '')
          {
              alert("Attenzione Manca codice pagamento del cliente");
              x_cpag.focus();
              return false;
          }
      if( (x_listper.value.toUpperCase() == 'G') && (x_listgroup.value == '') )
      	 {
    			alert("Attenzione!!! Definire il listini raggruppato del client.");
    			x_listgroup.focus();
    			return false;
  		 } 
       }
  //document.execmodcli.action="execmodcli.php";
  //document.execmodcli.submit();
  return true;
}

function cart()
{
  with(document.tipoauto)
      {
        if(tipo.value == '')
          {
              alert("selezionare casa");
              tipo.focus();
              return false;
          }
      }
  document.tipoauto.action="ricerca.php";
  document.tipoauto.submit();
  return true;
}

function modelli()
{
  document.prodotti.action="ricerca.php";
  document.prodotti.submit();
  return true;
}

function lingua()
{
  with(document.country)
      {
        if(language.value == '')
          {
              alert("choose language");
              language.focus();
              return false;
          }
      }
  document.country.action="lingua.php";
  document.country.submit();
  return true;
}

function qty(){
      with(document.ordini)
      {
   
          if((x_quantita.value == '')||(x_quantita == null)){
              alert("Inserire quantita dell'ordine!");
              x_quantita.focus();
              return false; }
          if(isNaN(x_quantita.value)){
          	alert("Inserire un numero!");
          	x_quantita.focus();
          	return false;}
          if (x_quantita.value == 0){
          	alert("Quantità nulla!" + " " + (x_quantita.value));
          	x_quantita.focus();
          	return false;}
          	////////////////////////prezzo agente////////////////////////////
          	var re = /^[0-9]{1}[.]{1}[0-9]{2}$/;
          	var ra = /^[0-9]{2}[.]{1}[0-9]{2}$/;
          	var ri = /^[0-9]{3}[.]{1}[0-9]{2}$/;
          	prezzo = x_prezzo_agente.value;
          	example = x_prezzo_sc.value;
		    if ((x_prezzo_agente.value != "")&&(x_prezzo_agente.value != "Inserire prezzo proposto")&&(re.test(prezzo)==false)&&(ra.test(prezzo)==false)&&(ri.test(prezzo)==false)){
					alert("il formato di prezzo" + " " + (prezzo) + " è sbagliato! usa questo formato "+ (example));
					x_prezzo_agente.focus();
                    return false;}
           //////////////////////////fine di controllo prezzo agente ////////////////////////////////////////////        
     }
     //document.ordini.submit();
     return true;
  }
  
function fqty()
{
      with(document.ordini)
      {
      x_quantita.focus();
      }
      return true;
}

function back()
{
      with(document.ordini)
      {
      parent.location=('cartshow.php');
      }
      return true;
}

function cat_back()
{
      with(document.ordini)
      {
      parent.location=('cartview.php');
      }
      return true;
}

function indietro()
{
      with(document.ordini)
      {
      parent.location=('ricerca.php');///usato nella pagina catshowpage 08012006
      }
      return true;
}

function list()
{
      with(document.ordini)
      {
      parent.location=('ricerca.php');
      }
      return true;
}

function listcatalogo()
{
      with(document.ordini)
      {
      parent.location=('catalogoricerca.php');
      }
      return true;
}

function elim()
   {
      var conferma=confirm("Vuoi eliminare l'articolo dal ordine");
      if (conferma)
      {			   
    	return true
      }
      else
      {
      	return false
      }
   }
   
 function elimina_ordine()
   {
      var conferma=confirm("Attenzione stai per eliminare gli ordini selezionati!!! fai clic su OK per confermare eliminazione oppure ANNULLA per tornare indietro.");
      if (conferma)
      {	
    	return true
      }
      else
      {
      	return false
      }
  }
    
function elimcli()
   {
      var conferma=confirm("Attenzione Stai per eliminare cliente dal database???");
      if (conferma)
      {			   
    	return true
      }
      else
      {
      	return false
      }
   }
   
  function no_auth_elimcli()
   {
      alert("Attenzione Non hai Autorizzazione per eliminare cliente dal database!!!");
      return false      
   }
   
 function elimagt()
   {
      var conferma=confirm("Attenzione Stai per eliminare un Agente dal database???");
      if (conferma)
      {			   
    	return true
      }
      else
      {
      	return false
      }
   }
   
function confermation(){
      with(document.ordini)
      {
   
          if((status.value == '')||(status==null)){
              alert("Attenzione Non Esiste Ordine da Conferma o Inviare Ritorna al Ordini Grazie");
              parent.location=('ricerca.php');
             return false; }
          if (status.value ==0){
          	alert("Attenzione Non Esiste Ordine da Conferma o Inviare Ritorna al Ordini Grazie");
          	parent.location=('ricerca.php');
          	return false;}
         /* if (message.value != ''){
          	alert("message_posted");
          	document.ordini.submit();
          	return true;
          }*/
          if (status.value != 0)
          {
           var conferma=confirm("Conferma e inviare l'ordine prima uscire?");
            if (conferma)
            { document.ordini.submit();
            	return true
            }
            else{return false}
          }
      }
   }
 
function profile()
{
  with(document.execprofile)
      {
        
        if(x_azienda.value == '')
          {
              alert("Attenzione Inserire la Ragione Sociale");
              x_azienda.focus();
              return false;
          }
       if(x_indirizzo.value == '')
          {
              alert("Attenzione Inserire L'indirizzo");
              x_indirizzo.focus();
              return false;
          }
       if((x_cap.value == '') || (x_cap.value == 0))
          {
              alert("Attenzione Inserire il Cap");
              x_cap.focus();
              return false;
          }
       if(x_citta.value == '')
          {
              alert("Attenzione Inserire la Citta");
              x_citta.focus();
              return false;
          }
       if(x_cap.value == '')
          {
              alert("Attenzione Inserire il Cap");
              x_cap.focus();
              return false;
          }
       if(x_provincia.value == '')
          {
              alert("Attenzione Inserire la Provincia");
              x_provincia.focus();
              return false;
          }
       if( (x_passwd_old.value != '') && (x_passwd_new.value.length < 6) )
      	 {
    			alert("Attenzione!!! nuovo password deve essere maggiore di 6 caratteri");
    			x_passwd_new.focus();
    			return false;
  		}
      }
        
  	document.execprofile.action="execprofile.php";
  	document.execprofile.submit();
  	return true;
 }

 
 function nuovaordine()
 {
      with(document.ordini)
      {
          if ((status.value != 0)||(status==0))
          {
           var conferma=confirm("crea nuovo ordine?");
            if (conferma)
            { document.ordini.submit();
            	return true
            }
            else{return false}
          }
     }
 }
 

function passwdcontrollo()
{
 with(document.passwd)
 {
 
        if(ncpasswd_new.value == '') 
          {
          	alert("Attenzione!!! Inserire Password");
            ncpasswd_new.focus();
            return false;
          }
          
         if(ncpasswd_new.value.length < 6) 
          {
              alert("Attenzione!!! nuovo password deve essere maggiore di 6 caratteri");
              ncpasswd_new.focus();
              return false;
          }
          
       if(ccpasswd_new.value == '') 
          {
          	alert("Attenzione!!! Inserire Password di conferma");
            ccpasswd_new.focus();
            return false;
          }
          
         if(ccpasswd_new.value.length < 6) 
          {
           alert("Attenzione!!! nuovo password deve essere maggiore di 6 caratteri");
           ccpasswd_new.focus();
           return false;
          }
         if(ccpasswd_new.value != ncpasswd_new.value) 
          {
           alert("Attenzione!!! Password di Conferma Risulta Diverso!!!");
           ccpasswd_new.focus();
           return false;
          }
          
		if(axpasswd.value == '')
          {
              alert("Attenzione!!! Inserire password di amministratore");
              axpasswd.focus();
              return false;
          }
          
       if((axpasswd.value.length < 6) || (axpasswd.value.length > 6))
          {
              alert("Attenzione!!! Password fasulo sei sicuro di essere luca ruggiero");
              axpasswd.focus();
              return false;
          }
 }
  document.passwd.action="execmodpasswd.php";
  document.passwd.submit();
  return true;
}
////////////////////////////modifica agenti////////////////////////////
function agente_profile()
{
  with(document.agente_execprofile)
      {
        
        if(x_ragione_sociale.value == '')
          {
              alert("Attenzione Inserire la Ragione Sociale");
              x_ragione_sociale.focus();
              return false;
          }

       if(x_telefono.value == '')
          {
              alert("Attenzione Inserire il numero di telefono");
              x_telefono.focus();
              return false;
          }
       if( (x_passwd_old.value != '') && (x_passwd_new.value.length < 6) )
      	 {
    			alert("Attenzione!!! nuovo password deve essere maggiore di 6 caratteri");
    			x_passwd_new.focus();
    			return false;
  		}
      }
        
  	document.execprofile.action="agente_execprofile.php";
  	document.execprofile.submit();
  	return true;
 }
 
function mdagente()
{
  with(document.agenti)
      {
        if(x_userid.value == '')
          {
              alert("Attenzione Inserire Userid del Agente");
              x_userid.focus();
              return false;
          }
		if(x_codice_agente.value == '')
          {
              alert("Attenzione Inserire Codice Agente");
              x_codice_agente.focus();
              return false;
          }
        if(x_azienda.value == '')
          {
              alert("Attenzione Inserire la Ragione Sociale");
              x_azienda.focus();
              return false;
          }
        if(x_piva.value == '')
          {
              alert("Attenzione Manca la Partita Iva");
              x_piva.focus();
              return false;
          } 
      if(x_abilitato.value == '')
          {
              alert("Attenzione Manca l'abilitazione del Agente");
              x_abilitato.focus();
              return false;
          }
      
       }
  document.agenti.action="execmodagenti.php";
  document.agenti.submit();
  return true;
} 
