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_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_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 OpenZoom(Image,Largeur,Hauteur)
{
	arrayOfStrings = Image.split('/');
	arrayOfName = arrayOfStrings[arrayOfStrings.length-1].split('.');
	Offset=5;	
	Largeur=Largeur+Offset;
	Hauteur=Hauteur+Offset;
	screen_width = screen.width - Largeur;
	screen_width = screen_width / 2;
	screen_width = Math.floor(screen_width);
	if(screen_width < 0)
		screen_width=0;
	screen_height = screen.height - Hauteur;
	screen_height = screen_height / 2;
	screen_height = Math.floor(screen_height);
	if(screen_height < 0)
		screen_height=0;
	if(document.layers)
  		window.open('zoommer.php4?Image='+Image+'&Width='+(Largeur-Offset)+'&Height='+(Hauteur-Offset),'ZOOM','width='+Largeur+',height='+Hauteur+',scrollbars=no,toolbar=no,location=no,status=no,menubar=no,resizable=yes,screenX='+screen_width+',screenY='+screen_height);
  	else
  		window.open('zoommer.php4?Image='+Image+'&Width='+(Largeur-Offset)+'&Height='+(Hauteur-Offset),'ZOOM','width='+Largeur+',height='+Hauteur+',scrollbars=no,toolbar=no,location=no,status=no,menubar=no,resizable=yes,left='+screen_width+',top='+screen_height);
}
function ValidationSaisie(Formulaire)
{
	if(Formulaire.nom.value=='')
	{
		alert("Le nom est obligatoire");
		return;
	}
	if(!isNaN(Formulaire.nom.value))
	{
		alert("Le nom est invalide");
		return;
	}
	if(Formulaire.prenom.value=='')
	{
		alert("Le prenom est obligatoire");
		return;
	}
	if(!isNaN(Formulaire.prenom.value))
	{
		alert("Le prénom est invalide");
		return;
	}
	
	if(Formulaire.tel.value=='')
	{
		alert("Le numéro de téléphone est obligatoire");
		return;
	}
	if(isNaN(Formulaire.nbchambres.value))
	{
		alert("Le nombre de chambres est invalide");
		return;
	}
	if((Formulaire.nbchambres.value)<=0)
	{
		alert("Le nombre de chambres est invalide");
		return;
	}
	if(isNaN(Formulaire.nbpers.value))
	{
		alert("Le nombre d'occupants est invalide");
		return;
	}
	if((Formulaire.nbpers.value)<=0)
	{
		alert("Le nombre d'occupants est invalide");
		return;
	}
	if( ValidationEmail(Formulaire.email.value) == false)
		return;
	if(!CompareAD(Formulaire.depart.value,Formulaire.arrivee.value))
		return;
//	alert('Bientôt en ligne !!');
//	return;
	Formulaire.submit();
}

function CompareAD(depart,arrivee)
{
	var Tablo=arrivee.split("/");
	var Tablo1=depart.split("/");
	if (isNaN(Number(Tablo[0])))
	{
		alert("La date est invalide ");
		return false;
	}
	if (isNaN(Number(Tablo[1])))
	{
		alert("La date est invalide ");
		return false;
	}
	if (isNaN(Number(Tablo[2])))
	{
		alert("La date est invalide ");
		return false;
	}
	if (isNaN(Number(Tablo1[0])))
	{
		alert("La date est invalide ");
		return false;
	}
	if (isNaN(Number(Tablo1[1])))
	{
		alert("La date est invalide ");
		return false;
	}
	if (isNaN(Number(Tablo1[2])))
	{
		alert("La date est invalide ");
		return false;
	}
	
	
	if (Number(Tablo[2])>Number(Tablo1[2]))
	{
		alert("La date de départ précède la date d'arrivée ");
		return false;
	}
	if (Number(Tablo[2])==Number(Tablo1[2]))
	{
		if (Number(Tablo[1])>Number(Tablo1[1]))
		{
			alert("La date de départ précède la date d'arrivée ");
			return false;
		}
		if (Number(Tablo[1])==Number(Tablo1[1]))
		{
			if (Number(Tablo[0])>Number(Tablo1[0]))
			{
				alert("La date de départ précède la date d'arrivée ");
				return false;
			}
		}
	}
	return true;
}
	

