//The following content is Copyright ©2005 Advanced Data Network.
//Please contact Advanced Data Network by e-mail at adn@adnsa.com if you want to use a part or the whole of it.


/**
* Gestion des boutons  suite / retour des  pages PDF
*

*
**/

var current_rub="";
var current_menu=-1;
var current_smenu=new Array();
var current_page=0;
hidenext('true');
hideback('true');

///

// tableau des rubriques générales
// l'ordre doit etre identique à celui de la page html
var rubrique=new Array("dis","cl1","cl2","cl3","cl4","cl5","cl6","va3","va2","va4","va1","red","aut");
// recherche de la rubrique ACTIVE ( ouverte et cliquée)
//_________________________________________________________________________________________________________
var t_body = window.top.frames["index"].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){
							if((window.top.frames["index"].document.getElementById(w).style.color=="#FF0000")||(window.top.frames["index"].document.getElementById(w).style.color=="#ff0000")||(window.top.frames["index"].document.getElementById(w).style.color=="rgb(255,0,0)") ||(window.top.frames["index"].document.getElementById(w).style.color=="rgb(255, 0, 0)")){
							  var info = w.split("_");
							  current_rub=info[1]; // rubrique allumé en rouge
							  current_menu = info[2];// numero du menu allumé en rouge
							   // on recupere le tableau complet des liens
							  current_smenu = eval("window.top.frames['index'].tab_"+current_rub+"_link");
							  //alert(current_smenu.length);
							  last_menu = current_smenu.length-1;
							 // Gestion bouton suite/retour pour arrivee directe
							 // Cas ou on arrive directement ds le derneir menu qui n'a qu 1 page
							 if (last_menu == current_menu){
							  hidenext('false');
							  hideback('false');
							   if ( current_smenu[current_menu].length==1 )
							   hidenext('true');
							     
							 }
							 if (current_menu == 0){
							  hidenext('false');
							  hideback('true');
							 }
							 if ((current_menu > 0) && (current_menu<last_menu)){
							  hidenext('false');
							  hideback('false');
							 }
							 
							  //alert(current_rub+" "+current_menu);
							  break;
							  }// fin if #ff0000
							}// fin if p!=-1
		  
    }// fin for t

}// fin for k

//_________________________________________________________________________________________________________

function pagesuivante(){
if ( (current_menu == last_menu) && (current_smenu[current_menu].length-1 == current_page) ){
 hidenext('true');
return;
}
if (current_smenu[current_menu].length-1 == current_page){
	
// on doit changer de rubrique
current_menu++;
changego(current_menu);
current_page=0;

}else{
current_page++;
//hideback('false');
}
hideback('false');
// gestion suppression btn suivant

if ( (current_menu == last_menu) && (current_smenu[current_menu].length-1 == current_page) )
hidenext('true');
 window.top.frames["body"].frames["right"].location.href=current_smenu[current_menu][current_page];


}
//_________________________________________________________________________________________________________

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
//_________________________________________________________________________________________________________

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];}}
}
//_________________________________________________________________________________________________________

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];}
}



//_________________________________________________________________________________________________________

function get_cookie()
{
cookies=document.cookie;
pos=cookies.indexOf("url");
	if (pos!=-1)
	{
	
	pos1=cookies.indexOf("=",pos);
	pos2=cookies.indexOf("#",pos1);
	nom_b=cookies.substring(pos1+1,pos2);
	
	}
return nom_b;	
}

//_________________________________________________________________________________________________________

function pageprecedente()
{
//alert(current_rub+" "+current_menu+" "+current_page);
right_uri = window.top.frames["body"].frames["right"].location.href.toString();
var pft = right_uri.toLowerCase().indexOf("/pdf_fichtech/");
var pins = right_uri.toLowerCase().indexOf("/pdf_instruct/");
var pom = right_uri.toLowerCase().indexOf("/pdf_opmanual/");
if ( (pft==-1) && (pins==-1) && (pom==-1)){
// on est dans les pages cata
hidenext('false');

//if (current_smenu[current_menu].length-1 == 0){
if (current_page == 0){
// on doit changer de rubrique
if(current_menu>0){
   current_menu--;
   changego(current_menu);
   current_page=current_smenu[current_menu].length-1;
  }
}else{
current_page--;
hidenext('false');
}
}// fin if pft==-1
else{
// on recupere le bon numero de page quand on vient
// d'une ft in instruction de service pour un reconstrcution
var pg = window.top.frames["index"].good_page;
if (pg!=-1)
  current_page = pg;
}
// gestion suppression btn prec

if ( (current_menu == 0) && (current_page == 0) )
 hideback('true');
 // juste pour quand on vient d'une fiche technique
if ( (current_menu == last_menu) && (current_smenu[current_menu].length-1 == current_page) )
 hidenext('true'); 
else
hidenext('false');
 
window.top.frames["body"].frames["right"].location.href=current_smenu[current_menu][current_page];


}


