// COPYRIGHT Arnaud Vial - ADN 2005 - LYON
// VAriables globales //
var clicked_name="";
var obj_name=null;
//______________________________________Gestion des menus_________________________________________________
// JavaScript Documentvar clicked_menu_name="";// choix du menu séléctionné
// si false le menu est invisible
var menu_for = false;
var menu_dir = false;


// determination des menus DISCUSSION directory
tab_for_text = new Array();
tab_for_link = new Array();
// determination des menus NEWS directory
tab_new_text = new Array();
tab_new_link = new Array();
// determination des menus DISCUSSION directory
tab_dir_text = new Array();
tab_dir_link = new Array();
// determination des menus CONTENTS updates
tab_upd_text = new Array();
tab_upd_link = new Array();
// determination des menus CONTENTS auteurs
tab_aut_text = new Array();
tab_aut_link = new Array();
// determination des menus CONTENTS board
tab_boa_text = new Array();
tab_boa_link = new Array();
// determination des menus INTERNET literature
tab_lit_text = new Array();
tab_lit_link = new Array();
// determination des menus INTERNET websites
tab_web_text = new Array();
tab_web_link = new Array();
//________________________________________________________________________________________________________
// rollOver dans les menus
function MenuMouseOUT(td_obj){
//if (clicked_name != td_obj.id)
td_obj.style.background="#E5E5E5"; 
	var work = td_obj.id;
	var name_menu = work.substring(0,3);
    id_menu = work.substring(3);

id_menu=name_menu+id_menu+"_"+id_menu;
//var dyn_obj="document.all."+id_menu;
var dyn_obj="document.getElementById(\""+id_menu+"\")";
eval(dyn_obj+".style.background='#E5E5E5'");

}

function MenuMouseOVER(td_obj){
	td_obj.style.background="#F0F0F0";
// ici on modifie la couleur de fond de la cellule créee dynamiquement	
	var work = td_obj.id;
	var name_menu = work.substring(0,3);
    id_menu = work.substring(3);

id_menu=name_menu+id_menu+"_"+id_menu;
//var dyn_obj="document.all."+id_menu;
var dyn_obj="document.getElementById(\""+id_menu+"\")";
eval(dyn_obj+".style.background='#F0F0F0'");

}
function putOrangeColor(href_obj){

/*//Récupération de menu_XXX courant 
var work =href_obj.id;
var t = work.split("_");
var current_menu = "menu_"+t[1];
*/

var t_body = document.getElementsByTagName("TBODY");
//var current_t_body = t_body.getElementById(current_menu); 
for (k=0;k<t_body.length;k++){
var t_id = t_body[k].getElementsByTagName("A");
    for (t=0;t<t_id.length;t++){
	  var w=t_id[t].id;
	  				 if (w!=href_obj.id){
					 var p= w.indexOf("href");
							if (p!=-1){
							 document.getElementById(w).style.color="#333333";//couleur d'origine
							}else{
							var p2= w.indexOf("__1");
									if (p2!=-1){
									 document.getElementById(w).style.color="#333333";// on eteint les menus
									}
							}
						  }	
						else
						document.getElementById(w).style.color="#4A75A1";// rouge
	   
	   
	   }// fin for t
	
	}// fin for k


// on recherche le nom de la rubrique dans laquelle	
var pp1 = href_obj.id.indexOf("_");
	if (pp1!=-1){
     var pp2 = href_obj.id.indexOf("_",pp1+1);
	     if (pp2!=-1){
	        var nom_menu = href_obj.id.substring(pp1+1,pp2);
		   // ww = "document.all."+nom_menu+"__1.style.color=\"#4A75A1\"";
		   ww = "document.getElementById(\""+nom_menu+"__1\").style.color=\"#4A75A1\"";
			eval(ww);
		 }
	}	
		
}
//_________________________________________________________________________________________________________
/*function switch_arrow(id_to_change){

var t_img = document.getElementsByTagName("IMG");
 	for (k=0;k<t_img.length;k++){
 	var id_img = t_img[k].id;
 	var pss = id_img.indexOf("_");
		 if (pss!=-1){
 			 id_img = id_img.substring(0,pss);
 
              var work = t_img[k].src;
              var pf = work.toLowerCase().indexOf("fleche");
			  if (pf!=-1){
			  if (!eval("menu_"+id_img))
			    t_img[k].src = "../images/fleche_right.gif";
			  else
			   t_img[k].src = "../images/fleche_down.gif";	
			  }
		}	  
 	}

}
*/
function putOriginalColor(){
// on eteind les menus et sous menu
   //for (var k=0;k<document.all.length;k++){
   // var w = document.all[k].id;
var t_body = document.getElementsByTagName("TBODY");

for (k=0;k<t_body.length;k++){
var t_id = t_body[k].getElementsByTagName("A");
    for (t=0;t<t_id.length;t++){
	  var w=t_id[t].id;
    var p= w.indexOf("href");
	var p2= w.indexOf("__1");
	  if((p!=-1)||(p2!=-1)){
       document.getElementById(w).style.color="#333333";// on eteint les menus et/ou sous-menu
	  }
   }//fin for t
 }// fin for k
}// fin func
function mouseOUT(td_obj){

//if (clicked_name != td_obj.id)
 td_obj.style.background='#C7C7C7'; 
}

