// ------------------------------------- Masques de saisie --------------------------------
var maskInt=new RegExp("^[0-9-]+$","");
var maskFloat=new RegExp("^[0-9]+([.][0-9]{1,2})?$","");
var maskMail=new RegExp("^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]{2,}[.][a-zA-Z]{2,}$","");
var maskTel=new RegExp("^[0-9]{2,3} [(][0][)] [0-9 ]+$","");
//var maskDate=new RegExp("^[0-9]{2}[/][0-9]{2}[/][0-9]{4}$","");
var maskDate=new RegExp("^[0-3][0-9][/][0-1][0-9][/][1-2][0-9]{3}$","");

// ------------------------------- Redimensonnement du margin de body ---------------------
function redim() {
	if((document.getElementById('Main'))&&(typeof(AffiliateID)=='undefined')) {
		var obj=document.getElementById('Main');
		if (document.body.offsetWidth<990) {
			obj.style.marginLeft=round(document.body.offsetWidth/2)-document.body.offsetWidth+'px';
		} else {
			obj.style.marginLeft='-495px';
		}
		//	Correction d'un décalage d'1 pixel sur Firefox et Chrome
		if (navigator.userAgent.indexOf('Firefox')>0) {
			obj.style.marginLeft=(parseInt(obj.style.marginLeft)-1)+'px';
		} else if (navigator.userAgent.indexOf('Chrome')>0) {
			obj.style.marginLeft=(parseInt(obj.style.marginLeft)+1)+'px';
		}
	}
}
// --------------------------------------- Recherche Rapide -------------------------------
function valideSearch() {
	if (document.getElementById('Search').value=="") {
		return false;
	} else {
		document.location='/reservation/result.php?Search='+escape(document.getElementById('Search').value);
	}
}

// --------------------------------------- explode et implode -----------------------------
function explode (separator,value) {
	var pos1=0;
	var tab=new Array();
	var i=0;
	while (pos1<value.length) {
		var pos2=value.indexOf(separator,pos1);
		if (pos2>=pos1) {
			tab[i]=value.substr(pos1,pos2-pos1);
			pos1=pos2+separator.length;
		} else {
			tab[i]=value.substr(pos1,value.length-pos1);
			pos1=value.length;
		}
		i++;
	}
	return tab;
}

function implode (separator,tab) {
	var str='';
	for (var i=0;i<tab.length;i++) {
		if (i>0) {
			str+=separator;
		}
		str+=tab[i];
	}
	return str;
}
// --------------------------------------------- round -----------------------------------
function round (num,p) {
	if (p==null) {
		p=0;
	}
	p=Math.pow(10,p);
	return Math.round(num*p)/p;
}

function addEvent( obj, event, func, mode){
	if (obj.addEventListener) {
		obj.addEventListener(event, func, mode ? mode : false);
  	} else { // IE
		if ((navigator.appVersion.indexOf('MSIE 7.')>0)||(navigator.appVersion.indexOf('MSIE 8.')>0)) { // IE 7+
			obj.attachEvent('on' + event, func);
		} else if ((obj==window)&&(event=='load')){ // IE6-
			func=func.toString();
			var pos=func.indexOf('unction ')+8;
			var pos1=func.indexOf('()');
			func=func.substr(pos,pos1-pos);
			strLoad+=func+'();\n';
		}
	}
}
var strLoad='';
function windowload() {
	eval(strLoad);
}
addEvent(window, 'load', redim);
addEvent(window, 'resize', redim);

// JavaScript Document
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 or higher.
  {
  for(var i=0; i<document.images.length; i++)
     {
          var img = document.images[i]
          var imgName = img.src.toUpperCase()
          if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
             {
                 var imgID = (img.id) ? "id='" + img.id + "' " : ""
                 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
                 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
                 var imgStyle = "display:inline-block;" + img.style.cssText
                 if (img.align == "left") imgStyle = "float:left;" + imgStyle
                 if (img.align == "right") imgStyle = "float:right;" + imgStyle
                 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle               
                 var strNewHTML = "<span " + imgID + imgClass + imgTitle
                 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
             + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
                 img.outerHTML = strNewHTML
                 i = i-1
             }
     }
}
// -------------------------------------------- timer -----------------------------------
function suppZero (val) {
	if ((' '+val).indexOf('0')==1) {
		val=parseInt(val.substr(1,1));
	} else {
		val=parseInt(val);
	}
	return val;
}
var timerFlash=null;
function timer() {
	var tab=document.getElementsByTagName('span');
	trouveTimer=false;
	for (var i=0;i<tab.length;i++) {
		if ((' '+tab[i].className).indexOf('timer')>0) {
			trouveTimer=true;
			var jour=null;
			var str=tab[i].innerHTML;
			if (langue=='') {
				if (str.indexOf('j')>0) {
					jour=str.substr(str.indexOf('j')-2,2);
				}
			} else if (langue=='_uk') {
				if (str.indexOf('d')>0) {
					jour=str.substr(str.indexOf('d')-2,2);	
				}
			} else if (langue=='_es') {
				if (str.indexOf('d')>0) {
					jour=str.substr(str.indexOf('d')-2,2);
				}	
			}
			jour=parseInt(jour);
			var heure=str.substr(str.indexOf('h')-2,2);
			var minute=str.substr(str.indexOf('m')-2,2);
			var seconde=str.substr(str.length-3,2);
			var heure=suppZero(heure);
			var minute=suppZero(minute);
			var seconde=suppZero(seconde);
			if (jour==0&&heure==0&&minute==0&&seconde==0) {
				
			} else {
				if (seconde==0) {
					if (minute>0||heure>0||jour>0) {
						seconde=59;
					}
					if (minute==0) {
						if (heure>0||jour>0) {
							minute=59;
						}
						if (heure==0) {
							if (jour!=null) {
								if (jour==3) {
									jour=0;
									heure=48;
								} else {
									heure=23;
									jour--;
								}
							}
						} else {
							heure--;
						}
					} else {
						minute--;
					}
				} else {
					seconde--;
				}
				str='';
				if (jour>0) {
					if (jour<10) {
						str=' ';
					}
					if (langue=='') {
						str+=jour+'j';	
					} else if (langue=='_uk') {
						str+=jour+'d';	
					} else if (langue=='_es') {
						str+=jour+'d';	
					}
					str+=' ';
				}
				if (heure<10) {
					str+='0';
				}
				str+=heure+'h';
				if (minute<10) {
					str+='0';
				}
				str+=minute+'m';
				if (seconde<10) {
					str+='0';
				}
				str+=seconde+'s';
				tab[i].innerHTML=str;
			}
		}
	}
	if (trouveTimer&&!timerFlash) {
		timerFlash=setInterval('timer()',1000);
	}
}
addEvent(window, 'load', timer);

// ---------------------------------- PUB ----------------------------
function clickPub(PubID,TypePub,Site) {
	requestSelect('/pub.php?PubID='+PubID+'&TypePub='+TypePub+'&Site='+Site);
}

// --------------------------------- ESPACE CLIENT -----------------------------------------------
function passOublie() {
	if (document.getElementById('EmailInscrit')&&(document.getElementById('EmailInscrit').value!='')) {
		var champ='EmailInscrit';
	} else if (document.getElementById('Email')&&(document.getElementById('Email').value!='')) {
		var champ='Email';
	} else {
		return false;
	}
	alert(requestSelect('/passOublie.php?Email='+escape(document.getElementById(champ).value)));
}

// -------------------------------- VISITE VIRTUELLE --------------------------------------------

function VirtualVisit (url,width,height) {
	var params='toolbar=no,location=no,directories=no,status=no,menubar=no';
	if (width!=0) {
		params+=',width='+width;
	}
	if (width!=0) {
		params+=',height='+height;
	}
	window.open(url,'',params);
}

// ------------------------------------- CALCUL DE L'AGE ----------------------------------------
function calculAge(Dte,DateNaissance) {
	// DateNaissance au format jj/mm/aaaa
	var j=DateNaissance.substr(0,2);
	var m=DateNaissance.substr(3,2);
	var a=DateNaissance.substr(6,4);
	// Dte au format aaaa-mm-jj
	var j1=Dte.substr(8,2);
	var m1=Dte.substr(5,2);
	var a1=Dte.substr(0,4);
	if ((a1+'-'+m1+'-'+j1) < (a1+'-'+m+'-'+j)) {
		var Age=parseInt(a1)-parseInt(a)-1;
	} else {
		var Age=parseInt(a1)-parseInt(a);
	}
	return Age;
}

