/* 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 setContents() {
    if (document.getElementById) {
        var windowHeight = getWindowHeight();
        if (windowHeight > 0) {
            var contentElement = document.getElementById('content_vertical');
            var contentHeight = contentElement.offsetHeight;
            if (contentHeight == 0) contentHeight = windowHeight;
            //alert(windowHeight + " - " + contentHeight);
            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<=20; i++) {
            if (document.getElementById('niveau'+i)) {
                document.getElementById('niveau'+i).style.display='none';
            }
        }
    if (d) {d.style.display='block';}
}
/**********************************************************/

/* Montre ou cache un element */
function montre_statut(id,statut) {
    var d = document.getElementById(id);
    if (d) {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() {
    setContents();
}

// Initialisation au moment du redimensionnement de la page
window.onresize = function() {
    setContents();
}
/******************************************************/
// Ouvrir popup
function OpenWindow(theURL,features) {
    window.open(theURL,'',features+',top='+((screen.height-600)/2)+',left='+((screen.width-600)/2));
}
