/****************************************************************************
							FUNCTIONS FOR VALIDATION 
****************************************************************************/
function validLeft(){
		if (isWhitespace(document.myForm.txtSelect1.value)){
			alert("S\'il vous plait selectionez la Village Club Med")
			document.myForm.txtSelect1.focus()
			return false
		}
		if (isWhitespace(document.myForm.txtSelect2.value)){
			alert("S\'il vous plait selectionez la Duree de votre sejour")
			document.myForm.txtSelect2.focus()
			return false
		}
		if (isWhitespace(document.myForm.txtSelect3.value)){
			alert("S\'il vous plait selectionez la Ville de depart")
			document.myForm.txtSelect3.focus()
			return false
		}
		
		if (isWhitespace(document.myForm.txtSelect5.value)){
			alert("S\'il vous plait selectionez le numero d\'adults")
			document.myForm.txtSelect5.focus()
			return false
		}
		if (isWhitespace(document.myForm.txtSelect6.value)){
			alert("S\'il vous plait selectionez le numero d\'enfants")
			document.myForm.txtSelect6.focus()
			return false
		}
		if (isWhitespace(document.myForm.txtSelect4.value)){
			alert("S\'il vous plait selectionez le Niveau de confort souhaite")
			document.myForm.txtSelect4.focus()
			return false
		}
		//date is not a editable field
		
		cal_prs_date1(document.myForm.dateDepart.value)
			
}
var digits = "0123456789";
var lowercaseLetters = "abcdefghijklmnopqrstuvwxyz"
var uppercaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
var whitespace = " \t\n\r";
var decimalPointDelimiter = "."
var defaultEmptyOK = false
function makeArray(n) {
   for (var i = 1; i <= n; i++) {
      this[i] = 0
   } 
   return this
}

var daysInMonth = makeArray(12);
daysInMonth[1] = 31;
daysInMonth[2] = 29;   // must programmatically check this
daysInMonth[3] = 31;
daysInMonth[4] = 30;
daysInMonth[5] = 31;
daysInMonth[6] = 30;
daysInMonth[7] = 31;
daysInMonth[8] = 31;
daysInMonth[9] = 30;
daysInMonth[10] = 31;
daysInMonth[11] = 30;
daysInMonth[12] = 31;

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

function isWhitespace (s)
{   var i;
    // Is s empty?
    if (isEmpty(s)) return true;
   for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (whitespace.indexOf(c) == -1) return false;
    }
    return true;
}

function stripCharsInBag (s, bag)
{   var i;
    var returnString = "";
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function stripCharsNotInBag (s, bag)
{   var i;
    var returnString = "";
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) != -1) returnString += c;
    }
    return returnString;
}

function stripWhitespace (s)
{   return stripCharsInBag (s, whitespace)
}

function charInString (c, s)
{   for (i = 0; i < s.length; i++)
    {   if (s.charAt(i) == c) return true;
    }
    return false
}

function stripInitialWhitespace (s)

{   var i = 0;
    while ((i < s.length) && charInString (s.charAt(i), whitespace))
       i++;
    return s.substring (i, s.length);
}

function isLetter (c)
{   return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) )
}

function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}

function isLetterOrDigit (c)
{   return (isLetter(c) || isDigit(c))
}

function isInteger (s)
{   var i;
    if (isEmpty(s)) 
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (!isDigit(c)) return false;
    }
    return true;
}

function isSignedInteger (s)
{   if (isEmpty(s)) 
       if (isSignedInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isSignedInteger.arguments[1] == true);
    else {
        var startPos = 0;
        var secondArg = defaultEmptyOK;
        if (isSignedInteger.arguments.length > 1)
            secondArg = isSignedInteger.arguments[1];
        // skip leading + or -
        if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
           startPos = 1;    
        return (isInteger(s.substring(startPos, s.length), secondArg))
    }
}

function isPositiveInteger (s)
{   var secondArg = defaultEmptyOK;
   if (isPositiveInteger.arguments.length > 1)
        secondArg = isPositiveInteger.arguments[1];
    return (isSignedInteger(s, secondArg)
        && ( (isEmpty(s) && secondArg)  || (parseInt (s) > 0) ) );
}

