/* ALIGNEMENT VERTICAL */
// Recupere la taille de la fenetre pour un alignement vertical
function getWindowHeight() {
    var windowHeight = 0;
    if (typeof(window.innerHeight) == 'number') {
        windowHeight = window.innerHeight;
    }
    else {
        if (document.documentElement && document.documentElement.clientHeight) {
            windowHeight = document.documentElement.clientHeight;
        }
        else {
            if (document.body && document.body.clientHeight) {
                windowHeight = document.body.clientHeight;
            }
        }
    }
    return windowHeight;
}

// Effectue l'alignement vertical sur l'identifiant 'content'
function setContent() {
    if (document.getElementById) {
        var windowHeight = getWindowHeight();
        if (windowHeight > 0) {
            var contentElement = document.getElementById('content');
            var contentHeight = contentElement.offsetHeight;
                //alert((windowHeight / 2) - (contentHeight / 2));
            if (windowHeight - contentHeight > 0) {
                contentElement.style.position = 'relative';
                contentElement.style.top = ((windowHeight / 2) - (contentHeight / 2)) + 'px';
            }
            else {
                contentElement.style.position = 'static';
            }
        }
    }
    montre();
}
/**********************************************************/

/* Navigation au travers des menus verticaux-horizontaux */
function montre(id) {
    var d = document.getElementById(id);
        for (var i = 1; i<=10; i++) {
            if (document.getElementById('niveau'+i)) {
                document.getElementById('niveau'+i).style.display='none';
            }
        }
    if (d) {d.style.display='block';}
}

/* Affichage d'une information */
function montrez(id,statut) {
    var d = document.getElementById(id);
    if(statut != ""){
        if (d) {d.style.display=statut;}
    }
    else{
        if (d) {
            if(d.style.display == "block"){statut = "none";}
            else statut = "block";
            d.style.display=statut;
        }
    }
}
/**********************************************************/

/* Ajout d'une information dans une listebox complexe */
function add_info(element,label){
   var comment;
   comment=prompt("Quelle information voulez-vous ajouter au niveau de la liste \"" + label + "\" ?","");
   if(comment != null) {
        document.forms[0].elements[element].value = comment
   }
}
/******************************************************/

// Initialisation à l'ouverture de la page
window.onload = function() {
    setContent();
}

// Initialisation au moment du redimensionnement de la page
window.onresize = function() {
    setContent();
}
function check_entry()
{
    var error_msg ='';
    var res = 0;
    if(!document.form1.email.value.match(/^[\w\._-]+@{1}[\w\._-]+\.{1}([\w_-]+)*$/g)){
        error_msg += 'Votre adresse e-mail est erronée.\n';
        res = 1;
    }
    if ( document.form1.To.value == 'X' ) {
        error_msg += 'Aucun sujet de selectionné.\n';
        res = 1;
    }
    if ( document.form1.nom.value == '' ) {
        error_msg += 'Le champ nom n\'est pas rempli.\n';
        res = 1;
    }
    if ( document.form1.prenom.value == '' ) {
        error_msg += 'Le champ prenom n\'est pas rempli.\n';
        res = 1;
    }
    if ( document.form1.sujet.value == '' ) {
        error_msg += 'L\'objet n\'est pas rempli.\n';
        res = 1;
    }
    if ( document.form1.message.value == '' ) {
        error_msg += 'Le message n\'est pas rempli.\n';
        res = 1;
    }
    if(error_msg != ""){
        error_msg = error_msg + "\n Merci de recommencer.\n";
        alert(error_msg);
        if(res == 1){
            document.form1.email.focus();
        }
        return false;
    }
    else{
        return true;
    }
}
