/*********************************************************************************************************/
// Fonction pour la confirmation d'action
// NB : pensez à addslashes les quotes \' dans le texte du message
// exemple d'uilisation : <a href="javascript:securit('Etes vous sur de vouloir supprimer le thème <?php echo addslashes($theme_nom); ?> ?','theme1.php?theme_id=<?php echo "$theme_id"; ?>&action=supprimer');">
function securit(message,action)
{

	if(confirm(message))
		window.location = action;
		

}
/*********************************************************************************************************/


/*********************************************************************************************************/
// fonction des vérification du nom de fichier dans un formulaire
// Utilisation : <form method="post" action="fileaction.php" enctype="multipart/form-data" onSubmit="return testnomfile(this.nomchampsfile)" >
function testnomfile(fichier) {
	
	
	//if(fichier.value=="") { alert('Le fichier est vide !');fichier.focus();return false }
	

	if (navigator.appVersion.indexOf("Mac",0)>0)
	{
			//alert("C'est un MAC");
			
			// TEST du nom de fichier pour MAC
			var chaine = fichier.value;
			
			var tableau=chaine.split("/");
		
			var num = tableau.length-1;
			
			for(i = 0; i < tableau[num].length; i++) 
			{
				if ((tableau[num].substr(i,1) != "a") && (tableau[num].substr(i,1) != "b") && (tableau[num].substr(i,1) != "c") && 
					(tableau[num].substr(i,1) != "d") && (tableau[num].substr(i,1) != "e") && (tableau[num].substr(i,1) != "f") &&
					(tableau[num].substr(i,1) != "g") && (tableau[num].substr(i,1) != "h") && (tableau[num].substr(i,1) != "i") &&
					(tableau[num].substr(i,1) != "j") && (tableau[num].substr(i,1) != "k") && (tableau[num].substr(i,1) != "l") &&
					(tableau[num].substr(i,1) != "m") && (tableau[num].substr(i,1) != "n") && (tableau[num].substr(i,1) != "o") &&
					(tableau[num].substr(i,1) != "p") && (tableau[num].substr(i,1) != "q") && (tableau[num].substr(i,1) != "r") &&
					(tableau[num].substr(i,1) != "s") && (tableau[num].substr(i,1) != "t") && (tableau[num].substr(i,1) != "u") &&
					(tableau[num].substr(i,1) != "v") && (tableau[num].substr(i,1) != "w") && (tableau[num].substr(i,1) != "x") &&
					(tableau[num].substr(i,1) != "y") && (tableau[num].substr(i,1) != "z") && (tableau[num].substr(i,1) != "A") &&
					(tableau[num].substr(i,1) != "B") && (tableau[num].substr(i,1) != "C") && (tableau[num].substr(i,1) != "D") &&
					(tableau[num].substr(i,1) != "E") && (tableau[num].substr(i,1) != "F") && (tableau[num].substr(i,1) != "G") &&
					(tableau[num].substr(i,1) != "H") && (tableau[num].substr(i,1) != "I") && (tableau[num].substr(i,1) != "J") &&
					(tableau[num].substr(i,1) != "K") && (tableau[num].substr(i,1) != "L") && (tableau[num].substr(i,1) != "M") && 
					(tableau[num].substr(i,1) != "N") && (tableau[num].substr(i,1) != "O") && (tableau[num].substr(i,1) != "P") &&
					(tableau[num].substr(i,1) != "Q") && (tableau[num].substr(i,1) != "R") && (tableau[num].substr(i,1) != "S") &&
					(tableau[num].substr(i,1) != "T") && (tableau[num].substr(i,1) != "U") && (tableau[num].substr(i,1) != "V") &&
					(tableau[num].substr(i,1) != "W") && (tableau[num].substr(i,1) != "X") && (tableau[num].substr(i,1) != "Y") &&
					(tableau[num].substr(i,1) != "Z") && (tableau[num].substr(i,1) != "0") && (tableau[num].substr(i,1) != "1") &&
					(tableau[num].substr(i,1) != "2") && (tableau[num].substr(i,1) != "3") && (tableau[num].substr(i,1) != "4") &&
					(tableau[num].substr(i,1) != "5") && (tableau[num].substr(i,1) != "6") && (tableau[num].substr(i,1) != "7") &&
					(tableau[num].substr(i,1) != "8") && (tableau[num].substr(i,1) != "9") && (tableau[num].substr(i,1) != "-") &&
					(tableau[num].substr(i,1) != "_") && (tableau[num].substr(i,1) != ".") && (tableau[num].substr(i,1) != " ") &&
					(tableau[num].substr(i,1) != "\\") && (tableau[num].substr(i,1) != ":") && (tableau[num].substr(i,1) != "/")
					)
				{
					alert('Le nom du fichier est incorrect !');fichier.focus();return false
				}
				
			}//fin du for test nom de fichier

	}//fin de test si mac
	else
	{
		//alert("Ce n'est pas un MAC");
	
		// TEST du nom di fichier pour window
		var chaine = fichier.value;
		
		var tableau=chaine.split("\\");
	
		var num = tableau.length-1;
		
		for(i = 0; i < tableau[num].length; i++) 
		{
			if ((tableau[num].substr(i,1) != "a") && (tableau[num].substr(i,1) != "b") && (tableau[num].substr(i,1) != "c") && 
				(tableau[num].substr(i,1) != "d") && (tableau[num].substr(i,1) != "e") && (tableau[num].substr(i,1) != "f") &&
				(tableau[num].substr(i,1) != "g") && (tableau[num].substr(i,1) != "h") && (tableau[num].substr(i,1) != "i") &&
				(tableau[num].substr(i,1) != "j") && (tableau[num].substr(i,1) != "k") && (tableau[num].substr(i,1) != "l") &&
				(tableau[num].substr(i,1) != "m") && (tableau[num].substr(i,1) != "n") && (tableau[num].substr(i,1) != "o") &&
				(tableau[num].substr(i,1) != "p") && (tableau[num].substr(i,1) != "q") && (tableau[num].substr(i,1) != "r") &&
				(tableau[num].substr(i,1) != "s") && (tableau[num].substr(i,1) != "t") && (tableau[num].substr(i,1) != "u") &&
				(tableau[num].substr(i,1) != "v") && (tableau[num].substr(i,1) != "w") && (tableau[num].substr(i,1) != "x") &&
				(tableau[num].substr(i,1) != "y") && (tableau[num].substr(i,1) != "z") && (tableau[num].substr(i,1) != "A") &&
				(tableau[num].substr(i,1) != "B") && (tableau[num].substr(i,1) != "C") && (tableau[num].substr(i,1) != "D") &&
				(tableau[num].substr(i,1) != "E") && (tableau[num].substr(i,1) != "F") && (tableau[num].substr(i,1) != "G") &&
				(tableau[num].substr(i,1) != "H") && (tableau[num].substr(i,1) != "I") && (tableau[num].substr(i,1) != "J") &&
				(tableau[num].substr(i,1) != "K") && (tableau[num].substr(i,1) != "L") && (tableau[num].substr(i,1) != "M") && 
				(tableau[num].substr(i,1) != "N") && (tableau[num].substr(i,1) != "O") && (tableau[num].substr(i,1) != "P") &&
				(tableau[num].substr(i,1) != "Q") && (tableau[num].substr(i,1) != "R") && (tableau[num].substr(i,1) != "S") &&
				(tableau[num].substr(i,1) != "T") && (tableau[num].substr(i,1) != "U") && (tableau[num].substr(i,1) != "V") &&
				(tableau[num].substr(i,1) != "W") && (tableau[num].substr(i,1) != "X") && (tableau[num].substr(i,1) != "Y") &&
				(tableau[num].substr(i,1) != "Z") && (tableau[num].substr(i,1) != "0") && (tableau[num].substr(i,1) != "1") &&
				(tableau[num].substr(i,1) != "2") && (tableau[num].substr(i,1) != "3") && (tableau[num].substr(i,1) != "4") &&
				(tableau[num].substr(i,1) != "5") && (tableau[num].substr(i,1) != "6") && (tableau[num].substr(i,1) != "7") &&
				(tableau[num].substr(i,1) != "8") && (tableau[num].substr(i,1) != "9") && (tableau[num].substr(i,1) != "-") &&
				(tableau[num].substr(i,1) != "_") && (tableau[num].substr(i,1) != ".") && (tableau[num].substr(i,1) != " ") &&
				(tableau[num].substr(i,1) != "\\") && (tableau[num].substr(i,1) != ":") && (tableau[num].substr(i,1) != "/")
				)
			{
				alert('Le nom du fichier est incorrect !');fichier.focus();return false
			}
			
		}//fin du for test nom de fichier

	}//fin du else test

	return true;
}
/*********************************************************************************************************/