// ---------------------------------------- SWFOBJECT --------------------------------------------
/*	SWFObject v2.2 <http://code.google.com/p/swfobject/>
	is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y<X;Y++){U[Y]()}}function K(X){if(J){X()}else{U[U.length]=X}}function s(Y){if(typeof O.addEventListener!=D){O.addEventListener("load",Y,false)}else{if(typeof j.addEventListener!=D){j.addEventListener("load",Y,false)}else{if(typeof O.attachEvent!=D){i(O,"onload",Y)}else{if(typeof O.onload=="function"){var X=O.onload;O.onload=function(){X();Y()}}else{O.onload=Y}}}}}function h(){if(T){V()}else{H()}}function V(){var X=j.getElementsByTagName("body")[0];var aa=C(r);aa.setAttribute("type",q);var Z=X.appendChild(aa);if(Z){var Y=0;(function(){if(typeof Z.GetVariable!=D){var ab=Z.GetVariable("$version");if(ab){ab=ab.split(" ")[1].split(",");M.pv=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}else{if(Y<10){Y++;setTimeout(arguments.callee,10);return}}X.removeChild(aa);Z=null;H()})()}else{H()}}function H(){var ag=o.length;if(ag>0){for(var af=0;af<ag;af++){var Y=o[af].id;var ab=o[af].callbackFn;var aa={success:false,id:Y};if(M.pv[0]>0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad<ac;ad++){if(X[ad].getAttribute("name").toLowerCase()!="movie"){ah[X[ad].getAttribute("name")]=X[ad].getAttribute("value")}}P(ai,ah,Y,ab)}else{p(ae);if(ab){ab(aa)}}}}}else{w(Y,true);if(ab){var Z=z(Y);if(Z&&typeof Z.SetVariable!=D){aa.success=true;aa.ref=Z}ab(aa)}}}}}function z(aa){var X=null;var Y=c(aa);if(Y&&Y.nodeName=="OBJECT"){if(typeof Y.SetVariable!=D){X=Y}else{var Z=Y.getElementsByTagName(r)[0];if(Z){X=Z}}}return X}function A(){return !a&&F("6.0.65")&&(M.win||M.mac)&&!(M.wk&&M.wk<312)}function P(aa,ab,X,Z){a=true;E=Z||null;B={success:false,id:X};var ae=c(X);if(ae){if(ae.nodeName=="OBJECT"){l=g(ae);Q=null}else{l=ae;Q=X}aa.id=R;if(typeof aa.width==D||(!/%$/.test(aa.width)&&parseInt(aa.width,10)<310)){aa.width="310"}if(typeof aa.height==D||(!/%$/.test(aa.height)&&parseInt(aa.height,10)<137)){aa.height="137"}j.title=j.title.slice(0,47)+" - Flash Player Installation";var ad=M.ie&&M.win?"ActiveX":"PlugIn",ac="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+ad+"&MMdoctitle="+j.title;if(typeof ab.flashvars!=D){ab.flashvars+="&"+ac}else{ab.flashvars=ac}if(M.ie&&M.win&&ae.readyState!=4){var Y=C("div");X+="SWFObjectNew";Y.setAttribute("id",X);ae.parentNode.insertBefore(Y,ae);ae.style.display="none";(function(){if(ae.readyState==4){ae.parentNode.removeChild(ae)}else{setTimeout(arguments.callee,10)}})()}u(aa,ab,X)}}function p(Y){if(M.ie&&M.win&&Y.readyState!=4){var X=C("div");Y.parentNode.insertBefore(X,Y);X.parentNode.replaceChild(g(Y),X);Y.style.display="none";(function(){if(Y.readyState==4){Y.parentNode.removeChild(Y)}else{setTimeout(arguments.callee,10)}})()}else{Y.parentNode.replaceChild(g(Y),Y)}}function g(ab){var aa=C("div");if(M.win&&M.ie){aa.innerHTML=ab.innerHTML}else{var Y=ab.getElementsByTagName(r)[0];if(Y){var ad=Y.childNodes;if(ad){var X=ad.length;for(var Z=0;Z<X;Z++){if(!(ad[Z].nodeType==1&&ad[Z].nodeName=="PARAM")&&!(ad[Z].nodeType==8)){aa.appendChild(ad[Z].cloneNode(true))}}}}}return aa}function u(ai,ag,Y){var X,aa=c(Y);if(M.wk&&M.wk<312){return X}if(aa){if(typeof ai.id==D){ai.id=Y}if(M.ie&&M.win){var ah="";for(var ae in ai){if(ai[ae]!=Object.prototype[ae]){if(ae.toLowerCase()=="data"){ag.movie=ai[ae]}else{if(ae.toLowerCase()=="styleclass"){ah+=' class="'+ai[ae]+'"'}else{if(ae.toLowerCase()!="classid"){ah+=" "+ae+'="'+ai[ae]+'"'}}}}}var af="";for(var ad in ag){if(ag[ad]!=Object.prototype[ad]){af+='<param name="'+ad+'" value="'+ag[ad]+'" />'}}aa.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ah+">"+af+"</object>";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab<ac;ab++){I[ab][0].detachEvent(I[ab][1],I[ab][2])}var Z=N.length;for(var aa=0;aa<Z;aa++){y(N[aa])}for(var Y in M){M[Y]=null}M=null;for(var X in swfobject){swfobject[X]=null}swfobject=null})}}();return{registerObject:function(ab,X,aa,Z){if(M.w3&&ab&&X){var Y={};Y.id=ab;Y.swfVersion=X;Y.expressInstall=aa;Y.callbackFn=Z;o[o.length]=Y;w(ab,false)}else{if(Z){Z({success:false,id:ab})}}},getObjectById:function(X){if(M.w3){return z(X)}},embedSWF:function(ab,ah,ae,ag,Y,aa,Z,ad,af,ac){var X={success:false,id:ah};if(M.w3&&!(M.wk&&M.wk<312)&&ab&&ah&&ae&&ag&&Y){w(ah,false);K(function(){ae+="";ag+="";var aj={};if(af&&typeof af===r){for(var al in af){aj[al]=af[al]}}aj.data=ab;aj.width=ae;aj.height=ag;var am={};if(ad&&typeof ad===r){for(var ak in ad){am[ak]=ad[ak]}}if(Z&&typeof Z===r){for(var ai in Z){if(typeof am.flashvars!=D){am.flashvars+="&"+ai+"="+Z[ai]}else{am.flashvars=ai+"="+Z[ai]}}}if(F(Y)){var an=u(aj,am,ah);if(aj.id==ah){w(ah,true)}X.success=true;X.ref=an}else{if(aa&&A()){aj.data=aa;P(aj,am,ah,ac);return}else{w(ah,true)}}if(ac){ac(X)}})}else{if(ac){ac(X)}}},switchOffAutoHideShow:function(){m=false},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]}},hasFlashPlayerVersion:F,createSWF:function(Z,Y,X){if(M.w3){return u(Z,Y,X)}else{return undefined}},showExpressInstall:function(Z,aa,X,Y){if(M.w3&&A()){P(Z,aa,X,Y)}},removeSWF:function(X){if(M.w3){y(X)}},createCSS:function(aa,Z,Y,X){if(M.w3){v(aa,Z,Y,X)}},addDomLoadEvent:K,addLoadEvent:s,getQueryParamValue:function(aa){var Z=j.location.search||j.location.hash;if(Z){if(/\?/.test(Z)){Z=Z.split("?")[1]}if(aa==null){return L(Z)}var Y=Z.split("&");for(var X=0;X<Y.length;X++){if(Y[X].substring(0,Y[X].indexOf("="))==aa){return L(Y[X].substring((Y[X].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(a){var X=c(R);if(X&&l){X.parentNode.replaceChild(l,X);if(Q){w(Q,true);if(M.ie&&M.win){l.style.display="block"}}if(E){E(B)}}a=false}}}}();

// ----------------------------------------- XMLHTTP ---------------------------------------------
function requestSelect (url) {
	var xhr_object = null;
	var title=document.title;
	document.title='chargement...';
	if(window.XMLHttpRequest) {// Firefox   
		xhr_object = new XMLHttpRequest();   
	} else if(window.ActiveXObject) {// Internet Explorer   
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");   
	} else { // XMLHttpRequest non supporté par le navigateur   
		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");   
		return;   
	}
	if (url.indexOf('?')>0) {
		url=url+'&ms='+new Date().getTime();
	} else {
		url=url+'?ms='+new Date().getTime();
	}
	xhr_object.open('GET', url, false); 
	xhr_object.setRequestHeader("Cache-Control","no-cache");
	xhr_object.send(null);
	document.title=title;
	if ((xhr_object.readyState == 4)&&(xhr_object.status == 200)) {
		return xhr_object.responseText;
	}
}
var iAjax=0;
var postscript_ie6=null;
function requestUpdate (url,postscript,afficher_patientez) {
        if (afficher_patientez==null) {
            var afficher_patientez=true;
        }
	var xhr_object = null;
        if (afficher_patientez) {
            iAjax++;
            if (document.getElementsByTagName('BODY')[0]) {
		var body=document.getElementsByTagName('BODY')[0];
		var html=document.getElementsByTagName('HTML')[0];
		var div=document.createElement('DIV');
		div.id='divPatientez'+iAjax;
		div.style.background='url(/images/patientez-fond.png)';
		if (navigator.appName.indexOf('Internet Explorer') > 0) {
			div.style.position='absolute';
			if (body.scrollTop > 0) {
				div.style.top = body.scrollTop + 'px';
			} else if (html.scrollTop > 0) {
				div.style.top = html.scrollTop + 'px';
			} else {
				div.style.top='0px';
			}
			window.onscroll=function () {
				if (document.getElementById('divPatientez' + iAjax)) {
					document.title='divPatientez'+iAjax;
					var body = document.getElementsByTagName('BODY')[0];
					var html = document.getElementsByTagName('HTML')[0];
					var div = document.getElementById('divPatientez' + iAjax);
					if (body.scrollTop > 0) {
						div.style.top = body.scrollTop + 'px';
					} else if (html.scrollTop > 0) {
						div.style.top = html.scrollTop + 'px';
					} else {
						div.style.top = '0px';
					}
				}
			}
		} else {
			div.style.position='fixed';
			div.style.top='0px';
		}
		div.style.left = '0px';
		div.style.color='white';
		div.style.width='150px';
		div.style.height='30px';
		div.style.margin='5px';
		div.style.zIndex=100;
		div.innerHTML='<img src="/images/patientez-small.gif" alt="" align="absmiddle"/> enregistrement...';
		body.appendChild(div);
            }
        } // if (afficher_patientez)
	if(window.XMLHttpRequest) // Firefox   
		xhr_object = new XMLHttpRequest();   
	else if(window.ActiveXObject) // Internet Explorer   
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");   
	else { // XMLHttpRequest non supporté par le navigateur   
		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");   
		return;   
	}
	var ie6=false;
	if (window.addEventListener) {
  	} else { // IE
		if ((navigator.appVersion.indexOf('MSIE 7.')>0)||(navigator.appVersion.indexOf('MSIE 8.')>0)) { // IE 7+
		} else { // IE6-
			ie6=true;
			if (postscript!=null) {
				postscript_ie6=postscript;
			}
		}
	}
	if (!ie6) {
		if (postscript == null) {
			xhr_object.postscript = '';
		} else {
			xhr_object.postscript = postscript;
		}
	}

	if (url.indexOf('?')>0) {
		url=url+'&ms='+new Date().getTime();
	} else {
		url=url+'?ms='+new Date().getTime();
	}
	xhr_object.onreadystatechange = function(){
		var div,body;
		if (xhr_object.readyState == 4) {
			if (document.getElementsByTagName('BODY')[0]) {
				body = document.getElementsByTagName('BODY')[0];
				if (div = document.getElementById('divPatientez' + iAjax)) {
					body.removeChild(div);
					iAjax--;
				}
				window.onbeforeunload=null;
				if (postscript_ie6!=null) {
					eval(postscript_ie6);
				} else if (this.postscript!='') {
					eval(this.postscript);
				}
			}
		}
	}
	// Méthode POST
	if (url.length>=255) {
		var params=url.substr(url.indexOf('?')+1,url.length-url.indexOf('?')-1);
		url=url.substr(0,url.indexOf('?'));
		xhr_object.open("POST", url, true);  
		xhr_object.setRequestHeader("Content-Type","application/x-www-form-urlencoded");  
		xhr_object.setRequestHeader("Cache-Control","no-cache");
		xhr_object.send(params);   
	} else {
		// Méthode GET
		xhr_object.open("GET", url, true);   
		xhr_object.setRequestHeader("Cache-Control","no-cache");
		xhr_object.send(null);   
	}
	window.onbeforeunload=function() {
		var message = "Une tâche est en cours d'exécution. Fermer cette page (ou l'actualiser) afin la fin de l'exécution peut être dangereux.";
		if (typeof evt == 'undefined') {
			evt = window.event;
		}
		if (evt) {
			evt.returnValue = message;
		}
		return message;
	}
}

// ----------------------- classe Search ------------------------------------
// Script de déclaration de la classe Search, qui permet l'ouverture d'une fenêtre avec le formulaire de recherche

var pppSearch=null;
function Search() {
	this.AbonneID=0; // ID de la Résidence
	this.AlloID=0; // ID du Logement
	this.AffiliateID=''; // Identifiant de l'affilié pour une recherche en marque blanche
	this.avance=new Array(); // tableau des critères picto
	this.CourtSejour=false; // Flag pour une recherche de court séjour
	this.Criteres=new Array("Linge","Piscine","Animaux","Parking","TV","Forme","Cheminee","Handicapes","Internet");
	this.DebSejours=new Array(); // Tableau des dates possibles en "longs" séjours
	this.DebCS=new Array(); // Tableau des dates possibles en courts séjours
	this.DptID=0; // Département français
	this.DteFrom=''; // Dates de début de séjour possibles
	this.Langue=langue; // Langue d'affichage
	this.MassifID=0; // Massif
	this.NbCriteres=0; // Nombre de critères sélectionnés (pictos)
	this.NbNuits='7'; // Nombre de nuits
	this.Nbpers=0; // Nombre de personnes
	this.PaysID=''; // Pays (string)
	this.PromoUniquement=false; // Flag pour n'afficher que les promotions
	this.Stations=new Array(); // Tableau des stations
	this.StationID=0; // Station de ski
	this.TypeLog=''; // 'hotel' 'appartement' ou 'chalet'
	this.VenteFlash=false; // Flag pour n'afficher que les ventes flash

	this.iPopup=null;

	this.affiche=function() {
		if (pppSearch!=null) {
			if (pppSearch.exists()) {
				popupClose(pppSearch.index);
			}
			pppSearch=null;
		}
		pppSearch=new popup();

		var url='/reservation/search.php';
		var params='?langue='+this.Langue;
		if (this.DteFrom!='') {
			params+='&DteFrom='+this.DteFrom;
		}
		if (this.CourtSejour) {
			params+='&NbNuits=<6';
		} else if (this.NbNuits!='') {
			params+='&NbNuits='+this.NbNuits;
		}
		if (this.TypeLog!='') {
			params+='&TypeLog='+this.TypeLog;
		}
		if (this.checkLogement) {
			params+='&checkLogement=Oui';
		}
		if (this.checkForfait) {
			params+='&checkForfait=Oui';
		}
		if (this.checkMateriel) {
			params+='&checkMateriel=Oui';
		}
		if (this.StationID) {
			params+='&StationID='+this.StationID;
		} else if (this.MassifID) {
			params+='&MassifID='+this.MassifID;
		} else if (this.PaysID) {
			params+='&Pays='+escape(this.PaysID);
		}
		if (this.AlloID) {
			params+='&AlloID='+this.AlloID;
		} else if (this.AbonneID){
			params+='&AbonneID='+this.AbonneID;
		}
		if (this.PromoUniquement) {
			params+='&Promo=Oui';
		}
		if (this.Nbpers) {
			params+='&Nbpers='+this.Nbpers;
		}
		for (var i=0;i<this.avance.length;i++) {
			params+='&'+this.avance[i]+'=True';
		}
		var html=requestSelect(url+params);
		pppSearch.contenu=html;
		pppSearch.title=strModifierLaRecherche;
		pppSearch.affiche();
		this.changeMassif(this.MassifID);
		this.NbCriteres=this.avance.length;
		initAgenda(); // Pour rendre les champs date cliquables
	}

	this.afficheDate=function(dte) {
		var a=dte.substr(0,4);
		var m=dte.substr(5,2);
		var j=dte.substr(8,2);
		return j+'/'+m+'/'+a;
	}

	this.changeMassif=function(MassifID) {
		if (this.Stations.length==0) {
			eval(requestSelect('/scripts/getSearch.php'));
		}
		var Pays='';
		if (typeof(MassifID)=='undefined') {
			var MassifID=0;
		} else {
			if (parseInt(MassifID)>=0) {
				var MassifID=parseInt(MassifID);
			} else {
				Pays=MassifID;
				var MassifID=0;
			}
		}
		var f=document.getElementById('formSearch');
		while (f.StationID.options.length>0) {
			f.StationID.options[f.StationID.options.length-1]=null;
		}
		f.StationID.options[f.StationID.options.length]=new Option(strIndifferent,'');
		for (var iStation=0;iStation<this.Stations.length;iStation++) {
			var affiche=false;
			if ((MassifID>0)&&(this.Stations[iStation].MassifID==MassifID)) {
				affiche=true;
			} else if ((Pays!='')&&(this.Stations[iStation].Pays==Pays)) {
				affiche=true;
			} else if ((MassifID==0)&&(Pays=='')) {
				affiche=true;
			}
			if (affiche) {
				var i=f.StationID.options.length;
				f.StationID.options[i]=new Option(this.Stations[iStation].Station,this.Stations[iStation].StationID);
				if (this.StationID==this.Stations[iStation].StationID) {
					f.StationID.options[i].selected=true;
				}
			}
		}
	}

	this.changeNbNuits=function() {
		var f=document.getElementById('formSearch');
		var NbNuits=f.NbNuits.value;
		if (this.DebSejours.length==0) {
			for (var i=1;i<f.DteFrom.options.length;i++) {
				this.DebSejours[this.DebSejours.length]=new DebSejour(f.DteFrom.options[i].value,f.DteFrom.options[i].innerHTML);
			}
		}
		if (NbNuits=='<6') {
			for (var i=(f.DteFrom.options.length-1);i>0;i--) {
				f.DteFrom.options[i]=null;
			}
			if (this.DebCS.length == 0) {
				eval(requestSelect('/scripts/getCSdeb.php'));
			}
			for (var i=0;i<this.DebCS.length;i++) {
				f.DteFrom.options[f.DteFrom.options.length]=new Option(this.DebCS[i].text,this.DebCS[i].value);
			}
		} else {
			for (var i=(f.DteFrom.options.length-1);i>0;i--) {
				f.DteFrom.options[i]=null;
			}
			for (var i=0;i<this.DebSejours.length;i++) {
				f.DteFrom.options[f.DteFrom.options.length]=new Option(this.DebSejours[i].text,this.DebSejours[i].value);
			}
		}
	}

	this.valide=function () {
		var url='/reservation/online_affiche.php';
		var f=document.getElementById('formSearch');
		var params=new Array();
		var DteSelected=false;
		var StationSelected=false;
		var flagDateSeule=true;
		var flagStationSeule=true;
		var obj,i,DteFrom='';
		if (f.checkLogement&&f.checkForfait&&f.checkMateriel) {
			// Si le forfait est coché seul, on coche aussi le logement
			if (f.checkForfait.checked) {
				flagDateSeule=false;
				flagStationSeule=false;
				f.checkLogement.checked=true;
				params[params.length]='checkForfait=Oui';
			}
			// Si le matériel est coché seul, on redirige l'action du formulaire vers le moteur Skiset
			if ((!f.checkMateriel.checked)&&(!f.checkLogement.checked)&&(!f.checkForfait.checked)) {
				f.checkLogement.checked=true;
			} else if ((f.checkMateriel.checked)&&(!f.checkLogement.checked)) {
				url='/skiset/'+strUrlSkiset+'.php';
			} else if (f.checkMateriel.checked) {
				flagDateSeule=false;
				flagStationSeule=false;
				params[params.length]='checkMateriel=Oui';
			}
		}
		for (i=0;i<f.NbNuits.options.length;i++) {
			if (f.NbNuits.options[i].selected) {
				var NbNuits=f.NbNuits.options[i].value;
			}
		}
		if (NbNuits!='7') {
			flagDateSeule=false;
			flagStationSeule=false;
		}
		var TypeLog="";
		if (typeof(f.TypeLog)!='undefined') {
			for (i=0;i<f.TypeLog.options.length;i++) {
				if ((f.TypeLog.options[i].selected)&&(f.TypeLog.options[i].value!='')) {
					flagDateSeule=false;
					flagStationSeule=false;
					TypeLog=f.TypeLog.options[i].value;
					params[params.length]='TypeLog='+TypeLog;
				}
			}
		}
		if (NbNuits=='<6') {
                    if (mv=='') {
			url='/reservation/'+strUrlCourtSejour+'.php';
                    } else {
                        url='/reservation/'+strUrlCourtSejour_mv+'.php';
                    }
			flagDateSeule=false;
			flagStationSeule=false;
		} else {
			params[params.length]='NbNuits='+NbNuits;
		}
		if (f.DteFrom.tagName=='INPUT') {
			var j=f.DteFrom.value.substr(0,2);
			var m=f.DteFrom.value.substr(3,2);
			var a=f.DteFrom.value.substr(6,4);
			var DteFrom=a+'-'+m+'-'+j;
			params[params.length]='DteFrom='+DteFrom;
			DteSelected=true;
			flagStationSeule=false;
		} else if (f.DteFrom.tagName=='SELECT') {
			var DteFrom=f.DteFrom.options[f.DteFrom.selectedIndex].value;
			params[params.length]='DteFrom='+DteFrom;
			if (DteFrom!='') {
				DteSelected=true;
				flagStationSeule=false;
			}
		}

		if (typeof(f.MassifID)!='undefined') {
			for (i=0;i<f.MassifID.options.length;i++) {
				if ((f.MassifID.options[i].selected)&&(f.MassifID.options[i].value!='0')) {
					flagDateSeule=false;
					params[params.length]='MassifID='+f.MassifID.options[i].value;
				}
			}
		}
		if (typeof(f.StationID)!='undefined') {
			for (i=0;i<f.StationID.options.length;i++) {
				if ((f.StationID.options[i].selected)&&(f.StationID.options[i].value!='')) {
					StationSelected=true;
					flagDateSeule=false;
					params[params.length]='StationID='+f.StationID.options[i].value;
				}
			}
		}
		if (typeof(f.Nbpers)!='undefined') {
			for (i=0;i<f.Nbpers.options.length;i++) {
				if ((f.Nbpers.options[i].selected)&&(f.Nbpers.options[i].value!='')) {
					flagDateSeule=false;
					flagStationSeule=false;
					params[params.length]='Nbpers='+f.Nbpers.options[i].value;
				}
			}
		}
		if (typeof(f.AbonneID)!='undefined') {
			if (f.AbonneID.checked) {
				flagDateSeule=false;
				flagStationSeule=false;
				params[params.length] = 'AbonneID=' + f.AbonneID.value;
			}
		}
		if (typeof(f.Promo)!='undefined') {
			if (f.Promo.checked) {
				flagDateSeule=false;
				flagStationSeule=false;
				params[params.length]='Promo='+f.Promo.value;
			}
		}
		var i=0;
		while (i<this.Criteres.length) {
			var str='if (f.'+this.Criteres[i]+') {';
			str+='if (f.'+this.Criteres[i]+'.value==\'True\') {';
			str+='flagDateSeule=false;';
			str+='flagStationSeule=false;';
			str+="params[params.length]='"+this.Criteres[i]+"=True';";
			str+='}}';
			eval(str);
			i++;
		}
		if (!DteSelected&&!StationSelected) {
			if (this.Langue=='') {
				alert("Veuillez sélectionner au moins une date de début de séjour ou une station");
			} else if (this.Langue=='_uk') {
				alert("Please select a date or a resort");
			}
			return false;
		} else if (StationSelected&&!DteSelected&&!flagStationSeule) {
			if (this.Langue=='') {
				alert("Lorsqu'aucune date n'est sélectionnée, seul le critère station est pris en compte dans la recherche.");
			} else if (this.Langue=='_uk') {
				alert("If there is no date selected, the search will be based on the resort name only.");
			}
		}
		if (flagDateSeule) {
			if ((!f.checkLogement)||(f.checkLogement.checked)) {
                            if (mv=='') {
				document.location='/'+strUrlSejour+'-'+DteFrom.substr(8,2)+'-'+DteFrom.substr(5,2)+'.html';
                            } else {
                                document.location='/'+strUrlSejour_mv+'-'+DteFrom.substr(8,2)+'-'+DteFrom.substr(5,2)+'.html';
                            }
				return false;
			}
		} else if (DteFrom=='') {
			url='/log_par_station.php';
		}
		document.location=url+'?'+implode('&',params);
		return false;
	}

	this.onCritere=function (ID) {
		var img=document.getElementById('img'+ID);
		eval('var obj=document.getElementById(\'formSearch\').'+ID+';');
		if (obj.value=='') {
			img.style.borderColor='#000000';
		}
	}

	this.outCritere=function (ID) {
		var img=document.getElementById('img'+ID);
		eval('var obj=document.getElementById(\'formSearch\').'+ID+';');
		if (obj.value=='') {
			img.style.borderColor='transparent';
		}
	}

	this.checkCritere=function(ID) {
		var img=document.getElementById('img'+ID);
		eval('var obj=document.getElementById(\'formSearch\').'+ID+';');
		if ((obj.value=='')&&(this.NbCriteres<3)) {
			this.NbCriteres++;
			obj.value='True';
			img.style.borderColor='red';
		} else if (obj.value!='') {
			this.NbCriteres--;
			obj.value='';
			img.style.borderColor='#000000';
		}
	}
}

function DebSejour(value,text) {
	this.value=value;
	this.text=text;
}

function Station (StationID,Station,MassifID,Pays) {
	this.StationID=StationID;
	this.Station=Station;
	this.MassifID=MassifID;
	this.Pays=Pays;
}

var recherche=new Search();

// ---------------------------- Objet Agenda ---------------------------

agenda=null;
function initAgenda() {
	var tab=document.getElementsByTagName('INPUT');
	for (var i=0;i<tab.length;i++) {
		if ((' '+tab[i].className).indexOf('DteAgenda')>0) {
			tab[i].style.width='6em';
			if (tab[i].onfocus==null) {
				tab[i].onfocus=function() {
					this.style.border='3px solid '+couleur_texte;
					if (navigator.appName == "Microsoft Internet Explorer") {
						this.style.borderRight = '0px';
					} else {
						this.style.borderBottom = '0px';
					}
					var div=document.createElement('DIV');
					div.id='divAgenda';
					div.style.position='absolute';
					div.style.background='white';
					if (agenda!=null) {
						agenda.detruire();
					}
					agenda=new Agenda(this.value);
					div.innerHTML=agenda.afficher();
					var parent=this.parentNode;
					if (this==parent.lastChild) {
						parent.appendChild(div);
					} else {
						parent.insertBefore(div,this.nextSibling);
					}
				}
				tab[i].onchange=function() {
					this.onfocus();
				}
			}
		}
	}
}

function Agenda (Dte) {
	if (Dte!='') {
		this.annee=parseInt(Dte.substr(6,4));
		var m=Dte.substr(3,2);
		if (m.substr(0,1)=='0') {
			this.mois=parseInt(m.substr(1,1));
		} else {
			this.mois=parseInt(m);
		}
		this.date=new Date(this.annee,(this.mois-1),1,12,0,0);
	} else {
		this.date=new Date();
		this.annee=this.date.getFullYear();
		this.mois=this.date.getMonth()+1;
		this.date=new Date(this.annee,(this.mois-1),1,12,0,0);
	}
	this.afficher=function() {
		var html='<table class="tableAgenda">';
		html+='<thead>';
		// Fermer
		html+='<tr>';
		html+='<td colspan="7" style="text-align:right;background:'+couleur_texte+';"><a style="color:white" href="javascript:agenda.detruire()">'+strFermer+'</a></td>';
		html+='</tr>';
		// Navigation
		html+='<tr>';
		html+='<td colspan="7"><table style="width:100%"><tbody><tr>';
		// <<
		html+='<td><a href="javascript:agenda.anneePrec()"><<</a></td>';
		// <
		html+='<td><a href="javascript:agenda.moisPrec()"><</a></td>';
		// Mois
		html+='<td style="text-align:center">'+moisNom[this.mois]+' '+this.annee+'</td>';
		// >
		html+='<td><a href="javascript:agenda.moisSuiv()">></a></td>';
		// >>
		html+='<td><a href="javascript:agenda.anneeSuiv()">>></a></td>';
		html+='</tr></tbody></table></td>';
		// Jours
		html+='<tr>';
		for (var i=1;i<=6;i++) {
			html+='<td style="background:'+couleur_texte+';color:white;">'+jourAbv[i]+'</td>';
		}
			html+='<td style="background:'+couleur_texte+';color:white;">'+jourAbv[0]+'</td>';
		html+='</tr>';
		html+='</tr>';
		html+='</thead>';
		html+='<tbody>';
		html+='<tr>';
		var dte=this.date;
		var js=dte.getDay(); // jour de la semaine
		if (js==0) {
			for (var i=1;i<=6;i++) {
				html+='<td>&nbsp;</td>';
			}
		} else {
			for (var i=1;i<js;i++) {
				html+='<td>&nbsp;</td>';
			}
		}
		var m=dte.getMonth();
		while (m==(this.mois-1)) {
			if((dte.getDay()==1)&&(dte.getDate()!=1)) {
				// Si le jour est un lundi on change de ligne
				html+='</tr><tr>';
			}
			html+='<td><a ';
			if (dte.getDay()==6) {
				html+='style="font-weight:bold"';
			}
			html+=' href="javascript:agenda.valide('+dte.getDate()+')">'+dte.getDate()+'</a></td>';
			dte=new Date(dte.getTime() + 24*3600*1000);
			m=dte.getMonth();
		}
		js=dte.getDay();
		if (js!=1) {
			while ((js<7)&&(js>0)) {
				html+='<td>&nbsp;</td>';
				js++;
			}
			if ((js==7)||js==0) {
				html+='<td>&nbsp;</td>';
			}
		}
		html+='</tr>';
		html+='</tbody>';
		html+='</table>';
		if (document.getElementById('divAgenda')) {
			var obj=document.getElementById('divAgenda');
			obj.innerHTML=html;
		}
		return html;
	}
	this.anneeSuiv=function () {
		this.date.setYear(this.date.getFullYear()+1);
		this.annee++;
		this.afficher();
	}
	this.anneePrec=function () {
		this.date.setYear(this.date.getFullYear()-1);
		this.annee--;
		this.afficher();
	}
	this.moisSuiv=function () {
		if (this.mois==12) {
			this.mois=1;
			this.annee++;
			this.date.setMonth(0);
			this.date.setYear(this.date.getFullYear()+1);
		} else {
			this.date.setMonth(this.date.getMonth()+1);
			this.mois++;
		}
		this.afficher();
	}
	this.moisPrec=function () {
		if (this.mois==1) {
			this.mois=12;
			this.annee--;
			this.date.setMonth(11);
			this.date.setYear(this.date.getFullYear()-1);
		} else {
			this.date.setMonth(this.date.getMonth()-1);
			this.mois--;
		}
		this.afficher();
	}
	this.valide=function (j) {
		var val='';
		if (j<10) {
			val+='0';
		}
		val+=j+'/';
		if (this.mois<10) {
			val+='0';
		}
		val+=this.mois+'/'+this.annee;
		var obj=document.getElementById('divAgenda');
		//var parent=obj.parentNode;
		obj.previousSibling.value=val;
		if (obj.previousSibling.onblur) {
			obj.previousSibling.onblur();
		}
		this.detruire();
	}
	this.detruire=function () {
		var obj=document.getElementById('divAgenda');
		obj.previousSibling.style.borderColor='';
		obj.previousSibling.style.borderStyle='inset';
		obj.previousSibling.style.borderWidth='2px';
		var parent=obj.parentNode;
		parent.removeChild(obj);
		agenda=null;
	}
}

addEvent(window,'load',initAgenda);

// --------------------------- Fonctions pour la résidence -----------------
/*
Script de gestion du menu dans les cadres résidence
 */

