// Menu globale Air France
// V0.4
// 07.10.2002
// F.Raffin
/*
*	06/10/2004 - F.FRATICELLI
*		Correction instabilité sur rollover niv 3
*
*/
var ns ;var ie ;var n6 ;var W ;var Arrow ;var Tcherno ;
var isCom=(navigator.appName.indexOf("Netscape")!=-1 && parseInt(navigator.appVersion) < 5);
var mx=0; var my=0; var coefpix=5;
var MaxSize = 780;var posY=67;
var TabPar = new Array("N","N","N","N","N","N","N","N");
var caleAvant = 50;
var TKDwidth=0;
var pixTrans="pixtrans";
var font1 = "txtMenu1";
var font2 = "txtMenu2";

var tm;
var strCode;
var cu_Marche = "FR";

function BrowserCheck() {
if (document.layers) ns=true;
if (document.all) ie=true;
if(!ie&&document.getElementById){ns=false;n6=true;};
if(ns||n6){W=window.innerWidth-16}else{W=document.body.offsetWidth-20;}
}

function TreeItem(id,parid,name,link,target,image,FRwidth,KDwidth)
{this.vname="AF"+TreeItem.dmcount;
TreeItem.dmcount++;
this.xpos = 0;
this.ypos = 86;
this.bckColor = "#ffffff";
this.bColor = "#041892";
this.selBckColor = "#D3DBE7";
this.iHeight = 21;
this.iHeight2 = 14;
this.visibility="hidden";
this.bSize = 1;
this.image = image;
this.KDwidth = KDwidth;
this.FRwidth = FRwidth;
this.name = name;
this.frname = "";
this.id = id;
this.parentItem = null;
this.parid = parid;
this.link = link;
this.target = target;
this.items = new Array();
this.itemCount = 0;
this.Opened = false;
this.child = false;
this.css = null;
this.arrIm = l_img_fleche0;
this.arrIm1 = l_img_fleche1;
this.arrIm2 = l_img_fleche2;
this.selected = 1;
this.height = 600;
this.width = new Array( 0, 0, 0, 0, 0, 0, 0 );
this.imWidth = 8;
this.focus = -1;
this.tW = MaxSize;
this.tH = 0;
this.WriteCSS = TreeItemWriteCSS;
this.Show = TreeItemShow;
this.Add = TreeItemAdd;
this.WriteDiv = TreeItemWriteDiv;
this.Write2cols = TreeItemWrite2cols;
this.Get = TreeItemGet;
this.A = TreeItemA;
this.align = "vert";
this.moveHandler = TreeItemMove;
this.outHandler = TIMout;
this.outH2 = TIMout2;
this.downHandler = TreeItemDown;
this.active = false;
this.Reset = TreeItemReset;
this.EventInit = TIEventInit;
this.MoveTo = TIMoveTo;
this.Write = TreeItemWrite;
this.Toggle=TIToggle;
this.normText = "";
this.selText = ""
this.SizeTot = 0;
this.etat = true;
eval( this.vname + "=this" );
}


function TIMoveTo(x,y){
	if(isNaN(x))this.itemCount=0;
	if(this.itemCount<1) return;
	if (Arrow==0){this.ypos=y} else {this.ypos=y+1}
	this.xpos=x
	this.css.left=this.xpos;
	this.css.top=this.ypos;
}

function TreeItemGet(id){
	if(id==this.id) return this;
	for(var i=0;i<this.itemCount;i++){
		It=this.items[i].Get(id);
		if(It!=null) return It;
	}
	return null;
}

function TreeItemA(id,parid,name,link,target,image,FRwidth,KDwidth){
	It=new TreeItem(id,parid,name,link,target,image,FRwidth,KDwidth);
	this.Add(It);
}


