function init_presentation() {
    obj = ID("presentation");
    ligne = obj.childNodes[0];
    while( ligne.nodeName != "A" )
        ligne = ligne.nextSibling;
    ligne = ligne.childNodes[0];
    while( ligne.nodeName != "IMG" )
        ligne = ligne.nextSibling;
    obj.the_image = ligne;
    obj.a = 0;
    obj.longeur = ligne.offsetHeight;
    obj.largeur = ligne.offsetWidth;
    obj.style.height = parseInt(ligne.offsetHeight /2) + 'px';
    obj.style.width = parseInt(ligne.offsetWidth /2) + 'px';
    ligne.style.height = obj.style.height;
    ligne.style.width = obj.style.width;
    ligne.style.display = "block";
    if( getIEVersion() ) {
        ligne.attachEvent("onmouseover", agrandi );
        ligne.attachEvent("onmouseout", retreci );
    } else {
        atribut = document.createAttribute("onmouseover");
        atribut.nodeValue = "agrandi('presentation')";
        ligne.attributes.setNamedItem(atribut);
        atribut = document.createAttribute("onmouseout");
        atribut.nodeValue = "retreci('presentation')";
        ligne.attributes.setNamedItem(atribut);
    }
}   

function agrandi( id ) {
    id = source_event(id);
    obj = ID( id );
    if( obj.a == 0 ) {
        if( obj.offsetHeight < 0.98*obj.longeur ) {
            obj.style.height = parseInt(obj.offsetHeight + (obj.longeur-obj.offsetHeight)*0.2) + 'px';
            obj.style.width = parseInt(obj.offsetWidth + (obj.largeur-obj.offsetWidth)*0.2) + 'px';
            obj.the_image.style.height = obj.style.height;
            obj.the_image.style.width = obj.style.width;
            agrandi_time = setTimeout("agrandi('" + id + "');",20);
        } else {
            obj.style.height = parseInt(0.98*obj.longeur) + 'px';
            obj.style.width = parseInt(0.98*obj.largeur) + 'px';
            obj.the_image.style.height = obj.offsetHeight + 'px';
            obj.the_image.style.width = obj.offsetWidth + 'px';
            obj.a = 1;
        }
    } else {
        obj.a = 0;
        clearTimeout(retreci_time);
        agrandi_time = setTimeout("agrandi('" + id + "');",20);
    }
}   


function retreci( id ) {
    id = source_event(id);
    obj = ID( id );
    if( obj.a == 1 ) {
        if( obj.offsetHeight > 1.02*(obj.longeur/2) ) {
            obj.style.height = parseInt(obj.offsetHeight - (obj.offsetHeight-obj.longeur/2) *0.2) + 'px';
            obj.style.width = parseInt(obj.offsetWidth - (obj.offsetWidth-obj.largeur/2)*0.2) + 'px';
            obj.the_image.style.height = obj.style.height;
            obj.the_image.style.width = obj.style.width;
            retreci_time = setTimeout("retreci('" + id + "');",20);
        } else {
            obj.style.height = parseInt(1.02*obj.longeur/2) + 'px';
            obj.style.width = parseInt(1.02*obj.largeur/2) + 'px';
            obj.the_image.style.height = obj.offsetHeight + 'px';
            obj.the_image.style.width = obj.offsetWidth + 'px';
            obj.a = 0;
        }
    } else {
        obj.a = 1;
        clearTimeout(agrandi_time);
        retreci_time = setTimeout("retreci('" + id + "');",20);
    }
}



//test navigateur

function getIEVersion() {
    nav = navigator.userAgent;
    if( nav.indexOf("MSIE ") != -1 )
        return nav.substr(nav.indexOf("MSIE ") + 5,1);
    else
        return false;
}

function ligne_over(ev) {
//log(source_event(ev));
obj = ID(source_event(ev));
    obj.style.backgroundImage = 'url(\'images/m1hov.jpg\')';
    contenu_over(obj.parentNode.parentNode.parentNode.parentNode.parentNode.id);
}

function ligne_no_over(ev) {
//log(source_event(ev));
obj = ID(source_event(ev));
    obj.style.backgroundImage = 'url(\'images/m1.jpg\')';
    //debugger;
    onglet_out(ev);
}