function affichePrestations (AbonneID,Nom,DteFrom,DteTo) {
	if (!DteFrom) {
		var DteFrom='';
	}
	if (!DteTo) {
		var DteTo='';
	}
	var html=requestSelect('/reservation/ajax/getPrestations.php?AbonneID='+AbonneID+'&DteFrom='+DteFrom+'&DteTo='+DteTo);
	ppp=new popup();
	ppp.title=Nom;
	ppp.contenu=html;
	ppp.affiche();
}

function afficheAccesStation (AbonneID,Nom) {
	var html=requestSelect('/reservation/ajax/getAccesStation.php?AbonneID='+AbonneID);
	ppp=new popup();
	ppp.title=Nom;
	ppp.contenu=html;
	ppp.affiche();
}
function afficheConditions (AbonneID,Nom) {
	var html=requestSelect('/reservation/ajax/getConditions.php?AbonneID='+AbonneID);
	ppp=new popup();
	ppp.title=Nom;
	ppp.contenu=html;
	ppp.affiche();
}
function afficheHoraires (AbonneID,Nom) {
	var html=requestSelect('/reservation/ajax/getHoraires.php?AbonneID='+AbonneID);
	ppp=new popup();
	ppp.title=Nom;
	ppp.contenu=html;
	ppp.affiche();
}

