

function verifCreationCompte(){
    var bPass = true;
    var aChampObligatoire = new Array("nom","login","mdp","confirmation");//On définis ici les champs obligatoires
    
    for(var i in aChampObligatoire){
        if(document.getElementById(aChampObligatoire[i]) && 
            document.getElementById(aChampObligatoire[i]).value == ""){
            bPass = false;
            break;
        }
    }
    
    if(bPass == true){
        return true;
    }else{
        alert('Tous champs marqué d\'une * sont obligatoires');
        document.getElementById(aChampObligatoire[i]).style.border = "1px solid #CC0000";
        document.getElementById(aChampObligatoire[i]).focus();
        return false;
    }       
}

function confirmeCreationCompte(){
    if((document.getElementById('mdp').value == document.getElementById('confirmation').value) && 
       ( (document.getElementById('mdp').value != "") || (document.getElementById('confirmation').value!="") ) ){
       
       document.getElementById('form').submit();
    }else{
       alert('Vous devez confirmer votre mot de passe');    
       document.getElementById('confirmation').style.border = "1px solid #CC0000";
       document.getElementById('confirmation').focus();
    }
}


function verifCreationDossier(){
    var bPass = true;
    var aChampObligatoire = new Array("nom", "adresse", "cp", "ville", "mt_principal", "reference");//On définis ici les champs obligatoires
    
    for(var i in aChampObligatoire){
        if(document.getElementById(aChampObligatoire[i]) && 
            document.getElementById(aChampObligatoire[i]).value == ""){
            bPass = false;
            break;
        }
    }
        
    if(bPass == true){
        return true;
    }else{
        alert('Tous champs marqué d\'une * sont obligatoires');
        document.getElementById(aChampObligatoire[i]).style.border = "1px solid #CC0000";
        document.getElementById(aChampObligatoire[i]).focus();
        return false;
    }
}

function verifMtPrincipal(){
        if(isNaN(parseFloat(document.getElementById('mt_principal').value)) || (parseFloat(document.getElementById('mt_principal').value)<=parseFloat(0))){
            alert('Vous devez spécifier un montant supérieur à 0');
            document.getElementById('mt_principal').style.border = "1px solid #CC0000";
            document.getElementById('mt_principal').focus();
            return false;
        }else{
            document.getElementById('form').submit();
        }
}


function DateHeure(){
    var dayarray=new Array("Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi")
    var montharray=new Array("janvier","f&eacute;vrier","mars","avril","mai","juin","juillet","ao&ucirc;t","septembre","octobre","novembre","d&eacute;cembre")

    thistime= new Date();
    var year=thistime.getFullYear()
    var day=thistime.getDay()
    var month=thistime.getMonth()
    var daym=thistime.getDate()
    var hours=thistime.getHours();
    var minutes=thistime.getMinutes();
    var seconds=thistime.getSeconds();

    if (eval(hours) <10) {hours="0"+hours;}
    if (eval(minutes) < 10) {minutes="0"+minutes;}
    if (seconds < 10) {seconds="0"+seconds;}
    thistime = "<strong>"+dayarray[day]+" "+daym+" "+montharray[month]+" "+year+"<br>"+hours+":"+minutes+":"+seconds+"</strong>";
    document.getElementById('DateHeure').innerHTML=thistime;
    
    timer=setTimeout("DateHeure()", 1000);
}

function verifChampsObligatoires(p_form,p_arrayListeChamp){
    if(p_form!=""){
      for(i=0;i<=(p_form.length-1);i++){
         if(p_form[i].value == ""){
           alert("Tous les champs sont obligatoires");
           p_form[i].focus();
           return false;
         }
      }
      return true;
    }else{
       for(var i in p_arrayListeChamp){
         if(document.getElementById(p_arrayListeChamp[i]) && document.getElementById(p_arrayListeChamp[i]).value == ""){
           alert("Tous les champs sont obligatoires");
           document.getElementById(p_arrayListeChamp[i]).focus();
           return false;
         }
       }
       return true;
    }
}

function load_content() {
    if (!parent.document.getElementById('main_div')) {
    window.location=('index.html') ;
    }
    parent.document.getElementById('cont').style.height = document.getElementById('inner_frame').offsetHeight+"px";
}

function ScrollUp(){
    parent.window.scrollTo(0,0);    
}

function verifMail(p_champ){
    var email     = p_champ.value;
    var verif     = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]{2,}[.][a-zA-Z]{2,3}$/
    if (verif.exec(email) == null){
       alert('Votre email est incorrect');
       return false;
    }
    return true;
}

function verifNumTelFax(p_champ){
     var exp = new RegExp("^[0-9]+$","g");
     if(exp.test(p_champ.value) == false){
         alert('Votre numéro de téléphone et/ou fax est incorrect');
         p_champ.focus();
         return false;
     }
     return true;
}

function verifMontant(p_montant){
   var verif     =  /^\d+([\.|,])?\d+$/;
   if (verif.exec(p_montant.value) == null){
       alert('Votre montant est incorrect');
       return false;
    }
   return false;
}

function verifNumDossier(p_champ){
     var exp = new RegExp("^[0-9]+$","g");
     if(exp.test(p_champ.value) == false){
         alert('Votre numéro de dossier est incorrect');
         p_champ.focus();
         return false;
     }
     return true;
}
