// 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_tfa = false;
var menu_tth = false;
var menu_tms = false;
var menu_tmi = false;
var menu_tax = false;
var menu_pte = false;
var menu_pth = false;
var menu_pms = false;
var menu_pmi = false;
var menu_psp = false;
var menu_gan = false;
var menu_geq = false;
var menu_gpa = false;
var menu_gpr = false;
var menu_ggu = false;
var menu_gin = false;
var menu_oax = false;
var menu_ope = false;

// determination des menus TECHNIQUES pour tete et cou
tab_tfa_text = new Array("Intracranial surgery","Eye blocks","Face anatomy","Face particularity","Ophtalmic nerve blocks","Maxillary nerve blocks","Mandibular nerve blocks", "Cervical plexus blocks");
tab_tfa_link = new Array("techniques/face/b_intracranial.htm","techniques/face/b_eyes.htm","techniques/face/b_anatomy.htm","techniques/face/b_particularity.htm","techniques/face/b_ophtalmic.htm","techniques/face/b_maxillary.htm","techniques/face/b_mandibular.htm","techniques/face/b_cervical.htm");
// determination des menus TECHNIQUES pour thorax et abdomen
tab_tth_text = new Array("Epidural anaesthesia in Cardio-thoracic surgery","Ilioinguinal-Iliohypogastric block","Peri-umbilical &<br>Rectus sheath block","Pudendal block");
tab_tth_link = new Array("techniques/thorax_abdomen/b_cardio.htm","techniques/thorax_abdomen/b_ilioinguinal.htm","techniques/thorax_abdomen/b_peri.htm","techniques/thorax_abdomen/b_pudendal.htm");
// determination des menus TECHNIQUES pour membre sup
tab_tms_text = new Array("Choice of a technique","Brachial plexus anatomy","Interscalen block","Supraclavicular blocks","Infraclavicular blocks","Humeral block","Axillary block");
tab_tms_link = new Array("techniques/ms/b_choix.htm","techniques/ms/b_pb.htm","techniques/ms/b_interscalen.htm","techniques/ms/b_supraclavicular.htm","techniques/ms/b_infraclavicular.htm","techniques/ms/b_humeral.htm","techniques/ms/b_axillary.htm");
// determination des menus TECHNIQUES pour membre inf
tab_tmi_text = new Array("Lumbar plexus block","Iliofascial block","Obturator block","US Obturator block","Sciatic blocks","Ankle blocks");
tab_tmi_link = new Array("techniques/mi/b_blp.htm","techniques/mi/b_iliofascial.htm","techniques/mi/b_obturator.htm","techniques/mi/b_us_obturator.htm","techniques/mi/b_sciat.htm","techniques/mi/b_ankle.htm");
// determination des menus TECHNIQUES pour blocs axial
tab_tax_text = new Array("Lumbar epidural");
tab_tax_link = new Array("techniques/axial/b_epidural.htm");


// determination des menus GENERALITES pour materiel
tab_geq_text = new Array("Tourniquet","Ultrasound");
tab_geq_link = new Array("generalites/equipment/b_garrot.htm","generalites/equipment/b_ultrasound.htm");
// determination des menus GENERALITES pour pathologie
tab_gpa_text = new Array("Haemodynamics complications");
tab_gpa_link = new Array("generalites/pathology/b_haemodynamic.htm");
// determination des menus GENERALITES pour anticoagulation
tab_gpr_text = new Array("RA & anticoagulation");
tab_gpr_link = new Array("generalites/anticoagulation/b_anticoagulation.htm");

// determination des menus OBSTETRIQUE pour axial blocs
tab_oax_text = new Array("Epidural");
tab_oax_link = new Array("obstetrique/axial/b_epidural.htm");
// determination des menus OBSTETRIQUE pour peripheral blocs
tab_ope_text = new Array("Pudendal block");
tab_ope_link = new Array("obstetrique/peripherique/b_pudendal.htm");

//________________________________________________________________________________________________________
// 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="#0F4781";// 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=\"#0F4781\"";
		   ww = "document.getElementById(\""+nom_menu+"__1\").style.color=\"#0F4781\"";
			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){
// juste pour la maquette
window.parent.frames["right"].switch_arrow("all");
var forum = window.parent.frames["right"].document.getElementById("for__1");
var directory = window.parent.frames["right"].document.getElementById("dir__1");
forum.style.color="#333333";
directory.style.color="#333333";

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=\"#0F4781\"";
var ww = "document.getElementById(\""+td_obj.id+"__1\").style.color=\"#0F4781\"";
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+"\")");
if (current_obj==null)
return;
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=\""+tab_link[i]+"\" id=\""+href_id+"\" onClick=\"putOrangeColor(this);return Go_On_Id('ESR', '"+tab_link[i]+"', 'code/code_saisie.html?urlgo=')\" 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 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__________________________________________