function mouseOVER(td_obj){
td_obj.style.background='#F0F0F0';
}

function putCLICK(td_obj){

window.parent.frames["body"].document.location.href="body.htm";


// on eteind tous les sous menu rouges
//for (var k=0;k<document.all.length;k++){
	//	var w = document.all[k].id;
var t_body = document.getElementsByTagName("TBODY");
//var current_t_body = t_body.getElementById(current_menu); 
for (k=0;k<t_body.length;k++){
var t_id = t_body[k].getElementsByTagName("A");
    for (t=0;t<t_id.length;t++){
	  var w=t_id[t].id;
	  	
		  var p= w.indexOf("href");
		        if (p!=-1){
		         document.getElementById(w).style.color="#333333";
		        }else{
				var p2= w.indexOf("__1");
				    if (p2!=-1){
				     document.getElementById(w).style.color="#333333";// on eteint les menus
				    }
				
				}
		
		}//fin du for t		
	}// fin du for k
/////

//var ww = "document.all."+td_obj.id+"__1.style.color=\"#4A75A1\"";
var ww = "document.getElementById(\""+td_obj.id+"__1\").style.color=\"#4A75A1\"";
eval(ww);// on allume le menu cliqué
	
eteintbtnframe('index');
if (obj_name != null){
 obj_name.style.background='#C7C7C7';
 }
 
  clicked_name=td_obj.id;
  obj_name=td_obj;
  pos_cookie(td_obj.id);
  gest_menu(td_obj.id);
  switch_arrow(td_obj.id);
}

function close_all_menu(){
var t_body = document.getElementsByTagName("TBODY");
   for (var t=0;t<t_body.length;t++){
    var current_id = t_body[t].id;
	   if (current_id != ""){
	    var pmenu = current_id.indexOf("menu_");
		   if (pmenu!=-1){
		     var mid = current_id.substring(pmenu+5);
			    current_obj = t_body[t];
				var tab_text = new Array();
				var tab_link = new Array();
				// on attribue les tableaux en fonction de l'id reçu !
				tab_text = eval("tab_"+mid+"_text");
				tab_link = eval("tab_"+mid+"_link");
				
				if ((eval(current_id)) &&(clicked_name!=mid )){
				// le menu est ouvert, alors on le ferme
					for(var i=tab_text.length-1;i>=0;i--){
						 current_obj.rows[i].deleteCell(0);
						 current_obj.deleteRow(i);
						 }
	    			 eval(current_id+"=false");
		 			// et on eteind le menu
					document.getElementById(mid+"__1").style.color="#333333";
						
				/////
				}
		   
		   }
	   
	   } 
    
   
   }

}