function ValidationEmail(Email)
{
	var Tablo=Email.split("@");
	if (Tablo.length != 2)
	{
		alert("L'e-mail est invalide");
		return false;
	}
	else 
	{
		var Tablo1 = Tablo[1].split(".");
		if (Tablo1.length < 2)
		{
			alert("Nom de domaine invalide");
			return false;
		}
		else
		{
			if(Tablo1[Tablo1.length-1].length < 2 || Tablo1[Tablo1.length-1].length > 3)
			{
				alert("l'extension du nom de domaine n'est pas valide");
				return false;
			}
		}
	}
	return true;
	
}
function clearfield(Form)
{
	if (Form.value == "JJ/MM/AAAA")
		Form.value = "";
}

function checkdate(objName) 
{
	var datefield = objName;
	if (chkdate(objName) == false)
	{
		datefield.select();
		alert("Date invalide. Recommencez.");
		datefield.focus();
		return false;
	}
	else
	{
		if (objName.value == "")
			objName.value = "JJ/MM/AAAA";
		return true;
	}
}

function chkdate(objName) 
{
//	var strDatestyle = "US"; //United States date style
	var strDatestyle = "EU";  //European date style
	var strDate;
	var strDateArray;
	var strDay;
	var strMonth;
	var strYear;
	var intday;
	var intMonth;
	var intYear;
	var booFound = false;
	var datefield = objName;
	var strSeparatorArray = new Array("-"," ","/",".");
	var intElementNr;
	var err = 0;
	var strMonthArray = new Array(12);
	strMonthArray[0] = "Janvier";
	strMonthArray[1] = "Février";
	strMonthArray[2] = "Mars";
	strMonthArray[3] = "Avril";
	strMonthArray[4] = "Mai";
	strMonthArray[5] = "Juin";
	strMonthArray[6] = "Juillet";
	strMonthArray[7] = "Août";
	strMonthArray[8] = "Septembre";
	strMonthArray[9] = "Octobre";
	strMonthArray[10] = "Novembre";
	strMonthArray[11] = "Décembre";
	strDate = datefield.value;
	if (strDate.length < 1)
	{
		return true;
	}
	for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++)
	{
		if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1)
		{
			strDateArray = strDate.split(strSeparatorArray[intElementNr]);
			if (strDateArray.length != 3)
			{
				err = 1;
				return false;
			}
			else
			{
				strDay = strDateArray[0];
				strMonth = strDateArray[1];
				strYear = strDateArray[2];
			}
			booFound = true;
   		}
	}
	if (booFound == false)
	{
		if (strDate.length>5)
		{
			strDay = strDate.substr(0, 2);
			strMonth = strDate.substr(2, 2);
			strYear = strDate.substr(4);
   		}
   		else
   			return false;
	}
	if (strYear.length == 2)
	{
		strYear = '20' + strYear;
	}
	if (strYear.length < 2 || strYear.length == 3 || strYear.length > 4 )
	{
		return false;
	}
//	US style
	if (strDatestyle == "US")
	{
		strTemp = strDay;
		strDay = strMonth;
		strMonth = strTemp;
	}
	intday = parseInt(strDay, 10);
	if (isNaN(intday))
	{
		err = 2;
		return false;
	}
	intMonth = parseInt(strMonth, 10);
	if (isNaN(intMonth))
	{
		for (i = 0;i<12;i++)
		{
			if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase())
			{
				intMonth = i+1;
				strMonth = strMonthArray[i];
				i = 12;
   			}
		}
		if (isNaN(intMonth))
		{
			err = 3;
			return false;
		}
	}
	intYear = parseInt(strYear, 10);
	if (isNaN(intYear))
	{
		err = 4;
		return false;
	}
	if (intMonth>12 || intMonth<1)
	{
		err = 5;
		return false;
	}
	if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1))
	{
		err = 6;
		return false;
	}
	if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1))
	{
		err = 7;
		return false;
	}
	if (intMonth == 2)
	{
		if (intday < 1)
		{
			err = 8;
			return false;
		}
		if (LeapYear(intYear) == true)
		{
			if (intday > 29)
			{
				err = 9;
				return false;
			}
		}
		else
		{
			if (intday > 28)
			{
				err = 10;
				return false;
			}
		}
	}
	if (strDatestyle == "US")
	{
		datefield.value = strMonthArray[intMonth-1] + " " + intday+" " + strYear;
	}
	else
	{
		Jour=new String(intday);
		if(Jour.length==1)
			Jour="0"+Jour;
		Mois=new String(intMonth);
		if(Mois.length==1)
			Mois="0"+Mois;
//		datefield.value = intday + " " + strMonthArray[intMonth-1] + " " + strYear;
		datefield.value = Jour + "/" + Mois + "/" + strYear;
	}
	return true;
}