var modeVisible='';
function modeAcces(mode,StationID) {
	head="";
	foot="";
	html="";
	if (modeVisible!='') {
		if (modeVisible=='Route') {
			document.getElementById('AccesRoute').innerHTML="";
		} else if (modeVisible=='Avion') {
			document.getElementById('AccesAvion').innerHTML="";
		} else if (modeVisible=='Train') {
			document.getElementById('AccesTrain').innerHTML="";
		}
	}
	if (mode!=modeVisible) {
		if (mode=='Route') {
			html=requestSelect('/reservation/ajax/getAcces.php?StationID='+StationID+'&Acces=ROUTE');
			document.getElementById('AccesRoute').innerHTML=head+html+foot;
		} else if (mode=='Avion') {
			html=requestSelect('/reservation/ajax/getAcces.php?StationID='+StationID+'&Acces=AVION');
			document.getElementById('AccesAvion').innerHTML=head+html+foot;
		} else if (mode=='Train') {
			html=requestSelect('/reservation/ajax/getAcces.php?StationID='+StationID+'&Acces=TRAIN');
			document.getElementById('AccesTrain').innerHTML=head+html+foot;
		}
		modeVisible=mode;
	} else {
		modeVisible='';
	}
}
var fenetre=null;
function photoResidence (AbonneID) {
	if (fenetre!=null) {
		fenetre.close();
	}
	fenetre=window.open('/affichePhoto.php?AbonneID='+AbonneID,'','resizable=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=yes');
}

