function validerMailing (objForm){
    if (objForm.txtNom.value == null || objForm.txtNom.value == ""){
        window.alert("Veuillez entrer votre nom."); 
        objForm.txtNom.focus();
        return false;
    }
    if (objForm.txtPrenom.value == null || objForm.txtPrenom.value == ""){
        window.alert("Veuillez entrer votre prenom."); 
        objForm.txtPrenom.focus();
        return false;
    }
    if (objForm.txtCodePostal.value == null || objForm.txtCodePostal.value == ""){
        window.alert("Veuillez entrer votre code postal."); 
        objForm.txtCodePostal.focus();
        return false;
    }
    if (objForm.txtCourriel.value == null || objForm.txtCourriel.value == ""){
        window.alert("Veuillez entrer votre courriel."); 
        objForm.txtCourriel.focus();
        return false;
    }
    
    if (!validerCourriel(objForm.txtCourriel.value)){
       alert("Adresse de courriel non valide")
       return false;                
    }
    
    return true;   
}

function validerCourriel(str) {
    var at="@"
    var dot="."
    var lat=str.indexOf(at)
    var lstr=str.length
    var ldot=str.indexOf(dot)

    if (str.indexOf(at)==-1){
        return false;
    }

    if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
        return false;
    }

    if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
        return false;
    }

    if (str.indexOf(at,(lat+1))!=-1){
        return false;
    }

    if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
        return false;
    }

    if (str.indexOf(dot,(lat+2))==-1){
        return false;
    }
    
    if (str.indexOf(" ")!=-1){
        return false;
    }
    
    return true;
}

function validerFormPromo (objForm,validImage){
    if (objForm.txtTitre.value == null || objForm.txtTitre.value == ""){
        window.alert("Veuillez entrer un titre."); 
        objForm.txtTitre.focus();
        return false;
    }
    if (objForm.txtDescription.value == null || objForm.txtDescription.value == ""){
        window.alert("Veuillez entrer une description."); 
        objForm.txtDescription.focus();
        return false;
    }
    if (objForm.txtConditions.value == null || objForm.txtConditions.value == ""){
        window.alert("Veuillez entrer les conditions qui s'appliquent à la promotion."); 
        objForm.txtConditions.focus();
        return false;
    }
    if (objForm.txtPrix.value == null || objForm.txtPrix.value == ""){
        window.alert("Veuillez entrer le prix."); 
        objForm.txtPrix.focus();
        return false;
    }
    if (isNaN(objForm.txtPrix.value)){              
        window.alert("Le prix entré n'est pas une valeur numérique'"); 
        objForm.txtPrix.focus(); 
        return false;
    }
    if (validImage){
        if (objForm.fileImage.value == null || objForm.fileImage.value == ""){
            window.alert("Veuillez entrer l'image du produit."); 
            return false;
        }         
    }
               
    return true;                       
}    