function isNonnegativeInteger (s)
{   var secondArg = defaultEmptyOK;
    if (isNonnegativeInteger.arguments.length > 1)
        secondArg = isNonnegativeInteger.arguments[1];
    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) >= 0) ) );
}

function isNegativeInteger (s)
{   var secondArg = defaultEmptyOK;
    if (isNegativeInteger.arguments.length > 1)
        secondArg = isNegativeInteger.arguments[1];
    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) < 0) ) );
}

function isNonpositiveInteger (s)
{   var secondArg = defaultEmptyOK;
    if (isNonpositiveInteger.arguments.length > 1)
        secondArg = isNonpositiveInteger.arguments[1];
    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) <= 0) ) );
}

function isFloat (s)
{   var i;
    var seenDecimalPoint = false;
    if (isEmpty(s)) 
       if (isFloat.arguments.length == 1) return defaultEmptyOK;
       else return (isFloat.arguments[1] == true);
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if ((c == decimalPointDelimiter) && !seenDecimalPoint) seenDecimalPoint = true;
        else if (!isDigit(c)) return false;
    }
    // All characters are numbers.
    return true;
}

function isSignedFloat (s)
{   if (isEmpty(s)) 
       if (isSignedFloat.arguments.length == 1) return defaultEmptyOK;
       else return (isSignedFloat.arguments[1] == true);
    else {
        var startPos = 0;
        var secondArg = defaultEmptyOK;
        if (isSignedFloat.arguments.length > 1)
            secondArg = isSignedFloat.arguments[1];
        // skip leading + or -
        if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
           startPos = 1;    
        return (isFloat(s.substring(startPos, s.length), secondArg))
    }
}

function isAlphabetic (s)
{   var i;
    if (isEmpty(s)) 
       if (isAlphabetic.arguments.length == 1) return defaultEmptyOK;
       else return (isAlphabetic.arguments[1] == true);
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is letter.
        var c = s.charAt(i);
        if (!isLetter(c))
        return false;
   }
    return true;
}

function isAlphanumeric (s)
{   var i;
    if (isEmpty(s)) 
       if (isAlphanumeric.arguments.length == 1) return defaultEmptyOK;
       else return (isAlphanumeric.arguments[1] == true);
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number or letter.
        var c = s.charAt(i);
        if (! (isLetter(c) || isDigit(c) ) )
        return false;
    }
    return true;
}

function isEmail (s)
{   if (isEmpty(s)) 
       if (isEmail.arguments.length == 1) return defaultEmptyOK;
       else return (isEmail.arguments[1] == true);
    // is s whitespace?
    if (isWhitespace(s)) return false;
    var i = 1;
    var sLength = s.length;
    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }
    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;
    // look for .
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }
    // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    // there must be a string after the .
    if (isAlphabetic(s.substring(s.lastIndexOf(".")+1,s.length))==false) return false;
    return true;
}

function isYear (s)
{   if (isEmpty(s)) 
       if (isYear.arguments.length == 1) return defaultEmptyOK;
       else return (isYear.arguments[1] == true);
    if (!isNonnegativeInteger(s)) return false;
    return ((s.length == 2) || (s.length == 4));
}

function isIntegerInRange (s, a, b)
{   if (isEmpty(s)) 
       if (isIntegerInRange.arguments.length == 1) return defaultEmptyOK;
       else return (isIntegerInRange.arguments[1] == true);
    if (!isInteger(s, false)) return false;
    var num = parseInt (s);
    return ((num >= a) && (num <= b));
}

function isMonth (s)
{   if (isEmpty(s)) 
       if (isMonth.arguments.length == 1) return defaultEmptyOK;
       else return (isMonth.arguments[1] == true);
    return isIntegerInRange (s, 1, 12);
}

function isDay (s)
{   if (isEmpty(s)) 
       if (isDay.arguments.length == 1) return defaultEmptyOK;
       else return (isDay.arguments[1] == true);   
    return isIntegerInRange (s, 1, 31);
}

function daysInFebruary (year)
{   // February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (  ((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0) ) ) ? 29 : 28 );
}