//------------------------------ objet Popup -------------------------
var activeMoving=null;
var zActuel=10;

function popup() {
	var body=document.getElementsByTagName('BODY')[0];
	var html=document.getElementsByTagName('HTML')[0];
	var obj=document.createElement('DIV');
	obj.id='popup'+body.childNodes.length;
	this.index=body.childNodes.length;
	obj.className='divCadre';
	obj.style.position='absolute';
	obj.style.visibility='hidden';
	obj.style.overflow='visible';
	obj.style.border='1px solid black';
	obj.style.padding='3px';
	obj.style.fontSize='.85em';
	obj.style.background='white url(/images/fond_cadre.png) repeat-y top left';
	zActuel++;
	obj.style.zIndex=zActuel;
	this.title='';
	this.contenu='';
	this.afficheClose=true;
	body.appendChild(obj);

	this.affiche=function () {
		var obj=document.getElementById('popup'+this.index);
		var objEntete=document.createElement('DIV');
		objEntete.className='divCadreEntete';
		objEntete.style.padding='0 0 0 3px';
		objEntete.style.fontWeight='bold';
		if (this.afficheClose) {
			objEntete.innerHTML='<div style="float:right"><a href="javascript:popupClose('+this.index+')"><img src="/images/popup/close.png" alt="'+strFermer+'" style="vertical-align:top"/></a></div>'
		}
		objEntete.innerHTML+=this.title;
		objEntete.style.cursor='move';
		objEntete.onmousedown=function(e) {
			var html=document.getElementsByTagName('HTML')[0];
			zActuel++;
			activeMoving=this.parentNode;
			activeMoving.style.zIndex=zActuel;
			// Définition de la position de la sourir avant mouvement
			this.xPrecedent=(navigator.appName.substring(0,3) == "Net") ? e.pageX : event.x+html.scrollLeft;
			this.yPrecedent=(navigator.appName.substring(0,3) == "Net") ? e.pageY : event.y+html.scrollTop;
			// Désactivation de la sélection de texte
			document.onselectstart=new Function ("return false");
			if (window.sidebar){
				document.onmousedown=function () {return false;}
				document.onclick=function () {return true;}
			}
		}
		objEntete.onmousemove=function(e) {
			if (activeMoving==this.parentNode) {
				// Largeur et hauteur totales du document
				if (document.getElementById('Main')) {
					var width=document.body.offsetWidth;
					var height=document.getElementById('Main').offsetHeight;
				} else {
					var width=document.body.offsetWidth;
					var height=document.body.offsetHeight;
				}
				var wid
				// Position du curseur
				var x = (navigator.appName.substring(0,3) == "Net") ? e.pageX : event.x+html.scrollLeft;
				var y = (navigator.appName.substring(0,3) == "Net") ? e.pageY : event.y+html.scrollTop;
				// Calcul de la différence de coordonnées par rapport au dernier appel de la fonction
				var xDiff = x-this.xPrecedent;
				var yDiff = y-this.yPrecedent;
				// Recherche si on doit modifier l'abscisse
				var moveX=false;
				if (xDiff>0) {
					if ((parseInt(activeMoving.style.left)+xDiff+parseInt(activeMoving.offsetWidth))<width) {
						moveX=true;
					}
				} else if (xDiff<0) {
					if ((parseInt(activeMoving.style.left)+xDiff)>0) {
						moveX=true;
					}
				}
				if (moveX) {
					activeMoving.style.left=(parseInt(activeMoving.style.left)+xDiff)+'px';
					this.xPrecedent=x;
				}
				// Recherche si on doit modifier l'ordonnée
				var moveY=false;
				if (yDiff>0) {
					if ((parseInt(activeMoving.style.top)+yDiff+parseInt(activeMoving.offsetHeight))<(height+html.scrollTop)) {
						moveY=true;
					}
				} else if (yDiff<0) {
					if ((parseInt(activeMoving.style.top)+yDiff)>0) {
						moveY=true;
					}
				}
				if (moveY) {
					activeMoving.style.top=(parseInt(activeMoving.style.top)+yDiff)+'px';
					this.yPrecedent=y;
				}
			}
		}
		objEntete.onmouseup=function (e) {
			activeMoving=null;
			// Réactivation de la sélection de texte
			document.onselectstart=new Function ("return true")
			if (window.sidebar){
				document.onmousedown=function () {return true;}
				document.onclick=function () {return true;}
			}
		}
		obj.appendChild(objEntete);
		var objContenu=document.createElement('DIV');
		objContenu.innerHTML=this.contenu;
		obj.appendChild(objContenu);
		if (html.scrollTop>0) {
			obj.style.top = (html.scrollTop + 20) + 'px';
		} else if (body.scrollTop>0) {
			obj.style.top = (body.scrollTop + 20) + 'px';
		} else {
			obj.style.top = '20px';
		}
		obj.style.visibility='visible';
		if (navigator.appName == 'Microsoft Internet Explorer') {
			// POUR IE : recherche s'il y a une iframe
			if (this.contenu.indexOf('iframe') > 0) {
				var iframe = document.getElementsByTagName('IFRAME')[0];
				obj.style.width = iframe.width + 'px';
			} else {
	 			/*obj.style.width = document.getElementsByTagName('BODY')[0].offsetWidth + 'px';
	 			var height = objContenu.offsetHeight;
	 			while (objContenu.offsetHeight == height) {
	 				obj.style.width = (parseInt(obj.style.width) - 10) + 'px';
	 			}
	 			obj.style.width = (parseInt(obj.style.width) + 10) + 'px';*/
				obj.style.maxWidth = '840px';
			}
		} else {
			obj.style.maxWidth='840px';
		}
		obj.style.left=parseInt((document.body.offsetWidth-obj.offsetWidth)/2)+'px';
		obj.style.height=parseInt(objEntete.offsetHeight+objContenu.offsetHeight+20)+'px';
	}
	this.exists=function() {
		if (document.getElementById('popup'+this.index)) {
			return true;
		} else {
			return false;
		}
	}
	this.close=function () {
		if (this.exists()) {
			var body=document.getElementsByTagName('BODY');
			body=body[0];
			body.removeChild(document.getElementById('popup'+this.index));
		}
	}
}

