// ENLEVE LE FOCUS SUR LES LIENS
function blurLinks() {
    lnks = document.getElementsByTagName('a');
    for (i = 0; i < lnks.length; i++) {
        lnks[i].onfocus = new Function("if(this.blur) this.blur()");
    }
    lnks2 = document.getElementsByTagName('area');
    for (j = 0; j < lnks2.length; j++) {
        lnks2[j].onfocus = new Function("if(this.blur) this.blur()");
    }
}


// LANCE UNE FONCTION AU CHARGEMENT DE LA PAGE
function addOnloadEvent(fnc) {
    if (typeof window.addEventListener != "undefined")
        window.addEventListener("load", fnc, false);
    else if (typeof window.attachEvent != "undefined") {
        window.attachEvent("onload", fnc);
    }
    else {
        if (window.onload != null) {
            var oldOnload = window.onload;
            window.onload = function(e) {
                oldOnload(e);
                window[fnc]();
            };
        }
        else
            window.onload = fnc;
    }
}


function maxlength(text, length) { if (text.value.length > length) text.value = text.value.substr(0, length); }

function cache(objet) {
    document.getElementById(objet).style.display = 'none';
}
function montre(objet) {
    document.getElementById(objet).style.display = '';
}

function openPopUp(fichier, nom, largeur, hauteur, options) {
    var id = nom;
    var gauche = (screen.width - largeur) / 2;
    var haut = (screen.height - hauteur) / 2;
    if (options) {
        options = 'width=' + largeur + 'px, height=' + hauteur + 'px,  top=' + haut + ', left=' + gauche + ', ' + options;
    }
    else {
        options = 'width=' + largeur + 'px, height=' + hauteur + 'px,  top=' + haut + ', left=' + gauche;
    }
    document.open(fichier, id, options);
}

var ok = "#FFFFFF";
var nok = "#FFE3C5";


function check_form_mail(f) {
    var txt = document.getElementById(f);
    var syntaxe_mail = new RegExp("^[a-zA-Z0-9]{1}[a-zA-Z0-9\-\._]*@[\-a-zA-Z0-9\._]+[\.]{1}[a-zA-Z]{2,4}$", "");
    if (!syntaxe_mail.test(txt.value)) {
        txt.style.background = nok;
        alert("Erreur de syntaxe dans l'adresse mail !");
        return false;
    }
    else {
        txt.style.background = ok;
        return true;
    }
}

function check_form() {
    var retour = true;

    var txtPrenom = document.getElementById("ctl00_ContentPlaceHolder1_txtPrenom");
    var txtVille = document.getElementById("ctl00_ContentPlaceHolder1_txtVille");
    var txtCodePostal = document.getElementById("ctl00_ContentPlaceHolder1_txtCodePostal");
    var txtTemoignage = document.getElementById("ctl00_ContentPlaceHolder1_txtTemoignage");
    if (!txtPrenom.value) {
        txtPrenom.style.background = nok;
        retour = false;
    } else { txtPrenom.style.background = ok; }

    if (!txtVille.value) {
        txtVille.style.background = nok;
        retour = false;
    } else { txtVille.style.background = ok; }

    if (!txtCodePostal.value) {
        txtCodePostal.style.background = nok;
        retour = false;
    } else { txtCodePostal.style.background = ok; }

    if (!txtTemoignage.value) {
        txtTemoignage.style.background = nok;
        retour = false;
    } else { txtTemoignage.style.background = ok; }


    if (retour) {
        return true;
    }
    else {
        return false;
    }
}