function isDate (year, month, day)
{   // catch invalid years (not 2- or 4-digit) and invalid months and days.
    if (! (isYear(year, false) && isMonth(month, false) && isDay(day, false))) return false;
    var intYear = parseInt(year);
    var intMonth = parseInt(month);
    var intDay = parseInt(day);
    // catch invalid days, except for February
    if (intDay > daysInMonth[intMonth]) return false; 
    if ((intMonth == 2) && (intDay > daysInFebruary(intYear))) return false;
    return true;
}
/****************************************************************************
							END FUNCTIONS FOR VALIDATION 
****************************************************************************/
// Functions pour la barre de nav de droite d'apparition et desaparition deu CALENDRIER et des DATES NAISSANCES ENFANT
var vSelectActual="";
gNB_PROP = 5;
function DisplayCalendar(LObj){
		if (vSelectActual !=""){
			document.getElementById(vSelectActual).style.visibility="hidden";	
		}	
		if (document.getElementById(LObj).style.display == 'none'){
			var cal1 = new calendar1(document.myForm.dateDepart);
			cal1.year_scroll = true;
			cal1.time_comp = false;
			cal1.popup();
			if (!notOpen)document.getElementById(LObj).style.display = 'block';
			//return false;
		}
		else{
			document.getElementById(LObj).style.display= 'none';
			//return false;
		}
	}
//For the calendar in telecommande. When user write date and the calendar is open

