//--------USER/AZIENDA REGISTRAZIONE-----------------------
function registrazione(){
  document.menuForm.azione.value="120";
  document.menuForm.action="RegistrazioneUserServlet";
  document.menuForm.submit();
}

function modify(){
  document.menuForm.azione.value="122";
  document.menuForm.action="RegistrazioneUserServlet";
  document.menuForm.submit();

}

function modify_merce(){
  document.uploadForm.azione.value="125";
  document.uploadForm.action="RegistrazioneUserServlet";
  document.uploadForm.submit();
}

function logoff(){
  document.menuForm.azione.value="3";
  document.menuForm.redirectOK.value="http://www.calcionapolistore.com/napolistore.jsp";
  document.menuForm.associato.value="http://www.calcionapolistore.com/UploadProfileServlet";
  document.menuForm.action="UploadProfileServlet";
  document.menuForm.submit();

}

function registrazione_step2(){
if (document.uploadForm.consenso_675[0].checked){
	if (document.uploadForm.tipo.value=="privato"){
	 document.uploadForm.action='registrazione.jsp?REDIRECT_page=registrazione/registrazione_user_step2.jsp&indicate_page=1&step=forward';
	 document.uploadForm.submit();
	}
	if (document.uploadForm.tipo.value=="azienda"){
	 document.uploadForm.action='registrazione.jsp?REDIRECT_page=registrazione/registrazione_azienda_step2.jsp&indicate_page=1&step=forward';
	 document.uploadForm.submit();
	}
}else { alert("");}


}

function registrazione_b2b(){
  document.menuForm.azione.value="118";
  document.menuForm.action="RegistrazioneUserServlet";
  document.menuForm.submit();

}
function setIndirizzo_merce(ctr){
 if (ctr=="1"){
   document.uploadForm.indirizzo_merce.value=document.uploadForm.indirizzo.value;
   document.uploadForm.provincia_merce.value=document.uploadForm.provincia.value;
   document.uploadForm.citta_merce.value=document.uploadForm.citta.value;
   document.uploadForm.cap_merce.value=document.uploadForm.cap.value;
   document.uploadForm.stato_merce.value=document.uploadForm.stato.value;

 }else {
  document.uploadForm.indirizzo_merce.value="";
  document.uploadForm.provincia_merce.value="";
  document.uploadForm.citta_merce.value="";
  document.uploadForm.cap_merce.value="";
  document.uploadForm.stato_merce.value="104";
 }

}

function check_form(){
  if (document.uploadForm.nome.value.length==0){
     alert ("Attenzione! Il campo Nome è obbligatorio ");
	 document.uploadForm.nome.focus();
	 return false;
  }
   if (document.uploadForm.cognome.value.length==0){
     alert ("Attenzione! Il campo Cognome è obbligatorio ");
	 document.uploadForm.cognome.focus();
	 return false;
  }
   if (document.uploadForm.comunenascita.value.length==0){
     alert ("Attenzione! Il campo Comune di Nascita è obbligatorio ");
	 document.uploadForm.comunenascita.focus();
	 return false;
  }
  if (document.uploadForm.codice_fiscale.value.length==0){
     alert ("Attenzione!  Il campo Codice Fiscale è obbligatorio");
	 document.uploadForm.codice_fiscale.focus();
	 return false;
  }

  if (document.uploadForm.indirizzo.value.length==0){
     alert ("Attenzione! Il campo Indirizzo è obbligatorio  ");
	 document.uploadForm.indirizzo.focus();
	 return false;
  }
  if (document.uploadForm.provincia.value.length==0){
     alert ("Attenzione! Il campo Provincia è obbligatorio  ");
	 document.uploadForm.provincia.focus();
	 return false;
  }

  if (document.uploadForm.citta.value.length==0){
     alert ("Attenzione! Il campo Città è obbligatorio  ");
	 document.uploadForm.citta.focus();
	 return false;
  }

   if (document.uploadForm.cap.value.length==0){
     alert ("Attenzione! il campo Cap è obbligatorio");
	 document.uploadForm.cap.focus();
	 return false;
  }

   if (document.uploadForm.telefono.value.length==0){
     alert ("Attenzione! il campo Telefono è obbligatorio");
	 document.uploadForm.telefono.focus();
	 return false;
  }
   if (document.uploadForm.email.value.length==0){
     alert ("Attenzione! il campo Email è obbligatorio");
	 document.uploadForm.email.focus();
	 return false;
  }


  if (document.uploadForm.userid.value.length==0){
    alert ("Attenzione! Il campo Userid è obbligatorio");
 return false;
  }else  if (document.uploadForm.userid.value.length<5){
    alert ("Attenzione! Il campo Userid deve contenere almeno 5 caratteri");
 return false;
  }
  if (document.uploadForm.password.value.length==0){
     alert ("Attenzione! Il campo Password è obbligatorio");
 return false;
  }else  if (document.uploadForm.password.value.length<5){
    alert ("Attenzione! Il campo Password deve contenere almeno 5 caratteri");
 return false;
  }else if (document.uploadForm.password.value!=document.uploadForm.password2.value){
     alert ("Attenzione! Il campo Password e il Campo Conferma password non coincidono");
 return false;
  }
  return true;
}

function validateEmail(field) {
  if(field.value.length>0){
    if ((field.value.indexOf("@") == -1) || (field.value.indexOf(".") == -1) || (field.value.length < 7)) {
      alert("Indirizzo Email non valido")
      field.select()
      return false
    }
  }
  return true
}

function doInsert_user(){
if(document.uploadForm.consenso_acquisto[0].checked){
 if (document.uploadForm.consenso_675[0].checked){
 if (check_form()&&validateEmail(document.uploadForm.email)){
    changeData();
    document.uploadForm.azione.value="121";
	document.uploadForm.submit();

 }
 }else {
  alert("Attenzione : E' richiesto il Consenso al Trattamento dei Dati Personali")
}
}else {
  alert("Attenzione : E' richiesta l'accettazione delle Condizioni generali di Vendita")
}



}

function doModify_user(){

 if (check_form()&&validateEmail(document.uploadForm.email)){
    changeData();
    document.uploadForm.azione.value="123";
	document.uploadForm.submit();

 }




}

//----data nascita----
function setDataStore(){
  datadb=document.uploadForm.datadinascita.value
  if(datadb.length > 0){
    document.uploadForm.anno.value= datadb.substring(0,4);
    document.uploadForm.mese.value= datadb.substring(5,7);
    document.uploadForm.giorno.value= datadb.substring(8,10);
    document.uploadForm.datadinascita.value= document.uploadForm.anno.value+"-"+document.uploadForm.mese.value+"-"+document.uploadForm.giorno.value
  }
}

function changeData(){
  indday   =   document.uploadForm.giorno.value
  indmonth =   document.uploadForm.mese.value
  indyear  =   document.uploadForm.anno.value
  document.uploadForm.datadinascita.value= document.uploadForm.anno.value+"-"+document.uploadForm.mese.value+"-"+document.uploadForm.giorno.value
}