function TreeItemAdd(item){
	item.Opened=false;
	It=this.Get(item.parid);
	if(item.parid==this.id) {
		item.width=item.KDwidth==""?this.width[item.id-1]:item.KDwidth;
		item.KDwidth = item.width;
		item.FRwidth=item.FRwidth;
		item.bckColor=this.bckColor;
		item.selBckColor=this.selBckColor;
		item.fntColor=this.fntColor;
		item.fntSize=this.fntSize;
		item.iHeight=this.iHeight2;
		item.imWidth=this.imWidth;
		item.arrIm=this.arrIm;item.arrIm1=this.arrIm1;item.arrIm2=this.arrIm2;
		item.selFntColor=this.selFntColor;
		this.items[this.itemCount]=item;
		item.parentItem=this;
		item.child = this.child;
		item.bSize=this.bSize;
		item.face=this.face;
		item.bColor=this.bColor;
		item.visibility="hidden";
		this.itemCount++;
		return;
	}
	if(It!=null) {It.Add(item);return;}
}



function TreeItemWrite2cols(i){
	im="";
	im1="<img src='" + eval( pixTrans + '.src' ) + "' width=5 height=5 border=0>";
	im2="";
	if(Arrow==0){var CellHeight=14;}else{var CellHeight=5;}
	if (this.items[i].itemCount==0&&this.arrIm!=""&&Arrow==0){
		im="<img name='"+this.items[i].vname+"im' src='"+this.iob.src+"' width=14 height=20 border=0>";
		im2="<img name='"+this.items[i].vname+"im' src='"+this.iob1.src+"' width=14 height=20 border=0>";
	} else if (this.items[i].itemCount>0&&this.arrIm!=""&&Arrow==0) {
		im="<img name='"+this.items[i].vname+"im1' src='"+this.iob.src+"' width=14'height=20 border=0>";
		im2="<img name='"+this.items[i].vname+"im1' src='"+this.iob2.src+"' width=14 height=20 border=0>";
	}
	t1="<table border='0' width='"+this.KDwidth+"' cellspacing='0' height='"+this.iHeight+"' cellpadding='0'><tr><td>"+im1+"</td><td width='" +this.KDwidth+"' >";// tableau de formatage de tous les contenus
	t2="</td><td width='"+this.iHeight+"'>";
	persClass=(ie)?font1:font2;
	ref="<font class='"+persClass+"'>"+this.items[i].name+"</font>";
	t3="</td></tr></table>";

	this.items[i].normText=t1+"<div id='"+this.items[i].vname+"t' >"+ref+"</div>"+t2+im+t3;
	this.items[i].selText=t1+ref+t2+im2+t3;

	document.write("<DIV ID='"+this.items[i].vname+"i'>"+this.items[i].normText+"</DIV>");

	if(ie){
		this.items[i].ilayer=document.all[this.items[i].vname+"i"];this.items[i].tlayer=document.all[this.items[i].vname+"t"];
	}
	if(n6) {
		this.items[i].ilayer=document.getElementById(this.items[i].vname+"i");
		this.items[i].tlayer=document.getElementById(this.items[i].vname+"t");
		var tl=this.items[i].tlayer.style;
		tl.color=this.items[i].fntColor;tl.fontFamily=this.face;
		tl.fontSize=6+2*this.items[i].fntSize+"pt";
	}

	if(ns)this.items[i].ilayer=eval("document."+this.vname+".document."+this.items[i].vname+"i");
}