/*********************************************************************************************************/
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];}
}
/*********************************************************************************************************/


/*********************************************************************************************************/
function openWin(theURL,winName,features)
{
    newWin = window.open('',winName,features);;
    newWin.document.write("<p align=center>");
    newWin.document.write("<img src=" + theURL + ">");
    newWin.document.write("</p>");
    newWin.document.write("<p align=center>");
    newWin.document.write("<a href=\"JavaScript:window.close()\">Fermer la fenêtre</a>");
    newWin.document.write("</p>");
}
/*********************************************************************************************************/




/*********************************************************************************************************/
// JavaScript Document
// This script is (c) copyright 2006 Jim Tucek under the
// GNU General Public License (http://www.gnu.org/licenses/gpl.html)
// For more information, visit www.jracademy.com/~jtucek/email/ 
// Leave the above comments alone!

var decryption_cache = new Array();

function decrypt_string(crypted_string,n,decryption_key,just_email_address) {
	var cache_index = "'"+crypted_string+","+just_email_address+"'";

	if(decryption_cache[cache_index])					// If this string has already been decrypted, just
		return decryption_cache[cache_index];				// return the cached version.

	if(addresses[crypted_string])						// Is crypted_string an index into the addresses array
		var crypted_string = addresses[crypted_string];			// or an actual string of numbers?

	if(!crypted_string.length)						// Make sure the string is actually a string
		return "Error, not a valid index.";

	if(n == 0 || decryption_key == 0) {					// If the decryption key and n are not passed to the
		var numbers = crypted_string.split(' ');			// function, assume they are stored as the first two
		n = numbers[0];	decryption_key = numbers[1];			// numbers in crypted string.
		numbers[0] = ""; numbers[1] = "";				// Remove them from the crypted string and continue
		crypted_string = numbers.join(" ").substr(2);
	}

	var decrypted_string = '';
	var crypted_characters = crypted_string.split(' ');

	for(var i in crypted_characters) {
		var current_character = crypted_characters[i];
		var decrypted_character = exponentialModulo(current_character,n,decryption_key);
		if(just_email_address && i < 7)				// Skip 'mailto:' part
			continue;
		if(just_email_address && decrypted_character == 63)	// Stop at '?subject=....'
			break;
		decrypted_string += String.fromCharCode(decrypted_character);
	}
	
	decryption_cache[cache_index] = decrypted_string;			// Cache this string for any future calls

	return decrypted_string;
}
/*********************************************************************************************************/