function log() {
    if( !getIEVersion() ) {
        var x = log.arguments;
        liste = x[0];
        for(wxcv=1; wxcv<x.length; wxcv++) {
            liste += "," + x[wxcv];
        }
        eval( "console.log('" + liste + "');" );
    } else {
        var x = log.arguments;
        if( debug ==  false ) {
            debug = window.open('',"debug","top=50,left=950,width=300,height=500,menubar=no,scrollbars=yes,statusbar=no");
            debug.document.write('<script>debug=self;</script><script src="PortailClient.aspx_fichiers/fonctions.js" type="text/javascript"></script><div style="position:absolute;top:0px;left:140px;width:140px;height:50px"><input size=10 onchange="log(this.value);"><input type="button" value="clear" onclick="document.write(\'</div>\');document.body.removeChild(document.all.le_log);document.write(\'<div id=le_log>\');"></div><div id="le_log">');
            self.focus();
        }
        debug.document.write( x[0] );
        for(wxcv=1; wxcv<x.length; wxcv++) {
            debug.document.write( " , " + x[wxcv] );
        }
        debug.document.write( "<br>" );
    }
}

// onglets
k=0;//nb de lignes dans les onglets
function init_menu( id ) {
    prechargimg();
    obj = ID(id);
    obj.style.height = "20px";
    obj.style.width = "0px";
    obj.style.position='absolute';
    obj2 = obj.childNodes[0];
    while( obj2.nodeName != "TABLE" )
        obj2 = obj2.nextSibling;
    obj2.cellSpacing = 0;
    obj2.cellPadding = 0;
    obj2.style.height = "20px";
    for(i=0;i<obj2.tBodies[0].rows[0].cells.length;i++ ) {
        
        enfant = obj2.tBodies[0].rows[0].cells[i];
        //log(enfant.nodeName);
        enfant.style.height = "20px";
        enfant.style.verticalAlign = "top";
        enfant.taille = 0;
        //enfant.style.backgoundRepeat = "no-repeat";
        enfant.style.position = 'relative';
        enfant.style.width = "200px";
        ligne2 = enfant.childNodes[0];
        while( ligne2.nodeName != "TABLE" )
            ligne2 = ligne2.nextSibling;
        ligne2.cellSpacing = 0;
        ligne2.cellPadding = 0;
        ligne2.style.width = "200px";
        for(j=1;j<ligne2.tBodies[0].rows.length;j++ ) {
            ligne = ligne2.tBodies[0].rows[j].cells[0].childNodes[0];
            ligne.style.textAlign = "center";
            ligne.style.height = "0px";
            ligne.style.overflow = "hidden";
            ligne.style.backgroundImage = 'url(\'images/m1.jpg\')';
            ligne.id = 'ligne' + k++;
            //log( ligne.id, j );
            if( !getIEVersion() ) {
                atribut = document.createAttribute("onmouseover");
                atribut.nodeValue = "contenu_over('onglet" + i + "');this.style.backgroundImage = \"url(\'images/m1hov.jpg\')\";";
                ligne.attributes.setNamedItem(atribut);
                atribut = document.createAttribute("onmouseout");
                atribut.nodeValue = "onglet_out('onglet" + i + "');this.style.backgroundImage = \"url(\'images/m1.jpg\')\";";
                ligne.attributes.setNamedItem(atribut);
            } else {
                ligne.attachEvent("onmouseover", ligne_over );
                ligne.attachEvent("onmouseout", ligne_no_over );
            }
            enfant.taille += 20; 
        }
        enfant.id = 'onglet' + i;
        //log(enfant.id);
        enfant = ligne2.tBodies[0].rows[0].cells[0];
        enfant.style.textAlign = "center";
        enfant.style.backgroundImage = 'url(\'images/ongletappel.gif\')';
        if( !getIEVersion() ) {
            atribut = document.createAttribute("onmouseover");
            atribut.nodeValue = "onglet_over('onglet" + i + "');";
            enfant.attributes.setNamedItem(atribut);
            atribut = document.createAttribute("onmouseout");
            atribut.nodeValue = "onglet_out('onglet" + i + "');";
            enfant.attributes.setNamedItem(atribut);
        } else {
            enfant.attachEvent("onmouseover", onglet_over );
            enfant.attachEvent("onmouseout", onglet_out );
        }
        enfant.style.width = enfant.offsetWidth + 200 + "px";
        if( enfant.previousSibling ) {
            enfant.style.position = 'relative';
            enfant.style.left = enfant.previousSibling.offsetLeft + enfant.previousSibling.offsetWidth + 'px';
            enfant.style.top = '0px';
        }
    }
}