function gest_menu(id){
close_all_menu();
var id_menu = "menu_"+id;

//current_obj = eval("document.all."+id_menu); // objet TBODY	 
current_obj = eval("document.getElementById(\""+id_menu+"\")");
var tab_text = new Array();
var tab_link = new Array();
// on attribue les tableaux en fonction de l'id reçu !
tab_text = eval("tab_"+id+"_text");
tab_link = eval("tab_"+id+"_link");

    if (!eval(id_menu)){	
	// ici le menu est fermé on doit donc l'ouvrir
	for(var i=0;i<tab_text.length;i++){
	      var oRow = current_obj.insertRow(i);
	      oCell = oRow.insertCell(0);
	      //oCell.bgColor="#E5E5E5";
		  oCell.style.background="#E5E5E5";
		  oCell.align="right";
		  oCell.id = id+i+"_"+i;
		  href_id= "href_"+id+"_"+i;
	      oCell.innerHTML="<table width=\"100%\"><tr><td align=\"right\" id=\""+id+i+"\" onMouseOver=\"MenuMouseOVER(this)\" onMouseOut=\"MenuMouseOUT(this)\"><a href=../site//%22%22+tab_link%5Bi%5D+%22/%22 id=\""+href_id+"\" onClick=\"putOrangeColor(this)\" target=\"body\">"+tab_text[i]+"</a></td></tr></table>";
		  
	}// fin du for
	eval(id_menu+"=true");
	}
	else{
		// on ferme le menu
		for(var i=tab_text.length-1;i>=0;i--){
		 current_obj.rows[i].deleteCell(0);
		 current_obj.deleteRow(i);
		}
	     eval(id_menu+"=false");
		 // et on eteind le menu
		document.getElementById(id+"__1").style.color="#333333";
	}
}

function eteintbtnframe(nom_frame){
color_index="#C7C7C7";
color="#C7C7C7";
if (nom_frame=="index")
  color = color_index;
nb = window.parent.frames.length;
            for (var i=0;i<nb;i++){
			
           			   if(window.parent.frames[i].name==nom_frame){
			 			 if(window.parent.frames[i].clicked_name!=""){
							 nav_name = navigator.appName.toString();
							 var n = nav_name.toLowerCase().indexOf("netscape");
							if (n==-1){			
			  					for (j=0;j<window.parent.frames[i].document.all.length;j++){
					//alert(window.top.frames[i].document.all[j].id+"    "+window.top.frames[i].clicked_name);
										   if(window.parent.frames[i].document.all[j].id!=""){
																if(window.parent.frames[i].document.all[j].id==window.parent.frames[i].clicked_name){
																		window.parent.frames[i].clicked_name="";
																		window.parent.frames[i].obj_name=null;
																		//window.parent.frames[i].document.all[j].style.background='#BDD5EC';
																		window.parent.frames[i].document.all[j].style.background=color;
																		
																}
											}
								}
							}else{
							// pour netscape
										if(parseInt(navigator.appVersion) > 4){
											 window.parent.frames[i].document.getElementById(window.parent.frames[i].clicked_name).style.background=color; 
											 window.parent.frames[i].clicked_name="";
											 window.parent.frames[i].obj_name=null;
										}
							}// fin du else
						}
              		 }
            }
}

function pos_cookie(id)
{
document.cookie='index='+id+'#;path=/';
}

function destroy_cookie(nom_cookie)
{
cookies=document.cookie;
pos=cookies.indexOf(nom_cookie);
	if (pos!=-1)
	{
	
	pos1=cookies.indexOf("=",pos);
	pos2=cookies.indexOf("#",pos1);
	nom_b=cookies.substring(pos1+1,pos2);
	}
	ladate=new Date(71,10,02);
	document.cookie=nom_cookie+"=;expires="+ladate.toGMTString();
}


function maj_cookie(){
cook = document.cookie;
var p = cook.indexOf("index=");
var p2 = cook.indexOf("#",p);
var value = cook.substring(p+6,p2);
if (value!=""){
	nav_name = navigator.appName.toString();
var n = nav_name.toLowerCase().indexOf("netscape");
if (n==-1){
		for (i=0;i<document.all.length;i++){
 			if(document.all[i].id==value){
				clicked_name=value;
				document.all[i].style.background='#C7C7C7';
				obj_name=document.all[i];
			}
		}
 }else{
 			if(parseInt(navigator.appVersion) > 4){
				 document.getElementById(value).style.background='#CCCCCC';
				 obj_name=document.getElementById(value);
				 clicked_name=value;
			}
 }	
}
}