/*********************************************************************************************************/
function decrypt_and_email(crypted_string,n,decryption_key) {
	if(!n || !decryption_key) { n = 0; decryption_key = 0; }
	if(!crypted_string) crypted_string = 0;

	var decrypted_string = decrypt_string(crypted_string,n,decryption_key,false);
	parent.location = decrypted_string;
}
/*********************************************************************************************************/

/*********************************************************************************************************/
function decrypt_and_echo(crypted_string,n,decryption_key) {
	if(!n || !decryption_key) { n = 0; decryption_key = 0; }
	if(!crypted_string) crypted_string = 0;

	var decrypted_string = decrypt_string(crypted_string,n,decryption_key,true);
	document.write(decrypted_string);
	return true;
}
/*********************************************************************************************************/

/*********************************************************************************************************/
// Finds base^exponent % y for large values of (base^exponent)
function exponentialModulo(base,exponent,y) {
	if (y % 2 == 0) {
		answer = 1;
		for(var i = 1; i <= y/2; i++) {
			temp = (base*base) % exponent;
			answer = (temp*answer) % exponent;
		}
	} else {
		answer = base;
		for(var i = 1; i <= y/2; i++) {
			temp = (base*base) % exponent;
			answer = (temp*answer) % exponent;
		}
	}
	return answer;
}
/*********************************************************************************************************/

/*********************************************************************************************************/
// Fonction permettant d'afficher une information dans une boite flottante.
// Utilistation : onmouseover="Box.show('TITRE','texte',event);" onmouseout="Box.hide();"
Box = function() { }
Box.__name__ = ["Box"];
Box.Box = null;
Box.showTop = function(title,content,evt) {
	if( (title != '') && (content != '') ) content = "<div class='BoxTitle'>" + title + "</div>" + "<div class='BoxContent'>" + content + "</div>";
	else if( (title == '') && (content != '') )content = "<div class='BoxContent'>" + content + "</div>";
	else if( (title != '') && (content == '') ) content = "<div class='BoxTitle'>" + title + "</div>";
	else content = "";
	document.getElementById("BoxContent").innerHTML = content;
	document.onmousemove = closure(Box,"updateTop");
	document.getElementById("Box").style.display = "block";
	Box.update(evt);
}
Box.show = function(title,content,evt) {
	if( (title != '') && (content != '') ) content = "<div class='BoxTitle'>" + title + "</div>" + "<div class='BoxContent'>" + content + "</div>";
	else if( (title == '') && (content != '') )content = "<div class='BoxContent'>" + content + "</div>";
	else if( (title != '') && (content == '') ) content = "<div class='BoxTitle'>" + title + "</div>";
	else content = "";
	document.getElementById("BoxContent").innerHTML = content;
	document.onmousemove = closure(Box,"update");
	document.getElementById("Box").style.display = "block";
	Box.update(evt);
}
Box.hide = function() {
	document.getElementById("Box").style.display = "none";
	document.onmousemove = null;
}
Box.getMouse = function(e) {
	if(e == null) e = window.event;
	if(e != null)
	{
		if( e.pageX != null) return { x : e.pageX, y : e.pageY}
		else if(e.clientX != null) return { x : e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft, y : e.clientY + document.body.scrollTop + document.documentElement.scrollTop}
	}
	else return { x : null, y : null}
}
Box.update = function(e) {
	var tip = document.getElementById("Box");
	var mouse = Box.getMouse(e);
	var x = (mouse.x - tip.offsetWidth / 2);
	var y = (mouse.y + 20);
	var innerWidth = document.documentElement.clientWidth + document.documentElement.scrollLeft;
	x = (Math.min(x,innerWidth - tip.offsetWidth - 10));
	tip.style.left = x + "px";
	tip.style.top = y + "px";
}
Box.updateTop = function(e) {
	var tip = document.getElementById("Box");
	var mouse = Box.getMouse(e);
	var x = (mouse.x - tip.offsetWidth / 2);
	var y = (mouse.y + 20);
	var innerWidth = document.documentElement.clientWidth + document.documentElement.scrollLeft;
	x = (Math.min(x,innerWidth - tip.offsetWidth - 10));
	tip.style.left = x + "px";
	tip.style.top = (y - 30 - tip.clientHeight) + "px";
}
closure = function(o,f) {
	var m = o[f];
	if(m == null) return null;
	var f1 = function() {
		return m.apply(o,arguments);
	}
	f1.scope = o;
	f1.method = m;
	return f1;
}
/*********************************************************************************************************/
/* Fonction permettant d'afficher un secteur */
/*********************************************************************************************************/
var idtoclose = -1; //variable globale l'id a fermer.

