/*
*	Fichier script.js : Fonctions clientes javascripts communes à toutes les pages du site
*/
// -- Fonctions Macromedias
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 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_reloadPage(init) {  //reloads the window if Nav4 resized
  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 MM_showHideLayers() { //v3.0
  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; }
}
// ----- Fonctions pour le menu
function interrupteur(num){
	if (eval("document.all.t"+num+".style.visibility")=='visible')
		cacher(num);
	else
		montrer(num);
}
function montrer(num){
	toutCacher();
	with(eval("document.all.t"+num)){
		style.visibility='visible';
		style.position='relative';
	}
}
function cacher(num){
	with(eval("document.all.t"+num)){
		style.visibility='hidden';
		style.position='absolute';
	}
}
function toutCacher(){
	for (i=0;eval("document.all.t"+i);i++)
		cacher(i);
}
// ----- Fonctions pour le survol des sous-rubriques dans infoBulle (fond de cellule en négatif)
function negatifon(obj){
	obj.parentElement.style.backgroundColor='#ffffff';
	obj.style.color='#336699';
}
function negatifoff(obj){
	obj.parentElement.style.backgroundColor='#000066';
	obj.style.color='#ffffff';
}
// ----- Fonctions pour le contrôle de saisie
function annuler(url){
	if (confirm('Cette action annulera votre saisie.')){
		location.href=url;
	}
}
//----- Transmet le nouveau numéro de page au formulaire et l'envoi
function changePage(numPage){
	f=document.forms[0];
	f.changementRequete.value='non';
	f.page.value=numPage;
	f.submit();
}
//------- Fonctions pour les pages de recherche
function genererPages(nbPages,pageCourante){
	reponse="";
	if (pageCourante>1){
		reponse+='<a class=lien href="javascript:changePage('+(pageCourante-1)+')">&lt;&lt; Page Précédente</a>&nbsp;&nbsp;';
	}
	for (i=1;i<=nbPages && (i<=10 || i<=pageCourante+2);i++){
		if (i!=pageCourante){
			reponse+='<A class=lien HREF="javascript:changePage('+i+');" target=_self>'+i+'</A>';
		}else{
			reponse+=i;
		}
		if (i<nbPages){
			reponse+=' | ';
		}
	}
	if (pageCourante<nbPages){
		reponse+=('&nbsp;<a class=lien href="javascript:changePage('+(pageCourante+1)+')">Page Suivante &gt;&gt;</a>');
	}
	document.write(reponse);
}
// -- Fonctions pour ouvrir une fenêtre POPUP avec URL,DIMX,DIMY
function popup(url,largeur,hauteur){
	var f=window.open(url,"fenetre","height="+hauteur+",width="+largeur);
	f.focus();
}
// -- Fonctions permmettant de generer une boite de selection
function genererBoite(strNom,tab,indice)
{	

	resultat='<select name="'+strNom+'">';
	resultat+='<option value="">--- Votre Choix ---</option>';
	for (i=0;i<tab.length-1;i+=2)
	{
		resultat+='<option value='+tab[i];
		if (tab[i]==indice)
		{
			resultat+=' selected';
		}
		resultat+='>'+tab[i+1]+'</option>';
	}
	resultat+='</select>';
	document.write(resultat);
}

// -- Fonction pour activer / decativer la bordure sur une image à partir de son nom
function bordure(nomImage,bordureActivee){
	if (bordureActivee){
		with(document.images[nomImage].style){
			border='solid';
			borderWidth='2px';
			borderColor='#000066';
		}
	}else{
		document.images[nomImage].style.borderWidth='0px';
	}
}