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_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_showHideLayers() { //v6.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; }
}

function change(id)
//Affichage ou non des sous-éléments
{
	testId = document.getElementById(id);
	if (testId)	
	{
		if (document.getElementById(id).style.display == 'block')
			document.getElementById(id).style.display = 'none';
		else
			document.getElementById(id).style.display = 'block';
	}
}

function changeLayerDestination(id)
//Affichage ou non des sous-éléments
{
	testId = document.getElementById(id);
	if (testId)	
	{
		if (document.getElementById(id).style.display == 'block')
		{
			document.getElementById(id).style.display = 'none';
			document.getElementById('imgdestination').src = 'design/menu_fleche1.gif';			
		}
		else
		{
			document.getElementById(id).style.display = 'block';
			document.getElementById('imgdestination').src = 'design/menu_fleche1_sel.gif';			
		}
	}
}


function cache(id)
//Affichage ou non des sous-éléments
{
	testId = document.getElementById(id);
	if (testId)	
		document.getElementById(id).style.display = 'none';
}

function VisibilityFiltre(id, elem)
//Affichage ou non des sous-éléments
{
	testId = document.getElementById(id);
	if (testId)	
	{
		if (document.getElementById(id).style.display == 'block')
			document.getElementById(id).style.display = 'none';
		else
		{
			document.getElementById(id).style.display = 'block';
			document.getElementById(elem).focus();
			document.getElementById(elem).select;		
		}
	}
}

function MAJchamp (obj1, valeur)
{
	alert(document.vol.inputville.name)
	alert(obj1)
	wobj1 = document.getElementById(obj1)
	alert(wobj1)
	wobj1.value = valeur
}


			function new_browser(src,name,w,h) 
			{
				size=",width="+w+",height="+h
				browser=window.open(src,name,"resizable=yes,scrollbars=yes,toolbar=yes,status=yes,menubar=yes,location=1,directories=yes,top=0,left=0"+size)
			}
			
			
			function new_browser1(src,name,w,h) 
			{
			size=",width="+w+",height="+h
			browser=window.open(src,name,"resizable=no,scrollbars=yes,toolbar=no,status=no,menubar=no,location=0,directories=no,top=0,left=0"+size)
			}
		
			function new_browser2(src,name,w,h) 
			{
			size=",width="+w+",height="+h
			browser=window.open(src,name,"resizable=no,scrollbars=no,toolbar=no,status=no,menubar=no,location=0,directories=no,top=0,left=0"+size)
			}
			
			function new_browser3(src,name,w,h) 
			{
			size=",width="+w+",height="+h
			browser=window.open(src,name,"resizable=no,scrollbars=yes,toolbar=yes,status=no,menubar=yes,location=0,directories=no,top=0,left=0"+size)
			}			
			function new_browser4(src,name,w,h) 
			{
			size=",width="+w+",height="+h
			browser=window.open(src,name,"resizable=yes,scrollbars=yes,toolbar=no,status=no,menubar=no,location=0,directories=no,top=0,left=0"+size)
			}	
		
			function photothequeFF(src,name,w,h) 
			{
			size=",width="+w+",height="+h
			browser=window.open(src,name,"resizable=yes,scrollbars=yes,toolbar=no,status=no,menubar=no,location=0,directories=no,top=0,left=0"+size)
			}	
					
			function imprimer ()
			{
				new_browser1("imprimer.html",'imprimer',320,240)
			}
			
			function calendrier(src,name,w,h) 
			{
			size=",width="+w+",height="+h
			browser=window.open(src,name,"resizable=no,scrollbars=no,toolbar=no,status=no,menubar=no,location=0,directories=no,top=350,left=700"+size)
			}
			
function fenetrephoto2 (repimages, lo, ha, nomimage,id)
	{	

		//alert ("document.formulaire."+monimage+".value")	
		//chemimage = repimages +	"/" + eval ("document.formulaire."+monimage+".value")			
		size=",width="+lo+",height="+ha		
		monURL = "visualisation4bb4.html?image="+repimages+"&id="+id
		//alert (monURL)
		browser=window.open(monURL, nomimage,"resizable=no,scrollbars=auto,toolbar=no,status=no,menubar=no,location=0,directories=no"+size)
	}

function MailFaux(ValeurInput)
		{

		  dotPos = ValeurInput.indexOf('.');
		  if (dotPos>0)
		  {
			  if (dotPos <= (ValeurInput.length - 3))
			  {
				  var Regex = new RegExp("^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$");		  
			      var Result = Regex.test(ValeurInput);
				  if (Result) {return false;}
				  else {return true;}
			   }	  
			  else 
			  {
			  	  return true;
			  }				
			}
			else 
			{
				return true;
			}
		}	
		
		
function TelFaux(ValeurInput)
		{
		  var pays = document.forms[0].pays.value;
		  var paysU = pays.toUpperCase();
		  if (paysU=="" || paysU=='FRANCE')
		  {
			 if (ValeurInput.length != 10)
			 	return true;
			 else
		 		return false;		
		  }	
		  else
		  {
		  	return false;
		  }		
		}	
				