function TreeItemWriteDiv(){
	
	strCode = "/" + cu_Marche;
	preload( pixTrans,  strCode + "/common/common/img/pixel/pixtrans.gif" );
	preload( this.vname + ".iob", this.arrIm );
	preload( this.vname + ".iob1", this.arrIm1 );
	preload( this.vname + ".iob2", this.arrIm2 );

	if(this.itemCount<1) return false;

	if(this.itemCount>5&&this.parentItem!=null) { // + de 5 items dans le sous menus ==> cas de figure Ã  2 colonnes
		this.DoubletW=((this.tW)*2);
		document.write("<DIV ID='"+this.vname+"' style='background-color:#ffffff;layer-background-color:#ffffff'><table border='"+this.bSize+"' width='"+this.DoubletW+"' height='"+this.tH+"' bordercolor='"+this.bColor+"' cellspacing='0' cellpadding='0'><tr><td>");

		for(var i=0;i<this.itemCount;i++) { 
			this.Write2cols(i); 
		}
		document.write("<DIV ID='vide"+this.vname+"'></DIV>"); // utilisÃ© pour la gestion du double liseret sous IE4.0
	} else {

		if (Arrow==0){this.tW=MaxSize;}

		document.write("<DIV ID='"+this.vname+"' style=';background-color:"+this.bckColor+";layer-background-color:"+this.bckColor+"'><table border='"+this.bSize+"' width='"+this.tW+"' height='"+this.tH+"' bordercolor='"+this.bColor+"' cellspacing='0' cellpadding='0' ><tr><td class='txtbleufonce10ns'>" );

		for(var i=0;i<this.itemCount;i++){
			im="";
			im1="<img src='" + eval( pixTrans + '.src' ) + "' width=5 height=5 border=0>";
			im2="";

			if (Arrow==0){var CellHeight=15;} else {var CellHeight=5;}

			if (this.width[i]>50){
				var localwidth = this.width[i];
			} else {
				var localwidth = this.KDwidth;
			}
			var NewWidth=(localwidth-CellHeight);

			if (this.items[i].itemCount==0&&this.arrIm!=""&&Arrow==0){
				im="<img name='"+this.items[i].vname+"im' src='"+this.iob.src+"' width='14' height='20' border='0'>";
				im2="<img name='"+this.items[i].vname+"im' src='"+this.iob1.src+"' width='14' height='20' border='0'>";
			} else if (this.items[i].itemCount>0&&this.arrIm!=""&&Arrow==0){
				this.items[i].child = true;
				im="<img name='"+this.items[i].vname+"im1' src='"+this.iob.src+"' width='14' height='20' border='0'>";
				im2="<img name='"+this.items[i].vname+"im1' src='"+this.iob2.src+"' width='14' height='20' border='0'>";
			}

			t1="<table border='0' width='"+localwidth+"' cellspacing='0' height='"+this.iHeight2+"' cellpadding='0'><tr><td width='"+CellHeight+"'>";

			t2="</td><td width='"+NewWidth+"'>";
			persClass=(ie)?font1:font2;
			ref="<font class='"+persClass+"'>"+this.items[i].name+"</font>";
			t3="</td></tr></table>";

			this.items[i].normText=t1+im+t2+"<div id='"+this.items[i].vname+"t'>"+ref+"</div>"+t3;
			this.items[i].selText=t1+im2+t2+ref+t3;

			document.write("<DIV ID='"+this.items[i].vname+"i'>"+this.items[i].normText+"</DIV>");
			document.write("<DIV ID='videh"+this.vname+"'></DIV>"); // utilisÃ© pour la gestion du double liseret sous IE4.0

			if(ie){
				this.items[i].ilayer=document.all[this.items[i].vname+"i"];
				this.items[i].tlayer=document.all[this.items[i].vname+"t"];
			}
			if(n6){
				this.items[i].ilayer=document.getElementById(this.items[i].vname+"i");
				this.items[i].tlayer=document.getElementById(this.items[i].vname+"t");
				var tl=this.items[i].tlayer.style;
				tl.color=this.items[i].fntColor;tl.fontFamily=this.face;
				tl.fontSize=6+2*this.items[i].fntSize+"pt";
			};

			if(ns)this.items[i].ilayer=eval("document."+this.vname+".document."+this.items[i].vname+"i");
		}
	}

	Arrow++; //variable pour prÃ©sence ou non de fleche
	document.write("</td></tr></table></DIV>");


	for(var i=0;i<this.itemCount;i++){this.items[i].WriteDiv();}
	if(ie){
		this.layer=document.all[this.vname];
		this.css=this.layer.style;
	} else if(n6){
		this.layer=document.getElementById(this.vname);
		this.css=this.layer.style;
	} else if(ns){ 
		this.layer=eval("document."+this.vname);
		this.css=this.layer;
	}
}







function TIEventInit(){
	var oinit=true;
	var j=1;
	for(var i=0;i<this.itemCount;i++){
		this.items[i].EventInit();
	}
	for(var i=0;i<this.itemCount;i++){
		var style=this.items[i].ilayer;
		this.layer.onmouseout=new Function(this.vname+".outHandler(); return false;");
		style.onmouseover=new Function(this.vname+".moveHandler("+i+");return false;");
		style.onmousedown=new Function(this.vname+".downHandler("+i+");return false;");
		if(ns)style.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
	}
}