function switch_arrow(id_to_change){

var p = id_to_change.indexOf("_");
var id_text="";

if (p!=-1){
 id_to_change = id_to_change.substring(0,p)+"_img";
 }
var t_img = document.getElementsByTagName("IMG");
 	for (k=0;k<t_img.length;k++){
    	var id_img = t_img[k].id;
               var work = t_img[k].src;
              var pf = work.toLowerCase().indexOf("fleche");
			  if (pf!=-1){
			  if (id_img != id_to_change){
			    t_img[k].src = "../images/fleche_left.gif";
				}
			  else
			   t_img[k].src = "../images/fleche_down.gif";
			   
			  }
	}	  
 

}
function changeTheColor(obj){
init();
switch_arrow(obj.id);
obj.style.color="#4A75A1";
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//______________________________ Initialisation du menu de l'index_________________________________

function init(){
// recuperation des objets TBODY de l'index
var t_right = window.parent.frames['right'].document.getElementById("for__1");
t_right.style.color="#333333";
t_right = window.parent.frames['right'].document.getElementById("dir__1");
t_right.style.color="#333333";
t_right = window.parent.frames['right'].document.getElementById("upd__1");
t_right.style.color="#333333";
t_right = window.parent.frames['right'].document.getElementById("aut__1");
t_right.style.color="#333333";
t_right = window.parent.frames['right'].document.getElementById("boa__1");
t_right.style.color="#333333";
t_right = window.parent.frames['right'].document.getElementById("lit__1");
t_right.style.color="#333333";
t_right = window.parent.frames['right'].document.getElementById("web__1");
t_right.style.color="#333333";
var t_body = window.parent.frames['index'].document.getElementsByTagName("TBODY");
      for (k=0;k<t_body.length;k++){
        if(t_body[k].id!=null){
	       if (t_body[k].id.length>0){
		    var pmenu=t_body[k].id.indexOf("menu_");
			  if(pmenu!=-1){
			   // c'est un id qui nous concerne
			   // on verifie si le menu est ouvert
			    var is_menu_open = eval("window.parent.frames['index']."+t_body[k].id);
				if (is_menu_open){
				 // on eteint le titre du menu 
				   window.parent.frames['index'].document.getElementById((t_body[k].id).substring(pmenu+5)+"__1").style.color="#333333";
				 // on remet la fleche dans le bon sens 
				   window.parent.frames['index'].document.getElementById((t_body[k].id).substring(pmenu+5)+"_img").src="../images/fleche_right.gif";
				 // et on ferme le menu ouvert  
				   window.parent.frames['index'].gest_menu((t_body[k].id).substring(pmenu+5));
				 }
			 }
		  
		  }
	    }
      }
	  
}// fin init()



function Centrer(page,name,largeur,hauteur,options) {
  var haut=(screen.height-hauteur)/2;
  var gauche=(screen.width-largeur)/2;
  window.open(page,name,"top="+haut+",left="+gauche+",width="+largeur+",height="+hauteur+","+options);
}

//functions ajoutees par EF pour gestion des markup

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


//_______________________________________________GESTION CODE_________________________________________

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function Is_Cookie_ID( ID , Field ) {

var Looking   = ID + "=";

var Long_Look = Looking.length;

var Cook = document.cookie; 
//alert(Cook);
// var Compteur=0;

if(Cook.length > 0 ) 
	{ 
	if (Cook.indexOf(Looking,0) != -1)
		{
		// 
		return(1);
		}
	}
return( 0 );
}

// ADN : Fonction Go_On_Id_ALRUS
// aiguille suivant la presence d'un cookie 1 si present, 0 si absent
// necessite Is_Cookie_ID
// Location_To_Call1 : URL de destination, si le cookies est present au va directement sur cette URL.
// sinon cette URL est passee a l'URL code ?urlgo=information/information.htm 

function Go_On_Id( Cookie_ID, Location_To_Call1,Location_To_Call2)
{
var ID = Is_Cookie_ID(Cookie_ID, 0 );

if ( ID == 0)
	{        
	//MM_openBrWindow(Location_To_Call2+Location_To_Call1,'code','scrollbars=no,resizable=yes,width=310,height=200')
	Centrer(Location_To_Call2+Location_To_Call1,'code',300,355,'scrollbars=no,resizable=yes');
	return(false);
	}
return(true);
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

//___________________________________________FIN GESTION CODE__________________________________________