function onglet_over( cible ) { //souris au dessus de l'onglet
    lacible = source_event( cible );
    if( lacible == null )
        debugger;
    objet = ID( lacible );
    objet.a = 1; //a à 1 pour que le timeout s'arrete si on a remis la souris dessu
    objet = objet.childNodes[0];
    while( objet.nodeName != "TABLE" )
        objet = objet.nextSibling;
    grossi(objet.tBodies[0].rows[1].cells[0].childNodes[0].id,20); // on lance l'agrandissement de la div
}

function source_event( ev ) {
    if( ev != null ) {
        if( typeof ev != "string" ) {
            if( getIEVersion() ){
                if( typeof ev.srcElement != "object" ){
                    if( typeof ev.fromElement != "object" ) {
                        lacible = null;
                    } else {
                        truc = ev.fromElement;
                        while( truc.id == "" )
                            truc = truc.parentNode;
                        lacible = truc.id;
                    }
                } else {
                    if( ev.srcElement.id != "" )
                        lacible = ev.srcElement.id;
                    else {
                        truc = ev.srcElement;
                        while( truc.id == "" )
                            truc = truc.parentNode;
                        lacible = truc.id;
                    }
                }
            } else
                return ev;
            return lacible;
        } else
            return ev;
    } else
        return null;
}


function onglet_out( cible ) {
    lacible2 = source_event( cible );
    if( lacible2 != null ) {
        if( lacible2.substr(0,5) == "ligne" )
            lacible2 = ID(lacible2).parentNode.parentNode.parentNode.parentNode.parentNode.id;
            //debugger;
        ID( lacible2 ).a = 0;
        setTimeout('if( ID(\'' + lacible2 + '\').a == 0 ){reduit(\'' + lacible2 + '\');}',75);
    }
}

function contenu_over( cible ) {
    objet = ID( cible );
    objet.b = 1;
    objet.a = 1;
}

function reduit( cible ) {
//debugger;
    objet = ID(cible);
    cible = objet.childNodes[0];
    while( cible.nodeName != "TABLE" )
        cible = cible.nextSibling;
    cible = cible.tBodies[0].rows[1];
    while( cible != null ) {
        if( cible.cells && cible.cells[0].nodeName == "TD" )
            cible.cells[0].childNodes[0].style.height = "0px";
        cible = cible.nextSibling;
    }
    objet.a=0;
    objet.style.height='20px';
}

function grossi( cible, taille ) {
    objet = ID(cible);
    if( objet.parentNode.parentNode.parentNode.parentNode.parentNode.a == 1 ) {
        ecart = 4;
        /*if( getIEVersion() && getIEVersion() < 7 )
            ecart = ecart*3;*/
        objet.style.height = objet.offsetHeight + ecart + 'px';
        if( objet.offsetHeight >= taille ) {
            objet.style.visibility = 'visible';
            objet.style.height = taille  + 'px';
            if( objet.parentNode.parentNode.nextSibling != null ) {
                cible = objet.parentNode.parentNode.nextSibling;
                while( cible != null && cible.nodeName != "TR" )
                    cible = cible.nextSibling;
                if( cible != null )
                    grossi( cible.cells[0].childNodes[0].id, 20 );
            }
        } else {
            setTimeout('grossi(\'' + cible + '\',' + taille + ');',0);
        }
    }
}

// accueil

var a1=0;
var a2=0;
var a3=0;
var a4=0;
var a5=0;
var a6=0;
var a7=0;
var a8=0;

function MouseOver( id_appelant, id_appele, nom_fichier_appelant, nom_fichier_appele ) {
    num = id_appelant.substr(4); // recuperation du num appelant
    num2 = id_appele.substr(4); // recuperation du num appelé
    if( nom_fichier_appelant.attributes != null ) // test si on a passé l'objet préchargé ou le lien en dur
         nom_fichier_appelant = nom_fichier_appelant.src; // on recupere l'adresse
    document.getElementById( id_appelant ).style.backgroundImage='url(' + nom_fichier_appelant + ')'; // changement de l'image
    eval( 'a' + num + '=1;' ); // variable permettant d'enregistrer le fait qu'on est au dessus du lien
    if( nom_fichier_appele.attributes != null ) // test de l'objet préchargé
         nom_fichier_appele = nom_fichier_appele.src; 
    setTimeout('if(a' + num + '==1)document.getElementById(\'' + id_appele + '\').style.backgroundImage=\'url(' + nom_fichier_appele + ')\'',300); // changemet de l'image cible dans 300 millisecondes si on est toujours au dessus du lien
}