function displaySector(id){
	if($(id).style.display == "none"){
		// Fermeture du secteur ouvert
		if(idtoclose != -1 && idtoclose != id)
		{
			$(idtoclose + '_img').src ="../images/fleche-inactive.gif";
			$(idtoclose + '_lien').style.color = "#668220";
			new Effect.BlindUp(idtoclose);
		}
		
		// Ouverture du secteur
		$(id + '_img').src ="../images/fleche-active.gif";
		$(id + '_lien').style.color = "#F48A04";
		new Effect.BlindDown(id,{duration:0.5}); //ouverture du secteur demandé
		idtoclose = id;
	}
	else{
		$(id + '_img').src ="../images/fleche-inactive.gif";
		$(id + '_lien').style.color = "#668220";
		new Effect.BlindUp(id);
	}
}
/***********************************************************************************************************/
/* Fonction affichant la liste des checkbox (page besoin) */
/**********************************************************************************************************/
function dispCheckboxList(){
	if($('listbesoin').style.display=="none"){
		new Effect.BlindDown('listbesoin',{duration:0.5}); //affichage on pour la liste
		$('dispbuttoncl').src = '../images/fleche_roll.gif'
	}
	else{
		new Effect.BlindUp('listbesoin',{duration:0.5}); //affichage off
		$('dispbuttoncl').src = '../images/fleche.gif';
	}
}

/*********************************************************************************************************/
/* Fonction permettant de masquer la photo d'un hotel, et d'afficher le suivant */
/*********************************************************************************************************/

function change_hotel( hotel_a_masquer, hotel_a_afficher )
{
	// Effet d'ouverture (apparition) :
	//  1 : Flou
	//  2 : Le bloc descend
	//  3 : Le bloc monte
	//  4 : Le bloc s'ouvre vers le bas
	var effet_ouverture = 1;
	
	// Effet de fermeture (disparition) :
	//  1 : Flou
	//  2 : Le bloc monte
	//  3 : Le bloc descend
	//  4 : Le bloc se ferme vers le haut
	var effet_fermeture = 1;
	
	hotel = $(hotel_a_masquer);
	if(hotel.style.display == "none")
	{
		hotel = $(hotel_a_afficher);
		switch ( effet_ouverture )
		{
			case 1 :
				new Effect.Appear(hotel);
				break;
			case 2 :
				new Effect.SlideDown(hotel);
				break;
			case 3 :
				new Effect.ReverseSlideDown(hotel);
				break;
			case 4 :
				new Effect.BlindDown(hotel);
				break;
			default :
				new Effect.Appear(hotel);
		}
	}
	else
	{
		switch ( effet_fermeture )
		{
			case 1 :
				new Effect.Fade(hotel);
				break;
			case 2 :
				new Effect.SlideUp(hotel);
				break;
			case 3 :
				new Effect.ReverseSlideUp(hotel);
				break;
			case 4 :
				new Effect.BlindUp(hotel);
				break;
			default :
				new Effect.Fade(hotel);
		}
		hotel = $(hotel_a_afficher);
		switch ( effet_ouverture )
		{
			case 1 :
				setTimeout("new Effect.Appear(hotel);", 1000);
				break;
			case 2 :
				setTimeout("new Effect.SlideDown(hotel);", 1000);
				break;
			case 3 :
				setTimeout("new Effect.ReverseSlideDown(hotel);", 1000);
				break;
			case 4 :
				setTimeout("new Effect.BlindDown(hotel);", 1000);
				break;
			default :
				setTimeout("new Effect.Appear(hotel);", 1000);
		}
	}
}

/*********************************************************************************************************/
/* Fonction permettant de vérifier les champs saisis avant envoi vers reservit */
/*********************************************************************************************************/