function LeapYear(intYear)
{
	if (intYear % 100 == 0)
	{
		if (intYear % 400 == 0)
		{
			return true;
		}
	}
	else
	{
		if ((intYear % 4) == 0)
		{
			return true;
		}
	}
	return false;
}

function OpenWindow(theURL,winName,Largeur,Hauteur)
{
	screen_width = screen.width - Largeur;
	screen_width = screen_width / 2;
	screen_width = Math.floor(screen_width);
	if(screen_width < 0)
		screen_width=0;
	screen_height = screen.height - Hauteur;
	screen_height = screen_height / 2;
	screen_height = Math.floor(screen_height);
	if(screen_height < 0)
		screen_height=0;
	if(document.layers)
  		window.open(theURL,winName,'width='+Largeur+',height='+Hauteur+',scrollbars=auto,toolbar=no,location=no,status=no,menubar=no,resizable=no,screenX='+screen_width+',screenY='+screen_height);
  	else
  		window.open(theURL,winName,'width='+Largeur+',height='+Hauteur+',scrollbars=auto,toolbar=no,location=no,status=no,menubar=no,resizable=no,left='+screen_width+',top='+screen_height);
}

var ScrollInfo 

function Initialise_Limite_Scroller_Info() 
{ 
	HEADER_TXT_INFO="<CENTER>"; 
	FOOTER_TXT_INFO="</CENTER>"; 
	VITESSE_DEPLACEMENT_INFO=20; 
} 
 
function Place_Info() 
{ 
	La_Position_X=ObjX("INFO","DIVINFO"); 
	La_Position_Y=ObjY("INFO","DIVINFO"); 
	La_Position_X=La_Position_X - VITESSE_DEPLACEMENT_INFO; 
	if(La_Position_X<=0) 
		La_Position_X=0; 
	PlacerObj("INFO",La_Position_X,La_Position_Y,"DIVINFO"); 
	if(La_Position_X!=0) 
		ScrollInfo = setTimeout("Place_Info();", 5); 
	else 
	{ 
		clearTimeout(ScrollInfo); 
		ScrollInfo = setTimeout("Attente_Info();", 5000); 
	} 
} 
 
function Attente_Info() 
{ 
	clearTimeout(ScrollInfo); 
	ScrollInfo = setTimeout("Degage_Info();", 5); 
} 
 
function Degage_Info() 
{ 
	La_Position_X=ObjX("INFO","DIVINFO"); 
	La_Position_Y=ObjY("INFO","DIVINFO"); 
	La_Position_X=La_Position_X - VITESSE_DEPLACEMENT_INFO; 
	if(La_Position_X<=-690) 
		La_Position_X=-690; 
	PlacerObj("INFO",La_Position_X,La_Position_Y,"DIVINFO"); 
	if(La_Position_X!=-690) 
		ScrollInfo = setTimeout("Degage_Info();", 5); 
	else 
	{ 
		ID_INFO++; 
		if(ID_INFO==TEXTE_INFO.length) 
			ID_INFO=1; 
		PlacerObj("INFO",690,La_Position_Y,"DIVINFO"); 
		ModifierObj("INFO",HEADER_TXT_INFO + TEXTE_INFO[ID_INFO] + FOOTER_TXT_INFO,"DIVINFO"); 
		ScrollInfo = setTimeout("Place_Info();", 5); 
	} 
} 
 
function Lance_Deplacement_Info() 
{ 
	ModifierObj("INFO",HEADER_TXT_INFO + TEXTE_INFO[ID_INFO] + FOOTER_TXT_INFO,"DIVINFO"); 
	ScrollInfo = setTimeout("Place_Info();", 5); 
}