function popupClose(i) {
	var body=document.getElementsByTagName('BODY');
	body=body[0];
	body.removeChild(document.getElementById('popup'+i));
}

function activerSelection (e) {
	activeMoving=null;
	// Réactivation de la sélection de texte
	document.onselectstart=new Function ("return true")
	if (window.sidebar){
		document.onmousedown=function () {return true;}
		document.onclick=function () {return true;}
	}
}

addEvent(document,'mouseup',activerSelection);

//--------------------- Fonctions pour le scroller photos ------------------
var scrollFlag=false;
var sens="";

function getMouseX() {
	if (scrollFlag) {
		var obj=document.getElementById('viewPhoto');
		if (sens=="left") {
			obj.scrollLeft-=15;
		}
		if (sens=="right") {
			obj.scrollLeft+=15;
		}
		setTimeout("getMouseX()",50);
	}
}

function scrollPhoto(commande,value) {
	if (commande=="start") {
		scrollFlag=true;
		sens=value;
		getMouseX();
	} else {
		scrollFlag=false;
		sens="";
	}
}

var fenetre=null;
function afficheImage(url,width,height) {
	if (fenetre!=null) {
		fenetre.close();
	}
	fenetre=window.open('/affichePhoto.php?url='+url,'','resizable=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=yes,width='+width+',height='+height);
}

function ouvrir(url) {
	if (fenetre!=null) {
		fenetre.close();
	}
	width=750;
	height=250;
	fenetre=window.open(url,'','resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=yes,width='+width+',height='+height+',top='+((screen.height-height)/2)+',left='+((screen.width-width)/2));
}

function ouvrirPresta(url,titre,fenetre) {
        if (fenetre==null) {
            var fenetre=false;
        }
        if (!fenetre) {
            var ppp=new popup();
            ppp.title=titre;
            ppp.contenu=requestSelect(url);
            ppp.affiche();
        } else {
            window.open(url,'','');
        }
}

// ------------------- Fonctions pour online_affiche -----------------------
var visible='';

function countOccurenceChar (str,car) {
	var pos=0;
	var nb=0;
	while (str.indexOf(car,pos)>0) {
		pos=str.indexOf(car,pos)+1;
		nb++;
	}
	return nb;
}

function Sejour (iAbo,iAllo,AlloID,NbChambre,DispoDte,NbNuits,Dispo,TarifPublic,Tarif,Promo,ParPers) {
	this.iAbo=iAbo;
	this.iAllo=iAllo;
	this.AlloID=AlloID;
	this.NbChambre=NbChambre;
	this.DteFrom=DispoDte.substr(0,10);
	this.DteTo=DispoDte.substr(11,10);
	this.Dispo=Dispo;
	this.NbNuits=NbNuits;
	this.TarifPublic=TarifPublic;
	this.Tarif=Tarif;
	if (parseInt(Promo)==parseFloat(Promo)) {
		this.Promo=round(Promo);
	} else {
		this.Promo=round(Promo,2);
	}
	if (ParPers) {
		this.ParPers=true;
	} else {
		this.ParPers=false;
	}
}

function changeQte(AlloID,operation) {
	var iSejour=parseInt(document.getElementById('iSejour-'+AlloID).value);
	if (operation=='-') {
		if (parseInt(document.getElementById('NbChambre-'+AlloID).value)>0) {
			document.getElementById('NbChambre-'+AlloID).value=parseInt(document.getElementById('NbChambre-'+AlloID).value)-1;
		}
	} else if (operation=='+') {
		if (parseInt(document.getElementById('NbChambre-'+AlloID).value)<parseInt(allSejour[iSejour].Dispo)) {
			document.getElementById('NbChambre-'+AlloID).value=parseInt(document.getElementById('NbChambre-'+AlloID).value)+1;
		}
	}
}

