	/*
 * Gestion du moteur de recherche
 * # remplacement des champs de formulaire pour customisation
 * # validation formulaire
 * # calendrier et gestion de la date
 * /!\ necessite sof_datas.js pour fonctionner
 */

// init namespace (A  utiliser pour eviter toute collision)
if(!SOF) {var SOF = {};}

// gestion de la date
SOF.today = new Date();
SOF.day = SOF.today.getDate();
SOF.month = SOF.today.getMonth() + 1;
SOF.year = SOF.today.getFullYear();
SOF.dates = {
	range: function(start, end, cgi) {
		var a = [];
		for(var i = start; i <= end; i++) {a[a.length] = !cgi && i < 10 ? '0' + i : '' + i;}
		return a;
	},
	firstDayOfMonth: function(y, m, d) {
		var day = new Date(y, m - 1, d).getDay();
		return day == 0 ? 6 : day - 1;
	},
	dayOfWeek: function(when) {
		var date = SOF.dates.getCurrent(when);
		var day = new Date(date.y, date.m - 1, date.d).getDay();
		day = day == 0 ? 6 : day - 1;
		return SOF[$$L]['days'][day];
	},
	leap: function(y) {
		if(y % 4 == 0) {return y % 100 != 0 || y % 100 == 0 && y % 400 == 0 ? 29 : 28;}
		return 28;
	},
	days: function(y) {
		return [31, SOF.dates.leap(y), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
	},
	getLimit: function(d, m, y) {
		return SOF.dates.getCorrect({'d': SOF.day + d, 'm': SOF.month + m, 'y': SOF.year + y});
	},
	getCurrent: function(when, duree) {
		if(!when) {
			return {'d': SOF.day, 'm': SOF.month, 'y': SOF.year};
		} else {
			duree = duree || 0;
			var r = $$DF.dates[when];
			var date = {'d': Number($$DF.fields[r.d].field.value) + duree, 'm': Number($$DF.fields[r.m].field.value), 'y': Number($$DF.fields[r.y].field.value)};
			if(isNaN(date.d) || date.d == 0) {date.d = SOF.day;}
			if(isNaN(date.m) || date.m == 0) {date.m = SOF.month;}
			if(isNaN(date.y) || date.y == 0) {date.y = SOF.year;}
			return date;
		}
	},
	getCorrect: function(date, when) {
		var tmp = new Date(date.y, date.m - 1, date.d);
		date.d = tmp.getDate();
		date.m = tmp.getMonth() + 1;
		date.y = tmp.getFullYear();
		return when ? SOF.dates.check(date, when) : date;
	},
	verif: function(start, end) {
		var d1 = '' + start.y + (start.m < 10 ? '0' + start.m : start.m) + (start.d < 10 ? '0' + start.d : start.d);
		var d2 = '' + end.y + (end.m < 10 ? '0' + end.m : end.m) + (end.d < 10 ? '0' + end.d : end.d);
		return (d2 - d1);
	},
	check: function(date, when) {
		$$DF.resetDate = false;
		var retour = "";
		if(when == 'start' && SOF.dates.limitSejour) {
			if(SOF.dates.verif(SOF.dates.limitMin, date) < 0) {
				/*correction@20071112*/if($$DF.infosDates) {$$DF.infosDatesDisplay = 'start';}/*END correction@20071112*/
				retour = SOF.dates.return_date(SOF.dates.limitMin);
			}
			if(SOF.dates.verif(date, SOF.dates.limitSejour) < 0) {
        /*correction@20071112*/if($$DF.infosDates) {$$DF.infosDatesDisplay = 'end';}/*END correction@20071112*/
        retour = SOF.dates.return_date(SOF.dates.limitSejour);
      }
		} else {
			if(SOF.dates.verif(SOF.dates.limitMin, date) < 0) {
				/*correction@20071112*/if($$DF.infosDates) {$$DF.infosDatesDisplay = 'start';}/*END correction@20071112*/
				if($$DF.noDate && $$DF.lastKeySelect == 38) {$$DF.resetDate = true;}
				retour = SOF.dates.return_date(SOF.dates.limitMin);
			}
			if(SOF.dates.verif(date, SOF.dates.limitMax) < 0) {
        /*correction@20071112*/if($$DF.infosDates) {$$DF.infosDatesDisplay = 'end';}/*END correction@20071112*/
        retour = SOF.dates.return_date(SOF.dates.limitMax);
      }
		}
		retour = (retour == "") ? SOF.dates.return_date(date) : retour;
		return retour;
	},

	is_weekend: function() {
		if (Box.nodes.get('#day_of_week')[0])	{
			var test = Box.nodes.get('#day_of_week')[0].value;
			var mon_tab = new Array('mon','tue','wed','thu','fri','sat','sun');
			SOF.dates.limited_day = new Array(6); 
			var tab_test = test.split("|");
			var outTest = 0, fdow = -1, old_fdow = -1, ldow = 0;
			//on décompose pour trouver le premier jour de la semaine
			for (var i=0; i<mon_tab.length; i++)	{
				if (SOF.dates.inArray(tab_test, mon_tab[i])) {
					if (fdow == -1) {
						fdow = i;
						old_fdow = i;
					}
					ldow++;
				}
				else 
					fdow = -1;
				//alert("i "+mon_tab[i]+" fdow "+fdow+" old "+old_fdow);
			}
			fdow = (fdow == -1) ? old_fdow : fdow;
			SOF.dates.fdow = fdow;
			SOF.dates.ldow = ldow;
			
			//alert("fdow "+fdow+" ldow "+ldow);
			
			for (var i=0; i<mon_tab.length; i++)	{
				if (SOF.dates.inArray(tab_test, mon_tab[i]))	{
					if (i < fdow)
						SOF.dates.limited_day[i] = i + fdow;
					else
						SOF.dates.limited_day[i] = i - fdow + 1;
				}	else	{
					outTest++;
					SOF.dates.limited_day[i] = -1;
				}
			} 
			
			//for (var k = 0; k < SOF.dates.limited_day.length; k++)
			//	alert(k+" K "+SOF.dates.limited_day[k]);
				
	    if (outTest > 0)
	        return true;
    }
    return false;
	},

	return_date: function(date) {
		if (!SOF.dates.weekend)
			return date;
		// Pris en compte des week-ends
		var day = new Date(date.y, date.m - 1, date.d).getDay();
		day = day == 0 ? 6 : day - 1;
		// Si le jour choisi ne fait pas parti des jours autorisés
		if (SOF.dates.limited_day[day] == -1)
		{
			var diff = (SOF.dates.fdow - day), month = SOF.dates.days(date.y);
			diff = (diff == -2) ? 5 : diff;
			if (date.d + diff > month[date.m-1])
			{
				if (date.m == 12)
					date = {'d': date.d + diff - month[11], 'm': 1, 'y': date.y+1};
				else
					date = {'d': date.d + diff - month[date.m-1], 'm': date.m+1, 'y': date.y};
			}
			else
				date = {'d': date.d + diff, 'm': date.m, 'y': date.y};
		}
		day = new Date(date.y, date.m - 1, date.d).getDay();
		day = day == 0 ? 6 : day - 1;
		/* nombre de nuits dégressives à réserver pour un weekend */
		// on cache tous les li
		var mon_ul = Box.nodes.get("li", Box.nodes.get("ol", Box.nodes.get('#nb_nuit-rpl')[0])[0]);
		for (var i = 0; i < mon_ul.length; i++) {
			Box.nodes.addClass(mon_ul[i], "hidden");
		}
		var chaine = "";
		for (var j = 0; j < SOF.dates.limited_day.length; j++)	{
			if (SOF.dates.limited_day[j] != -1)	{
				if (chaine != "")
					chaine += "|";
				chaine += SOF.dates.limited_day[j];
			}
		}
		var tab_chaine = chaine.split("|"); 
		var max = tab_chaine.length - (SOF.dates.limited_day[day] - 1);
		var nb_nuit_min = 0;
		
		var m_min = (SOF.dates.nb_nuit_min) ? SOF.dates.nb_nuit_min : -1;
		var m_max = (SOF.dates.nb_nuit_max) ? SOF.dates.nb_nuit_max : -1;
		m_max = (m_max > -1) ? m_max : 1000;
		if (m_min > -1)
			max = max + (m_min -1);
		var NN = Box.nodes.get("#val-nb_nuit")[0].innerHTML;
		var def_nb_nuit = 0, comp = ""; 
		for (var i = 0; i < max; i++)	{
			if (mon_ul[i])	{
				if (i >= (m_min -1)) {
					if (i < m_max) {
						def_nb_nuit = def_nb_nuit == 0 ? i : def_nb_nuit;
						Box.nodes.removeClass(mon_ul[i], "hidden");
						var j = i + 1;
						j = (j.toString().length > 1) ? j.toString() : "0"+j.toString();
						if (j == NN) {
							comp = j;
						}
					}
				}
			}
		}
		def_nb_nuit = def_nb_nuit + 1;
		def_nb_nuit = (def_nb_nuit.toString().length > 1) ? def_nb_nuit.toString() : "0"+def_nb_nuit.toString();
		
		if (comp == "")
			Box.nodes.get("#val-nb_nuit")[0].innerHTML = def_nb_nuit;
		//alert("chaine "+chaine+" max "+max+" lmtd_day "+SOF.dates.limited_day[day]+" Min "+m_min+" Max "+m_max+" def "+def_nb_nuit+" nn "+NN);
		return date;
	},
	inArray: function(tab, day) {
		var retour = false;
		for (var i = 0; i < tab.length; i++)	{
			if (tab[i] == day)
				retour = true;
		}
		return retour;
	},
	reset: function(when) {
		var f = $$DF.dates[when];
		$$DF.fields[f.d].index = 0;
		$$DF.fields[f.d].display.innerHTML = $$DF.fields[f.d].val[0];
		$$DF.fields[f.d].field.value = '';
		$$DF.fields[f.m].index = 0;
		$$DF.fields[f.m].display.innerHTML = $$DF.fields[f.m].val[0];
		$$DF.fields[f.m].field.value = '';
		$$DF.fields[f.y].index = 0;
		$$DF.fields[f.y].display.innerHTML = $$DF.fields[f.y].val[0];
		$$DF.fields[f.y].field.value = '';
	},
	update: function(date, when) {
		var f = $$DF.dates[when], i = 0;
		var adjust = $$DF.fields[f.d].noValuePossible && location.href.indexOf($$DF.fields[f.d].noValuePossible) > -1 ? 0 : 1;
		$$DF.fields[f.d].index = date.d - adjust;
		$$DF.fields[f.d].display.innerHTML = date.d < 10 ? '0' + date.d : date.d;
		$$DF.fields[f.d].field.value = date.d;
		$$DF.fields[f.m].index = date.m - adjust;
		$$DF.fields[f.m].display.innerHTML = date.m < 10 ? '0' + date.m : date.m;
		$$DF.fields[f.m].field.value = date.m;
		while($$DF.fields[f.y].val[i] != date.y && i < $$DF.fields[f.y].val.length) {i++;}
		$$DF.fields[f.y].index = i;
		$$DF.fields[f.y].display.innerHTML = date.y;
		$$DF.fields[f.y].field.value = date.y;
	},
	updateNights: function(n) {
		$$DF.fields['nb_nuit'].index = n - 1;
		$$DF.fields['nb_nuit'].display.innerHTML = n < 10 ? '0' + n : n;
		$$DF.fields['nb_nuit'].field.value = $$DF.fields['nb_nuit']['cgi'][$$DF.fields['nb_nuit'].index];
	},
	updateDuree: function() {
		SOF.dates.dureeSejour = Number($$DF.dureeSejour.value) || 0;
		var date = {'d': SOF.dates.limitMax.d, 'm': SOF.dates.limitMax.m, 'y': SOF.dates.limitMax.y};
		date.d = date.d - SOF.dates.dureeSejour;
		SOF.dates.limitSejour = SOF.dates.getCorrect(date);
		SOF.dates.startSejour = {'d': SOF.dates.limitMin.d, 'm': SOF.dates.limitMin.m, 'y': SOF.dates.limitMin.y};
		SOF.dates.startSejour.d = SOF.dates.startSejour.d + SOF.dates.dureeSejour;
		SOF.dates.startSejour = SOF.dates.getCorrect(SOF.dates.startSejour);
		SOF.dates.update(SOF.dates.startSejour, 'end');
	},
	control: function(when, noDate) {

		$$DF.infosDatesDisplay = false;
		var r = $$DF.fields, start, end;
		start = SOF.dates.getCorrect(SOF.dates.getCurrent('start'), 'start');
		$$DF.noDate = noDate && location.href.indexOf(noDate) > -1 ? true : false;
		if($$DF.dates.end.d) {end = SOF.dates.getCorrect(SOF.dates.getCurrent('end'), 'end');}
		if(when == 'start') {
			if($$DF.dates.end.d) {
				if($$DF.dureeSejour) {
					end.d = start.d + SOF.dates.dureeSejour; end.m = start.m; end.y = start.y;
					end = SOF.dates.getCorrect(end);
					SOF.dates.update(end, 'end');
					start.d = end.d - SOF.dates.dureeSejour; start.m = end.m; start.y = end.y;
					start = SOF.dates.getCorrect(start);
					SOF.dates.update(start, 'start');
				} else {
					if((start.y > end.y) || (start.y == end.y && start.m > end.m) || (start.y == end.y && start.m == end.m && start.d > end.d)) {
						end.d = start.d; end.m = start.m; end.y = start.y;
						end = SOF.dates.getCorrect(end);
						SOF.dates.update(end, 'end');
						start.d = end.d; start.m = end.m; start.y = end.y;
						start = SOF.dates.getCorrect(start);
						SOF.dates.update(start, 'start');
					} else {
						start = SOF.dates.getCorrect(start);
						SOF.dates.update(start, 'start');
					}
				}
			} else {
				if($$DF.noDate && $$DF.resetDate) {
					SOF.dates.reset(when);
					return;
				}
				/*correction@20071112*/if(r['nb_nuit'].display && !r['nb_nuit'].standalone) {/*END correction@20071112*/
					var v = Number(r['nb_nuit'].display.innerHTML);
					var n = SOF.dates.verif(start, SOF.dates.limitMax);
					v = n < v ? n + 1 : v;
					if(SOF.dates.dureeSejourMin && v < SOF.dates.dureeSejourMin) {
						start.d = start.d - (SOF.dates.dureeSejourMin - v);
						SOF.dates.getCorrect(start, 'start');
						v = SOF.dates.dureeSejourMin;
					}
					SOF.dates.updateNights(v);
				}
				SOF.dates.update(start, 'start');
			}
		} else if(when == 'end') {
			if($$DF.dureeSejour) {
				start.d = end.d - SOF.dates.dureeSejour; start.m = end.m; start.y = end.y;
				start = SOF.dates.getCorrect(start, 'start');
				SOF.dates.update(start, 'start');
				end.d = start.d + SOF.dates.dureeSejour; end.m = start.m; end.y = start.y;
				end = SOF.dates.getCorrect(end);
				SOF.dates.update(end, 'end');
			} else {
				if((start.y > end.y) || (start.y == end.y && start.m > end.m) || (start.y == end.y && start.m == end.m && start.d > end.d)) {
					start.d = end.d; start.m = end.m; start.y = end.y;
					start = SOF.dates.getCorrect(start, 'start');
					SOF.dates.update(start, 'start');
					end.d = start.d; end.m = start.m; end.y = start.y;
					end = SOF.dates.getCorrect(end);
					SOF.dates.update(end, 'end');
				} else {
					end = SOF.dates.getCorrect(end);
					SOF.dates.update(end, 'end');
				}
			}
		}
		/*correction@20071112*/if($$DF.infosDatesDisplay) {SOF.niceforms.onInfos($$DF.infosDatesDisplay);}/*END correction@20071112*/
		r = null; // nettoyage
	}
};

// dates courante et limites
SOF.dates.current = {'d': SOF.day, 'm': SOF.month, 'y': SOF.year};
//SOF.dates.limit = SOF.dates.getLimit(7, 1, 1);

SOF.dates.weekend = false; // sert pour le calendrier 'weekend' qui n'affiche que les vendredis et samedis

	// bornes customisees par la page html appelante avec les variables calendarStartDate et calendarEndDate
	// a mettre forcement avant l'appel de sof_search !
SOF.dates.limitMin = typeof(calendarStartDate)!="undefined"?calendarStartDate:SOF.dates.current;
SOF.dates.limitMax = typeof(calendarEndDate)!="undefined"?calendarEndDate:SOF.dates.getLimit(7, 1, 1);

// données pour les scripts de cette page
SOF.datasDatesForms = {
	'dates': {
		'start': {'d': '', 'm': '', 'y': ''},
		'end': {'d': '', 'm': '', 'y': ''}
	},
	
	'fields': {
		'theme': {
	   'replaceBy': 'select',
	   'action': function() { go_liste_theme(this.index); }
	  },
	  'partheme': {
	   'replaceBy': 'select',
	   'action': function() { go_liste_theme(this.index); }
	  },
	  'pardestination': {
	   'replaceBy': 'select',
	   'action': function() { go_liste_destination(this.index); }
	  },
	  'sejdestination': {
	   'replaceBy': 'select',
	   'action': function() { go_liste_destination(this.index); }
	  },
	  'ds_theme': {
	   'replaceBy': 'select',
	   'action': function() { sel_liste(this.name, this.index); }
	  },
	  'ds_destination': {
	   'replaceBy': 'select',
	   'action': function() { sel_liste(this.name, this.index); }
	  },
	  'ds_periode': {
	   'replaceBy': 'select',
	   'action': function() { sel_liste(this.name, this.index); }
	  },		
		'topSelect': {
			'replaceBy': 'select',
			'action': function() {SOF.niceforms.changeDestination();}
		},
		'type_sejour': {
			'replaceBy': 'select', 'dureeSejour': [],
			'action': function() {SOF.niceforms.trimThalassa({
				'target': 'code_hotel',
				'retrieve': 'nb_nuit',
				'datas': {
					'duree-6': SOF[$$L]['thalassa']['duree-6'],
					'duree-7': SOF[$$L]['thalassa']['duree-7'],
					'duree-2': SOF[$$L]['thalassa']['duree-2']
				}
			});},
			'check': 'required'
		},
		'code_hotel': {
			'replaceBy': 'select', 'codeMarque': [], 'check': 'required'
		},
		'offres_pays': {
			'replaceBy': 'select', 
      		'check': 'required',
			'offres': {
				'url': ' {ADDR}{OFFRE}.xml',
				'target': 'offres_pays',
				'item': 'pays'
			},
			'ajax_offre': {
				'url': ' {ADDR}{OFFRE}.xml', //~ Only the path, get the file in request method
				'target': 'offres_participant',
				'item': 'participant'
			}
		},
		'offres_participant': {
			'replaceBy': 'select',
			'check': 'required',
			'disabled': true
		},
		'nom_pays': {
			'replaceBy': 'select', 
      'check': 'required',
			'source': {
				'url': '/{LANG}/hotel-deals/pays/pays.xml',
				'target': 'nom_pays',
				'item': 'pays'
			},
			'ajax': {
				'url': '/{LANG}/hotel-deals/villes/{FILE}.xml', //~ Only the path, get the file in request method
				'target': 'nom_ville_pays',
				'item': 'ville'
			}
		},
		'nom_ville_pays': {
		  'pseudoId': 'hotel_ou_ville',
			'replaceBy': 'select',
			'check': 'required',
			'disabled': true
		},
		'hotel_ou_ville': {
			'check': 'required',
			'applyOn': 'home, destination, generique',
			'action': function(n) {
				Box.events.add(n, 'focus', SOF.niceforms.clearValue);
				//Box.events.add(n, 'blur', SOF.niceforms.restoreValue);
				
        if (undefined !== Box.nodes.get("#topSelect")[0])
            Box.events.add(n, 'blur', function(e) {SOF.niceforms.resetValue(e, 'topSelect');});
        else
            Box.events.add(n, 'blur', SOF.niceforms.restoreValue);
			}
		},
		'jour_arrivee': {
			'replaceBy': 'select', 'start': 1, 'end': 31, 'index': SOF.day - 1, 'checkDates': ['d', 'start'], 
      'checkStart': ['mois_arrivee', 'annee_arrivee'], 
      'noValuePossible': '/' + $$L + '/home/', 'noValuePossible2': '/' + $$L + '/reservation/recherche_destination',
			'action': function() {SOF.dates.control('start', '/' + $$L + '/home/');},
			'tooltip': SOF[$$L].tooltips.day
		},
		'mois_arrivee': {
			'replaceBy': 'select', 'start': 1, 'end': 12, 'index': SOF.month - 1, 'checkDates': ['m', 'start'], 
      'noValuePossible': '/' + $$L + '/home/', 'noValuePossible2': '/' + $$L + '/reservation/recherche_destination',
			'action': function() {SOF.dates.control('start');},
			'tooltip': SOF[$$L].tooltips.month
		},
		'annee_arrivee': {
			'replaceBy': 'select', 'start': SOF.dates.limitMin.y, 'end': SOF.dates.limitMax.y, 'index': 0, 'checkDates': ['y', 'start'], 
      'noValuePossible': '/' + $$L + '/home/', 'noValuePossible2': '/' + $$L + '/reservation/recherche_destination',
			'calendar': true,
			'action': function() {SOF.dates.control('start');},
			'tooltip': SOF[$$L].tooltips.year
		},
		'jour_depart': {
			'replaceBy': 'select', 'start': 1, 'end': 31, 'index': SOF.day - 1, 'checkDates': ['d', 'end'],
			'action': function() {SOF.dates.control('end');},
			'tooltip': SOF[$$L].tooltips.day
		},
		'mois_depart': {
			'replaceBy': 'select', 'start': 1, 'end': 12, 'index': SOF.month - 1, 'checkDates': ['m', 'end'],
			'action': function() {SOF.dates.control('end');},
			'tooltip': SOF[$$L].tooltips.month
		},
		'annee_depart': {
			'replaceBy': 'select', 'start': SOF.dates.limitMin.y, 'end': SOF.dates.limitMax.y, 'index': 0, 'checkDates': ['y', 'end'],
			'calendar': true,
			'action': function() {SOF.dates.control('end');},
			'tooltip': SOF[$$L].tooltips.year
		},
		'nb_nuit': {
			'replaceBy': 'select', 'start' : 1, 'end': 23, 'index': 0, 'checkDuree': true,
			'action': function() {SOF.dates.control('start');}
		},
		'checkboxAvantage': {
			'replaceBy': 'checkbox', 'default': 0
		},
		'ID_PAYS': {
			'replaceBy': 'select', 'cible': 'ID_ETAT', 'applyOn': 'press-form',
			'action': function() {SOF.niceforms.addStates('ID_PAYS');}
		},
		'hotelLocation': {
			'replaceBy': 'select'
		},
		'ID_EVENEMENT_JOUR_ARR': {
			'replaceBy': 'select', 'start': 1, 'end': 31, 'index': SOF.day - 1, 'checkDates': ['d', 'start'],
			'action': function() {SOF.dates.control('start');}
		},
		'ID_EVENEMENT_MOIS_ARR': {
			'replaceBy': 'select', 'start': 1, 'end': 12, 'index': SOF.month - 1, 'checkDates': ['m', 'start'],
			'action': function() {SOF.dates.control('start');}
		},
		'ID_EVENEMENT_ANNEE_ARR': {
			'replaceBy': 'select', 'start': SOF.dates.limitMin.y, 'end': SOF.dates.limitMax.y, 'index': 0, 'checkDates': ['y', 'start'],
			'calendar': true,
			'action': function() {SOF.dates.control('start');}
		},
		'ID_EVENEMENT_JOUR_DEP': {
			'replaceBy': 'select', 'start': 1, 'end': 31, 'index': SOF.day - 1, 'checkDates': ['d', 'end'],
			'action': function() {SOF.dates.control('end');}
		},
		'ID_EVENEMENT_MOIS_DEP': {
			'replaceBy': 'select', 'start': 1, 'end': 12, 'index': SOF.month - 1, 'checkDates': ['m', 'end'],
			'action': function() {SOF.dates.control('end');}
		},
		'ID_EVENEMENT_ANNEE_DEP': {
			'replaceBy': 'select', 'start': SOF.dates.limitMin.y, 'end': SOF.dates.limitMax.y, 'index': 0, 'checkDates': ['y', 'end'],
			'calendar': true,
			'action': function() {SOF.dates.control('end');}
		},
		'ID_NAVIGATEUR_NOM': {
			'replaceBy': 'radio', 'group': []
		},
		'ID_PAYS_o': {
			'replaceBy': 'select'
		},
		'arrivalDay': {
			'replaceBy': 'select', 'start': 1, 'end': 31, 'index': SOF.day - 1, 'checkDates': ['d', 'start'],
			'action': function() {SOF.dates.control('start');}
		},
		'arrivalMonth': {
			'replaceBy': 'select', 'start': 1, 'end': 12, 'index': SOF.month - 1, 'checkDates': ['m', 'start'],
			'action': function() {SOF.dates.control('start');}
		},
		'arrivalYear': {
			'replaceBy': 'select', 'start': SOF.dates.limitMin.y, 'end': SOF.dates.limitMax.y, 'index': 0, 'checkDates': ['y', 'start'],
			'calendar': true,
			'action': function() {SOF.dates.control('start');},
			'select_year' : 'true'
		},
		'departureDay': {
			'replaceBy': 'select', 'start': 1, 'end': 31, 'index': SOF.day - 1, 'checkDates': ['d', 'end'],
			'action': function() {SOF.dates.control('end');}
		},
		'departureMonth': {
			'replaceBy': 'select', 'start': 1, 'end': 12, 'index': SOF.month - 1, 'checkDates': ['m', 'end'],
			'action': function() {SOF.dates.control('end');}
		},
		'departureYear': {
			'replaceBy': 'select', 'start': SOF.dates.limitMin.y, 'end': SOF.dates.limitMax.y, 'index': 0, 'checkDates': ['y', 'end'],
			'calendar': true,
			'action': function() {SOF.dates.control('end');},
			'select_year' : 'true'
		},
		'currency': {
			'replaceBy': 'select'
		},
		'competitorCurrency': {
			'replaceBy': 'select'
		},
		'generalConditions': {
			'replaceBy': 'checkbox', 'default': 0
		},
		'civility': {
			'replaceBy': 'select'
		},
		'companyType': {
			'replaceBy': 'select'
		},
		'ID_ETAT': {
			'replaceBy': 'select'
		},
		'destination': {
			'replaceBy': 'radio', 'group': [], 'onPage': 'destination',
			'action': function() {SOF.niceforms.changeDestination();}
		},
		'GC_country': {
			'check': 'required', 'replaceBy': 'select', 'cible': 'GC_state',
			'action': function() {SOF.niceforms.addStates('GC_country');},
			'source': {
				'url': '/{LANG}/hotel-deals/pays/pays_maporama.xml',
				'target': 'GC_country',
				'item': 'pays'
			}
		},
		'GC_address': {
			'check': 'required'
		},
		'GC_city': {
			'check': 'required', 'twin': 'GC_zip', 'verif': 'empty'
		},
		'GC_state': {
			'replaceBy': 'select'
		},
		'SA_word': {
			'check': 'required', 'twin': 'SA_config', 'verif': '0'
		},
		'SA_config': {
			'replaceBy': 'select', 'default': 2
		},

		'RA1': {
			'replaceBy': 'select', 'applyOn': 'accorhotelform'
		},
		'productCodeArea': {
			'replaceBy': 'select'
		},
		'productCodeInterestPoint': {
			'replaceBy': 'select'
		},
		'productCodeEvents': {
			'replaceBy': 'select'
		},
		'personnes': {
			'replaceBy': 'radio', 'group': []
		},
		'productCodeServices': {
			'replaceBy': 'checkbox', 'group': []
		},
		'productCodeActivities': {
			'replaceBy': 'checkbox', 'group': []
		},
		'ID_RESTAURATION_COCKTAIL': {
			'replaceBy': 'checkbox', 'default': SOF[$$L]['checkValue']['n']
		},
		'ID_RESTAURATION_DEJEUNER': {
			'replaceBy': 'checkbox', 'default': SOF[$$L]['checkValue']['n']
		},
		'ID_RESTAURATION_DINER': {
			'replaceBy': 'checkbox', 'default': SOF[$$L]['checkValue']['n']
		},
		'ID_HEBERGEMENT_OUI_NON': {
			'replaceBy': 'checkbox', 'default': SOF[$$L]['checkValue']['n'],
			'action': function() {
				var block = Box.nodes.get("#roomNumberBlock")[0];
				block.style.display = (block.style.display=='none'?'block':'none');
			}
		},
		'ID_SERVICES_CENTRE_AFFAIRE': {
			'replaceBy': 'checkbox', 'default': SOF[$$L]['checkValue']['n']
		},
		'ID_SERVICES_TRADUCTION': {
			'replaceBy': 'checkbox', 'default': SOF[$$L]['checkValue']['n']
		},
		'ID_SERVICES_LOCATION_ORDINATEUR': {
			'replaceBy': 'checkbox', 'default': SOF[$$L]['checkValue']['n']
		},
		'ID_SERVICES_ACCES_HANDICAPE': {
			'replaceBy': 'checkbox', 'default': SOF[$$L]['checkValue']['n']
		},
		'ID_SERVICES_PARKING': {
			'replaceBy': 'checkbox', 'default': SOF[$$L]['checkValue']['n']
		},
		'ID_SERVICES_PROXIMITE_AEROPORT': {
			'replaceBy': 'checkbox', 'default': SOF[$$L]['checkValue']['n']
		},
		'ID_SERVICES_GOLF': {
			'replaceBy': 'checkbox', 'default': SOF[$$L]['checkValue']['n']
		},
		'ID_SERVICES_TENNIS': {
			'replaceBy': 'checkbox', 'default': SOF[$$L]['checkValue']['n']
		},
		'ID_SERVICES_PISCINE': {
			'replaceBy': 'checkbox', 'default': SOF[$$L]['checkValue']['n']
		},
		'ID_SERVICES_ESPACE_FORME': {
			'replaceBy': 'checkbox', 'default': SOF[$$L]['checkValue']['n']
		},
		'ID_EVENEMENT_SALLE_COMMISSION': {
			'replaceBy': 'radio', 'group': [],
			'action': function() {
				var block = Box.nodes.get("#breakoutRoomsBlock")[0];
				block.style.display = (this.field.value=='OUI'?'block':'none');
			}
		},
		'ID_EVENEMENT_DATE_FLEXIBLE': {
			'replaceBy': 'radio', 'group': []
		},
		'MEETING_ROOM_SETUP': {
			'replaceBy': 'select'
		},
		'ID_TYPE_STRUCTURE': {
			'replaceBy': 'select'
		},
		'ID_PAYS_SOCIETE': {
			'replaceBy': 'select', 'cible': 'ID_ETAT_SOCIETE', 'applyOn': 'rfpOfflineForm',
			'action': function() {SOF.niceforms.addStates('ID_PAYS_SOCIETE');}
		},
		'ID_TITRE': {
			'replaceBy': 'select'
		},
		'ITI_START_city': {
			'check': 'required', 'twin': 'ITI_START_zip', 'verif': 'empty'
		},
		'ITI_START_country': {
			'replaceBy': 'select', 'openDir': 'up', 'check': 'required'
		},
		'nbSingle': {
			'check': 'required', 'twin': 'nbDouble', 'verif': 'empty'
		},
		'type_carte_fidelite': {
			'replaceBy': 'select', 'check': 'required'
		}
	},
	
	'calendar': {
		'targets': {
			'start': {'after': ['#annee_arrivee', '#ID_EVENEMENT_ANNEE_ARR', '#arrivalYear'], 'd': '', 'm': '', 'y': ''},
			'end': {'after': ['#annee_depart', '#ID_EVENEMENT_ANNEE_DEP', '#departureYear'], 'd': '', 'm': '', 'y': ''}
		},
		'isPresent': false
	},
	
	'required': {
		'msg': function(id) {return SOF[$$L][id + 'ErrorMsg']},
		'test': function(o) {
			if(SOF[$$L]['defaults'] && SOF[$$L]['defaults'][o.id]) {
				return o.value == SOF[$$L]['defaults'][o.id] ? false : !/^\s*$/.test(o.value);
			} else {
				return !/^\s*$/.test(o.value);
			}
		}
	},
	
	'empty': function(o) {
		return /^\s*$/.test(o.value);
	},
	
	'scroll': {
		'upDown': 28,
		'borders': 2,
		'limit': 30,
		'itemH': 14,
		'nbItems': 15,
		'animDelay': 30,
		'animSlow': 6
	}
};
if(!$$DF) {var $$DF = SOF.datasDatesForms;}

// remplacements formulaires
SOF.niceforms = {
	onSubmitTasks: {},
	onErrorMsg: {},
	enableFields: false,	
	imgTree: (document.location.href.match(/fichehotel/))?'fichehotel/sof':'commun',
	
	init: function() {
		var search = Box.nodes.get('#search')[0];
		var contact = Box.nodes.get('#contact')[0];
		var garantie = Box.nodes.get('#garantie')[0];
		if(!search && !contact && !garantie) {return;}
		$$DF.datesControls = contact ? 'min' : 'max';
		SOF.dates.weekend = SOF.dates.is_weekend();
		$$DF.dureeSejour = Box.nodes.get('#nb_nuit[type=hidden]')[0];
		$$DF.infosDates = Box.nodes.get('#infos-dates')[0];
		//$$DF.dayOfWeek = Box.nodes.get('#dayOfWeek')[0];	//ne sert plus (PA)
		if($$DF.infosDates) {$$DF.infosDatesCible = $$DF.infosDates.className.replace(' hide', '');}
		var o, f, g, l;
		for(var id in $$DF.fields) {
      var o = Box.nodes.get('#'+id)[0];
      try
      {
        if(o.getAttribute("alt") == "no_ctrl"){
         // plus de controle sur la date       
         $$DF.fields[id].action = '';
         // deblinde le calendrier       
         SOF.dates.limitMin = SOF.dates.getLimit(7, -1, -1);

          // gestion du select annee
          if($$DF.fields[id].select_year == 'true'){
            $$DF.fields[id].start = SOF.year - 1; 
            $$DF.fields[id].index = 1;
          }     
        }
      }
      catch (e)
      {
      }		
		
			if($$DF.fields[id].onPage && !Box.nodes.hasClass(document.body, $$DF.fields[id].onPage)) {continue;}
			if($$DF.fields[id].group) {
				g = Box.nodes.get('input[name=' + id + ']');
				if(!g.length) {continue;}
				SOF.niceforms.replace(g, id, $$DF.fields[id].replaceBy);
				if($$DF.fields[id].replaceBy == 'checkbox') {SOF.niceforms.enableFields = true;}
			} else {
				o = Box.nodes.get('#' + id)[0];
				if(!o || (o.type && o.type == 'hidden')) {continue;}
				if($$DF.fields[id].replaceBy) {
					SOF.niceforms.replace(o, id, $$DF.fields[id].replaceBy);
				} else {
					if($$DF.fields[id].action) {$$DF.fields[id].action(o);}
				}
        if($$DF.fields[id].source) {SOF.niceforms.requestSource(id);}//prise en compte de la source
        if($$DF.fields[id].offres) {SOF.niceforms.requestOffres(id);}//prise en compte des offres
				if($$DF.fields[id].checkDates) {
					var c = $$DF.fields[id].checkDates;
					$$DF.dates[c[1]][c[0]] = id;
					$$DF.calendar.targets[c[1]][c[0]] = id;
				}
				if($$DF.fields[id].calendar) {$$DF.calendar.isPresent = true;}
			}
			if($$DF.fields[id].check) {
				if(!$$DF.fields[id].applyOn || $$DF.fields[id].applyOn && $$DF.fields[id].applyOn.indexOf(document.body.className) > -1) {
          SOF.niceforms.onSubmitTasks[id] = $$DF.fields[id].check;
        }
			}
		}
		if($$DF.dureeSejour) {SOF.dates.updateDuree();}
		if(search) {
			// pas de validation sur les formulaires de contact / meilleur prix / presse (traité par Accor...)
			f = search.nodeName.toLowerCase() == 'form' ? search : Box.nodes.get('form', [search])[0];
			Box.events.add(f, 'submit', function(e) {SOF.niceforms.onSubmit(e, this);});
		}
		if($$DF.dayOfWeek) {$$DF.dayOfWeek.innerHTML = '(' + SOF.dates.dayOfWeek('start') + ')';}
		o = null; f = null; g = null; // nettoyage
	},
	
	onSubmit: function(e, f) {
		var o, n = 0, condition = true, field;
		SOF.niceforms.onErrorMsg = {};
		for(var id in SOF.niceforms.onSubmitTasks) {
		  if ($$DF.fields[id].pseudoId)
			   o = Box.nodes.get('#' + $$DF.fields[id].pseudoId)[0];
			else
			   o = Box.nodes.get('#' + id)[0];
			if($$DF.fields[id].conditionField && $$DF.fields[id].conditionType) {
				field = Box.nodes.get('#' + $$DF.fields[id].conditionField)[0];
				condition = $$DF[$$DF.fields[id].conditionType](field);
			}
			// validation de champs multiples à base de jumeau (twin) - Pascal A. le 11/09/07
      if ($$DF.fields[id].twin && $$DF.fields[id].verif) {
				twin = $$DF.fields[id].twin;
				verif = $$DF.fields[id].verif;
				if (verif == "empty") {
				  if($$DF[SOF.niceforms.onSubmitTasks[id]].test(o) == false && Box.nodes.get('#' + twin)[0].value == "") {
            SOF.niceforms.onErrorMsg[id] = SOF[$$L].errorMsg[id];
            n++;
          }
				} else {
				  if($$DF[SOF.niceforms.onSubmitTasks[id]].test(o) == false && Box.nodes.get('#' + twin)[0].value == verif) {
            SOF.niceforms.onErrorMsg[id] = SOF[$$L].errorMsg[id];
            n++;
          }
				}
			}	else {
  			if($$DF[SOF.niceforms.onSubmitTasks[id]].test(o) == false) {
  				SOF.niceforms.onErrorMsg[id] = SOF[$$L].errorMsg[id];
  				if(condition) {n++;}
  			}
  		}
		}
		if(n > 0) {
      SOF.niceforms.onError(f, n);
			e.preventDefault();
		}
		else {
			// Seulement pour les pages offres de noheto
			var change_offre = Box.nodes.get('#offres_participant')[0];
			if (change_offre) {
				change_offre.id = "hotel_ou_ville";
				change_offre.name = "hotel_ou_ville";
				var val_CH = Box.nodes.get('#val-offres_participant')[0];
				val_CH.id = "val-hotel_ou_ville";
				var val_OP = Box.nodes.get('#val-offres_pays')[0];
				val_OP.id = "val-nom_pays";
				val_OP = Box.nodes.get('#offres_pays')[0];
				val_OP.id = "nom_pays";
				val_OP.name = "nom_pays";
			}
			// FIN : Seulement pour les pages offres de noheto
			// Seulement pour la page site_touristique
			var config = Box.nodes.get('#SA_config')[0];
			if (config && config.value < 2)
				config.value = 2;
			// FIN : Seulement pour la page site_touristique
		}
		if(n < 1 && SOF.niceforms.enableFields) {
			var fs = Box.nodes.get('input[type=checkbox]');
			for(var i = 0, f; f = fs[i]; i++) {
				if(f.disabled) {f.disabled = false;}
			}
			fs = null; f = null; // nettoyage
		}
		o = null; // nettoyage
	},
	
	onError: function(f, n) {
		var d = Box.nodes.get('#search-error')[0];
		if(d) {d.parentNode.removeChild(d);}
		var intro = n > 1 ? SOF[$$L].errorMsg.introP : SOF[$$L].errorMsg.introS;
		var insert = '<div id="search-error"><p>' + intro + '</p><ol>';
		for(var id in SOF.niceforms.onErrorMsg) {
			insert += '<li><a href="#" class="focus-' + id + '">' + SOF.niceforms.onErrorMsg[id] + '</a></li>';
		}
		insert += '</ol><a href="#" class="close"><img alt="" src="../../imagerie/commun/search_error_close.gif" /></a></div>';
		Box.nodes.insert(insert, f, 'before', {
			'tag': 'div',
			'click': function(e) {SOF.niceforms.onErrorClose(e, f);}
		});
		// si necessaire, recalculer la hauteur de la popup et ajuster le scroll
		if(SOF.fakePopups && $$DP.stateH) {SOF.fakePopups.recompute();}
		d = null; // nettoyage
	},
	
	onErrorClose: function(e, f) {
		var t = e.target || e.srcElement;
		if(t.nodeName.toLowerCase() == 'img') {t = t.parentNode;}
		if(t.nodeName.toLowerCase() == 'a') {
			var id = t.className.replace('focus-', '');
			e.preventDefault();
			f.parentNode.removeChild(Box.nodes.get('#search-error')[0]);
			if(id != 'close') {
				var o = Box.nodes.get('#' + id)[0];
				if (o) {
  				if(o.type && o.type == 'hidden') {o = Box.nodes.get('a', Box.nodes.get('#' + id + '-rpl'))[0];}
  				o.focus();
				}
			}
		}
		// si necessaire, recalculer la hauteur de la popup et ajuster le scroll
		if(SOF.fakePopups && $$DP.stateH) {SOF.fakePopups.recompute();}
		t = null; o = null; // nettoyage
	},
	
	/*correction@20071112*/onInfos: function(when) {
		if(!SOF[$$L].infosMsg[$$DF.infosDatesCible][when]) {return;}/*END correction@20071112*/
		var fH = Box.nodes.findPos($$DF.calendar.parent);
		var tH = Box.nodes.findPos($$DF.fields[$$DF.dates.start.d].main);
		$$DF.infosDates.style.top = tH[1] - fH[1] + 'px';
    /*correction@20071112*/var insert = '<p><a href="#">' + SOF[$$L].infosMsg[$$DF.infosDatesCible][when] + '</a></p>';/*END correction@20071112*/
		insert += '<a href="#" class="close"><img alt="" src="../../imagerie/commun/search_error_close.gif" /></a>';
		Box.nodes.insert(insert, $$DF.infosDates, 'first', {
			'tag': 'a',
			'click': function(e) {SOF.niceforms.onInfosClose(e);}
		});
		Box.nodes.removeClass($$DF.infosDates, 'hide');
	},
	
	onInfosClose: function(e) {
		var t = e.target || e.srcElement;
		if(t.nodeName.toLowerCase() == 'img') {t = t.parentNode;}
		if(t.nodeName.toLowerCase() == 'a') {
			e.preventDefault();
			Box.nodes.addClass($$DF.infosDates, 'hide');
			$$DF.infosDates.innerHTML = '';
		}
		t = null; // nettoyage
	},
	
	onFocus: function(n) {
		while((n = n.parentNode) && n.id.indexOf('-rpl') == -1);
		Box.nodes.addClass(n, 'focus') || Box.nodes.removeClass(n, 'focus');
		n = null; // nettoyage
	},
	
	clearValue: function(e) {
		var n = e.target || e.srcElement;
		if(n.form.id) {return;}
		if(n.value == SOF[$$L]['defaults'][n.id]) {n.value = '';}
		n = null; // nettoyage
	},
	
	restoreValue: function(e) {
		var n = e.target || e.srcElement;
		if(n.form.id) {return;}
		if(n.value == '') {n.value = SOF[$$L]['defaults'][n.id];}
		n = null; // nettoyage
	},
	resetValue: function(e, thetarget) {
    // BEGIN : PA 20071001 reset to 'default' value
	  $$DF.fields[thetarget].index = 0;
		$$DF.fields[thetarget].display.innerHTML = $$DF.fields[thetarget].val[0];
		// END : PA 20071001 reset to 'default' value
	},
	
	request: function(id) {
		var r = $$DF.fields[id];
		var page = location.href;
			page = page.substring(page.lastIndexOf('http://www.sofitel.com/') + 1);
			page = page.replace('.shtml', '');
			page = page.replace('#', '');
		var url = r.ajax.url;
		if(r.ajax.url.indexOf('{LANG}')) {url = url.replace("{LANG}", $$L);}
		if(r.ajax.url.indexOf('{FILE}')) {url = url.replace("{FILE}", r.field.value);}
		url += '?lang=' + $$L + '&page=' + page + '&GC_country=' + r.field.value;
		if(r.field.value) {
			Box.ajax({
				'type': 'GET',
				'url': url,
				'onSuccess': SOF.niceforms.requestExe,
				'onSuccessDatas': {'target': r.ajax.target, 'item': r.ajax.item, 'page': page}
			});
		}
		r = null // nettoyage
	},
  
	requestSource: function(id) {
		var r = $$DF.fields[id];
		var page = location.href;
			page = page.substring(page.lastIndexOf('http://www.sofitel.com/') + 1);
			page = page.replace('.shtml', '');
			page = page.replace('#', '');
		var url = r.source.url;
		if(r.source.url.indexOf('{LANG}')) {url = url.replace("{LANG}", $$L);}
		if(r.source.url.indexOf('{FILE}')) {url = url.replace("{FILE}", r.field.value);}
		url += '?lang=' + $$L + '&page=' + page + '&GC_country=' + r.field.value;
		Box.ajax({
			'type': 'GET',
			'url': url,
			'onSuccess': SOF.niceforms.requestExe,
			'onSuccessDatas': {'target': r.source.target, 'item': r.source.item, 'page': page}
		});
		r = null // nettoyage
	},
	
	participants: function(id) {
		var r = $$DF.fields[id];
		var page = page2 = location.href;
			page = page.substring(page.lastIndexOf('http://www.sofitel.com/') + 1);
			var nom_fich = page;
			page = page.replace('.shtml', '');
			page = page.replace('#', '');
		var url = r.ajax_offre.url;
		var root = page2.replace(nom_fich, '');
		if(url.indexOf('{ADDR}')) {url = url.replace("{ADDR}", root);}
		if(url.indexOf('{OFFRE}')) {url = url.replace("{OFFRE}", page);}
		url += '?pays=' + r.field.value;
		Box.ajax({
			'type': 'GET',
			'url': url,
			'onSuccess': SOF.niceforms.requestExeParticipants,
			'onSuccessDatas': {'target': r.ajax_offre.target, 'item': r.ajax_offre.item, 'pays': r.field.value}
		});
		r = null // nettoyage
	},
	
	requestOffres: function(id) {
		var r = $$DF.fields[id];
		var page = page2 = location.href;
			page = page.substring(page.lastIndexOf('http://www.sofitel.com/') + 1);
			var nom_fich = page;
			page = page.replace('.shtml', '');
			page = page.replace('#', '');
		var url = r.offres.url;
		var root = page2.replace(nom_fich, '');
		if(url.indexOf('{ADDR}')) {url = url.replace("{ADDR}", root);}
		if(url.indexOf('{OFFRE}')) {url = url.replace("{OFFRE}", page);}
		Box.ajax({
			'type': 'GET',
			'url': url,
			'onSuccess': SOF.niceforms.requestExeOffre,
			'onSuccessDatas': {'target': r.offres.target, 'item': r.offres.item, 'page': page}
		});
		r = null // nettoyage
	},
	
	requestExeParticipants: function(d, p) {
		var l = Box.nodes.get(p.item, d);
		var c = Box.nodes.get('ol', Box.nodes.get('#' + p.target + '-rpl'))[0];
		var v = Box.nodes.get('#val-' + p.target)[0];
		if(!l || !c || !v) {return;}
		c.innerHTML = '';
		v.innerHTML = '';
		var r = $$DF.fields[p.target];
		r.end = l.length;
		r.index = -1;
		if(Box.nodes.hasClass(r.main, 'disabled')) {
			Box.nodes.removeClass(r.main, 'disabled');
			r.img.src = '/imagerie/'+SOF.niceforms.imgTree+'/fleche_select.gif';
		}
		var insert = '';
		for(var i = 0; i < l.length; i++) {
			if(Box.nodes.attribute(l[i].parentNode, 'cgi') != p.pays) {continue;}			
			r.val[i] = l[i].firstChild.nodeValue;
			r.cgi[i] = Box.nodes.attribute(l[i], 'cgi');
			insert += '<li><a href="#" class="' + i + '" tabindex="-1">' + l[i].firstChild.nodeValue + '</a></li>';
		}
		Box.nodes.insert(insert, c, 'last', {
			'tag': 'a',
			'click': function(e) {SOF.niceforms.manage.select(e, p.target, false);}
		});
		// actualisation du scroll
		if(r.scroll) {r.scroll.main.parentNode.removeChild(r.scroll.main);}
		if(parseInt(r.list.scrollHeight / $$DF.scroll.itemH) > $$DF.scroll.nbItems) {SOF.scroller.create(p.target);}
		l = null; c = null; r = null; v = null; // nettoyage
	},
	
	requestExeOffre: function(d, p) {
		var l = Box.nodes.get(p.item, d);
		var c = Box.nodes.get('ol', Box.nodes.get('#' + p.target + '-rpl'))[0];
		var v = Box.nodes.get('#val-' + p.target)[0];
		if(!l || !c || !v) {return;}
		c.innerHTML = '';
		v.innerHTML = '';
		var r = $$DF.fields[p.target];
		r.end = l.length;
		r.index = -1;
		if(Box.nodes.hasClass(r.main, 'disabled')) {
			Box.nodes.removeClass(r.main, 'disabled');
			r.img.src = '/imagerie/'+SOF.niceforms.imgTree+'/fleche_select.gif';
		}
		var insert = '';
		for(var i = 0; i < l.length; i++) {			
			r.val[i] = Box.nodes.attribute(l[i], 'nom');
			r.cgi[i] = Box.nodes.attribute(l[i], 'cgi');
			insert += '<li><a href="#" class="' + i + '" tabindex="-1">' + r.val[i] + '</a></li>';
		}
		Box.nodes.insert(insert, c, 'last', {
			'tag': 'a',
			'click': function(e) {SOF.niceforms.manage.select(e, p.target, false);}
		});
		// actualisation du scroll
		if(r.scroll) {r.scroll.main.parentNode.removeChild(r.scroll.main);}
		if(parseInt(r.list.scrollHeight / $$DF.scroll.itemH) > $$DF.scroll.nbItems) {SOF.scroller.create(p.target);}
		l = null; c = null; r = null; v = null; // nettoyage
	},

	requestExe: function(d, p) {
		var l = Box.nodes.get(p.item, d);
		var c = Box.nodes.get('ol', Box.nodes.get('#' + p.target + '-rpl'))[0];
		var v = Box.nodes.get('#val-' + p.target)[0];
		if(!l || !c || !v) {return;}
		c.innerHTML = '';
		v.innerHTML = '';
		var r = $$DF.fields[p.target];
		r.end = l.length;
		r.index = -1;
		if(Box.nodes.hasClass(r.main, 'disabled')) {
			Box.nodes.removeClass(r.main, 'disabled');
			r.img.src = '/imagerie/'+SOF.niceforms.imgTree+'/fleche_select.gif';
		}
		var insert = '';
		for(var i = 0; i < l.length; i++) {			
			if(Box.nodes.attribute(l[i].parentNode, 'url') != p.page) {continue;}
			r.val[i] = l[i].firstChild.nodeValue;
			r.cgi[i] = Box.nodes.attribute(l[i], 'cgi');
			insert += '<li><a href="#" class="' + i + '" tabindex="-1">' + l[i].firstChild.nodeValue + '</a></li>';
		}
		Box.nodes.insert(insert, c, 'last', {
			'tag': 'a',
			'click': function(e) {SOF.niceforms.manage.select(e, p.target, false);}
		});
		// actualisation du scroll
		if(r.scroll) {r.scroll.main.parentNode.removeChild(r.scroll.main);}
		if(parseInt(r.list.scrollHeight / $$DF.scroll.itemH) > $$DF.scroll.nbItems) {SOF.scroller.create(p.target);}
		l = null; c = null; r = null; v = null; // nettoyage
	},
	
	trimThalassa: function(o) {
		switch($$DF.dureeSejour.value) {
			case '2':
				Box.nodes.get('#RA1')[0].value = "FWEWEB";
				Box.nodes.get('#RA2')[0].value = "FAWWEB";
				break;
			case '6':
				Box.nodes.get('#RA1')[0].value = "FCUWEB";
				Box.nodes.get('#RA2')[0].value = "FACWEB";
				break;
			case '7':
				Box.nodes.get('#RA1')[0].value = "FC7WEB";
				Box.nodes.get('#RA2')[0].value = "FA7WEB";
				break;
			default:
				Box.nodes.get('#RA1')[0].value = "FWEWEB";
				Box.nodes.get('#RA2')[0].value = "FAWWEB";
				break;
		}
		var l = Box.nodes.get('li', [$$DF.fields[o.target].list]), i = 0, hide = true, inner;
		var d = 'duree-' + $$DF.dureeSejour.value;
		while(l[i]) {
			inner = l[i].innerHTML.toLowerCase();
			if(inner.indexOf('</span>') > -1) {
				inner = inner.replace(/<\/?span>/g, '');
				hide = o.datas[d].indexOf(inner) > -1 ? false : true;
				hide ? Box.nodes.addClass(l[i], 'hide') : Box.nodes.removeClass(l[i], 'hide');
				i++;
				continue;
			}
			hide ? Box.nodes.addClass(l[i], 'hide') : Box.nodes.removeClass(l[i], 'hide');
			i++;
		}
	},
	
	addStates: function(id, onStates) {
		if($$DF.fields[id].applyOn && document.body.className.indexOf($$DF.fields[id].applyOn) < 0) {return;}
		var c = $$DF.fields[id].cible;
		var r = $$DF.fields[c];
		var v = $$DF.fields[id].field.value;
		var verif = Box.nodes.get('#' + c + '-rpl')[0];
		if(verif) {
			verif = verif.parentNode;
			verif.parentNode.removeChild(verif);
			// si necessaire, recalculer la hauteur de la popup et ajuster le scroll
			if(SOF.fakePopups && $$DP.stateH) {SOF.fakePopups.recompute();}
		}
		if(onStates && onStates.indexOf('[' + v + ']') == -1) {return;}
		if(SOF[$$L].states[v]) {
			var insert = '', items = '';
			r.start = 0; r.end = SOF[$$L].states[v].cgi.length; r.index = 0; r.val = SOF[$$L].states[v].val; r.cgi = SOF[$$L].states[v].cgi;
			for(var i = 0; i < SOF[$$L].states[v].cgi.length; i++) {
				items += '<li><a href="#" class="val-' + i + '" tabindex="-1">' + r.val[i] + '</a></li>';
			}
			insert += '<div class="field etat">';
			insert += '<label for="' + c + '">' + SOF[$$L].label[c] + '</label>';
			insert += '<input type="hidden" id="' + c + '" name="' + c + '" value="" />';
			insert += '<div id="' + c + '-rpl" class="js-select">';
			insert += '<div class="open-close"><a href="#"><img alt="' + SOF[$$L].alt.openSelect + '" src="/imagerie/'+SOF.niceforms.imgTree+'/fleche_select.gif" /></a></div>';
			insert += '<div class="current"><span id="val-' + c + '"></span></div>';
			insert += '<ol class="hidden">';
			insert += items;
			insert += '</ol>';
			insert += '</div>';
			insert += '</div>';
			Box.nodes.insert(insert, $$DF.fields[id].main.parentNode, 'after', {
				'tag': 'a',
				'click': function(e) {SOF.niceforms.manage.select(e, c, false);},
				'keydown': function(e) {SOF.niceforms.manage.select(e, c, true);},
				'focus': function() {SOF.niceforms.onFocus(this);},
				'blur': function() {SOF.niceforms.onFocus(this);}
			});
			r.main = Box.nodes.get('#' + c + '-rpl')[0];
			r.display = Box.nodes.get('#val-' + c)[0];
			r.field = Box.nodes.prev(r.main);
			r.list = Box.nodes.get('ol', [r.main])[0];
			r.img = Box.nodes.get('img', [r.main])[0];
			l = Box.nodes.get('label[for=' + c + ']')[0];
			if(l) {Box.events.add(l, 'click', function(e) {SOF.niceforms.manage.label(e, this, c, 'select');});}
			if(parseInt(r.list.offsetHeight / $$DF.scroll.itemH) > $$DF.scroll.nbItems) {SOF.scroller.create(c);}
			// si nécessaire, recalculer la hauteur de la popup et ajuster le scroll
			if(SOF.fakePopups && $$DP.stateH) {SOF.fakePopups.recompute();}
			if(r.openDir && r.openDir == 'up') {r.list.style.top = '-' + r.list.offsetHeight + 'px';}
		}
		r = null; verif = null; // nettoyage
	},
	
	changeDestination: function() {
		var v;
		if($$DF.fields.topSelect.field) {
			v = $$DF.fields.topSelect.val[$$DF.fields.topSelect.index];
			v = v == SOF[$$L].defaults.topSelect ? SOF[$$L].defaults.hotel_ou_ville : v;
		} else if($$DF.fields.destination.field) {
			v = $$DF.fields.destination.field.value;
		} else {
			return;
		}
		Box.nodes.get('#hotel_ou_ville')[0].value = v;
		Box.nodes.get('#hotel_ou_ville')[0].focus();
	},
	
	tooltip: function(id) {
		Box.nodes.addClass($$DF.fields[id].tooltipE, 'hidden') || Box.nodes.removeClass($$DF.fields[id].tooltipE, 'hidden');
	},
	
	replace: function(o, id, type) {
		if($$DF.fields[id].group && $$DF.fields[id].replaceBy == 'checkbox') {type = 'checkboxGroup';}
		SOF.niceforms.create[type](o, id);
	},
	classExtract: function(str, srch)	{
		var retour = "-1", num = "", temp = "";
		if (str.indexOf(srch) > -1)	{
			for (var i = str.indexOf(srch)+4; i < str.length; i++)	{
				temp = str.charAt(i);
				if (temp != " ")
					num += temp.toString();
				else
					continue;
			}
			retour = num;
		}
		return retour;
	},	
	create: {
		select: function(o, id) {
      var r = $$DF.fields[id];
			var insert = '', items = '', l, minify = '';
      /*correction@20071112*/if(Box.nodes.hasClass(o, 'standalone')) {r.standalone = true;}/*END correction@20071112*/
			if(o.name) {r.name = o.name;}
			if(o.type == 'select-one') {
				r.start = o.selectedIndex; r.end = o.length; r.index = o.selectedIndex; r.val = []; r.cgi = []; var h;
				for(var i = 0; i < o.length; i++) {
					r.val[i] = o[i].innerHTML;
					r.cgi[i] = o[i].value;
					h = i == 0 && !r.val[i] ? ' class="hide"' : '';
					// BEGIN : PA 20070928 - Initialyse empty select option with 'default' tag
          if(Box.nodes.attribute(o, 'default') == 'empty')
					   h = ' class="hide"';
					// END : PA 20070928 - Initialyse empty select option with 'default' tag
					if(Box.nodes.hasClass(o[i], 'title')) {
						items += '<li' + h + '><span>' + r.val[i] + '</span></li>';
					} else {
						items += '<li' + h + '><a href="#" class="val-' + i + '" tabindex="-1">' + r.val[i].replace('\\', '') + '</a></li>';
					}
					if(r.dureeSejour) {
						r.dureeSejour[r.dureeSejour.length] = o[i].className ? Number(o[i].className.match(/\d+/)[0]) : '';
					}
					if(r.codeMarque) {
						r.codeMarque[r.codeMarque.length] = o[i].className ? o[i].className.replace('marque-', '') : '';
					}
				}
			} else {
			if(r.checkDuree) {
				var m_index = SOF.niceforms.classExtract(o.className, 'min-');
				m_index = parseInt(m_index);
				if(m_index > -1) {
					r.start = m_index;
					SOF.dates.dureeSejourMin = r.start;
				}
				m_index = SOF.niceforms.classExtract(o.className, 'max-');
				m_index = parseInt(m_index);
				if(m_index > -1) {r.end = m_index;}
				if (SOF.dates.weekend) {r.end = SOF.dates.ldow;}
				if(r.end < 7) {minify = ' minify';}
			}
/*				correction@20071112*/
				if(r.checkStart) {
					var tmp = o.className.match(/\d+/g);
					if(tmp) {
						if(tmp.length == 1) {
							SOF.dates.current.d = SOF.dates.current.d + Number(tmp[0]);
							SOF.dates.current = SOF.dates.getCorrect(SOF.dates.current);
						} else if(tmp.length >= 3) {
							SOF.dates.current.d = Number(tmp[0]);
							SOF.dates.current.m = Number(tmp[1]);
							SOF.dates.current.y = Number(tmp[2]);
						}
						r.index = SOF.dates.current.d - 1;
						$$DF.fields[r.checkStart[0]].index = SOF.dates.current.m - 1;
						var c = 0, year = SOF.dates.current.y;
						while(year < SOF.dates.current.y) {year++; c++;}
						$$DF.fields[r.checkStart[1]].index = c;
						if(tmp.length == 6) {
							SOF.dates.limitMax.d = Number(tmp[3]);
							SOF.dates.limitMax.m = Number(tmp[4]);
							SOF.dates.limitMax.y = Number(tmp[5]);
						}
					}
				}
/*				END correction@20071112*/
			r.val = SOF.dates.range(r.start, r.end);
			r.cgi = SOF.dates.range(r.start, r.end, 'cgi');
			var additionnalClass = '';
			if(r.noValuePossible && location.href.indexOf(r.noValuePossible) > -1) {
				r.val.unshift('-');
				r.cgi.unshift('');
				r.index = 0;
				additionnalClass = ' empty';
			}
			// BEGIN : PA 20071001 no defaults dates for 'destination' 
			if(r.noValuePossible2 && location.href.indexOf(r.noValuePossible2) > -1) {
				r.val.unshift('-');
				r.cgi.unshift('');
				r.index = 0;
				additionnalClass = ' empty';
			}
			// END : PA 20071001 no defaults dates for 'destination' 
			for(var i = 0; i < r.val.length; i++) {
				if(additionnalClass && i > 0) {additionnalClass = '';}
				items += '<li><a href="#" class="val-' + i + additionnalClass + '" tabindex="-1">' + r.val[i] + '</a></li>';
			}
			}
			var disabled = r.disabled ? ' disabled' : '';
			insert += '<input type="hidden" id="' + r.name + '" name="' + r.name + '" value="' + r.cgi[r.index] + '" />';
			insert += '<div id="' + id + '-rpl" class="js-select' + disabled + minify + '">';
			disabled = r.disabled ? 'fleche_select_disabled' : 'fleche_select';
			insert += '<div class="open-close"><a href="#"><img alt="' + SOF[$$L].alt.openSelect + '" src="/imagerie/'+SOF.niceforms.imgTree+'/' + disabled + '.gif" /></a></div>';
			insert += '<div class="current"><span id="val-' + id + '">' + r.val[r.index] + '</span></div>';
			insert += '<ol class="hidden">';
			insert += items;
			insert += '</ol>';
			if(r.tooltip) {insert += '<div id="' + id + '-tip" class="tooltip hidden"><span>' + r.tooltip + '</span></div>';}
			insert += '</div>';
			Box.nodes.insert(insert, o, 'after', {
				'tag': 'a',
				'click': function(e) {SOF.niceforms.manage.select(e, id, false);},
				'keydown': function(e) {SOF.niceforms.manage.select(e, id, true);},
				'focus': function() {SOF.niceforms.onFocus(this);},
				'blur': function() {SOF.niceforms.onFocus(this);}
			});
			o.parentNode.removeChild(o);
			r.main = Box.nodes.get('#' + id + '-rpl')[0];
			r.display = Box.nodes.get('#val-' + id)[0];
			r.field = Box.nodes.prev(r.main);
			r.list = Box.nodes.get('ol', [r.main])[0];
			r.img = Box.nodes.get('img', [r.main])[0];
			if(r.tooltip) {
				r.tooltipE = Box.nodes.get('#' + id + '-tip')[0];
				r.tooltipE.style.top = '-' + (r.tooltipE.offsetHeight + 2) + 'px';
				Box.events.add(r.main, 'mouseover', function() {SOF.niceforms.tooltip(id);});
				Box.events.add(r.main, 'mouseout', function() {SOF.niceforms.tooltip(id);});
			}
			l = Box.nodes.get('label[for=' + id + ']')[0];
			if(l) {Box.events.add(l, 'click', function(e) {SOF.niceforms.manage.label(e, this, id, 'select');});}
			if(r.codeMarque) {r.codeMarqueField = Box.nodes.next(r.main);}
			
			//alert("offsetHeight "+r.list.offsetHeight+", itemH "+$$DF.scroll.itemH+", nbItems "+$$DF.scroll.nbItems);
			if(parseInt(r.list.offsetHeight / $$DF.scroll.itemH) > $$DF.scroll.nbItems) {SOF.scroller.create(id);}
			if(r.openDir && r.openDir == 'up') {r.list.style.top = '-' + r.list.offsetHeight + 'px';}
			r = null; l = null; // nettoyage
		},
		checkbox: function(o, id) {
			var r = $$DF.fields[id];
			var l = Box.nodes.next(o), insert = '', checked;
			if(l) {Box.events.add(l, 'click', function(e) {SOF.niceforms.manage.label(e, this, id, 'checkbox');});}
			checked = o.checked ? 'checked' : 'notchecked';
			insert += '<input type="hidden" id="' + id + '" name="' + id + '" value="' + r['default'] + '" />';
			insert += '<div id="' + id + '-rpl" class="js-checkbox"><a href="#" class="' + checked + '"></a></div>';
			Box.nodes.insert(insert, o, 'after', {
				'tag': 'a',
				'click': function(e) {SOF.niceforms.manage.checkbox(e, id, false);},
				'keydown': function(e) {SOF.niceforms.manage.checkbox(e, id, true);}
			});
			r.main = Box.nodes.get('#' + id + '-rpl')[0];
			r.field = Box.nodes.prev(r.main);
			if(o.checked) {r.field.value = SOF[$$L]['checkValue']['y'];}
			o.parentNode.removeChild(o);
			r = null; l = null; // nettoyage
		},
		checkboxGroup: function(g, id) {
			var r = $$DF.fields[id], l, checked;
			for(var i = 0, gi; gi = g[i]; i++) {
				l = Box.nodes.next(gi);
				if(l) {Box.events.add(l, 'click', function(e) {SOF.niceforms.manage.label(e, this, Box.nodes.attribute(this, 'for'), 'checkboxGroup');});}
				if(gi.checked) {
					checked = 'checked';
				} else {
					checked = 'notchecked';
				}
				insert = '<div id="' + gi.id + '-rpl" class="js-checkbox"><a href="#" class="' + checked + '"></a></div>';
				Box.nodes.insert(insert, gi, 'after', {
					'tag': 'a',
					'click': function(e) {SOF.niceforms.manage.checkbox(e, id, false);},
					'keydown': function(e) {SOF.niceforms.manage.checkbox(e, id, true);}
				});
				r.group[r.group.length] = Box.nodes.get('#' + gi.id + '-rpl')[0];
				Box.nodes.addClass(gi, 'hidden');
				gi.disabled = true;
			}
			r = null; l = null; // nettoyage
		},
		radio: function(g, id) {
			var r = $$DF.fields[id], l, checked;
			var insert = '<input type="hidden" name="' + id + '" value="" />';
			Box.nodes.insert(insert, g[0], 'before');
			r.field = Box.nodes.prev(g[0]);
			for(var i = 0, gi; gi = g[i]; i++) {
				l = Box.nodes.next(gi);
				if(l) {Box.events.add(l, 'click', function(e) {SOF.niceforms.manage.label(e, this, id, 'radio');});}
				if(gi.checked) {
					checked = 'checked';
					r.field.value = gi.value;
				} else {
					checked = 'notchecked';
				}
				insert = '<div id="' + gi.id + '-rpl" class="js-radio val-' + gi.value + '"><a href="#" class="' + checked + '"></a></div>';
				Box.nodes.insert(insert, gi, 'after', {
					'tag': 'a',
					'click': function(e) {SOF.niceforms.manage.radio(e, id, false);},
					'keydown': function(e) {SOF.niceforms.manage.radio(e, id, true);}
				});
				r.group[r.group.length] = Box.nodes.get('#' + gi.id + '-rpl')[0];
				if(gi.checked) {r.last = Box.nodes.get('a', [r.group[r.group.length - 1]])[0];}
				gi.parentNode.removeChild(gi);
			}
			r = null; l = null; // nettoyage
		}
	},
	
	manage: {
		label: function(e, n, id, type) {
			var t = e.target || e.srcElement;
			if(t.nodeName.toLowerCase() == 'a' || n.nodeName.toLowerCase() != 'label') {return;}
			e.preventDefault();
			var a;
			if(type == 'select') {
				a = Box.nodes.get('a', [$$DF.fields[id].main])[0];
				a.focus();
			} else if(type == 'checkbox') {
				$$DF.fields[id].field.value = $$DF.fields[id].field.value == '0' ? '1' : '0';
				a = Box.nodes.get('a', [Box.nodes.prev(n)])[0];
				Box.nodes.swapClass(a, 'checked', 'notchecked') || Box.nodes.swapClass(a, 'notchecked', 'checked');
				a.focus();
			} else if(type == 'checkboxGroup') {
				var c = Box.nodes.get('#' + id)[0];
				c.checked = c.checked ? false : true;
				a = Box.nodes.get('a', [Box.nodes.prev(n)])[0];
				Box.nodes.swapClass(a, 'checked', 'notchecked') || Box.nodes.swapClass(a, 'notchecked', 'checked');
				a.focus();
			} else if(type == 'radio') {
				if($$DF.fields[id].last) {Box.nodes.swapClass($$DF.fields[id].last, 'checked', 'notchecked');}
				a = Box.nodes.get('a', [Box.nodes.prev(n)])[0];
				if(Box.nodes.hasClass(a, 'notchecked')) {
					Box.nodes.swapClass(a, 'notchecked', 'checked');
					$$DF.fields[id].field.value = a.parentNode.className.replace(/^.+val-/, '');
					$$DF.fields[id].last = a;
					if($$DF.fields[id].action) {$$DF.fields[id].action();}
				}
			}
			t = null; a = null; // nettoyage
		},
		getTarget: function(e, id) {
			var t = e.target || e.srcElement;
			var limit = id ? $$DF.fields[id].main : document.body;
			while(t.nodeName.toLowerCase() != 'a' && t  != limit) {t = t.parentNode;}
			if(t.nodeName.toLowerCase() != 'a') {t = null;}
			return t;
		},
		getKey: function(e) {
			return e.which || e.keyCode;
		},
		checkbox: function(e, id, keyboard) {
			var t = SOF.niceforms.manage.getTarget(e, id), c;
			if(!t) {return;}
			var k = SOF.niceforms.manage.getKey(e);
			if(!keyboard || k == 32) {
				if(Box.nodes.hasClass(t, 'checked')) {
					Box.nodes.swapClass(t, 'checked', 'notchecked');
					if(!$$DF.fields[id].group) {
						if (!isNaN(parseFloat(Box.nodes.get('#'+id)[0].value)))
							$$DF.fields[id].field.value = 0;
						else
							$$DF.fields[id].field.value = SOF[$$L]['checkValue']['n'];
					} else {
						c = Box.nodes.prev(t.parentNode);
						c.checked = false;
					}
				} else {
					Box.nodes.swapClass(t, 'notchecked', 'checked');
					if(!$$DF.fields[id].group) {
						if (!isNaN(parseFloat(Box.nodes.get('#'+id)[0].value)))
							$$DF.fields[id].field.value = 1;
						else
							$$DF.fields[id].field.value = SOF[$$L]['checkValue']['y'];
					} else {
						c = Box.nodes.prev(t.parentNode);
						c.checked = true;
					}
				}
				if($$DF.fields[id].action) {$$DF.fields[id].action();}
				e.preventDefault();
			}
			t = null; c = null; // nettoyage
		},
		radio: function(e, id, keyboard) {
			var t = SOF.niceforms.manage.getTarget(e);
			if(!t) {return;}
			var k = SOF.niceforms.manage.getKey(e);
			if(!keyboard || k == 32) {
				if($$DF.fields[id].last) {Box.nodes.swapClass($$DF.fields[id].last, 'checked', 'notchecked');}
				if(Box.nodes.hasClass(t, 'notchecked')) {
					Box.nodes.swapClass(t, 'notchecked', 'checked');
					$$DF.fields[id].field.value = t.parentNode.className.replace(/^.+val-/, '');
					$$DF.fields[id].last = t;
				}
				if($$DF.fields[id].action) {$$DF.fields[id].action();}
				e.preventDefault();
			}
			t = null; // nettoyage
		},
		select: function(e, id, keyboard) {
			var t = SOF.niceforms.manage.getTarget(e, id);
			if(!t) {return;}
			$$DF.lastKeySelect = null;
			var r = $$DF.fields[id];
			var k = SOF.niceforms.manage.getKey(e);
			if(Box.nodes.hasClass(r.main, 'disabled')) {if(k != 9) {e.preventDefault();} return;}
			if(keyboard) {
				$$DF.lastKeySelect = k;
				if($$DF.lastSelect) {Box.nodes.addClass($$DF.lastSelect, 'hidden');}
				if($$DF.lastImg) {$$DF.lastImg.alt = SOF[$$L].titleOpenSelect;}
				if($$DF.lastField) {Box.nodes.removeClass($$DF.lastField, 'active');}
				if(k == 40) {
					r.index = r.index >= r.val.length - 1 ? r.val.length - 1 : r.index + 1;
					e.preventDefault();
				} else if(k == 38) {
					r.index = r.index <= 0 ? 0 : r.index - 1;
					e.preventDefault();
				} else if(k == 13) {
					if(r.scroll) {SOF.scroller.toggle();}
					e.preventDefault();
				} else {
					if(r.scroll) {SOF.scroller.toggle();}
					return;
				}
			} else {
				if($$DF.lastSelect && $$DF.lastSelect != r.list) {Box.nodes.addClass($$DF.lastSelect, 'hidden');}
				if($$DF.lastImg && $$DF.lastImg != r.img) {$$DF.lastImg.alt = SOF[$$L].alt.openSelect;}
				$$DF.lastSelect = r.list;
				$$DF.lastImg = r.img;
				if(Box.nodes.attribute(r.img, 'alt') == SOF[$$L].alt.closeSelect) {
					Box.nodes.addClass(r.list, 'hidden');
					if($$DF.lastField) {
						Box.nodes.removeClass($$DF.lastField, 'active');
						$$DF.lastField = null;
					}
					if(r.scroll) {SOF.scroller.toggle(id);}
					r.img.alt = SOF[$$L].alt.openSelect;
				} else {
					Box.nodes.removeClass(r.list, 'hidden');
					if($$DF.lastField) {Box.nodes.removeClass($$DF.lastField, 'active');}
					$$DF.lastField = r.list.parentNode.parentNode;
					Box.nodes.addClass($$DF.lastField, 'active');
					if(r.scroll) {SOF.scroller.toggle(id);}
					r.img.alt = SOF[$$L].alt.closeSelect;
				}
				if(t.className) {
					r.index = t.className.replace('val-', '');
					r.index = Number(r.index.replace(' empty', ''));
				}
				e.preventDefault();
			}
			if(keyboard || t.className) {
				if(r.dureeSejour) {
					$$DF.dureeSejour.value = r.dureeSejour[r.index];
					SOF.dates.dureeSejour = r.dureeSejour[r.index];
					SOF.dates.updateDuree();
					SOF.dates.control('start');
				}
				if(r.codeMarqueField) {r.codeMarqueField.value = r.codeMarque[r.index];}
				r.display.innerHTML = r.index < 0 ? '' : r.val[r.index];
				r.field.value = r.index < 0 ? '' : r.cgi[r.index];
				if(r.noValuePossible && r.val[r.index] == '-') {
					SOF.dates.reset('start');
				} else if(r.action) {
					r.action();
				}
				if(r.ajax) {SOF.niceforms.request(id);}
				if(r.ajax_offre) {SOF.niceforms.participants(id);}
				if($$DF.dayOfWeek) {$$DF.dayOfWeek.innerHTML = '(' + SOF.dates.dayOfWeek('start') + ')';}
			}
			r = null; t = null; // nettoyage
		}
	},
	update: {
		select: function(id, value) {
			var r = $$DF.fields[id];
			// trouver l'index de la valeur dans les valeurs du select
			var index = null;
			for (var i=r.start; i<r.end && index==null; i++){
			   if (r.cgi[i].toLowerCase() == value.toLowerCase()) index=i;
			}
			// mise a jour du display (affichage) et du champ (valeur hidden)
			if (index!=null){
				r.index=index;
				if(r.dureeSejour) {
					$$DF.dureeSejour.value = r.dureeSejour[index];
					SOF.dates.dureeSejour = r.dureeSejour[index];
					SOF.dates.updateDuree();
					SOF.dates.control('start');
				}
				if(r.codeMarqueField) {r.codeMarqueField.value = r.codeMarque[index];}
				r.display.innerHTML = r.val[index];
				r.field.value = r.cgi[index];
				if(r.action) {r.action();}
				if(r.ajax) {SOF.niceforms.request(id);}
				if($$DF.dayOfWeek) {$$DF.dayOfWeek.innerHTML = '(' + SOF.dates.dayOfWeek('start') + ')';}
			}
		}
	}
};

// scroller sur les listes
SOF.scroller = {
	create: function(id) {
		var r = $$DF.fields[id], insert = '';
		Box.nodes.addClass(r.list, 'scrolled');
		insert += '<div class="scroller">';
		insert += '<a class="scroller-up" href="#"><img src="/imagerie/'+SOF.niceforms.imgTree+'/scroll_up.gif" alt="' + SOF[$$L].alt.scrollUp + '" /></a>';
		insert += '<a class="scroller-down" href="#"><img src="/imagerie/'+SOF.niceforms.imgTree+'/scroll_down.gif" alt="' + SOF[$$L].alt.scrollDown + '" /></a>';
		insert += '<span class="scroller-state"></span>';
		insert += '</div>';
		Box.nodes.insert(insert, r.main, 'last');
		r.scroll = {};
		r.scroll.main = Box.nodes.get('div.scroller', [r.main])[0];
		r.scroll.upDown = Box.nodes.get('a', [r.scroll.main]);
		r.scroll.span = Box.nodes.get('span', [r.scroll.main])[0];
		r.scroll.target = Box.nodes.get('li', [r.list])[0];
		if(Box.nodes.hasClass(r.scroll.target, 'hide')) {r.scroll.target = Box.nodes.next(r.scroll.target);}
		r.scroll.mask = r.list.offsetHeight - $$DF.scroll.borders;
		r.scroll.dispo = r.scroll.mask - $$DF.scroll.upDown;
		r.scroll.full = r.list.scrollHeight;
		// New nurun
		r.scroll.dim = Math.ceil(r.scroll.mask / r.scroll.full * r.scroll.dispo);
		//r.scroll.min = Math.floor(r.scroll.dispo * r.scroll.dispo / r.scroll.full);
		//r.scroll.max = Math.ceil(r.scroll.dispo * r.scroll.dispo / r.scroll.full);
		r.scroll.left = r.list.offsetWidth - r.scroll.main.offsetWidth - $$DF.scroll.borders;
		// New nurun
		r.scroll.amount = r.scroll.dispo - Math.ceil(r.scroll.dispo / r.scroll.dim);
		//r.scroll.amount = r.scroll.dispo - Math.ceil(r.scroll.dispo / r.scroll.min);
		r.scroll.main.style.height = r.scroll.mask + 'px';
		r.scroll.main.style.left = '-10000px';
		if(r.openDir && r.openDir == 'up') {r.scroll.main.style.top = '-' + (r.list.offsetHeight - 1) + 'px';}
		// New nurun
		r.scroll.span.style.height = r.scroll.dim + 'px';
		//r.scroll.span.style.height = r.scroll.max + 'px';
		r.scroll.span.style.top = '0';
		r.scroll.target.style.marginTop = '0';
		Box.events.add(r.scroll.upDown[0], 'click', function(e) {
			SOF.scroller.exe(e, id);
		});
		Box.events.add(r.scroll.upDown[1], 'click', function(e) {
			SOF.scroller.exe(e, id);
		});
		Box.events.add(r.scroll.main, 'click', function(e) {
			SOF.scroller.exe(e, id);
		});
		// coordonnées maximum pour drag'n'drop
		// New nurun
		var maxY = r.scroll.dispo - r.scroll.dim;
		//var maxY = r.scroll.dispo - r.scroll.max;
		// init Drag'n'drop
		Box.drag.init(r.scroll.span, null, 0, 0, 0, maxY);
		r.scroll.span.onDrag = function(nx, ny) {SOF.scroller.dragMove(id, ny);}
		r = null; //nettoyage
	},
	dragMove: function(id, ny) {
		var r = $$DF.fields[id].scroll;
		var top = Math.round(ny / r.dispo * r.full);
		if(top > (r.full - r.mask)) {top = r.full - r.mask;}
		r.target.style.marginTop = - top + 'px';
		r = null; //nettoyage
	},
	exe: function(e, id) {
		var t = e.target || e.srcElement, r = $$DF.fields[id].scroll;
		// cas d'un clic sur une zone pouvant contenir la scrollbar
		if(t.nodeName.toLowerCase() == 'div' && Box.nodes.hasClass(t, 'scroller')) {
			var c = Box.events.getXY(e).y - (Box.nodes.findPos(t)[1] + $$DF.scroll.upDown / 2),
				top = parseInt(r.span.style.top),
				move = c - top < 0 ? top - c : c - top - r.dim,
				amount = Math.round(move / r.dispo * r.full);
			if(c - top > 0) {
				SOF.scroller.startDown(id, amount);
			} else {
				SOF.scroller.startUp(id, amount);
			}
		}
		// fin cas
		while(t.nodeName.toLowerCase() != 'a' && t != r.main) {t = t.parentNode;}
		var top = Math.abs(parseInt(r.target.style.marginTop));
		if(t == r.upDown[0] && !r.inAnim) {
			// New nurun
			SOF.scroller.startUp(id);
			/*
			var to = top - r.amount <= 0 ? 0 : top - r.amount;
			if(to < $$DF.scroll.limit) {to = 0;}
			r.inAnim = true;
			SOF.scroller.objectUp(to, id);
			var scroll = Math.ceil(to / r.full * r.dispo);
			if((scroll <= 0) || (to == 0 && scroll != 0)) {scroll = 0;}
			r.inAnim1 = true;
			SOF.scroller.barUp(scroll, id);
			*/
		} else if(t == r.upDown[1] && !r.inAnim) {
			// New nurun
			SOF.scroller.startDown(id);
			/*
			var to = (top + r.mask + r.amount) > r.full ? r.full - r.mask : top + r.amount;
			if(r.full - to - r.mask < $$DF.scroll.limit) {to = r.full - r.mask;}
			r.inAnim = true;
			SOF.scroller.objectDown(to, id);
			var scroll = Math.ceil(to / r.full * r.dispo);
			if((scroll + r.max > r.dispo) || (to == r.full - r.mask)) {scroll = r.dispo - r.max;}
			r.inAnim1 = true;
			SOF.scroller.barDown(scroll, id);
			*/
		}
		e.preventDefault();
		t = null; r = null; // nettoyage
	},
	startDown: function(id, move) {
		var r = $$DF.fields[id].scroll,
			top = Math.abs(parseInt(r.target.style.marginTop)),
			amount = move || r.amount,
			to = top - amount <= 0 ? 0 : top - amount;
		var to = (top + r.mask + amount) > r.full ? r.full - r.mask : top + amount;
		if(r.full - to - r.mask < $$DF.scroll.limit) {to = r.full - r.mask;}
		r.inAnim = true;
		SOF.scroller.objectDown(to, id);
		var scroll = parseInt(r.span.style.top) - Math.ceil(r.dispo * (top - to) / r.full);		
		if((scroll + r.dim > r.dispo) || (to == r.full - r.mask)) {scroll = r.dispo - r.dim;}
		r.inAnim1 = true;
		SOF.scroller.barDown(scroll, id);
		r = null; // nettoyage
	},
	startUp: function(id, move) {
		var r = $$DF.fields[id].scroll,
			top = Math.abs(parseInt(r.target.style.marginTop)),
			amount = move || r.amount,
			to = (top + r.mask + amount) > r.full ? r.full - r.mask : top + amount;
		var to = top - amount <= 0 ? 0 : top - amount;
		if(to < $$DF.scroll.limit) {to = 0;}
		r.inAnim = true;
		SOF.scroller.objectUp(to, id);
		var scroll = parseInt(r.span.style.top) - Math.ceil(r.dispo * (top - to) / r.full);
		if((scroll < 0) || (to == 0 && scroll != 0)) {scroll = 0;}
		r.inAnim1 = true;
		SOF.scroller.barUp(scroll, id);
		r = null; // nettoyage
	},
	objectDown: function(to, id) {
		var top = Math.abs(parseInt($$DF.fields[id].scroll.target.style.marginTop));
		if(top >= to) {
			$$DF.fields[id].scroll.target.style.marginTop = - to + 'px';
			clearTimeout($$DF.fields[id].scroll.timer);
			$$DF.fields[id].scroll.timer = null;
			$$DF.fields[id].scroll.inAnim = false;
		} else {
			$$DF.fields[id].scroll.target.style.marginTop = - (top + Math.ceil((to - top) / $$DF.scroll.animSlow)) + 'px';
			$$DF.fields[id].scroll.timer = setTimeout(function() {SOF.scroller.objectDown(to, id)}, $$DF.scroll.animDelay);
		}
	},
	objectUp: function(to, id) {
		var top = Math.abs(parseInt($$DF.fields[id].scroll.target.style.marginTop));
		if(top <= to) {
			$$DF.fields[id].scroll.target.style.marginTop = - to + 'px';
			clearTimeout($$DF.fields[id].scroll.timer);
			$$DF.fields[id].scroll.timer = null;
			$$DF.fields[id].scroll.inAnim = false;
		} else {
			$$DF.fields[id].scroll.target.style.marginTop = - (top + Math.floor((to - top) / $$DF.scroll.animSlow)) + 'px';
			$$DF.fields[id].scroll.timer = setTimeout(function() {SOF.scroller.objectUp(to, id)}, $$DF.scroll.animDelay);
		}
	},
	barDown: function(to, id) {
		var top = Math.abs(parseInt($$DF.fields[id].scroll.span.style.top));
		if(top >= to) {
			$$DF.fields[id].scroll.span.style.top = to + 'px';
			clearTimeout($$DF.fields[id].scroll.timer1);
			$$DF.fields[id].scroll.timer1 = null;
			$$DF.fields[id].scroll.inAnim1 = false;
		} else {
			$$DF.fields[id].scroll.span.style.top = top + Math.ceil((to - top) / $$DF.scroll.animSlow) + 'px';
			$$DF.fields[id].scroll.timer1 = setTimeout(function() {SOF.scroller.barDown(to, id)}, $$DF.scroll.animDelay);
		}
	},
	barUp: function(to, id) {
		var top = Math.abs(parseInt($$DF.fields[id].scroll.span.style.top));
		if(top <= to) {
			$$DF.fields[id].scroll.span.style.top = to + 'px';
			clearTimeout($$DF.fields[id].scroll.timer1);
			$$DF.fields[id].scroll.timer1 = null;
			$$DF.fields[id].scroll.inAnim1 = false;
		} else {
			$$DF.fields[id].scroll.span.style.top = top + Math.floor((to - top) / $$DF.scroll.animSlow) + 'px';
			$$DF.fields[id].scroll.timer1 = setTimeout(function() {SOF.scroller.barUp(to, id)}, $$DF.scroll.animDelay);
		}
	},
	toggle: function(id) {
		if(!id) {
			if($$DF.lastScroll) {
				$$DF.lastScroll.style.left = '-10000px';
				$$DF.lastScroll = null;
			}
		} else {
			if($$DF.fields[id].scroll.main.style.left == '-10000px') {
				$$DF.fields[id].scroll.main.style.left = $$DF.fields[id].scroll.left + 'px';
				if($$DF.lastScroll) {SOF.scroller.toggle();}
				$$DF.lastScroll = $$DF.fields[id].scroll.main;
			} else {
				$$DF.fields[id].scroll.main.style.left = '-10000px';
				$$DF.lastScroll = null;
			}
		}
	}
};

// calendrier
SOF.calendar = {
	init: function() {
		if(!$$DF.calendar.isPresent) {return;}
		var s = Box.nodes.get('#search')[0], c = Box.nodes.get('#contact')[0], g = Box.nodes.get('#garantie')[0], r;
		$$DF.calendar.parent = s || c || g || null;
		if(!$$DF.calendar.parent || Box.nodes.hasClass(document.body, 'press-form')) {return;}
		SOF.calendar.create($$DF.calendar.parent);
		for(var i in $$DF.calendar.targets) {
			for(var j = 0; j < $$DF.calendar.targets[i].after.length; j++) {
				r = Box.nodes.get($$DF.calendar.targets[i].after[j] + '-rpl')[0];
				if(r) {break;}
			}
			if(!r) {continue;}
			Box.nodes.insert('<a href="#" id="use-' + i + '" class="open-calendar"><img alt="' + SOF[$$L].alt.openCalendar + '" src="/imagerie/'+SOF.niceforms.imgTree+'/picto_calendar.gif" /></a>', r, 'after', {
				'tag': 'a',
				'click': function(e) {SOF.calendar.openClose(e);}
			});
		}
		r = null; s = null; // nettoyage
	},
	
	openClose: function(e) {
		var t = e.target || e.srcElement;
		while(t.nodeName.toLowerCase() != 'a') {t = t.parentNode;}
		$$DF.use = t.id.replace('use-', '');
		var date = $$DF.calendar.main.className.match(/\d+/g);
		var m = Number(date[0]);
		var y = Number(date[1]);
		SOF.calendar.push(m, y);
		if($$DF.lastSelect && $$DF.lastImg) {
			Box.nodes.addClass($$DF.lastSelect, 'hidden');
			$$DF.lastImg.alt = SOF[$$L].alt.openSelect;
		}
		Box.nodes.removeClass($$DF.calendar.main, 'hide') || Box.nodes.addClass($$DF.calendar.main, 'hide');
		Box.nodes.removeClass($$DF.calendar.bg, 'hide') || Box.nodes.addClass($$DF.calendar.bg, 'hide');
		SOF.calendar.position(t);
		e.preventDefault();
		t = null; // nettoyage
	},
	
	position: function(t) {
		var cH = $$DF.calendar.main.offsetHeight;
		var cW = $$DF.calendar.main.offsetWidth;
		$$DF.calendar.bg.style.width = cW + 4 + 'px';
		$$DF.calendar.bg.style.height = cH + 4 + 'px';
		if($$DF.calendar.parent.id != 'search') {
			var pAbs = Box.nodes.findPos(t);
			var pRel = Box.nodes.findPos($$DF.calendar.parent);
			$$DF.calendar.main.style.top = pAbs[1] - pRel[1] + 'px';
			$$DF.calendar.main.style.left = pAbs[0] - pRel[0] + t.offsetWidth + 5 + 'px';
			$$DF.calendar.bg.style.top = pAbs[1] - pRel[1] - 2 + 'px';
			$$DF.calendar.bg.style.left = pAbs[0] - pRel[0] + t.offsetWidth + 3 + 'px';
		} else {
			var top = Math.floor(($$DF.calendar.parent.offsetHeight - cH) / 2);
			var left = Math.floor(($$DF.calendar.parent.offsetWidth - cW) / 2);
			$$DF.calendar.main.style.top = top + 'px';
			$$DF.calendar.main.style.left = left + 'px';
			$$DF.calendar.bg.style.top = top - 2 + 'px';
			$$DF.calendar.bg.style.left = left - 2 + 'px';	
		}
	},
	
	create: function(s) {
		var insert = '';
		insert += '<div id="calendar-under"></div>';
		insert += '<div id="calendar" class="month-' + SOF.month + ' year-' + SOF.year + '"></div>';
		Box.nodes.insert(insert, s, 'last');
		$$DF.calendar.main = Box.nodes.get('#calendar')[0];
		$$DF.calendar.bg = Box.nodes.get('#calendar-under')[0];
		$$DF.use = 'start';
		SOF.calendar.push(SOF.dates.current.m, SOF.dates.current.y);
		Box.nodes.addClass($$DF.calendar.main, 'hide');
		Box.nodes.addClass($$DF.calendar.bg, 'hide');
	},
	
	push: function(m, y) {
		$$DF.calendar.main.innerHTML = '';
		//SOF.dates.weekend = SOF.dates.is_weekend();
		$$DF.calendar.main.className = Box.nodes.hasClass($$DF.calendar.main, 'hide') ? 'date-' + m + '-' + y + ' hide' : 'date-' + m + '-' + y;
		var d = SOF.day;
		var month = SOF[$$L]['months'][m - 1];
		var prev = m - 1 == 0 ? SOF[$$L]['months'][11] : SOF[$$L]['months'][m - 1];
		var next = m + 1 > 12 ? SOF[$$L]['months'][0] : SOF[$$L]['months'][m + 1];
		var first = SOF.dates.firstDayOfMonth(y, m, 1);
		var verif = SOF.dates.days(y);
		var start = SOF.dates.startSejour || SOF.dates.limitMin;
		var end = SOF.dates.limitSejour || SOF.dates.limitMax;
		var insert = '', cur = 0, check = 0;
		insert += '<div class="main-inner">';
		insert += '<div class="sub-inner">';
		insert += '<a href="#" class="close-calendar">' + SOF[$$L].alt.close + '</a>';
    /*correction@20071112*/if(y > SOF.dates.limitMin.y || (y == SOF.dates.limitMin.y && m > SOF.dates.limitMin.m)) {/*END correction@20071112*/
			insert += '<a href="#" class="prev-month"><img alt="' + SOF[$$L].alt.prevMonth + prev + '" src="/imagerie/'+SOF.niceforms.imgTree+'/fleche_month_prev.gif" /></a>';
		}
    /*correction@20071112*/if(y < SOF.dates.limitMax.y || (y == SOF.dates.limitMax.y && m < SOF.dates.limitMax.m)) {/*END correction@20071112*/
			insert += '<a href="#" class="next-month"><img alt="' + SOF[$$L].alt.nextMonth + next + '" src="/imagerie/'+SOF.niceforms.imgTree+'/fleche_month_next.gif" /></a>';
		}
		insert += '<div class="caption">' + month + ' ' + y + '</div>';
		insert += '<table>';
		insert += '<thead>';
		insert += '<tr>';
		for(var i = 0, di; di = SOF[$$L]['days'][i]; i++) {
			insert += '<th scope="col" title="' + di + '">' + di.charAt(0) + '</th>';
		}
		insert += '</tr>';
		insert += '</thead>';
		insert += '<tbody>';
		for(var j = 0; j < 6; j++) {
			insert += '<tr>';
			for(var k = 0;  k < 7; k++) {
				if(check < first || cur >= verif[m - 1]) {
					insert += '<td><span>&nbsp;</span></td>';
				} else {
					cur++;
					if(
              (
                $$DF.use == 'start' && (y == start.y && m == start.m && cur < start.d) 
                || 
                (y == end.y && m == end.m && cur > end.d)
              ) 
            || 
              (
                $$DF.use == 'end' && (y == start.y && m == start.m && cur < start.d) 
                || 
                (y == end.y && m == end.m && cur > SOF.dates.limitMax.d)
              )
            ) 
          {
						insert += '<td><span>' + cur + '</span></td>';
					} else {
            if (!SOF.dates.weekend) // BEGIN : PA 20070928 gestion des weekends
						  insert += '<td><a href="#">' + cur + '</a></td>';
						else
						{
							if (SOF.dates.limited_day[k] != -1)
							{
						    insert += '<td><a href="#">' + cur + '</a></td>';
						  }
							else
						    insert += '<td><span>' + cur + '</span></td>';
						}             // END : PA 20070928 gestion des weekends
					}
				}
				check++;
			}
			insert += '</tr>';
		}
		insert += '</tbody>';
		insert += '</table>';
		insert += '</div>';
		insert += '</div>';
		Box.nodes.insert(insert, $$DF.calendar.main, 'last', {
			'tag': 'a',
			'click': function(e) {SOF.calendar.exe(e);}
		});
	},
	
	exe: function(e) {
		var t = e.target || e.srcElement;
		var r = $$DF.fields;
		var use = $$DF.calendar.targets[$$DF.use];
		while(t.nodeName.toLowerCase() != 'a' && t  != $$DF.calendar.main) {t = t.parentNode;}
		var date = $$DF.calendar.main.className.match(/\d+/g);
		var m = Number(date[0]);
		var y = Number(date[1]);
		if(Box.nodes.hasClass(t, 'close-calendar')) {
			Box.nodes.addClass($$DF.calendar.main, 'hide');
			Box.nodes.addClass($$DF.calendar.bg, 'hide');
		} else if(Box.nodes.hasClass(t, 'next-month')) {
			if(m == 12) {
				m = 1;
				y++;
			} else {
				m++;
			}
			SOF.calendar.push(m, y);
		} else if(Box.nodes.hasClass(t, 'prev-month')) {
			if(m == 1) {
				m = 12;
				y--;
			} else {
				m--;
			}
			SOF.calendar.push(m, y);
		} else {
			SOF.dates.update({'d': Number(t.innerHTML), 'm': date[0], 'y': date[1]}, $$DF.use);
			SOF.dates.control($$DF.use);
			Box.nodes.addClass($$DF.calendar.main, 'hide');
			Box.nodes.addClass($$DF.calendar.bg, 'hide');
			if($$DF.dayOfWeek) {$$DF.dayOfWeek.innerHTML = '(' + SOF.dates.dayOfWeek('start') + ')';}
		}
		e.preventDefault();
		t = null; r = null; use = null; // nettoyage
	}
};

// fermeture des listes et du calendrier sur un clic externe
Box.events.add(document, 'click', function(e) {
	var t = e.target || e.srcElement, verif = false;
	while(t != document.documentElement) {
		if(Box.nodes.hasClass(t, 'open-calendar') || Box.nodes.hasClass(t, 'close-calendar')) {return;}
		if(Box.nodes.attribute(t, 'id') == 'calendar' || Box.nodes.hasClass(t, 'js-select')) {verif = true; break;}
		t = t.parentNode;
	}
	if(verif) {return;}
	if($$DF.calendar.main) {
		Box.nodes.addClass($$DF.calendar.main, 'hide');
		Box.nodes.addClass($$DF.calendar.bg, 'hide');
	}
	if($$DF.lastSelect && $$DF.lastImg) {
		Box.nodes.addClass($$DF.lastSelect, 'hidden');
		if($$DF.lastScroll) {SOF.scroller.toggle();}
		$$DF.lastImg.alt = SOF[$$L].alt.openSelect;
	}
	if($$DF.lastField) {
		Box.nodes.removeClass($$DF.lastField, 'active');
		$$DF.lastField = null;
	}
	t = null; // nettoyage
});

SOF.weekend = {
	init: function() {
		if (SOF.dates.weekend) {
			SOF.dates.limitMin = SOF.dates.return_date(SOF.dates.limitMin);
			Box.nodes.get("#jour_arrivee")[0].value = SOF.dates.limitMin;
			SOF.dates.update(SOF.dates.limitMin, 'start');
		}
	}
};

// chargement des fonctions
Box.events.load(SOF.niceforms.init);
Box.events.load(SOF.calendar.init);
Box.events.load(SOF.weekend.init);

// déchargement (nettoyage variables)
Box.events.add(window, 'unload', function() {
	$$DF = null;
	SOF.datasDatesForms = null;
});