//1 start modification
function DisplayNbEnfants(selObj,restore){
	// lo primero que se hace es esconder todos los campos por si a caso hay unos que se enseean
	for (var i=1; i<=6; i++){
		document.getElementById('enfant'+i).style.display = 'none';
		document.getElementById('text_enfant').style.display = 'none';
		document.getElementById('text_enfants').style.display = 'none';
	}
	combien = selObj.options[selObj.selectedIndex].value;
	// alert (combien)
	if (combien == 0){
		for (var i=1; i<=6; i++){
		// alert (document.getElementById('enfant'+i))
			document.getElementById('enfant'+i).style.display = 'none';
			document.getElementById('text_enfant').style.display = 'none';
			document.getElementById('text_enfants').style.display = 'none';
		}
	}
	else if(combien == 1){		
		// alert (document.getElementById('enfant'+i))
			document.getElementById('enfant1').style.display = 'block';
			document.getElementById('text_enfant').style.display = 'block';
		}
		else{
		//// start of modification
			for (var i=1; i<=combien; i++){
		//// end of modification
		// alert (document.getElementById('enfant'+i))
			document.getElementById('enfant'+i).style.display = 'block';
			document.getElementById('text_enfants').style.display = 'block';
		}	
	}
}
//1 end modification
function ActualiceDate(){
	var cal1 = new calendar1(document.myForm.dateDepart);
	cal1.year_scroll = true;
	cal1.time_comp = false;
	cal1.popup()
	document.getElementById('calendar').style.display = 'block';
	return false;	
}
function DisplayCalendarOLD(LObj){
	if (document.getElementById(LObj).style.display == 'none'){
		document.getElementById(LObj).style.display = 'block';
		return false;
	}
	else{
		document.getElementById(LObj).style.display= 'none';
		return false;
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}
// Functions pour apparition et disparition du detail de la chambre
function DisplayIframe(x, page, coordy){
	iService = x //-1 //for  page service
	laTable = "iframe" + x;
	liframe = "iiframe" + x;
	lancre = "ancre" + x;
	laChambre = "table_" + x;
	//ecartement
	//if is open then close pop-in and if is closed then open it
	if (document.getElementById(laTable).style.display == "none" || document.getElementById(laTable).style.display == "") {
		document.getElementById(laTable).style.display = "block";
		//chargement iframe
		chargeIframe(liframe, page, lancre, 0, 0, coordy, 538, laTable);
	}
	else{ 
		document.getElementById(laTable).style.display = "none";
		// pourquoi charger une frame qui se ferme? ==> chargeIframe(liframe, "", lancre, 0, 0, 614, 538, laTable);
	}	
}

function fermeTable(what){
	document.getElementById(what).style.display = "none";
}
////javascripts iframe
//positionnement iframe
function positionIframe(what, x, y){
	document.getElementById(what).style.left = x;
	document.getElementById(what).style.top = y;
}
//affichage contenu iframe
function chargeIframe(what, url, ancre, pox, poy, w, h, chambre){
	//positionIframe(what, aleft(document.getElementById(ancre)), atop(document.getElementById(ancre)));
	//document.getElementById(what).src = "detailsvide.html";
	document.getElementById(what).style.width = w;
	document.getElementById(what).style.height = h;
	if(url.indexOf("?")>=0){
		url = url + "&container=" + what + "@reg1@&chambre="+chambre+"@reg2@";
	}
	else{
		url = url + "?container=" + what + "@reg1@&chambre="+chambre+"@reg2@";
	}
	document.getElementById(what).src = url;
	document.getElementById(what).style.display = "block";
}
//dechargement iframe et cacher iframe
function dechargeIframe(what){
	//document.getElementById(what).src = "";
	document.getElementById(what).style.display = "none";
}
//attribution hauteur iframe selon son contenu

function regleHautIframe(whatIframe, whatTable, h){
	document.getElementById(whatIframe).style.height = h+"px";
	document.getElementById(whatTable).style.height = h+"px";
}
var ns4=(document.layers);var ie4=(document.all&&!document.getElementById);var ie5=(document.all&&document.getElementById);var ns6=(!document.all&&document.getElementById);var mac=(navigator.appVersion.indexOf("Mac")>=0)?1:0;var dom=(document.getElementById)?1:0;var ie=(ie4||ie5)?1:0;
//setToAnchor
function aleft(MyObject){if(dom||ie4){if(MyObject.offsetParent){return(MyObject.offsetLeft + aleft(MyObject.offsetParent));}else{return(MyObject.offsetLeft);}}if(ns4){return(MyObject.x);}}
function atop(MyObject){if(dom||ie4){if(MyObject.offsetParent){return(MyObject.offsetTop + atop(MyObject.offsetParent));}else{return(MyObject.offsetTop);}}if(ns4){return(MyObject.y);}}
function setToAnchor(AnchorName,lyr){var MyAnchor;if(dom){MyAnchor=document.getElementById(AnchorName);}else if(ie4){MyAnchor=document.all[AnchorName];}else if(ns4){MyAnchor=document.anchors[AnchorName];}if(arguments.length==2){posLeft(lyr,aleft(MyAnchor));posTop(lyr,atop(MyAnchor));}else{if(arguments[2]=="x"){posLeft(lyr,aleft(MyAnchor));}else{posTop(lyr,atop(MyAnchor));}}}
// fin setToAnchor
/////////////////////////// recuperation des elements _parent (iframe et table "ecartement")
var container = "";
var table = "";
var etat_chambre = 0;
function init(){
	tempSearch = unescape(self.location.search);
	container = tempSearch.substring(tempSearch.indexOf("container=")+10, tempSearch.indexOf("@reg1@"));
	table = container.substring(1, container.length);
	chambre = tempSearch.substring(tempSearch.indexOf("chambre=")+8, tempSearch.indexOf("@reg2@"));
	if(top.document.getElementById(chambre).className.indexOf("_on")>=0) etat_chambre = 1;
	if(etat_chambre){
		document.getElementById("popHebergement").className = "bg_pophebergement_on";
	}
	hauteur = document.height;
	if(hauteur == undefined) hauteur = document.body.scrollHeight;
	top.regleHautIframe(container, table, hauteur);
}
function fermeLa(){
	top.fermeTable(table);
	top.dechargeIframe(container);
}

//fin javascript iframe

function changeClass(LaTD){
	for  (var i=1; i<=9; i++){
		document.getElementById('table_'+i).className = 'unsel';
	}
	document.getElementById(LaTD).className  = 'sel';

}
//FONCTIONS CALCULS
function recupValeur(what){
	nb = document.getElementById(what).innerHTML;
	if(nb == "---"){
		nb = 0;
	}
	else{
		//on supprime les espaces
		nb = nb.replace(" ","");
		//on remplace la "," par "."
		nb = nb.replace(",",".");
	}
	//alert(parseFloat(nb));
	return(parseFloat(nb));
}

function attribVal(champ, val) {
	if (document.getElementById(champ))
		document.getElementById(champ).innerHTML = val;
}

function attribValeur(what, howmuch){
	howmuch = howmuch.toString();
	//on met un espace apres les milliers
	entier = howmuch.length - 3;
	if(howmuch.indexOf(".")>=0){
		entier = (howmuch.length - (howmuch.length - howmuch.indexOf("."))) - 3;
	}
	temp1 = howmuch.substring(0,entier);
	temp2 = howmuch.substring(entier,howmuch.length);
	howmuch = temp1 + " " + temp2;
	//on remplace le "." par ","
	howmuch = howmuch.replace(".",",");
	//rajouter "0" a la fin du chiffre si il y a une virgule...
	if(howmuch.indexOf(",")>=0) howmuch = howmuch + "0";
	//alert("howmuch = " + howmuch);
	document.getElementById(what).innerHTML = howmuch;
}

function calculTotalHeber(val, x){
	//val=value du bouton radio //x indice proposition
	prixAffiche = "prixHebergement" + x;
	LaTable = "table_" + x;
	//val contient le prix de la chambre + les cotisations, il faut donc enlever la valeur des cotisations a val pour retrouver le prix de la chambre seule
	if(val != recupValeur(prixAffiche)) val = recupValeur(prixAffiche);
	prixChambre = val - recupValeur("RPCotiz");
	//attribution prix chambre au bloc recap
	attribValeur("RPHeber", prixChambre);
	//calcul total
	prixTotal = recupValeur("RPHeber") + recupValeur("RPCotiz") + recupValeur("RPServ");
	//alert("prixTotal = " + prixTotal);
	attribValeur("RPTotal", prixTotal);
	attribValeur("RPTotal2", prixTotal);
}

function calculPartage(that, x){
	////that=checkBox //x indice proposition
	val = that.value;
	chambre = "prixHebergement" + x;
	table = "table_" + x;
	if(that.checked != true) val = "-" + val;
	prixChambre = recupValeur(chambre) + parseFloat(val);
	attribValeur(chambre, prixChambre);
	if(document.getElementById(table).className.indexOf("_on")>=0){
		calculTotalHeber(prixChambre, x);
	}
}

//select destination col left
function showSelect(nmeSel){
	if (document.getElementById("calendar").style.display == "block")document.getElementById("calendar").style.display = "none";		
	if (vSelectActual !="") document.getElementById(vSelectActual).style.visibility="hidden";	
	////1 start of modification
	/*for(u=1; u<=6; u++){
		document.getElementById("enfant"+u).style.display = "none";
	}*/
	////1 end of modification
	if(vSelectActual == nmeSel){
		vSelectActual = "";
		document.getElementById(nmeSel).style.visibility = "hidden";
	}
	else{
		vSelectActual=nmeSel;
		document.getElementById(nmeSel).style.visibility = "visible";
	}
}

function hideSelect(nmeSel,opt){
//see value
	theInputSee=eval("document.myForm.txt"+nmeSel)
	theInputSee.value=eval("document.myForm."+nmeSel+"_"+opt+".value")
//save value
	theInputSave=eval("document.myForm.val"+nmeSel)
	theInputSave.value=	document.getElementById(nmeSel).style.visibility="hidden";
	vSelectActual = "";
	//alert(document.myForm.valSelect1.value);
	//hideASelect();
	//apparition dates naissances enfants
	if(nmeSel == "Select6"){
		
		for(u=1; u<=6; u++){
			document.getElementById("enfant"+u).style.display = "none";
		}
		for(u=1; u<=theInputSee.value; u++){
			document.getElementById("enfant"+u).style.display = "block";
		}
	}
	
}

/* With this script we hide select menu from FORM when DIV appear, because if not, the select menu if display in the DIV */
/* firstable I count the number of select menu of the page*/
/* 
Then I hide the select menu which are in the page like this
<div id="champselect5" style="display : block">
I pass from BLOCK to HIDE when I call the function HideSelect()
*/
//function hideASelect(layer){
//alert (total)		
	//if (document.getElementById(layer).style.display == 'none')
	//{
		//document.getElementById(layer).style.display = 'block';
	//}
		//else
		//{	
			//document.getElementById(layer).style.display= 'none';
		//}

	//}
/* functions for alternative radiobuttons*/
function UnSelTrans(){	
	document.myForm2.transport[1].click() 
   /*for (var i = 0; i < document.myForm2.transport.length; i++) {
        document.myForm2.transport[i].checked = false;

        //document.myForm2.transport2.checked = true;
  }*/
}

function UnSelCM(){	
   for (var i = 1; i <= 5; i++) {
	 		if (document.getElementById("americanCardPaymentChoice"+i)) {
	 			document.getElementById("americanCardPaymentChoice"+i).checked = false;
	 		}
  }
}	

function checkKidsDates(champKids){
	 // fonction qui permet d'effacer toutes les dates de naissance du type jj/mm/aaaa (valeur par defaut)
	 // afin de ne pas rendre fou le DateFormatter java lors de la recuperation des donnees
	 var nbKids = document.getElementById(champKids).options[document.getElementById(champKids).selectedIndex].value;
	 nbKids++;
	 for (var i=nbKids; i<=6; i++) {
	 		if (document.getElementById("dtn"+i)) {
	 			document.getElementById("dtn"+i).value = '';
	 		}
	 }
}

function extractFileName (str) {
	// Retourne le nom d'un fichier a partir d'une url
	var idxSlash = str.lastIndexOf('/')+1;
	var filename = str.substring(idxSlash, str.length);
	return filename;
}

function nextPic (img, arrPics) {	
	idx = 0;
	currentPic = extractFileName(document.getElementById(img).src);
	// Cherche l'index de l'image courante
	for (var i=0; i<arrPics.length; i++) {
		var pic = extractFileName(arrPics[i]);
		if (currentPic == pic)
			idx = i+1; // index de la photo suivante
	}
	if (idx > (arrPics.length)-1)
		idx=0;
	document.getElementById(img).src = arrPics[idx];
}

function prevPic (img, arrPics) {	
	idx = 0;
	currentPic = extractFileName(document.getElementById(img).src);
	// Cherche l'index de l'image courante
	for (var i=0; i<arrPics.length; i++) {
		var pic = extractFileName(arrPics[i]);
		if (currentPic == pic)
			idx = i-1; // index de la photo suivante
	}
	if (idx < 0)
		idx=(arrPics.length)-1;
	document.getElementById(img).src = arrPics[idx];
}

function processNbParticipants(nbPart, nbAd, nbKi) {
	var nbParticipants = document.getElementById(nbPart);
	var nbAdults = document.getElementById(nbAd);
	var nbEnfants = document.getElementById(nbKi);
	nbParticipants.value = Number(nbAdults.value) + Number(nbEnfants.value);
	//alert('processNbParticipants '+nbParticipants.value);
}

function processDTN(champKids){
	 // fonction qui concatene les dates de naissance des enfants pour les passer en param d'une nouvelle demande (telecommande)
	 var nbKids = document.getElementById(champKids).options[document.getElementById(champKids).selectedIndex].value;
	 var dtn = '';
	 for (var i=1; i<=nbKids; i++) {
	 		if (document.getElementById("guest"+i)) {
	 			if (i > 1) {
	 				dtn += ',';
	 			}
	 			dtn += document.getElementById("guest"+i).value;
	 		}
	 }
	 var dateDeNaissance = document.getElementById('dateDeNaissance');
	 dateDeNaissance.value = dtn;
}

function specialHide() {
	if (document.getElementById('special1')) {
		document.getElementById('special1').className = 'hidden';
	}
	if (document.getElementById('special2')) {
		document.getElementById('special2').className = 'hidden';
	}
}

function specialShow() {
	if (document.getElementById('special1')) {
		document.getElementById('special1').className = 'block';
	}
	if (document.getElementById('special2')) {
		document.getElementById('special2').className = 'block';
	}
}

function isValidDate(val, format) {
	var date = getDateFromFormat(val, format);
	if (date==0) {
		return false; 
	}
	return true;
}

function _isInteger(val) {
	var digits="1234567890";
	for (var i=0; i < val.length; i++) {
		if (digits.indexOf(val.charAt(i))==-1) { return false; }
	}
	return true;
}

function _getInt(str, i, minlength, maxlength) {
	for (var x=maxlength; x>=minlength; x--) {
		var token=str.substring(i,i+x);
		if (token.length < minlength) { return null; }
		if (_isInteger(token)) { return token; }
	}
	return null;
}	

// ------------------------------------------------------------------
// getDateFromFormat( date_string , format_string )
//
// This function takes a date string and a format string. It matches
// If the date string matches the format string, it returns the 
// getTime() of the date. If it does not match, it returns 0.
// ------------------------------------------------------------------
function getDateFromFormat(val, format) {
	val=val+"";
	format=format+"";
	var i_val=0;
	var i_format=0;
	var c="";
	var token="";
	var token2="";
	var x,y;
	var now=new Date();
	var year=now.getYear();
	var month=now.getMonth()+1;
	var date=1;
	var hh=now.getHours();
	var mm=now.getMinutes();
	var ss=now.getSeconds();
	var ampm="";
	while (i_format < format.length) {
		// Get next token from format string
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
		}
		// Extract contents of value based on format token
		if (token=="yyyy" || token=="yy" || token=="y" || token=="aaaa" || token=="jjjj") {
			if (token=="jjjj") { x=4;y=4; }
			if (token=="aaaa") { x=4;y=4; }
			if (token=="yyyy") { x=4;y=4; }
			if (token=="yy")   { x=2;y=2; }
			if (token=="y")    { x=2;y=4; }
			year=_getInt(val,i_val,x,y);
			if (year==null) { return 0; }
			i_val += year.length;
			if (year.length==2) {
				if (year > 20) { year=1900+(year-0); }
				else { year=2000+(year-0); }
			}
		}
		else if (token=="MM"||token=="M"||token=="mm") {
			month=_getInt(val,i_val,token.length,2);
			if(month==null||(month<1)||(month>12)){return 0;}
			i_val+=month.length;
		}
		else if (token=="dd"||token=="d"||token=="jj"||token=="gg"||token=="tt") {
			date=_getInt(val,i_val,token.length,2);
			if(date==null||(date<1)||(date>31)){return 0;}
			i_val+=date.length;
		}
		else if (token=="a") {
			if (val.substring(i_val,i_val+2).toLowerCase()=="am") {ampm="AM";}
			else if (val.substring(i_val,i_val+2).toLowerCase()=="pm") {ampm="PM";}
			else {return 0;}
			i_val+=2;
		}
		else {
			if (val.substring(i_val,i_val+token.length)!=token) {return 0;}
			else {i_val+=token.length;}
		}
	}
	// If there are any trailing characters left in the value, it doesn't match
	if (i_val != val.length) { return 0; }
	// Is date valid for month?
	if (month==2) {
		// Check for leap year
		if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) ) { // leap year
			if (date > 29){ return 0; }
			}
		else { if (date > 28) { return 0; } }
		}
	if ((month==4)||(month==6)||(month==9)||(month==11)) {
		if (date > 30) { return 0; }
		}
	// Correct hours value
	if (hh<12 && ampm=="PM") { hh=hh-0+12; }
	else if (hh>11 && ampm=="AM") { hh-=12; }
	var newdate=new Date(year,month-1,date,hh,mm,ss);
	return newdate;
}


