// FONCTIONS
function goMenu(ref){
	alert("action sur menu"+ref);
}

function js2as_function(ref){
	thisMovie("menu").goToMethod(ref);
}

function thisMovie(movieName){
    if (navigator.appName.indexOf("Microsoft") != -1) {return window[movieName];}
    else {return document[movieName];}
}

function changePage(ref,refpage){
	if(ref){
		if(refpage!=''){document.getElementById('ifrm').src = refpage;}
		else{document.getElementById('ifrm').src = 'contenu.php?pg='+ref;}
		//frames['ifrm'].location.href = 'contenu.php?pg='+ref;
	}
}

function reSize(){
	if (ifrm.document.height) {
    	var iframeElement = document.getElementById('ifrm');
		iframeElement.style.height = '520px';
    	iframeElement.style.width = '520px';
    	iframeElement.style.height = ifrm.document.body.scrollHeight + 'px';
    	iframeElement.style.width = ifrm.document.body.scrollWidth + 'px';
	}
  
	else if(document.all) {
    	var iframeElement = document.all['ifrm'];
    	if (ifrm.document.compatMode && ifrm.document.compatMode != 'BackCompat') {
      		iframeElement.style.height = ifrm.document.documentElement.scrollHeight + 5 + 'px';
      		iframeElement.style.width = ifrm.document.documentElement.scrollWidth + 5 + 'px';
    	}
    	else {
			iframeElement.style.height = '520px';
    		iframeElement.style.width = '520px';
			if(ifrm.document.body.scrollHeight>520){
      			iframeElement.style.height = ifrm.document.body.scrollHeight + 5 + 'px';
			}
      		iframeElement.style.width = ifrm.document.body.scrollWidth + 5 + 'px';
    	}
	}
}

function goTop(ref){

	document.getElementById('divCloser').style.left=(calcX(ref)-closer_border)+"px";
	document.getElementById('divCloser').style.top=(head_height)+"px";
	document.getElementById('divCloser').style.width=(cell_menu_width+closer_border*2)+"px";
	//document.getElementById('divCloser').style.height=(max_cell_menu*cell_menu_height+closer_border)+"px";
	document.getElementById('divCloser').style.height=(tabMenuMax[ref]*cell_menu_height)+"px";
	
	document.getElementById('shim').style.width=(cell_menu_width+closer_border*2)+"px";
	//document.getElementById('shim').style.height=(max_cell_menu*cell_menu_height+closer_border)+"px";
	document.getElementById('shim').style.height=(tabMenuMax[ref]*cell_menu_height)+"px";
	
	flevHideMenus(false,ref);
	
	if(navigator.userAgent.indexOf("Firefox")!=-1 || navigator.userAgent.indexOf("Safari")!=-1){
				document.getElementById('divMenu'+ref).style.top=head_height+"px";
				document.getElementById('divMenu'+ref).style.visibility="visible";
	}
	else{flvFSL1('divMenu'+ref,calcX(ref),head_height,10,0,0);}
	
	document.getElementById('divMenu'+ref).style.display = "inline";
	
	//for (i=0; i<6; i++){if(ref!=i){document.getElementById('divMenu'+i).style.display = "none";}}
}

function initDIV(){
	//alert(document.getElementById('tablo1').width);
	//document.getElementById('store').style.display = "none";
	
	//var myMenu;
	//myMenu = new SDMenu("menu_gauche");
	//myMenu.init();
	//myMenu.collapseAll();
	
	document.getElementById('store').style.left=calcX(0)+"px";
	document.getElementById('store').style.width=(site_width+width_decalage)+"px";
	document.getElementById('store').style.height=(head_height+height_decalage)+"px";
	tabDivName[0]="store";
	tabDivY0[0]=0;
	
	document.getElementById('divMenu1').style.left=calcX(1)+"px";
	document.getElementById('divMenu1').style.top=calcY(tabMenuMax[1],head_height)+"px";
	tabDivName[1]="divMenu1";
	tabDivY0[1]=calcY(tabMenuMax[1],head_height);
	
	document.getElementById('divMenu2').style.left=calcX(2)+"px";
	document.getElementById('divMenu2').style.top=calcY(tabMenuMax[2],head_height)+"px";
	tabDivName[2]="divMenu2";
	tabDivY0[2]=calcY(tabMenuMax[2],head_height);
	
	document.getElementById('divMenu3').style.left=calcX(3)+"px";
	document.getElementById('divMenu3').style.top=calcY(tabMenuMax[3],head_height)+"px";
	tabDivName[3]="divMenu3";
	tabDivY0[3]=calcY(tabMenuMax[3],head_height);
	
	document.getElementById('divMenu4').style.left=calcX(4)+"px";
	document.getElementById('divMenu4').style.top=calcY(tabMenuMax[4],head_height)+"px";
	tabDivName[4]="divMenu4";
	tabDivY0[4]=calcY(tabMenuMax[4],head_height);
	
	document.getElementById('divMenu5').style.left=calcX(5)+"px";
	document.getElementById('divMenu5').style.top=calcY(tabMenuMax[5],head_height)+"px";
	tabDivName[5]="divMenu5";
	tabDivY0[5]=calcY(tabMenuMax[5],head_height);
	
	document.getElementById('divMenu6').style.left=calcX(6)+"px";
	document.getElementById('divMenu6').style.top=calcY(tabMenuMax[6],head_height)+"px";
	tabDivName[6]="divMenu6";
	tabDivY0[6]=calcY(tabMenuMax[6],head_height);

	document.getElementById('divMenu1').style.display = "inline";
	document.getElementById('divMenu2').style.display = "inline";
	document.getElementById('divMenu3').style.display = "inline";
	document.getElementById('divMenu4').style.display = "inline";
	document.getElementById('divMenu5').style.display = "inline";
	document.getElementById('divMenu6').style.display = "inline";
	
	flevHideMenus(true);
}

