    /*FONCTIONS DIVERSES*/
    /**************************************************************************/
    function verif_email(email) {
    	var place = email.indexOf("@",1);
    	var point = email.indexOf(".",place+1);
    	return ((place > -1) && (email.length >2) && (point > 1));
    }
    function verif_url(url) {
    	var point = url.indexOf(".",1);
    	return ((url.length >2) && (point > 1));
    }
    function verif_cond() {
      var choice = false;
      if (document.getElementsByName("cond_inscription")[0].checked) choice = true;
      if (!choice) return (false);

      return (true);
    }


    /*ANALYSER L'ETAPE 1*/
    /**************************************************************************/
    function controle_register_step1() {
        validity = true; alert_msg="";
        
        /*Champs tous complets*/
        if (document.form.prest_nom.value=="" || document.form.prest_assujetti.value=="" || 
            document.form.prest_mdp1.value=="" || 
            document.form.prest_quartier.value=="0" || document.form.prest_adresse.value=="" || 
            document.form.prest_email.value=="" || document.form.prest_tel.value=="" || 
            document.form.prest_nom_responsable.value=="" || document.form.prest_prenom_responsable.value=="" || 
            document.form.prest_statut_responsable.value=="") {
          alert_msg+="-Veuillez remplir les champs obligatoires: \n";
          validity = false;
        }
        

        if(document.form.prest_nom.value=="") alert_msg+="nom de l'hotel, ";
        if(document.form.prest_assujetti.value=="") alert_msg+="numero de TVA, ";
        if(document.form.prest_mdp1.value=="") alert_msg+="mot de passe, ";
        if(document.form.prest_quartier.value=="0") alert_msg+="quartier, ";
        if(document.form.prest_adresse.value=="") alert_msg+="adresse, ";
        if(document.form.prest_email.value=="") alert_msg+="adresse email, ";
        if(document.form.prest_tel.value=="") alert_msg+="numero de telephone, ";
        if(document.form.prest_nom_responsable.value=="") alert_msg+="nom du responsable, ";
        if(document.form.prest_prenom_responsable.value=="") alert_msg+="prenom du responsable, ";
        if(document.form.prest_statut_responsable.value=="") alert_msg+="statut du responsable, ";
        if (validity==false) alert_msg=alert_msg.substring(0, (alert_msg.length)-2)+"\n";
        
        
        /*Format d'url correct*/
        if(document.form.prest_url.value!="") {
          if (!verif_url(document.form.prest_url.value)) {
		        validity=false;
		        alert_msg+="-Votre adresse url n'est pas au bon format!\n";
          }
        }
        /*Numero de TVA*/
        if(document.form.prest_assujetti.value!="") {
          if (document.form.prest_assujetti.value.length!=13) {
		        validity=false;
            alert_msg+="-Votre numéro de TVA est invalide!\n";
          }
        }
        /*Mots de passe différents*/
        if(document.form.prest_mdp1.value!="" || document.form.prest_mdp2.value!="") {
          if (document.form.prest_mdp1.value!=document.form.prest_mdp2.value) {
		        validity=false;
		        alert_msg+="-Le mot de passe entré et sa confirmation doivent être identiques!\n";
          }
        }
        /*Format d'email correct*/
        if(document.form.prest_email.value!="") {
          if (!verif_email(document.form.prest_email.value)) {
		        validity=false;
		        alert_msg+="-Votre adresse email n'est pas au bon format!\n";
          }
        }
        /*Format de l'image*/
        var champ=document.getElementById("ID_prest_image").value;
  	    var point = champ.lastIndexOf(".");
  	    var extension=champ.substr(point+1).toLowerCase();
        
        if (champ.length>0) {
          if (extension!="jpg" && extension!="jpeg" && extension!="png" && extension!="gif" && extension!="bmp") {
            alert_msg+="-Votre photo n'est pas au bon format!\n";
            validity=false;
          }
        }
        /*Conditions acceptées*/
        if (!verif_cond()) {
            validity=false;
            alert_msg+="-Vous n'avez pas accepté les conditions d'inscription au bas du formulaire.\n";
        }

        if (champ.length==0 && validity==true) {
          if (!confirm("Vous n'avez pas choisis de photos pour votre hotel! Cela peut pourtant significativement augmenter vos chances de réservation. Voulez vous continuer?"))
            validity=false;
        }

    
        if (alert_msg!="") {
          alert(""+alert_msg+"");
        }
        return validity;
    }            


    /*ANALYSER L'ETAPE 2*/
    /**************************************************************************/
    function controle_register_step2() {
        validity = true; alert_msg="";
        
    
        if (alert_msg!="") {
          alert(""+alert_msg+"");
        }
        return validity;
    }            


    /*ANALYSER L'ETAPE 3*/
    /**************************************************************************/
    function controle_register_step3(max_photos) {
        validity = true; alert_msg="";
        var incomplet=1;
        
        /*Photos au bon format*/
        for (i_photo=0;i_photo<max_photos;i_photo++) {
          var champ=document.getElementById("ID_photo_"+i_photo+"_detail").value;
    	    var point = champ.lastIndexOf(".");
    	    var extension=champ.substr(point+1).toLowerCase();
          
          if (champ.length>0) {
            incomplet=0;  //Avertir un champ minimum de remplit
            
            if (extension!="jpg" && extension!="jpeg" && extension!="png" && extension!="gif" && extension!="bmp") {
              alert_msg+="-La photo n°"+(i_photo+1)+" n'est pas au bon format!\n";
              validity=false;
            }
          }
        }

        /*Aucune photo choisie*/
        if (incomplet==1 && validity==true) {
          if (!confirm("Vous n'avez pas choisis de photos! Cela peut pourtant significativement augmenter vos chances de réservation. Voulez vous continuer?"))
            validity=false;
        }
    
        if (alert_msg!="") {
          alert(""+alert_msg+"");
        }
        return validity;
    }            


    /*ANALYSER L'ETAPE 4*/
    /**************************************************************************/
    function controle_register_step4(max_chbrs) {
        validity = true; alert_msg="";
        incomplet=1;
        
        /*Chambres correctement remplies*/
        for (i_chbr=0;i_chbr<max_chbrs;i_chbr++) {
          var sous_type=document.getElementsByName("sous_type_chbr_"+i_chbr+"")[0].value;
          var qte_chambre=document.getElementsByName("qte_chbr_"+i_chbr+"")[0].value;
          
          if (sous_type!="0" || qte_chambre!="0") {
            if (sous_type=="0" || qte_chambre=="0") {
                alert_msg+="-La chambre n°"+(i_chbr+1)+" n'est pas correctement renseignée! Merci d'indiquer: ";
                if (sous_type=="0") alert_msg+="la catégorie, ";
                if (qte_chambre=="0") alert_msg+="le nombre total de ce type de chambre, ";
  
                alert_msg=alert_msg.substring(0, (alert_msg.length)-2)+"\n";
                validity=false;
            }
            else {
              incomplet=0;
            }
          }
        }

        /*Aucune chambre renseignée*/
        if (incomplet==1 && validity==true) {
          alert_msg+="Vous n'avez pas ajouté de chambres! Cela est obligatoire pour terminer votre inscription.\n";
          validity=false;
        }

    
        if (alert_msg!="") {
          alert(""+alert_msg+"");
        }
        return validity;
    }            