function TreeItemWriteCSS(){
var dx;
var dy;
var bCol=(ns)?"layer-background-color:" : "background-color:";

if(this.align=="vert"){
	if (this.parentItem==null){

	Height=this.itemCount*this.iHeight+2*this.bSize;
	Width=this.width*1+(2*this.bSize);
	dx=0;
	dy=this.iHeight;

	} else if (this.parentItem!=null&&this.itemCount<=5){
		Height=this.itemCount*this.iHeight+2*this.bSize;
		Width=this.width*1+(2*this.bSize)
		dx=0;
		dy=this.iHeight;
	} else {
		Height=5*this.iHeight+2*this.bSize;
		Width=this.width*1+(2*this.bSize)
		dx=0;
		dy=this.iHeight;
	}

} else {
	Height=this.iHeight+2*this.bSize;
	Width=MaxSize;
	dy=0;
	dx=this.KDwidth;
}

this.tH=Height; this.tW=Width;
if(this.itemCount>0){
	if(this.parentItem==null)document.write("<STYLE TYPE='text/css'><!--\r\n");
	document.write("#"+this.vname+" {position:absolute");
	document.write(";left:"+this.FRwidth+"px;top:"+this.ypos+"px;width:"+Width+"px;");
	document.write("visibility: "+this.visibility+"; cursor: hand; z-index:20}\r\n");
	// --------- cas sur 2 colonnes ---------------
	if(this.itemCount>5&&this.parentItem!=null){
		for(var i=0;i<this.itemCount;i++) {
			var resarr=this.items[i].name.match(eval( '/&/g' ));
			if(resarr) nboc=resarr.length*6; else nboc=0;
			var lg=(this.items[i].name.length - nboc)*coefpix;
			if(this.parentItem==null ){
				this.width[i]=lg+15+caleAvant;
				TKDwidth = this.width[i];
			} else {
				if(this.KDwidth!=0){
				if(lg>=this.KDwidth){TKDwidth=lg+30;}
			} else{TKDwidth=lg+50;
		}
	}
	document.write("#"+this.items[i].vname+"i {position:absolute;"+bCol+this.items[i].bckColor);
	if( TKDwidth != 0 ) { this.KDwidth = TKDwidth; this.tW = TKDwidth + 2; }
	if (i<5){
		document.write(";top:"+(i*dy+this.bSize)+"px;left:"+(i*dx+this.bSize)+"px"+";width:"+this.KDwidth+"px;");
	}else{
		document.write(";top:"+((i-5)*dy+this.bSize)+"px;left:"+( (i*dx+this.bSize)+1*this.KDwidth)+"px"+";width:"+(2+1*this.KDwidth)+"px;");
	}
		document.write("height:"+this.iHeight+"px; z-index:1;}\r\n");
	}
	if(this.itemCount<10) { // gestion du double liseret sous IE4.0
		strVide="#vide"+this.vname+"{position:absolute;"+bCol+this.bckColor+";font-size: 11px";
		strVide+=";top:"+((this.itemCount-5)*dy+this.bSize)+"px;left:"+((this.itemCount*dx+this.bSize)+1*this.KDwidth)+"px"+";width:"+(2+1*this.KDwidth)+"px;";
		strVide+="height:"+this.iHeight2*(10-this.itemCount)+"px; z-index:1;}\r\n";
		document.write(strVide);
	}
	dy=0;

// --------- cas sur 1 colonne ---------------
} else {
	var positionx=0;
	this.KDwidth = TKDwidth;
	for(var i=0;i<this.itemCount;i++) {
		var resarr=this.items[i].name.match(eval( '/&/g' ));
		if(resarr) nboc=resarr.length*6; else nboc=0;
		var lg=(this.items[i].name.length - nboc)*coefpix;
		if(this.parentItem==null ){
			caleA = caleAvant - ( this.itemCount * 6 );
			this.width[i]=lg+15+caleA;
			TKDwidth = this.width[i];
		} else {
			if(lg>=this.KDwidth && this.KDwidth!=0){
			TKDwidth=lg+30;
		}
	}
	document.write("#"+this.items[i].vname+"i {position:absolute;"+bCol+this.items[i].bckColor);
	if(this.parentItem!=null){
		if( TKDwidth != 0 ) { this.KDwidth = TKDwidth; this.tW = TKDwidth + 2; }
			document.write(";top:"+(i*dy+this.bSize)+"px;left:"+(i*dx+this.bSize)+"px"+";width:"+(this.KDwidth)+"px;");
		} else {
			document.write(";top:"+(i*dy+this.bSize)+"px;left:"+positionx+"px"+";width:"+this.width[i]+"px;");
		}
			document.write("height:"+this.iHeight+"px; z-index:1;}\r\n");
			this.items[i].WriteCSS();
			positionx+=this.width[i];
		}
	}
	if(this.parentItem==null){
		if(positionx<MaxSize){ // gestion du double liseret sous IE4.0
			strVide="#videh"+this.vname+"{position:absolute;"+bCol+this.bckColor;
			strVide+=";top:"+this.bSize+"px;left:"+positionx+"px"+";width:"+(MaxSize-positionx-1)+"px;";
			strVide+="height:"+this.iHeight+"px; z-index:1;}\r\n";
			document.write(strVide);
		}
		document.write("--></STYLE>\r\n");}
	}
}