// Fonction pour les courts séjours, quand les séjours sont regroupés dans un menu déroulant
function changeDebSejour (value) {
	// Division des variables contenues dans value : AlloID DteFrom
	var valTab=explode('|',value)
	var AlloID=valTab[0];
	var DteFrom=valTab[1];
	// Recherche de la durée sélectionnée
	var duree=0;
	var obj=document.getElementById('dureeSelected-'+AlloID);
	obj=obj.childNodes[obj.childNodes.length-1];
	if (obj.tagName=="SELECT") {
		for (iNuit=0;iNuit<obj.options.length;iNuit++) {
			if (obj.options[iNuit].selected) {
				valTab=explode('|',obj.options[iNuit].value)
				duree=parseInt(valTab[1]);
			}
		}
		// Destruction des options du menu déroulant de la durée
		for (iNuit=obj.options.length-1;iNuit>=0;iNuit--) {
			obj.options[iNuit]=null;
		}
	} else {
		valTab=explode('|',obj.value);
		duree=parseInt(valTab[1]);
	}
	// Création des options du menu déroulant de la durée
	var iSejour=-1;
	var j;
	var tabNuits=new Array();
	for (j = 0; j < allSejour.length; j++) {
		if ((allSejour[j].AlloID == AlloID) && (allSejour[j].DteFrom == DteFrom)) {
			if (iSejour == -1) {
				iSejour = j;
			}
			if (allSejour[j].NbNuits < 10) {
				tabNuits[tabNuits.length] = new Array('0' + allSejour[j].NbNuits, AlloID + '|' + allSejour[j].NbNuits);
			} else {
				tabNuits[tabNuits.length] = new Array(allSejour[j].NbNuits, AlloID + '|' + allSejour[j].NbNuits);
			}
			if (allSejour[j].NbNuits==duree) {
				iSejour=j;
			}
		}
	}
	if (tabNuits.length>1) {
		obj=obj.parentNode;
		while (obj.childNodes.length>0) {
			obj.removeChild(obj.childNodes[0]);
		}
		obj.innerHTML='<select onchange="changeDureeSejour(this.value)"></select>';
		obj=obj.childNodes[0];
		for (var iNuit=0;iNuit<tabNuits.length;iNuit++) {
			obj.options[iNuit]=new Option(tabNuits[iNuit][0],tabNuits[iNuit][1]);
			if (parseInt(tabNuits[iNuit][0])==duree) {
				obj.options[iNuit].selected=true;
			}
		}
	} else {
		obj=obj.parentNode;
		while (obj.childNodes.length>0) {
			obj.removeChild(obj.childNodes[0]);
		}
		obj.innerHTML=parseInt(tabNuits[0][0])+'<input type="hidden" value="'+tabNuits[0][1]+'"/>';
	}

	// Mémorisation de l'index du séjour sélectionné pour ce AlloID
	document.getElementById('iSejour-'+AlloID).value=iSejour;
	// Si le nombre de logements sélectionnés est supérieur au nombre de dispos
	if (parseInt(document.getElementById('NbChambre-'+AlloID).value)>allSejour[iSejour].Dispo) {
		document.getElementById('NbChambre-'+AlloID).value='0';
	}
	document.getElementById('Nb_dispo-'+allSejour[iSejour].AlloID).innerHTML=allSejour[iSejour].Dispo;
	if (document.getElementById('Promo-'+allSejour[iSejour].AlloID)) {
		var pourcent=allSejour[iSejour].Promo;
		if (pourcent>0) {
			document.getElementById('Promo-'+allSejour[iSejour].AlloID).innerHTML='<img src="/images/promo/'+pourcent+'.png" alt="'+pourcent+'%"/>';
		} else {
			document.getElementById('Promo-'+allSejour[iSejour].AlloID).innerHTML='';
		}
	}
	document.getElementById('Tarif-'+allSejour[iSejour].AlloID).innerHTML='';
	if (allSejour[iSejour].TarifPublic>allSejour[iSejour].Tarif) {
		document.getElementById('Tarif-'+allSejour[iSejour].AlloID).innerHTML+='<span class="pxbarre">'+allSejour[iSejour].TarifPublic+'</span>';
	}
	document.getElementById('Tarif-'+allSejour[iSejour].AlloID).innerHTML+='<span class="important">'+allSejour[iSejour].Tarif+' &euro;</span>';
	if (allSejour[iSejour].ParPers) {
		document.getElementById('Tarif-'+allSejour[iSejour].AlloID).innerHTML+='/'+strAdulte;
	}
	document.getElementById('Tarif-'+allSejour[iSejour].AlloID).innerHTML+='';
}

// Fonction pour les courts séjours, quand les séjours sont regroupés dans un menu déroulant
function changeDureeSejour (value) {
	// Division des variables contenues dans value : AlloID NbNuits
	var valTab=explode('|',value)
	var AlloID=valTab[0];
	var NbNuits=valTab[1];
	// Recherche de la date sélectionnée
	var obj=document.getElementById('debutSelected-'+AlloID);
	if (obj.tagName=="SELECT") {
		for (iNuit=0;iNuit<obj.options.length;iNuit++) {
			if (obj.options[iNuit].selected) {
				valTab=explode('|',obj.options[iNuit].value);
				DteFrom=valTab[1];
			}
		}
	} else {
		valTab=explode('|',obj.value);
		DteFrom=valTab[1];
	}
	var i;
	for (i=0;i<allSejour.length;i++) {
		if ((allSejour[i].AlloID==AlloID)&&(allSejour[i].DteFrom==DteFrom)&&(allSejour[i].NbNuits==NbNuits)) {
			document.getElementById('Nb_dispo-'+allSejour[i].AlloID).innerHTML=allSejour[i].Dispo;
			if (document.getElementById('Promo-'+allSejour[i].AlloID)) {
				var pourcent=allSejour[i].Promo;
				if (pourcent>0) {
					document.getElementById('Promo-'+allSejour[i].AlloID).innerHTML='<img src="/images/promo/'+pourcent+'.png" alt="'+pourcent+'%"/>';
				} else {
					document.getElementById('Promo-'+allSejour[i].AlloID).innerHTML='';
				}
			}
			document.getElementById('Tarif-'+allSejour[i].AlloID).innerHTML='';
			if (allSejour[i].TarifPublic>allSejour[i].Tarif) {
				document.getElementById('Tarif-'+allSejour[i].AlloID).innerHTML+='<span class="pxbarre">'+allSejour[i].TarifPublic+'</span>';
			}
			document.getElementById('Tarif-'+allSejour[i].AlloID).innerHTML+='<span class="important">'+allSejour[i].Tarif+' &euro;</span>';
			if (allSejour[i].ParPers) {
				document.getElementById('Tarif-'+allSejour[i].AlloID).innerHTML+='/'+strAdulte;
			}
			// Mémorisation de l'index du séjour sélectionné pour ce AlloID
			document.getElementById('iSejour-'+AlloID).value=i;
		}
	}
}

function afficheLog(iAbo,iAllo,AlloID,DispoDte,NbNuits) {
	if (visible!='') {
		document.getElementById('Div'+visible).innerHTML='';
		document.getElementById('Tr'+visible).style.display='none';
		if (visible=='-'+iAbo+'-'+iAllo) {
			iAbo=-1;iAllo=-1;
		} else if (visible=='-'+AlloID) {
			iAbo=-1;iAllo=-1;
		}
	}
	if ((iAbo>=0)&&(iAllo>=0)) {
		visible='-'+iAbo+'-'+iAllo;
		var objTr=document.getElementById('Tr'+visible);
		var objDiv=document.getElementById('Div'+visible);
		var html=requestSelect('/reservation/logement.php?AlloID='+AlloID+'&DispoDte='+DispoDte+'&NbNuits='+NbNuits);
		objDiv.innerHTML=html;
		objTr.style.display='';
	} else if ((iAbo>=0)&&(iAllo==-1)) {
		visible='-'+AlloID;
		var objTr=document.getElementById('Tr'+visible);
		var objDiv=document.getElementById('Div'+visible);
		var html=requestSelect('/reservation/logement.php?AlloID='+AlloID+'&DispoDte='+DispoDte+'&NbNuits='+NbNuits);
		objDiv.innerHTML=html;
		objTr.style.display='';
	} else {
		visible='';
	}
}

