/*####################################################
########## FORMULARI DE CONTACTE #####################
####################################################*/
function validateFormContacte(thisform){
var digits=" .-,/+0123456789";
var temp;
var idioma = thisform.idioma.value;

switch(idioma){
case "1":
  error_nom = "Ha d'indicar el seu nom"
	error_tel = "Ha d'indicar el seu telèfon"
	error_tel2 = "Format de telèfon incorrecte"
	error_mail = "Ha d'indicar el seu e-mail"
	error_mail2 = "Format e-mail incorrecte"
	error_miss = "Ha d'indicar el seu missatge"
  break;
case "2":
  error_nom = "Debe indicar su nombre"
	error_tel = "Debe indicar su teléfono"
	error_tel2 = "Formato de teléfono incorrecto"
	error_mail = "Debe indicar su e-mail"
	error_mail2 = "Formato e-mail incorrecto"
	error_miss = "Debe indicar su mensaje"
  break;
default:
  idioma = 1;
}

if (thisform.nom.value==""){
	 alert(error_nom);
	 thisform.nom.focus();
	 return false;
	 }
if (thisform.telefon.value==""){
	 alert(error_tel);
	 thisform.telefon.focus();
	 return false;
	 }
if (thisform.telefon.value!=""){
    for (var i=0;i<thisform.telefon.value.length;i++){
      temp=thisform.telefon.value.substring(i,i+1)
      if (digits.indexOf(temp)==-1){
        alert(error_tel2);
        thisform.telefon.focus();
        return false;
      }
    }
    }
if (thisform.email.value==""){
	 alert(error_mail);
	 thisform.email.focus();
	 return false;
	 }
if (thisform.email.value!="") {
    if (thisform.email.value.indexOf("@")==-1 || thisform.email.value.indexOf(".")==-1 || thisform.email.value.indexOf(" ")!=-1 || thisform.email.value.length<6) {
      alert(error_mail2);
      thisform.email.focus();
      return false;
    }
    }
if (thisform.missatge.value==""){
	 alert(error_miss);
	 thisform.missatge.focus();
	 return false;
	 }
else return true;
}

/*####################################################
################# LOGIN USUARI #######################
####################################################*/
function validateFormLogin(thisform){
var idioma = thisform.idioma.value;
switch(idioma){
case "1":
	error_mail = "Ha d'indicar el seu e-mail."
	error_mail2 = "Format e-mail incorrecte."
	error_password = "Ha d'indicar la contrassenya."
	error_passshort = "La contrassenya ha de tenir com a mínim 5 caràcters."
  break;
case "2":
	error_mail = "Debe indicar su e-mail."
	error_mail2 = "Formato e-mail incorrecto."
	error_password = "Debe indicar su contraseña."
	error_passshort = "La contraseña tiene que tener como  mínimo 5 carácteres."
  break;
default:
  idioma = 1;
}

if (thisform.mail.value==""){
	 alert(error_mail);
	 thisform.mail.focus();
	 return false;
	 }
if (thisform.mail.value!="") {
    if (thisform.mail.value.indexOf("@")==-1 || thisform.mail.value.indexOf(".")==-1 || thisform.mail.value.indexOf(" ")!=-1 || thisform.mail.value.length<6) {
      alert(error_mail2);
      thisform.mail.focus();
      return false;
    }
    }
if (thisform.password.value==""){
	 alert(error_password);
	 thisform.password.focus();
	 return false;
	 }
if (thisform.password.value.length<5){
	 alert(error_passshort);
	 thisform.password.focus();
	 return false;
	 }
else return true;
}