function verif_form_resa( form_resa )
{
	var form_ok 	= true;
	var formulaire 	= $(form_resa);
	var fday 		= parseInt( formulaire.fday.value );
	var fmonth 		= parseInt( formulaire.fmonth.value );
	var fyear 		= parseInt( formulaire.fyear.value );
	var nbnights 	= parseInt( formulaire.nbnights.value );
	var numroom 	= parseInt( formulaire.numroom.value );
	var nbadt1 		= parseInt( formulaire.nbadt1.value );
	
	var maintenant = new Date();
	
	if ( form_ok )
	{
		if ( fyear < 100 )
			fyear = fyear+2000;
			
		if ( fmonth < 1 || fmonth > 12 )
			form_ok = false;
		if ( fday < 1 || fday > 31 )
			form_ok = false;
		if ( fmonth == 4 || fmonth == 6 || fmonth == 9 || fmonth == 11 )
			if ( fday == 31 )
				form_ok = false;
		if ( fmonth == 2 )
		{
			var b = parseInt( fyear / 4 , 10 );
			if ( isNaN( b ) ) 
				form_ok = false;
			if ( fday > 29 )
				form_ok = false;
			if ( fday == 29 && ( ( fyear / 4 ) != parseInt( fyear / 4, 10 ) ) ) 
				form_ok = false;
		}
			
		if ( ! form_ok )
		{
			alert("Les dates saisies semblent incorrectes.");
			formulaire.fday.focus();
		}
	}

	if ( form_ok )
	{
		
		if ( fyear < maintenant.getFullYear() || fyear > ( maintenant.getFullYear() + 10 ) )
			form_ok = false;
		
		if ( ! form_ok )
		{
			alert("Vous ne pouvez pas réserver plus de 10 ans en avance.");
			formulaire.fday.focus();
		}
	}

	if ( form_ok )
	{
		if ( fyear == maintenant.getFullYear() && fmonth <= ( maintenant.getMonth() + 1 ) && fday < maintenant.getDate() )
			form_ok = false;
			
		if ( ! form_ok )
		{
			alert("Vous ne pouvez plus réserver pour des dates antérieures au "+maintenant.getDate()+"/"+( maintenant.getMonth() + 1 )+"/"+maintenant.getFullYear()+".");
			formulaire.fday.focus();
		}
	}

	if ( form_ok )
	{
		if ( nbnights < 1 )
			form_ok = false;
		if ( ! form_ok )
			alert("Vous devez réserver pour au moins une nuit.");
			formulaire.nbnights.focus();
	}

	if ( form_ok )
	{
		if ( numroom < 1 )
			form_ok = false;
		if ( ! form_ok )
			alert("Vous devez réserver au moins une chambre.");
			formulaire.numroom.focus();
	}

	if ( form_ok )
	{
		if ( nbadt1 < 1 )
			form_ok = false;
		if ( ! form_ok )
			alert("Vous devez réserver pour au moins un adulte.");
			formulaire.nbadt1.focus();
	}

	/*
	
	if ( form_ok )
	{
		var action = "http://bretagne-hotel-charme.reservit.com/reservit/reserhotel.php";
		action += "?action="+formulaire.action.value;
		action += "&lang="+formulaire.lang.value;
		action += "&numroom="+numroom;
		
		if ( numroom > 0 )
		{
			var ages1 = '';
			if ( formulaire.nbchd1.value > 0 )
				ages1 += formulaire.ages1_1.value+"";
			if ( formulaire.nbchd1.value > 1 )
				ages1 += ","+formulaire.ages1_2.value+"";
			if ( formulaire.nbchd1.value > 2 )
				ages1 += ","+formulaire.ages1_3.value+"";
			if ( formulaire.nbchd1.value > 3 )
				ages1 += ","+formulaire.ages1_4.value+"";
			if ( formulaire.nbchd1.value > 4 )
				ages1 += ","+formulaire.ages1_5.value+"";
			if ( formulaire.nbchd1.value > 5 )
				ages1 += ","+formulaire.ages1_6.value+"";
			if ( formulaire.nbchd1.value > 6 )
				ages1 += ","+formulaire.ages1_7.value+"";
			if ( formulaire.nbchd1.value > 7 )
				ages1 += ","+formulaire.ages1_8.value+"";
			if ( formulaire.nbchd1.value > 8 )
				ages1 += ","+formulaire.ages1_9.value+"";
				
			formulaire.ages1.value = ages1;
			action += "&nbadt1="+formulaire.nbadt1.value;
			action += "&nbchd1="+formulaire.nbchd1.value;
			action += "&ages1="+ages1;
		}

		if ( numroom > 1 )
		{
			var ages2 = '';
			if ( formulaire.nbchd2.value > 0 )
				ages2 += formulaire.ages2_1.value+"";
			if ( formulaire.nbchd2.value > 1 )
				ages2 += ","+formulaire.ages2_2.value+"";
			if ( formulaire.nbchd2.value > 2 )
				ages2 += ","+formulaire.ages2_3.value+"";
			if ( formulaire.nbchd2.value > 3 )
				ages2 += ","+formulaire.ages2_4.value+"";
			if ( formulaire.nbchd2.value > 4 )
				ages2 += ","+formulaire.ages2_5.value+"";
			if ( formulaire.nbchd2.value > 5 )
				ages2 += ","+formulaire.ages2_6.value+"";
			if ( formulaire.nbchd2.value > 6 )
				ages2 += ","+formulaire.ages2_7.value+"";
			if ( formulaire.nbchd2.value > 7 )
				ages2 += ","+formulaire.ages2_8.value+"";
			if ( formulaire.nbchd2.value > 8 )
				ages2 += ","+formulaire.ages2_9.value+"";
				
			formulaire.ages2.value = ages2;
			action += "&nbadt2="+formulaire.nbadt2.value;
			action += "&nbchd2="+formulaire.nbchd2.value;
			action += "&ages2="+ages2;
		}

		if ( numroom > 2 )
		{
			var ages3 = '';
			if ( formulaire.nbchd3.value > 0 )
				ages3 += formulaire.ages3_1.value+"";
			if ( formulaire.nbchd3.value > 1 )
				ages3 += ","+formulaire.ages3_2.value+"";
			if ( formulaire.nbchd3.value > 2 )
				ages3 += ","+formulaire.ages3_3.value+"";
			if ( formulaire.nbchd3.value > 3 )
				ages3 += ","+formulaire.ages3_4.value+"";
			if ( formulaire.nbchd3.value > 4 )
				ages3 += ","+formulaire.ages3_5.value+"";
			if ( formulaire.nbchd3.value > 5 )
				ages3 += ","+formulaire.ages3_6.value+"";
			if ( formulaire.nbchd3.value > 6 )
				ages3 += ","+formulaire.ages3_7.value+"";
			if ( formulaire.nbchd3.value > 7 )
				ages3 += ","+formulaire.ages3_8.value+"";
			if ( formulaire.nbchd3.value > 8 )
				ages3 += ","+formulaire.ages3_9.value+"";
				
			formulaire.ages3.value = ages3;
			action += "&nbadt3="+formulaire.nbadt3.value;
			action += "&nbchd3="+formulaire.nbchd3.value;
			action += "&ages3="+ages3;
		}

		if ( numroom > 3 )
		{
			var ages4 = '';
			if ( formulaire.nbchd4.value > 0 )
				ages4 += formulaire.ages4_1.value+"";
			if ( formulaire.nbchd4.value > 1 )
				ages4 += ","+formulaire.ages4_2.value+"";
			if ( formulaire.nbchd4.value > 2 )
				ages4 += ","+formulaire.ages4_3.value+"";
			if ( formulaire.nbchd4.value > 3 )
				ages4 += ","+formulaire.ages4_4.value+"";
			if ( formulaire.nbchd4.value > 4 )
				ages4 += ","+formulaire.ages4_5.value+"";
			if ( formulaire.nbchd4.value > 5 )
				ages4 += ","+formulaire.ages4_6.value+"";
			if ( formulaire.nbchd4.value > 6 )
				ages4 += ","+formulaire.ages4_7.value+"";
			if ( formulaire.nbchd4.value > 7 )
				ages4 += ","+formulaire.ages4_8.value+"";
			if ( formulaire.nbchd4.value > 8 )
				ages4 += ","+formulaire.ages4_9.value+"";
				
			formulaire.ages4.value = ages4;
			action += "&nbadt4="+formulaire.nbadt4.value;
			action += "&nbchd4="+formulaire.nbchd4.value;
			action += "&ages4="+ages4;
		}

		if ( numroom > 4 )
		{
			var ages5 = '';
			if ( formulaire.nbchd5.value > 0 )
				ages5 += formulaire.ages5_1.value+"";
			if ( formulaire.nbchd5.value > 1 )
				ages5 += ","+formulaire.ages5_2.value+"";
			if ( formulaire.nbchd5.value > 2 )
				ages5 += ","+formulaire.ages5_3.value+"";
			if ( formulaire.nbchd5.value > 3 )
				ages5 += ","+formulaire.ages5_4.value+"";
			if ( formulaire.nbchd5.value > 4 )
				ages5 += ","+formulaire.ages5_5.value+"";
			if ( formulaire.nbchd5.value > 5 )
				ages5 += ","+formulaire.ages5_6.value+"";
			if ( formulaire.nbchd5.value > 6 )
				ages5 += ","+formulaire.ages5_7.value+"";
			if ( formulaire.nbchd5.value > 7 )
				ages5 += ","+formulaire.ages5_8.value+"";
			if ( formulaire.nbchd5.value > 8 )
				ages5 += ","+formulaire.ages5_9.value+"";
				
			formulaire.ages5.value = ages5;
			action += "&nbadt5="+formulaire.nbadt5.value;
			action += "&nbchd5="+formulaire.nbchd5.value;
			action += "&ages5="+ages5;
		}

		if ( numroom > 5 )
		{
			var ages6 = '';
			if ( formulaire.nbchd6.value > 0 )
				ages6 += formulaire.ages6_1.value+"";
			if ( formulaire.nbchd6.value > 1 )
				ages6 += ","+formulaire.ages6_2.value+"";
			if ( formulaire.nbchd6.value > 2 )
				ages6 += ","+formulaire.ages6_3.value+"";
			if ( formulaire.nbchd6.value > 3 )
				ages6 += ","+formulaire.ages6_4.value+"";
			if ( formulaire.nbchd6.value > 4 )
				ages6 += ","+formulaire.ages6_5.value+"";
			if ( formulaire.nbchd6.value > 5 )
				ages6 += ","+formulaire.ages6_6.value+"";
			if ( formulaire.nbchd6.value > 6 )
				ages6 += ","+formulaire.ages6_7.value+"";
			if ( formulaire.nbchd6.value > 7 )
				ages6 += ","+formulaire.ages6_8.value+"";
			if ( formulaire.nbchd6.value > 8 )
				ages6 += ","+formulaire.ages6_9.value+"";
				
			formulaire.ages6.value = ages6;
			action += "&nbadt6="+formulaire.nbadt6.value;
			action += "&nbchd6="+formulaire.nbchd6.value;
			action += "&ages6="+ages6;
		}

		if ( numroom > 6 )
		{
			var ages7 = '';
			if ( formulaire.nbchd7.value > 0 )
				ages7 += formulaire.ages7_1.value+"";
			if ( formulaire.nbchd7.value > 1 )
				ages7 += ","+formulaire.ages7_2.value+"";
			if ( formulaire.nbchd7.value > 2 )
				ages7 += ","+formulaire.ages7_3.value+"";
			if ( formulaire.nbchd7.value > 3 )
				ages7 += ","+formulaire.ages7_4.value+"";
			if ( formulaire.nbchd7.value > 4 )
				ages7 += ","+formulaire.ages7_5.value+"";
			if ( formulaire.nbchd7.value > 5 )
				ages7 += ","+formulaire.ages7_6.value+"";
			if ( formulaire.nbchd7.value > 6 )
				ages7 += ","+formulaire.ages7_7.value+"";
			if ( formulaire.nbchd7.value > 7 )
				ages7 += ","+formulaire.ages7_8.value+"";
			if ( formulaire.nbchd7.value > 8 )
				ages7 += ","+formulaire.ages7_9.value+"";
				
			formulaire.ages7.value = ages7;
			action += "&nbadt7="+formulaire.nbadt7.value;
			action += "&nbchd7="+formulaire.nbchd7.value;
			action += "&ages7="+ages7;
		}

		if ( numroom > 7 )
		{
			var ages8 = '';
			if ( formulaire.nbchd8.value > 0 )
				ages8 += formulaire.ages8_1.value+"";
			if ( formulaire.nbchd8.value > 1 )
				ages8 += ","+formulaire.ages8_2.value+"";
			if ( formulaire.nbchd8.value > 2 )
				ages8 += ","+formulaire.ages8_3.value+"";
			if ( formulaire.nbchd8.value > 3 )
				ages8 += ","+formulaire.ages8_4.value+"";
			if ( formulaire.nbchd8.value > 4 )
				ages8 += ","+formulaire.ages8_5.value+"";
			if ( formulaire.nbchd8.value > 5 )
				ages8 += ","+formulaire.ages8_6.value+"";
			if ( formulaire.nbchd8.value > 6 )
				ages8 += ","+formulaire.ages8_7.value+"";
			if ( formulaire.nbchd8.value > 7 )
				ages8 += ","+formulaire.ages8_8.value+"";
			if ( formulaire.nbchd8.value > 8 )
				ages8 += ","+formulaire.ages8_9.value+"";
				
			formulaire.ages8.value = ages8;
			action += "&nbadt8="+formulaire.nbadt8.value;
			action += "&nbchd8="+formulaire.nbchd8.value;
			action += "&ages8="+ages8;
		}

		if ( numroom > 8 )
		{
			var ages9 = '';
			if ( formulaire.nbchd9.value > 0 )
				ages9 += formulaire.ages9_1.value+"";
			if ( formulaire.nbchd9.value > 1 )
				ages9 += ","+formulaire.ages9_2.value+"";
			if ( formulaire.nbchd9.value > 2 )
				ages9 += ","+formulaire.ages9_3.value+"";
			if ( formulaire.nbchd9.value > 3 )
				ages9 += ","+formulaire.ages9_4.value+"";
			if ( formulaire.nbchd9.value > 4 )
				ages9 += ","+formulaire.ages9_5.value+"";
			if ( formulaire.nbchd9.value > 5 )
				ages9 += ","+formulaire.ages9_6.value+"";
			if ( formulaire.nbchd9.value > 6 )
				ages9 += ","+formulaire.ages9_7.value+"";
			if ( formulaire.nbchd9.value > 7 )
				ages9 += ","+formulaire.ages9_8.value+"";
			if ( formulaire.nbchd9.value > 8 )
				ages9 += ","+formulaire.ages9_9.value+"";
				
			formulaire.ages9.value = ages9;
			action += "&nbadt9="+formulaire.nbadt9.value;
			action += "&nbchd9="+formulaire.nbchd9.value;
			action += "&ages9="+ages9;
		}
		
		action += "&fday="+fday;
		action += "&fmonth="+fmonth;
		action += "&fyear="+fyear;
		action += "&nbnights="+nbnights;
		//alert( action );
		//formulaire.action = action;
	}
	*/
	
	return form_ok;
}