function MouseOut( id_appelant, id_appele, nom_fichier_appelant, nom_fichier_appele ) {
    num = id_appelant.substr(4); // recuperation des numeros
    num2 = id_appele.substr(4);
    if( nom_fichier_appelant.attributes != null ) // test de precharge
         nom_fichier_appelant = nom_fichier_appelant.src; // adresse
    document.getElementById( id_appelant ).style.backgroundImage='url(' + nom_fichier_appelant + ')'; // retablissement de l'image
    eval( 'a' + num + '=0;' ); // variable annulant le fait d'etre au dessus
    if( nom_fichier_appele.attributes != null ) // testde precharge
         nom_fichier_appele = nom_fichier_appele.src;
    setTimeout('if(a' + num + '==0)document.getElementById(\'' + id_appele + '\').style.backgroundImage=\'url(' + nom_fichier_appele + ')\'',150); // retablissement de l'image cible dans 150 ms
}

//préchargement d'image


// pompé sur : http://www.jejavascript.net/
function prechargimg() {
var doc=document;
if(doc.images) {
    if(!doc.precharg)
        doc.precharg = new Array();
    var i;
    var j=doc.precharg.length;
    var x=prechargimg.arguments;
    for(i=0; i<x.length; i++)
        if (x[i].indexOf("#")!=0) {
            doc.precharg[j]=new Image;
            doc.precharg[j++].src=x[i];
        }
    }
}

//augmentaion taille police

function increase( id ) {
    objet = document.getElementById( id );
    if( !objet.a ) {
        objet.a = 0;
        objet.b = 1;
    }
    if( objet.a <= 0 && objet.b == 1 ) {
        //objet.style.fontSize = '11pt';
        objet.a = 1;
        objet.b = 1;
    }
    if( getIEVersion() && getIEVersion() < 7 )
        a = 20;
    else
        a = 50;
    if( objet.a < a && objet.b == 1 ) {
        objet.style.fontSize = 100 + objet.a + '%';
        objet.a = objet.a + 5; 
        setTimeout('increase(\'' + id + '\');',10);
    } else {
        setTimeout('decrease(\'' + id + '\');',500);
    }
}

function decrease( id ) {
    objet = document.getElementById( id );
    if( !objet.a ) {
        objet.a = 0;
    }
    if( objet.a <= 0 ) {
        objet.a = 0;
    }
    if( objet.a > 0 ) {
        objet.b = 0;
        objet.style.fontSize = 100 + objet.a + '%';
        objet.a = objet.a - 5;
        setTimeout('decrease(\'' + id + '\');',10);
    }
}




// function png transparent

function png() {
    if( getIEVersion() && getIEVersion() > 5 && getIEVersion() < 7 ) {
        for( i=0;i<document.images.length;i++ ) {
            img = document.images[i];
            if( img.src.substr(img.src.length-3).toUpperCase() == "PNG" ) {
                img.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + img.src + "',sizingMethod='scale')";
                img.style.width=img.offsetWidth + "px";
                img.style.height=img.offsetHeight + "px";
                img.src="images/vide.gif";
            }
        }
    }
}
setTimeout("png();",1);
//changement d'image

function change(objet1,image) {
    //objet1 = document.getElementById(id);
    if( objet1.src )
        objet1.src=image;
    else
        objet1.style.backgroundImage="url('"+image+"')";
    png();
}

function ID( id ) {
    if( id != null && id != "" && typeof id == "string" )
        return document.getElementById( id );
    else
        return null;
}

function resolution() {
    if(screen.width>1200)
        //ID('css1').href="";
        ID('div0').style.backgroundImage="url('Images/fondbleu.jpg')";
    else if(screen.width>1000)
        ID('div0').style.backgroundImage="url('Images/fondbleu1024.jpg')";
    else
        ID('div0').style.backgroundImage="url('Images/fondbleu800.jpg')";
}

function police() {
    if( !getIEVersion() ) {
        document.getElementById("com").style.right="45px";
        document.getElementById("crm").style.right="15px";
        document.getElementById("maint").style.left="20px";
        document.getElementById("heu").style.right="45px";
        document.getElementById("pre").style.right="15px";
        document.getElementById("pro").style.left="20px";
        }       
}    