// JavaScript Document
function MM_effectBlind(targetElement, duration, from, to, toggle){
Spry.Effect.DoBlind(targetElement, {duration: duration, from: from, to: to, toggle: toggle});
}

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_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_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];}
}

//******************************************************************************************************************//
//Pour la gestion des boites menus avec Spry Effect BLIND

//Lors de l'arrivée dans la page, vérification des valeurs des cookies + mémoriser dans des variables
function load_pour_boite(nom_boite,etat_initial){
nom_cookie_en_cours="ind_boite_"+nom_boite;
eval("etat_initial_"+nom_boite+"='"+etat_initial+"'");
eval("cookie_"+nom_boite+"='"+etat_initial+"'");
eval(nom_cookie_en_cours+"='"+etat_initial+"'"); 
}

//Lors de l'arrivée dans la page, affichage ouvert ou fermé de la boite de détails selon la valeur du cookie
function afficher_cacher_boite(nom_boite,chemin){
nom_boite_en_cours="boite_"+nom_boite;
	if(eval("cookie_"+nom_boite)=='on',chemin){
	traiterImageDetails(nom_boite,'off');
	document.getElementById(nom_boite_en_cours).style.visibility='visible';
	document.getElementById(nom_boite_en_cours).style.display='block';
	}
	else{
	traiterImageDetails(nom_boite,'on',chemin);
	document.getElementById(nom_boite_en_cours).style.visibility='hidden';
	document.getElementById(nom_boite_en_cours).style.display='none';
	}
}

//Permet de basculer l'image de détails (flèche vers le haut ou vers le bas) + basculer la valeur du cookie
function traiterImageDetails(nom,etat_boite,chemin){
    if(etat_boite=='off'){
	MM_swapImage("btn_details_boite_"+nom,'',chemin+'images/img_fleche_haut.gif',1);
	eval("ind_boite_"+nom+"='on'");
	//ecrire_cookie("ind_boite_"+nom,'on',date);
	}
    else{
    MM_swapImage("btn_details_boite_"+nom,'',chemin+'images/img_fleche_bas.gif',1);
	eval("ind_boite_"+nom+"='off'");
	//ecrire_cookie("ind_boite_"+nom,'off',date);
    }
}

//Lors d'un clic, permet de faire afficher ou de cacher la boite de détails (effet bascule)
function afficher_function_blind(nom_boite){ 
  function_blind="";
  boite_en_cours='boite_'+nom_boite;
  cookie_en_cours='ind_boite_'+nom_boite;
	 if(eval("cookie_"+nom_boite)=='off'){
		  if(eval("etat_initial_"+nom_boite)=="" || eval("etat_initial_"+nom_boite)=="off"){
				if(eval("var_premiere_fois_"+nom_boite)=='true'){ //1
				function_blind="MM_effectBlind(boite_en_cours, 300, '0%', '100%', false)";
				eval("var_premiere_fois_"+nom_boite+"='false'");
				//alert('OFF - 1');
				}
				else{ //3
				 function_blind="MM_effectBlind(boite_en_cours, 300, '100%', '0%', true)";
				eval("var_premiere_fois_"+nom_boite+"='false'");
				//alert('OFF - 3');
				}
		  }
		  else{ //2/
		  function_blind="MM_effectBlind(boite_en_cours, 300, '100%', '0%', false)";
		  eval("var_premiere_fois_"+nom_boite+"='false'");
		  //alert('OFF - 2');
		  }
	  }
	   if(eval("cookie_"+nom_boite)=='on'){
		 if(eval("etat_initial_"+nom_boite)=="on"){
				if(eval("var_premiere_fois_"+nom_boite)=='true'){ //1
				function_blind="MM_effectBlind(boite_en_cours, 300, '100%', '0%', true)";
				eval("var_premiere_fois_"+nom_boite+"='false'");
				//alert('ON - 1');
				}
				else{ //3
				function_blind="MM_effectBlind(boite_en_cours, 300, '100%', '0%',true)";
				eval("var_premiere_fois_"+nom_boite+"='false'");
				//alert('ON - 3');
				}
		}
		else{ //2
		function_blind="MM_effectBlind(boite_en_cours, 300, '100%', '0%', true)";
		eval("var_premiere_fois_"+nom_boite+"='false'");
		//alert('ON - 2');
		}
	 }
  }
//******************************************************************************************************************//
//Ouverture d'une nouvelle fenêtre
function NewWindow(mypage,myname,w,h,scroll){
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/2;
var settings  ='height='+h+',';
    settings +='width='+w+',';
    settings +='top='+wint+',';
    settings +='left='+winl+',';
	settings +='scrollbars='+scroll+',';
    settings +='resizable=yes';
win=window.open(mypage,myname,settings);
	if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}

function resultats_pour_impression(idForm,page,nomPopup) {
my_form = document.getElementById(idForm);
window.open(page, nomPopup, "height=600, width=660, menubar=no, toolbar=no, location=no, status=no, scrollbars=yes, resizable=yes");
my_form.target = nomPopup;
my_form.action = page;
my_form.submit();
}

function resultats_pour_excel(idForm,page,nomPopup) {
my_form = document.getElementById(idForm);
//window.open(page, nomPopup, "height=600, width=660, menubar=no, toolbar=no, location=no, status=no, scrollbars=yes, resizable=yes");
//my_form.target = nomPopup;
my_form.action = page;
my_form.submit();
}

function disableEnterKey(evt){
var key = (window.Event) ? evt.which : evt.keyCode;
	if (key == 13/* || key == 8*/) return false;
return true;
}

function imprimerPage(url){
window.open(url,'', 'top=-100000, left=-100000, width=1, height=1, resizable=no, toolbar=no, scrollbars=no, status=no');
}