function verif_form_resa2( form_resa )
{
	var form_ok 	= true;
	var formulaire 	= $(form_resa);
	var fday 		= parseInt( formulaire.fday.value );
	var fmonth 		= parseInt( formulaire.fmonth.value );
	var fyear 		= parseInt( formulaire.fyear.value );
	
	var tday 		= parseInt( formulaire.tday.value );
	var tmonth 		= parseInt( formulaire.tmonth.value );
	var tyear 		= parseInt( formulaire.tyear.value );
	
	var maintenant = new Date();
	
	if ( form_ok )
	{
		if ( fyear < 100 )
			fyear = fyear+2000;
			
		if ( fmonth < 1 || fmonth > 12 )
			form_ok = false;
		if ( fday < 1 || fday > 31 )
			form_ok = false;
		if ( fmonth == 4 || fmonth == 6 || fmonth == 9 || fmonth == 11 )
			if ( fday == 31 )
				form_ok = false;
		if ( fmonth == 2 )
		{
			var b = parseInt( fyear / 4 , 10 );
			if ( isNaN( b ) ) 
				form_ok = false;
			if ( fday > 29 )
				form_ok = false;
			if ( fday == 29 && ( ( fyear / 4 ) != parseInt( fyear / 4, 10 ) ) ) 
				form_ok = false;
		}
			
		if ( ! form_ok )
		{
			alert("Les dates saisies semblent incorrectes.");
			formulaire.fday.focus();
		}
	}
	
	if ( form_ok )
	{
		if ( tyear < 100 )
			tyear = tyear+2000;
			
		if ( tmonth < 1 || tmonth > 12 )
			form_ok = false;
		if ( tday < 1 || tday > 31 )
			form_ok = false;
		if ( tmonth == 4 || tmonth == 6 || tmonth == 9 || tmonth == 11 )
			if ( tday == 31 )
				form_ok = false;
		if ( tmonth == 2 )
		{
			var b = parseInt( tyear / 4 , 10 );
			if ( isNaN( b ) ) 
				form_ok = false;
			if ( tday > 29 )
				form_ok = false;
			if ( tday == 29 && ( ( tyear / 4 ) != parseInt( tyear / 4, 10 ) ) ) 
				form_ok = false;
		}
			
		if ( ! form_ok )
		{
			alert("Les dates saisies semblent incorrectes.");
			formulaire.tday.focus();
		}
	}

	if ( form_ok )
	{
		
		if ( fyear < maintenant.getFullYear() || fyear > ( maintenant.getFullYear() + 10 ) )
			form_ok = false;
		
		if ( ! form_ok )
		{
			alert("Vous ne pouvez pas réserver plus de 10 ans en avance.");
			formulaire.fday.focus();
		}
	}

	if ( form_ok )
	{
		
		if ( tyear < maintenant.getFullYear() || tyear > ( maintenant.getFullYear() + 10 ) )
			form_ok = false;
		
		if ( ! form_ok )
		{
			alert("Vous ne pouvez pas réserver plus de 10 ans en avance.");
			formulaire.tday.focus();
		}
	}

	if ( form_ok )
	{
		if ( fyear == maintenant.getFullYear() && fmonth <= ( maintenant.getMonth() + 1 ) && fday < maintenant.getDate() )
			form_ok = false;
			
		if ( ! form_ok )
		{
			alert("Vous ne pouvez plus réserver pour des dates antérieures au "+maintenant.getDate()+"/"+( maintenant.getMonth() + 1 )+"/"+maintenant.getFullYear()+".");
			formulaire.fday.focus();
		}
	}

	if ( form_ok )
	{
		if ( parseInt( tyear, 10 ) == parseInt( fyear, 10 ) && parseInt( tmonth, 10 ) == parseInt( fmonth, 10 ) && parseInt( tday, 10 ) <= parseInt( fday, 10 ) )
			form_ok = false;
			
		if ( ! form_ok )
		{
			//alert("Vous devez réserver pour au moins une nuit.\nDu " + fday + "/" + fmonth + "/" + fyear + " au " + tday + "/" + tmonth + "/" + tyear );
			alert("Vous devez réserver pour au moins une nuit." );
			formulaire.tday.focus();
		}
	}
	
	return form_ok;
}