function CodePostalFaux(ValeurInput)
		{
		  var pays = document.forms[0].pays.value;
		  var paysU = pays.toUpperCase();
		  if (paysU=="" || paysU=='FRANCE')
		  {		
			 if (ValeurInput.length != 5)
			 	return true;
			 else
		 		return false;
		  }		
		  else
		  {
		  	return false;
		  }		
		}	

function clearfield(obj,texteAeffacer)
		{
			if (obj.value.toLowerCase() == texteAeffacer.toLowerCase()) obj.value = "";
		}
function clearfield2()
		{
			if (document.vol.d.value == "JJ/MM/AA") document.vol.d.value = "";
		}
		
function controle ()
{		
	// 1er argument = identifiant du formulaire

	// obli#idcontrolejs#nominput
	
	//idcontrolejs
	// 0 : aucun controle
	// 1 : controle numerique 
	// 2 : controle e-mail - null autorisé
				
	var args = controle.arguments;
	var erreur = 0;
	var idform = args[0];
	var premierchamperreur = "";
	
	for (i=1;i<args.length;i++)
	{		
		// extraction variable obli
		var obli = args[i].substring(0, 1);
		
		//extraction IDcontroleJS 
		var pos2emediese = args[i].indexOf("#", 2);
		var idcontrolejs = args[i].substring(2, pos2emediese);
		
		if (idcontrolejs!=-1)
		{
		
			//extraction nominput
			pos2emediese = pos2emediese + 1;
			var nominput = args[i].substring(pos2emediese, args[i].length);
			
			nom = "p" + nominput;
			// on reinitialise tout les marqueurs d'erreur	
			var t = eval("document.forms." + idform + "."+nom+".name");
			eval("document.forms." + idform + "."+nom+".src='design/pixel.gif'");
			var valeurinput = eval("document.forms[idform]." + nominput + ".value");
			var valeurcheck = 0;
			
			
			// si checkbox verification case coché
			if (idcontrolejs == 4)
			{
				
				n = 0;
				y = 0;
				temp = 0 
				temp = eval("document.forms." + idform + "." + nominput + ".length");
															
				if (!isNaN(temp))
					{
					for (y = 0; y < temp ; y++)
			 			  {
				   	 		if ( eval("document.forms." + idform + "." + nominput + "[" + y + "].checked"))
			    				{
									n = n + 1;	
			    				}
  			 	   		  }
				 	}
			 
				 if (n == 0)
				 {
					 valeurcheck = 1;
				 }
			}
			

			// si Listbox vérif si valeur 0
			if (idcontrolejs == 6)
			{
			temp = eval("document.forms." + idform + "." + nominput + ".value");
			
				if (temp == 0)
					{
						valeurcheck = 1;
					}
	
			}
				

			// test si champ obligatoire			 
			if (obli==1)
			{			
				if ((valeurinput == "") || (valeurcheck == 1)) 
				{
					eval("document.forms." + idform + "."+nom+".src='design/Erreur2.gif'");
					erreur = 1;
					if (premierchamperreur == '') premierchamperreur  = nominput;
					valeurcheck = "null"
				}
			}
		
			// controle en fonction du type du champ	
			switch (idcontrolejs) 
			{
						
			   case "1" :
			  
					if (valeurinput != '') 
					{
						wvaleurinput = Remplace(valeurinput,",",".");
						
						if (isNaN(wvaleurinput)) 
						{
							eval("document.forms." + idform + "."+nom+".src='design/Erreur2.gif'"); 
							erreur = 1;
							if (premierchamperreur == '') premierchamperreur  = nominput;							
						}		
					}
					break;						
					
			   case "2" :
					if (MailFaux(valeurinput)) 
					{
						eval("document.forms." + idform + "."+nom+".src='design/Erreur2.gif'"); 
						erreur = 1;
						if (premierchamperreur == '') premierchamperreur  = nominput;								
					}		
					break;
					
				case "3" :
				
					var nominput2 = "confirmation" + nominput
					var valeurinput2 = eval("document.forms[idform]." + nominput2 + ".value");
					if (valeurinput2 != valeurinput)
					{
						eval("document.forms." + idform + "."+nom+".src='design/Erreur2.gif'"); 					
						erreur = 1;
						if (premierchamperreur == '') premierchamperreur  = nominput2;							
					}
				

				
			}						
		} 				
		
	}
	if (erreur == 1)
		return premierchamperreur;
	else			
		return "0";

}		

		
function MailFaux(ValeurInput)
{
  if (ValeurInput!='')
  {
	  dotPos = ValeurInput.indexOf('.');
	  if (dotPos>0)
	  {
		  if (dotPos <= (ValeurInput.length - 3))
		  {
			  var Regex = new RegExp("^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$");		  
	    	  var Result = Regex.test(ValeurInput);
			  if (Result) {return false;}
			  else {return true;}
		   }	  
		   else 
		  {
		  	  return true;
		  }				
		}
		else 
		{
			return true;
		}
	}
}			

function Remplace(expr,a,b) 
{
 var i=0
    while (i!=-1) 
 {
     i=expr.indexOf(a,i);
        if (i>=0) 
  {
            expr=expr.substring(0,i)+b+expr.substring(i+a.length);
            i+=b.length;
         }
      }
      return expr
}