function WinSize(){
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {  //Firefox
		myWidth = window.innerWidth; myHeight = window.innerHeight;  //-18
	} else if( document.documentElement && ( document.documentElement.clientWidth ||document.documentElement.clientHeight ) ) {
		myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		myWidth = document.body.clientWidth; myHeight = document.body.clientHeight;
	} else { //IE
		myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight;
	}
	//alert(myWidth);
	return myWidth;
}

function calcX(ex){
	twin = WinSize();
	ttab = document.getElementById('tablo1').width;
	corH = (parseInt(twin/2) - ttab/2);
	if(corH<0){corH=0}
	corV = 0;
	if(ex==0){ex=1;x_decalage+=x_decalage_store;} // store
	return cell_menu_width*(ex-1) + corH + x_decalage;
}

function calcY(nbr,refH){
	cellheight = 25;   // hauteur d'une cellule de menu
	menu_foot = 8;     // taille du pied menu 
	correction = 50;   // correction en hauteur
	return refH-nbr*cell_menu_height-menu_foot-correction;
}

function MM_reloadPage(init) {  //Updated by PVII. Reloads the window if Nav4 resized
	//alert("MM_reloadPage");
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function flevHideMenus(bHideCloser,ref) {
	//alert("flevHideMenus:"+bHideCloser);
	//for(i=1;i<=6;i++){if(i!=ref){flvFSL1('divMenu'+i,calcX(i),calcY(tabMenuMax[i],head_height),10,0,0);}}
	//if(navigator.userAgent.indexOf("Firefox")!=-1 || navigator.userAgent.indexOf("Safari")!=-1){
	//}
	//else{
		flvFSL1('divMenu1',calcX(1),calcY(tabMenuMax[1],head_height),10,0,0);
		flvFSL1('divMenu2',calcX(2),calcY(tabMenuMax[2],head_height),10,0,0);
		flvFSL1('divMenu3',calcX(3),calcY(tabMenuMax[3],head_height),10,0,0);
		flvFSL1('divMenu4',calcX(4),calcY(tabMenuMax[4],head_height),10,0,0);
		flvFSL1('divMenu5',calcX(5),calcY(tabMenuMax[5],head_height),10,0,0);
		flvFSL1('divMenu6',calcX(6),calcY(tabMenuMax[6],head_height),10,0,0);
	//}
	if (bHideCloser) {
		MM_showHideLayers('divCloser','','hide');
	}
	else {
		MM_showHideLayers('divCloser','','show');
	}
}

function MM_showHideLayers() { //v3.0
  //alert("MM_showHideLayers");
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

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 flvFSL1(){//v2.3
// Copyright 2002-2004, Marja Ribbers-de Vroed, FlevOOware (www.flevooware.nl/dreamweaver/)
var v1=arguments,v2=v1[0],v3=MM_findObj(v2),v4,v5,v6,v7,v8,v9,v10,v11,v12,v13,v14,v15,v16,v17,v18,v19,v20=window,v21=navigator;
/*
var prompt="";
prompt+="v1="+v1+"\n";
prompt+="v2="+v2+"\n";
prompt+="v3="+v3+"\n";
prompt+="v4="+v4+"\n";
prompt+="v5="+v5+"\n";
prompt+="v6="+v6+"\n";
prompt+="v7="+v7+"\n";
prompt+="v8="+v8+"\n";
prompt+="v9="+v9+"\n";
prompt+="v10="+v10+"\n";
prompt+="v11="+v11+"\n";
prompt+="v12="+v12+"\n";
prompt+="v13="+v13+"\n";
prompt+="v14="+v14+"\n";
prompt+="v15="+v15+"\n";
prompt+="v16="+v16+"\n";
prompt+="v17="+v17+"\n";
prompt+="v18="+v18+"\n";
prompt+="v19="+v19+"\n";
prompt+="v20="+v20+"\n";
prompt+="v21="+v21+"\n";
alert(prompt);
*/
if (v3){
	v4=parseInt(v1[1]);
	v5=parseInt(v1[2]);
	v6=parseInt(v1[3]);
	v7=(v1.length>4)?parseInt(v1[4]):0;
	v8=(v1.length>5)?parseInt(v1[5]):0;
	v9=10;
	v10=document.layers?v3:v3.style;
	if (v3.SL1!=null){clearTimeout(v3.SL1);}
	v11=isNaN(parseInt(v10.left))?v3.offsetLeft:parseInt(v10.left);
	v12=isNaN(parseInt(v10.top))?v3.offsetTop:parseInt(v10.top);
	if (v8!=0){
		if (v8==1){v4=v11-v4;v5=v12;}
		else if (v8==2){v4=v11+v4;v5=v12;}
		else if (v8==3){v5=v12-v5;v4=v11;}
		else {v5=v12+v5;v4=v11;}}v13=v4;
		v14=v5;
		if ((v11!=v4)||(v12!=v5)){
			if (v7>0){
				v9=v6;
				v15=v7;
				v16=v7,v17=Math.abs(v11-v4),v18=Math.abs(v12-v5);
					if (v17<v18){v16=(v17!=0)?((v18/v17)*v7):v7;}
					else {v15=(v18!=0)?((v17/v18)*v7):v7;}
					if (v15>=v17){v15=Math.min(Math.ceil(v15),v7);}
					if (v16>=v18){v16=Math.min(Math.ceil(v16),v7);}
					if ((v11<v4)&&(v11+v15<v4)){v4=v11+v15;}
					if ((v11>v4)&&(v11-v15>v4)){v4=v11-v15;}
					if ((v12<v5)&&(v12+v16<v5)){v5=v12+v16;}
					if ((v12>v5)&&(v12-v16>v5)){v5=v12-v16;}
			}
			else {
				v17=((v4-v11)/v6);
				v18=((v5-v12)/v6);
				v17=(v17>0)?Math.ceil(v17):Math.floor(v17);
				v4=v11+v17;
				v18=(v18>0)?Math.ceil(v18):Math.floor(v18);
				v5=v12+v18;
			}
			v19=((parseInt(v21.appVersion)>4||v21.userAgent.indexOf("MSIE")>-1)&&(!v20.opera))?"px":"";
			if (v17!=0){v10.left=v4+v19;}
			if (v18!=0){v10.top=v5+v19;}
			var v22="flvFSL1('"+v2+"',"+v13+","+v14+","+v6+","+v7+",0)";
			v3.SL1=setTimeout(v22,v9);
		}
		else {
			if (v20.onSlideEnd){onSlideEnd(v2);}
		}
	}
	
	var indDiv = tabDivName.indexOf(v2);
	var divY0 = tabDivY0[indDiv]+"px";
	if(divY0==document.getElementById(v2).style.top){document.getElementById(v2).style.visibility="hidden";}
	else{document.getElementById(v2).style.visibility="visible";}
}

// PARAMETRAGE
var site_width       = 800;   // largeur du tableau
var cell_menu_width  = 134;   // largeur des cellules menu déroulant
var cell_menu_height = 25;    // hauteur des cellules menu déroulant
var head_height      = 368;   // hauteur de l'entete = reference des menus deroulants
var closer_border    = 5;     // bordure du calque de fermeture

//var max_cell_menu    = 10;    // definit la hauteur du calque de fermeture

// ACTIONS INITIALES

if(navigator.userAgent.indexOf("Firefox")!=-1 || navigator.userAgent.indexOf("Safari")!=-1){
	var x_decalage=-9;
	var width_decalage=-2;
	var height_decalage=-2;
	var x_decalage_store=1;
}
else{var x_decalage=0;var width_decalage=0;var height_decalage=0;var x_decalage_store=0;}

var OSName="Unknown OS";
if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";