function backButton(pageToGo) {
	window.location.replace(pageToGo);
}

// ------------------------------------------------------------------
// fonctions js pour la selection des modes de paiements
// ------------------------------------------------------------------

var nmodep = 4; // Nombre de mode de paiement

function changeBG(laTable) {
	for  (var i=1; i<=nmodep; i++) {
		if (document.getElementById('table_'+i+'_a'))
			document.getElementById('table_'+i+'_a').className = 'bg_transport';
		if (document.getElementById('table_'+i+'_b'))
			document.getElementById('table_'+i+'_b').className = 'bg_transport';
	}
	if (document.getElementById(laTable+'_a'))
		document.getElementById(laTable+'_a').className  = 'bg_100';
	if (document.getElementById(laTable+'_b'))
		document.getElementById(laTable+'_b').className  = 'bg_100';
}
		
function changeBG2(laTb) {
	for  (var i=1; i<=nmodep; i++) {
		if (document.getElementById('tb_'+i+'_a'))
			document.getElementById('tb_'+i+'_a').className = 'bg_a';
		if (document.getElementById('tb_'+i+'_b'))
			document.getElementById('tb_'+i+'_b').className = 'bg_a';
	}
	if (document.getElementById(laTb+'_a'))
		document.getElementById(laTb+'_a').className  = 'bg_70';
	if (document.getElementById(laTb+'_b'))
		document.getElementById(laTb+'_b').className  = 'bg_70';
}

function selectAmexRadio() {
	if (document.getElementById('paymentAmex')) {
		document.getElementById('paymentAmex').checked = true;
	}
}

function checkFirstAmexRadio() {
	if (document.getElementById('americanCardPaymentChoice1')) {
		document.getElementById('americanCardPaymentChoice1').checked = true;
	}
}