//_________________________________________________________________________________________________________

function changeimg(efface)
//si efface=true on efface, si efface = false, on affiche
{
var tabimage=new Array("next");
	    i=-1
	    i=-1
		nbframe = eval(window.parent.frames.length);
		for (var j=0;j<nbframe;j++)
	   {
	    if (eval("window.parent.frames[j].name=='foot'"))
		{ 
			for (var i=0;i<window.parent.frames[j].document.images.length;i++)
    		{ 
			for (var k=0;k<tabimage.length;k++)
				{ 
				if (window.parent.frames[j].document.images[i].name == tabimage[k])
					{
					if (efface=="true")
					{
					//supprlien('suite');
					window.parent.frames[j].document.images[i].src="../images/avance2.gif";
					}
					else 
					window.parent.frames[j].document.images[i].src="../images/btn_"+tabimage[k]+".gif";
					}
				}// fin du fork 
    		}// fin du fori 
		}// fin du if head

	  }
}
//_________________________________________________________________________________________________________

function changego(num){
var menu_red_id="";
var t_body = window.top.frames["index"].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 pid= w.indexOf("href");
		  if (pid!=-1){
		     //if(window.top.frames["index"].document.getElementById(w).style.color=="#ff0000"){
			 if((window.top.frames["index"].document.getElementById(w).style.color=="#FF0000")||(window.top.frames["index"].document.getElementById(w).style.color=="#ff0000")||(window.top.frames["index"].document.getElementById(w).style.color=="rgb(255,0,0)") || (window.top.frames["index"].document.getElementById(w).style.color=="rgb(255, 0, 0)")){
			     var ps = w.lastIndexOf("_");
				 menu_red_id = w.substring(0,ps+1)+num;
			     window.top.frames["index"].document.getElementById(w).style.color="#333333";
			 }// fin #ff0000
		  
		  
		  
		  }// fin pid
		  
	}// fin for t
	
 }// fin for k	  
var chg="window.top.frames[\"index\"].document.getElementById(\""+menu_red_id+"\").style.color=\"#ff0000\"";
eval(chg);
}// fin funct

//_______________________________________________________________________________________________________
/*

function supprlien(nom_tag)
{
balise=document.all;
for(var i=0;i<balise.length;i++)
	{
	if((balise[i].tagName=="A")&&(balise[i].id==nom_tag))
	//balise[i].href="";
	balise[i].disabled=true;
	}
}
*/
//_________________________________________________________________________________________________________

function hidenext(vrai)
//si efface=true on efface, si efface = false, on affiche
{
var tabimage=new Array("next");
	    i=-1
	    i=-1
		nbframe = eval(window.parent.frames.length);
		for (var j=0;j<nbframe;j++)
	   {
	    if (eval("window.parent.frames[j].name=='foot'"))
		{ 
			for (var i=0;i<window.parent.frames[j].document.images.length;i++)
    		{ 
			for (var k=0;k<tabimage.length;k++)
				{ 
				if (window.parent.frames[j].document.images[i].name == tabimage[k])
					{
			        if(vrai=="false")
					{
					window.parent.frames[j].document.images[i].src="../images/btn_"+tabimage[k]+".gif";
					//document.all.f_next.style.cursor="";
					document.getElementById("f_next").style.cursor="";
					}
					else
					{
					window.parent.frames[j].document.images[i].src="../images/avance2.gif";
					//document.all.f_next.style.cursor="default";
					document.getElementById("f_next").style.cursor="default";
					}
					}
				}// fin du fork 
    		}// fin du fori 
		}// fin du if head

	  }

}
//_________________________________________________________________________________________________________

function hideback(vrai)
//si efface=true on efface, si efface = false, on affiche
{
var tabimage=new Array("back");
	    i=-1
	    i=-1
		nbframe = eval(window.parent.frames.length);
		for (var j=0;j<nbframe;j++)
	   {
	    if (eval("window.parent.frames[j].name=='foot'"))
		{ 
			for (var i=0;i<window.parent.frames[j].document.images.length;i++)
    		{ 
			for (var k=0;k<tabimage.length;k++)
				{ 
				if (window.parent.frames[j].document.images[i].name == tabimage[k])
					{
			        if(vrai=="false")
					{
					window.parent.frames[j].document.images[i].src="../images/btn_"+tabimage[k]+".gif";
					document.getElementById("f_back").style.cursor="";
					}
					else
					{
					window.parent.frames[j].document.images[i].src="../images/avance2.gif";
					document.getElementById("f_back").style.cursor="default";
					}
					}
				}// fin du fork 
    		}// fin du fori 
		}// fin du if head

	  }
			
}
//_________________________________________________________________________________________________________

function loadmark()
{

/*
futur release ( si necessaire )
*/
}