// Ã  prÃ©sent renvoi true ou false
function TreeItemShow(o){
	this.focus=-1;
	if(this.itemCount<1) { return false };
	if(o==1){
		this.css.visibility=(ns)? "show":"visible";
	} else {
		for(var i=0;i<this.itemCount;i++) {
			this.items[i].Show(0);
		}
		this.css.visibility=(ns)? "hide":"hidden";
	}
	return true;
}


function TIToggle(mod){
	this.Opened=mod;
	var c1=this.bckColor;var c2=this.selBckColor;
	if(ie||n6){

		if(document.images[this.vname+"im"]){document.images[this.vname+"im"].src=(mod)? this.arrIm1:this.arrIm;}
		if(document.images[this.vname+"im1"]){document.images[this.vname+"im1"].src=(mod)? this.arrIm2:this.arrIm;}
		this.ilayer.style.backgroundColor=(mod)? c2 : c1;
		this.ilayer.style.background=(mod)? c2:c1;
		this.tlayer.style.color=(mod)? this.selFntColor:this.fntColor;
	}
	if(ns){
		var txt=(mod)? this.selText:this.normText;
		this.ilayer.document.bgColor=(mod)? c2 : c1;
		this.Write(txt);
	}
}


function TreeItemMove(i){
	if(this.itemCount<1)return;
	if( this.items[this.selected] == null ) {
		this.selected = 0;
	}
	sel=i;
	j=i-1;
	this.active=true;
	if(this.parentItem!=null)this.items[this.selected].active=true;
	var localposition=0;
	var nxpos=this.xpos;
	var nypos=this.ypos+i*this.iHeight;
	if(this.align!="vert") {
		if (i==0) {
			nxpos=this.xpos;
		} else {
			for (l_count=0;l_count<i;l_count++) {
				localposition+=this.width[l_count];
			}
			nxpos=this.xpos+localposition;
		}
		nypos=this.ypos+this.iHeight;
		if (nxpos+(this.width*2)>MaxSize){nxpos=776-(this.width*2);}
	}
	if(nxpos+this.width[i]>W) nxpos=nxpos-1*this.width;
	this.items[sel].MoveTo(nxpos,nypos);
	this.items[this.selected].Show(0);
	this.items[sel].Show(1);
	if(sel!=this.focus){
		this.items[this.selected].Toggle(false);
		this.items[sel].Toggle(true);status=this.items[sel].link;
	}
	this.selected=sel;this.focus=sel;
}


function TreeItemDown(i){
	sel=i;
	if(this.items[sel].link!=""){
		if(this.items[sel].target=="_blank") {
			eval( this.items[sel].link );
		}else location.href=this.items[sel].link;
	}
}