/*####################################################
########## REGISTRE NOU USUARI #######################
####################################################*/
function validateFormAltauser(thisform){
var digits=" .-,/+0123456789";
var temp;
var idioma = thisform.idioma.value;
switch(idioma){
case "1":
	error_nom = "Ha d'indicar el seu nom."
	error_cognoms = "Ha d'indicar el seus cognoms."
	error_notel = "Ha d'indicar un telèfon."
	error_telfix = "Format de telèfon fix incorrecte."
	error_telmob = "Format de telèfon mòbil incorrecte."
	error_mail = "El camp e-mail és obligatori."
	error_mail2 = "Format e-mail incorrecte."
	error_password = "El camp contrassenya és obligatori."
	error_passshort = "La contrassenya ha de tenir com a mínim 5 caràcters."
	error_confpass = "El camp confirmar contrassenya és obligatori."
	error_passnomatch = "Les contrassenyes introduïdes no coincideixen."
  break;
case "2":
	error_nom = "Debe indicar su nombre."
	error_cognoms = "Debe indicar sus apellidos."
  error_notel = "Debe indicar un teléfono."
	error_telfix = "Formato de teléfono fijo incorrecto."
	error_telmov = "Formato de teléfono móvil incorrecto."
	error_mail = "El campo e-mail es obligatorio."
	error_mail2 = "Formato e-mail incorrecto."
	error_password = "El campo contraseña es obligatorio."
	error_passshort = "La contraseña tiene que tener como  mínimo 5 carácteres."
	error_confpass = "El campo confirmar contraseña es obligatorio."
	error_passnomatch = "Las contraseñas introducidas no coinciden."

  break;
default:
  idioma = 1;
}

if (thisform.nom.value==""){
	 alert(error_nom);
	 thisform.nom.focus();
	 return false;
	 }
if (thisform.cognoms.value==""){
	 alert(error_cognoms);
	 thisform.cognoms.focus();
	 return false;
	 }
if (thisform.telmob.value=="" && thisform.telfix.value==""){
	 alert(error_notel);
	 thisform.telfix.focus();
	 return false;
	 }
if (thisform.telfix.value!=""){
    for (var i=0;i<thisform.telfix.value.length;i++){
      temp=thisform.telfix.value.substring(i,i+1)
      if (digits.indexOf(temp)==-1){
        alert(error_telfix);
        thisform.telfix.focus();
        return false;
      }
    }
    }
if (thisform.telmob.value!=""){
    for (var i=0;i<thisform.telmob.value.length;i++){
      temp=thisform.telmob.value.substring(i,i+1)
      if (digits.indexOf(temp)==-1){
        alert(error_telmob);
        thisform.telmob.focus();
        return false;
      }
    }
    }
if (thisform.email.value==""){
	 alert(error_mail);
	 thisform.email.focus();
	 return false;
	 }
if (thisform.email.value!="") {
    if (thisform.email.value.indexOf("@")==-1 || thisform.email.value.indexOf(".")==-1 || thisform.email.value.indexOf(" ")!=-1 || thisform.email.value.length<6) {
      alert(error_mail2);
      thisform.email.focus();
      return false;
    }
    }
if (thisform.password.value==""){
	 alert(error_password);
	 thisform.password.focus();
	 return false;
	 }
if (thisform.password.value.length<5){
	 alert(error_passshort);
	 thisform.password.focus();
	 return false;
	 }
if (thisform.confpass.value==""){
	 alert(error_confpass);
	 thisform.confpass.focus();
	 return false;
	 }
if (thisform.confpass.value.length<5){
	 alert(error_passshort);
	 thisform.confpass.focus();
	 return false;
	 }
if (thisform.password.value!=thisform.confpass.value){
	 alert(error_passnomatch);
	 thisform.password.value="";
	 thisform.confpass.value="";
	 thisform.password.focus();
	 return false;
	 }
else return true;
}

/*####################################################
############# RECORDATORI PASSWORD ###################
####################################################*/
function validateFormRecordapass(thisform){
var idioma = thisform.idioma.value;
switch(idioma){
case "1":
	error_mail = "Ha d'indicar el seu e-mail."
	error_mail2 = "Format e-mail incorrecte."
  break;
case "2":
	error_mail = "Debe indicar su e-mail."
	error_mail2 = "Formato e-mail incorrecto."
  break;
default:
  idioma = 1;
}

if (thisform.email.value==""){
	 alert(error_mail);
	 thisform.email.focus();
	 return false;
	 }
if (thisform.email.value!="") {
    if (thisform.email.value.indexOf("@")==-1 || thisform.email.value.indexOf(".")==-1 || thisform.email.value.indexOf(" ")!=-1 || thisform.email.value.length<6) {
      alert(error_mail2);
      thisform.email.focus();
      return false;
    }
    }
else return true;
}