function calculer(iAbo) {
	var f=document.getElementById('form'+iAbo);
	var NbPersMax=0;
	var tabSejour=new Array();
	var i;
	// recherche des logements sélectionnés
	for (i=0;i<f.elements.length;i++) {
		var name=" "+f.elements[i].id;
		if (name.indexOf("NbChambre")>0) {
			if (parseInt(f.elements[i].value)!=0) {
				var AlloID=parseInt(name.replace(' NbChambre-',''));
				var iSejour=parseInt(document.getElementById('iSejour-'+AlloID).value);
				var j=tabSejour.length;
				tabSejour[j]=allSejour[iSejour];
				tabSejour[j].NbChambre=parseInt(f.elements[i].value);
			}
		}
	}
	// Si aucun logement sélectionné
	if (tabSejour.length==0) {
		if (langue=='') {
			alert("Veuillez sélectionner un(des) logement(s).");
		} else if (langue=='_uk') {
			alert("Please select an accommodation.");
		} else if (langue=='_es') {
			alert("Selecciona el(los)  alojamiento(s).");
		}
		return false;
	}
	// Vérification de la possibilité de la sélection
	var AlloID=tabSejour[0].AlloID;
	var strAlloID='?AlloID='+AlloID;
	var NbChambre=tabSejour[0].NbChambre;
	var strNbChambre='&NbChambre='+NbChambre;
	var DteFrom=tabSejour[0].DteFrom;
	var DteTo=tabSejour[0].DteTo;
	NbPersMax+=(parseInt(NbChambre)*parseInt(document.getElementById('NbpersMax-'+AlloID).value));
	i=1;
	// Récupération du nombre et des dates du 1er logement
	while ((i<tabSejour.length)&&(AlloID==tabSejour[i].AlloID)) {
		if (tabSejour[i].NbChambre!=NbChambre) {
			if (langue=='') {
				alert("Veuillez sélectionner le même nombre de logement sur chaque date.");
			} else if (langue=='_uk') {
				alert("Please select the same number of accommodation for each date.");
			} else if (langue=='_es') {
				alert("");
			}
			return false;
		} else if (tabSejour[i].DteFrom==DteTo) {
			DteTo=tabSejour[i].DteTo;
		} else {
			if (langue=='') {
				alert("Sélection impossible.");
			} else if (langue=='_uk') {
				alert("Impossible selection.");
			} else if (langue=='_es') {
				alert("");
			}
			return false;
		}
		i++;
	}
	var strDispoDte='&DispoDte='+DteFrom+'|'+DteTo;
	// Vérification des autres logements
	NbChambre=0;
	AlloID=0;
	while (i<tabSejour.length) {
		if (AlloID!=tabSejour[i].AlloID) {
			AlloID=tabSejour[i].AlloID;
			strAlloID+='|'+AlloID;
			NbChambre=tabSejour[i].NbChambre;
			strNbChambre+='|'+NbChambre;
			NbPersMax+=(parseInt(NbChambre)*parseInt(document.getElementById('NbpersMax-'+AlloID).value));
			j=i;
			var DteFrom1=tabSejour[i].DteFrom;
			var DteTo1=tabSejour[i].DteTo;
			while ((j<tabSejour.length)&&(tabSejour[j].AlloID==AlloID)) {
				if (tabSejour[j].NbChambre!=NbChambre) {
					if (langue=='') {
						alert("Veuillez sélectionner le même nombre de logement sur chaque date.");
					} else if (langue=='_uk') {
						alert("Please select the same number of accommodation for each date.");
					} else if (langue=='_es') {
						alert("");
					}
					return false;
				} else if (tabSejour[j].DteFrom==DteFrom1) {
				} else if (tabSejour[j].DteFrom==DteTo1) {
					DteTo1=tabSejour[j].DteTo;
				} else {
					if (langue=='') {
						alert("Sélection impossible.");
					} else if (langue=='_uk') {
						alert("Impossible selection.");
					} else if (langue=='_es') {
						alert("");
					}
					return false;
				}
				j++;
			}
			if ((DteFrom!=DteFrom1)||(DteTo!=DteTo1)) {
				if (langue=='') {
					alert("Veuillez sélectionner les mêmes dates pour chaque logement.");
				} else if (langue=='_uk') {
					alert("Please select the same dates for each accommodation.");
				} else if (langue=='_es') {
					alert("");
				}
				return false;
			}
			i=j-1;
		}
		i++;
	}
	var strAutres='';
	if (document.getElementById('Nbpers')) {
		if (NbPersMax<parseInt(document.getElementById('Nbpers').value)) {
			if (langue=='') {
				alert("Votre sélection de logements ne peut pas accueillir toutes les personnes que vous souhaitez.");
			} else if (langue=='_uk') {
				alert("Your accommodation choice can\'t welcome the number of people you want.");
			} else if (langue=='_es') {
				alert("El alojamiento seleccionado no puede acojer al número de personas que deseas.");
			}
			return false;
		}
		strAutres+='&Nbpers='+document.getElementById('Nbpers').value;
	}
	if (f.checkForfait) {
		strAutres+='&checkForfait=Oui';
	}
	if (f.checkMateriel) {
		strAutres+='&checkMateriel=Oui';
	}
	if (document.getElementById('AffiliateID')) {
		strAutres+='&AffiliateID='+document.getElementById('AffiliateID').value;
	}

	var url='/reservation/descriptif.php'+strAlloID+strNbChambre+strDispoDte+strAutres;
	document.location=url;
	return true;
//	f.submit();
}

function modifCoche(check) {
	for (i=0;i<document.forms.length;i++) {
		for (j=0;j<document.forms[i].elements.length;j++) {
			if ((document.forms[i].elements[j].type=="checkbox")&&(document.forms[i].elements[j].name=="checkForfait")) {
				document.forms[i].elements[j].checked=check;
			}
		}
	}
}

// ----------------- Fonctions pour le comparateur de produits ----------
// Script pour comparer les produits

var tabCompare=new Array();

function initCompare () {
	// Affichage d'un bord sur chaque ligne de comparaison au passage de la souris
	var tab=document.getElementsByTagName('TR');
	for (var i=0;i<tab.length;i++) {
		if (tab[i].className=='TrProduct') {
			tab[i].onmouseover=function () {
				var tab=this.childNodes;
				for (var i=0;i<tab.length;i++) {
					if (i==0) {
						tab[i].style.borderLeft='1px solid #CCCCCC';
					} else if (i==(tab.length-1)) {
						tab[i].style.borderRight='1px solid #CCCCCC';
					}
					tab[i].style.borderTop='1px solid #CCCCCC';
					tab[i].style.borderBottom='1px solid #CCCCCC';
				}
			}
			tab[i].onmouseout=function () {
				var tab=this.childNodes;
				for (var i=0;i<tab.length;i++) {
					tab[i].style.border='0px';
				}
			}
		}
	}
}

function chgLogement(objSelect,AlloID) {
	for (var i=0;i<objSelect.options.length;i++) {
		document.getElementById('AlloID'+objSelect.options[i].value).style.visibility='hidden';
		document.getElementById('AlloID'+objSelect.options[i].value).style.position='absolute';
		document.getElementById('Tarif'+objSelect.options[i].value).style.visibility='hidden';
		document.getElementById('Tarif'+objSelect.options[i].value).style.position='absolute';
	}
	document.getElementById('AlloID'+AlloID).style.visibility='visible';
	document.getElementById('AlloID'+AlloID).style.position='';
	document.getElementById('Tarif'+AlloID).style.visibility='visible';
	document.getElementById('Tarif'+AlloID).style.position='';
}

function chgCompare(obj) {
	// Récupération du cookie compare
	var tabCompare=getCompareCookie();
	if (!obj) {
		var obj=null;
		var AbonneID=0;
		// Coche des produits contenus dans le cookie
		var trouveProduit=false;
		for (var i=0;i<tabCompare.length;i++) {
			var obj1=document.getElementById('Compare'+tabCompare[i]);
			if (obj1) {
				// Si le produit est affiché, on le coche
				obj1.checked=true;
			}
		}
	} else {
		var AbonneID=obj.id.replace('Compare','');
	}
	if (obj!=null) {
		if (obj.checked) {
			if (tabCompare.length<3) {
				tabCompare[tabCompare.length]=AbonneID;
			} else {
				obj.checked=false;
				alert(strCompare3OffresMax);
			}
		} else {
			for (var i=0;i<tabCompare.length;i++) {
				if (tabCompare[i]==AbonneID) {
					tabCompare.splice(i,1);
				}
			}
		}
	}
	setCompareCookie(tabCompare);
	setCompareTitre(strComparer+'('+tabCompare.length+')');
}

function setCompareCookie(tabCompare) {
	var expDate = new Date();
	expDate.setTime(expDate.getTime() + (1 * 24 * 3600 * 1000));
	document.cookie = "compare="+implode('|',tabCompare)+";expires=" + expDate.toGMTString() + ";path=/";
}

function getCompareCookie() {
	var deb=document.cookie.indexOf("compare=");
	if (deb>=0) {
		deb += "compare".length + 1;
	}
	fin=document.cookie.indexOf(";",deb);
	if (fin < 0) {
		fin = document.cookie.length
	}
	if ((deb>=0)&&(fin>deb)) {
		var str=unescape(document.cookie.substring(deb,fin));
		return explode('|',str);
	} else {
		return new Array();
	}
}
function viderCompare() {
	var tabCompare=getCompareCookie();
	for (var i=0;i<tabCompare.length;i++) {
		var obj=document.getElementById('Compare'+tabCompare[i])
		if (obj) {
			obj.checked=false;
		}
	}
	var	tabCompare=new Array();
	setCompareCookie(tabCompare);
	setCompareTitre(strComparer+'('+tabCompare.length+')');
}

function retour(url) {
	if (window.opener) {
		window.opener.location=url;
		window.opener.focus();
	} else {
		var f=window.open(url);
		f.focus();
	}
}

function validCompare(DteFrom,NbNuits) {
	var tabCompare=getCompareCookie();
	if (tabCompare.length>=2) {
		window.open('/reservation/compare.php?Products='+tabCompare.join('|')+'&DteFrom='+DteFrom+'&NbNuits='+NbNuits,'','resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=yes,width='+screen.width+',height='+screen.height+',top=0,left=0');
	} else if (tabCompare.length<=1) {
		alert(strCompare2OffresMin);
	}
}

function setCompareTitre(titre) {
	var tab=document.getElementsByTagName('SPAN');
	for (var i=0;i<tab.length;i++) {
		if (tab[i].className=='DivCompare') {
			tab[i].innerHTML=titre;
		}
	}
}