function TreeItemReset(){
	if(this.active)return;
	for(var i=0;i<this.itemCount;i++)this.items[i].Show(0);
	this.focus=-1;
	if(this.parentItem!=null){
		this.parentItem.Reset();this.parentItem.Show(0);
	}
	this.items[this.selected].Toggle(false);
	Arrow==0;
}

function TreeItemWrite(text){
	var style=this.ilayer;
	style.document.open();
	style.document.write(text);
	style.document.close();
}

function position(e){
	mx = e.pageX;
	my = e.pageY;
}



// changement liÃ© au zonning des niv4 : pb d'effacement sur passage en oblique
function TIMout(e){
	if(this.itemCount>5 ){var l_tw=2*this.tW;}
	else {var l_tw=this.tW;}
	if(ie){
		mx=window.event.clientX;
		if(document.body.scrollLeft)mx+=document.body.scrollLeft;
		my=window.event.clientY;
		if(document.body.scrollTop)my+=document.body.scrollTop;
	} else {
		if(navigator.appName.substring(0,3)=="Net") {
			document.captureEvents( Event.MOUSEMOVE );
			document.onmousemove = position;			/*+++++++++++++++++++++*/
		}
	}

	if( ie ) {
		if( ((mx>this.xpos+1) && (mx<this.xpos+l_tw)) && ((my>this.ypos+1) && (my<this.ypos+this.tH)) ) {
			if( tm != null ) {			
				tm = clearTimeout(tm);
			}
			return;
		}
		if( (((my>this.ypos+1) || (my>this.ypos+this.tH)) || ((mx<=this.xpos+1) || (mx>this.xpos+l_tw))) && tm==null) {
			this.vname+".Reset()";
			tm = setTimeout("HideAll(menu_base)",2000);
		} 

	} else {
		if( ((mx>this.xpos+1) && (mx+3<this.xpos+l_tw)) && ((my>this.ypos+1) && (my+3<this.ypos+this.tH)) ) {
			if( tm != null ) {			
				tm = clearTimeout(tm);
			}
			return;
		}
		if( (((my>this.ypos+1) || (my+3>this.ypos+this.tH)) || ((mx<=this.xpos+1) || (mx>this.xpos+l_tw))) && tm==null) {
			this.vname + ".Reset()";
			tm = setTimeout("HideAll(menu_base)",2000);
		}

	}

}







// changement liÃ© au zonning des niv3
function TIMout2(f){
	if(this.itemCount>5 ){var l_tw=2*this.tW;}
	else {var l_tw=this.tW;}
	if(ie){
		mx=window.event.clientX;
		if(document.body.scrollLeft)mx+=document.body.scrollLeft;
		my=window.event.clientY;
		if(document.body.scrollTop)my+=document.body.scrollTop;
	} else {
		if(navigator.appName.substring(0,3)=="Net") {
			document.captureEvents( Event.MOUSEMOVE );
			document.onmousemove=position;
		}
	}
}


function HideAll(track){
	if (menu_selected != 1) {
		eval("T" + (menu_selected-1) + ".Show(0)");
	}
	DstepRoll('im' + menu_selected, img_off[menu_selected-1].src, 'NavBar');
	if (HideAll.arguments.length < 1) {track = menu_base;}
	if(track==8){
		DstepRoll('im7', img_on[7].src, 'NavBar');
		menu_selected = 7;
	} else {
		DstepRoll('im' + track, img_on[track-1].src, 'NavBar');
		menu_selected = track;
	}
}




function preload( imgObj, imgSrc ){
	if( document.images ) {
		eval(imgObj+' = new Image()')
		eval(imgObj+'.src = "'+imgSrc+'"')
	}
}




TreeItem.dmcount=0;


// fonction de roll-over
function DstepRoll(ImgNam,Chemimg,Mylayon){
	var ns4=(document.layers)?true:false;
	var ie4=(document.all)?true:false;
	var ns6=(document.getElementById && !document.all)?true:false;
	if(Mylayon==0){
		if(document.images){document.images[ImgNam].src=Chemimg;}
	} else {
		if (ns4)document.layers[Mylayon].document.images[ImgNam].src=Chemimg;
		if (ie4||ns6) document.images[ImgNam].src=Chemimg;
	}
}

