var html;
var count_vid=0;

function goto_in(dest){
	parent.centre.location.href=dest;
	affiche2();
}


function actu_file(param){
	var dest="";
	//actualisation de la frame cachée pour connaitre l'id de l'élément actuel pour util d'un style particulier
	parent.gauche2.document.forms[0].selec.value=param;
	for (count_vid=0;count_vid<nb_objects-1;count_vid++)
	 //fermeture de ses freres ouverts
    	if ((obj[count_vid].NIVELEM==obj[param].NIVELEM)&&(obj[count_vid].STAELEM==1)) fermeture(count_vid);
	dest=obj[param].IDFEUI+".htm";
	goto_in(dest);


    }

function ouverture(param){
     var dest="";
	//actualisation de la frame cachée pour connaitre l'id de l'élément actuel pour util d'un style particulier
     parent.gauche2.document.form1.selec.value=param;
     if (obj[param].STAELEM==0){
         for (count_vid=0;count_vid<nb_objects-1;count_vid++)
              //fermeture de ses freres ouverts puis lui-même devient ouvert
			  if ((obj[count_vid].NIVELEM==obj[param].NIVELEM)&&(obj[count_vid].STAELEM==1)) fermeture(count_vid);
         obj[param].STAELEM=1;
         }
     //sinon lui-même est ouvert et il faut donc le fermer
	 else  if (obj[param].IDPERE!="") fermeture(param);else parent.gauche2.location.reload();
	 dest=obj[param].IDFEUI+".htm";
	goto_in(dest);
}
function fermeture(param){
         //il faut fermer un élément et ses fils et leurs fils :appel récursif
         obj[param].STAELEM=0;
         for (count_vid=0;count_vid<nb_objects-1;count_vid++)
               if ((obj[count_vid].IDPERE==obj[param].ALIELEM)&&(obj[count_vid].STAELEM==1))
                    param=fermeture(count_vid);
return param;
}




function has_sons(param){
         var a=true;
         for (count_vid=0;count_vid<nb_objects-1;count_vid++){
              if (obj[count_vid].IDPERE==obj[param].IDELEM){a=true;break;}
              else a=false;}
return a;
}

function has_brothers(param){
         var r=false;
         for (count_vid=0;count_vid>nb_objects;count_vid++){
               if ((obj[count_vid].IDPERE==obj[param].IDPERE)&&(param!=count_vid)&&obj[count_vid].AFFELEM==0){
                   r=true;
                   break;
                   }
               else r=false;
         }
         return r;
}

function affiche_ouvert(param){
        var icone="";
        var a=0;
        var b=0;
        var espace="";
        var r="";
		var ecart_icone_lien="&nbsp;&nbsp;"
        if (obj[param].AFFELEM==1) return;
        obj[param].AFFELEM=1;
        for (n=0;n<obj[param].NIVELEM;n++)  espace+=blank;
       if (obj[param].ETREDOSS==false){ //c'est un fichier
	   	if (parent.gauche2.document.forms[0].selec.value==param) 
			style='menu_java_file_active'; 
		else 
			style='menu_java_files';
	       
            html="<tr background=\"char3.jpg\" valign=\"top\"><td></td><td nowrap>\n";
            html+=espace+" <a href='javascript:parent.gauche2.actu_file("+param +");' class='"+style+"'>";
            html+=feuille+ecart_icone_lien;
            html+=obj[param].ALIELEM+"</a></td>\n</tr>\n\n";
            }
            
        else{//c'est un dossier
             if (parent.gauche2.document.forms[0].selec.value==param) style='menu_java_file_active'; 
			 else style='menu_java';
			dossier=dossier_closed;
            //La racine a un traitement d'affichage spécial
            if (obj[param].IDPERE==""){
                 icone=racine+ecart_icone_lien;
                 dossier="";
				 }
            //Affichage final
            html="<tr background=\"char3.jpg\" valign=\"top\"><td></td><td nowrap>\n";
            html+=espace+"<a href='javascript:parent.gauche2.ouverture("+param +");'class='"+style+"'>";
            html+=icone+dossier+ecart_icone_lien;
            html+=obj[param].ALIELEM+"</a></td>\n</tr>\n";
            }
   parent.gauche1.document.write(html);
}

function fils(param){
//Recherche des fils du param soumis
        var count_vid=0;
        for (count_vid=0;count_vid<nb_objects-1;count_vid++)
                if (obj[count_vid].IDPERE==obj[param].IDELEM){
                   affiche_ouvert(count_vid);
                   if (obj[count_vid].STAELEM==1) fils(count_vid);
                   }
}

function pere_ouvert(param){
         var r;
         var indice;
         for (indice=0;indice>nb_objects-1;indice++)
              if (obj[indice].IDELEM==obj[param].IDPERE){
                  r=obj[indice].STAELEM;
                  break;}
return r;
}

function affiche2(){
        var indice;
        var init="";
        var l=0;
		
		for (indice=0;indice<nb_objects;indice++) obj[indice].AFFELEM=0
        parent.gauche1.document.open();
        init="<html>\n<body text='#000000' leftmargin='0' topmargin='0' marginwidth='0' marginheight='0' bgcolor=\"#AEAAA1\">\n";
        init+="\n<link rel='stylesheet' href='menu.css' type='text/css'>\n";
		init+="<table valign=\"top\" width=\"180 px\" height=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" background=\"char3.jpg\">\n";
		init+="  <tr>\n";
		init+="	<td colspan=\"2\" background=\"char3.jpg\" height=\"2\">&nbsp; </td>\n";
		init+=" </tr>\n";
		init+="  <tr> \n";
		init+="    <td><img src=\"char7.gif\" width=\"5 px\"></td>\n";    
		init+="    <td valign=\"top\"> \n";
		//alert(screen.height);
		if (document.all){
			ma_hauteur=Math.round((520*screen.height)/768)-75;
			if (screen.height==768)	init+= "<div id=\"Layer1\" style=\"position:relative; width:175px; height:500 px; z-index:1 ;overflow: auto ;\">"; 
			else 
			init+= "<div id=\"Layer1\" style=\"position:relative; width:175px; height:"+ma_hauteur +" px; z-index:1 ;overflow: auto ;\">"; 
			}
		init+="      <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n";
		parent.gauche1.document.write(init);
        for (l=0;l<lvl_max;l++){
             for (indice=0;indice<nb_objects-1;indice++){
                  if (obj[indice].NIVELEM==0){
                    affiche_ouvert(indice);
                    if (obj[indice].STAELEM==1) fils(indice);
                    }
             }
        }   
 		init="	 	</table>\n";
		init+="				</td>\n";
		init+="  </tr>\n";
		init+="</table>\n";
		init+="</body></html>";
		parent.gauche1.document.write(init);
        //parent.gauche1.document.close();
	//parent.gauche1.document.location.reload();
		
}
affiche2();
