function firstFocus() {
	if (document.forms.length > 0) {
		document.forms[0].elements[1].focus();
	}
}

function begin() {
	if (self != top) {
		top.location = self.document.location;
		}
}


function Validator(msg) { 

		if (confirm(msg)) {
			top.location ="validate.asp?decon=1";
		} else {
			return (false);
		}
}


function checkAll(form,xsource,xname) {

	for (i=0; i < form.elements.length; i++) {

		if (form.elements[i].name.substr(0,xname.length) == xname ) {

			if (form.elements[xsource].checked == true) {
				form.elements[i].checked = true;
			} else {
				form.elements[i].checked = false;
			}
		}
	}
}

// FUNCTION MENU / SUB MENU ATIPIC / LARS FORNELL JUIN 2005 COPYRIGHT V1.0
function lightup(x,li,q,mn,mo,ml)
{
	if (li == 1) {

		if (document.getElementById(x).className != ml )
		{
			document.getElementById(x).className = mo;
		}
	} else if (li == 2) {

		for (var i=0;i<q;i++)
		{
			document.getElementById('me' +i).className = mn;
		}

		document.getElementById(x).className = ml;

	} else {
		if (document.getElementById(x).className != ml )
		{
			document.getElementById(x).className = mn;
		}
	}
}

function openPictureWindow_Fever(imageType,imageName,imageWidth,imageHeight,alt,posLeft,posTop) {  // v4.01
	newWindow = window.open("","newWindow","width="+imageWidth+",height="+imageHeight+",scrollbars=no,left="+posLeft+",top="+posTop);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+alt+'</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">'); 
	if (imageType == "swf"){
	newWindow.document.write('<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\" width=\"'+imageWidth+'\" height=\"'+imageHeight+'\">');
	newWindow.document.write('<param name=movie value=\"'+imageName+'\"><param name=quality value=high>');
	newWindow.document.write('<embed src=\"'+imageName+'\" quality=high pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"'+imageWidth+'\" height=\"'+imageHeight+'\">');
	newWindow.document.write('</embed></object>');	}else{
	newWindow.document.write('<img src=\"'+imageName+'\" width='+imageWidth+' height='+imageHeight+' alt=\"'+alt+'\">'); 	}
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function GP_popupConfirmMsg(msg) { //v1.0
  document.MM_returnValue = confirm(msg);
}


function tmt_lenValidator(f,sp,ep,ks,eMsg){
	var str;var myErr="";var re=/^(\s*)$/;fv=MM_findObj(f).value;
	if(ks){if(re.test(fv)){fv=fv.replace(re,"");}}
	if(fv.length<sp||fv.length>ep){alert(unescape(eMsg));myErr += 'eMsg';}
	document.MM_returnValue=(myErr=="");
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&id.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function YY_checkform() { //v4.66
//copyright (c)1998,2002 Yaromat.com
  var args = YY_checkform.arguments; var myDot=true; var myV=''; var myErr='';var addErr=false;var myReq;
  for (var i=1; i<args.length;i=i+4){
    if (args[i+1].charAt(0)=='#'){myReq=true; args[i+1]=args[i+1].substring(1);}else{myReq=false}
    var myObj = MM_findObj(args[i].replace(/\[\d+\]/ig,""));
    myV=myObj.value;
    if (myObj.type=='text'||myObj.type=='password'||myObj.type=='hidden'){
      if (myReq&&myObj.value.length==0){addErr=true}
      if ((myV.length>0)&&(args[i+2]==1)){ //fromto
        var myMa=args[i+1].split('_');if(isNaN(myV)||myV<myMa[0]/1||myV > myMa[1]/1){addErr=true}
      } else if ((myV.length>0)&&(args[i+2]==2)){
          var rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-z]{2,4}$");if(!rx.test(myV))addErr=true;
      } else if ((myV.length>0)&&(args[i+2]==3)){ // date
        var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]);
        if(myAt){
          var myD=(myAt[myMa[1]])?myAt[myMa[1]]:1; var myM=myAt[myMa[2]]-1; var myY=myAt[myMa[3]];
          var myDate=new Date(myY,myM,myD);
          if(myDate.getFullYear()!=myY||myDate.getDate()!=myD||myDate.getMonth()!=myM){addErr=true};
        }else{addErr=true}
      } else if ((myV.length>0)&&(args[i+2]==4)){ // time
        var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]);if(!myAt){addErr=true}
      } else if (myV.length>0&&args[i+2]==5){ // check this 2
            var myObj1 = MM_findObj(args[i+1].replace(/\[\d+\]/ig,""));
            if(myObj1.length)myObj1=myObj1[args[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!myObj1.checked){addErr=true}
      } else if (myV.length>0&&args[i+2]==6){ // the same
            var myObj1 = MM_findObj(args[i+1]);
            if(myV!=myObj1.value){addErr=true}
      }
    } else
    if (!myObj.type&&myObj.length>0&&myObj[0].type=='radio'){
          var myTest = args[i].match(/(.*)\[(\d+)\].*/i);
          var myObj1=(myObj.length>1)?myObj[myTest[2]]:myObj;
      if (args[i+2]==1&&myObj1&&myObj1.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
      if (args[i+2]==2){
        var myDot=false;
        for(var j=0;j<myObj.length;j++){myDot=myDot||myObj[j].checked}
        if(!myDot){myErr+='* ' +args[i+3]+'\n'}
      }
    } else if (myObj.type=='checkbox'){
      if(args[i+2]==1&&myObj.checked==false){addErr=true}
      if(args[i+2]==2&&myObj.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
    } else if (myObj.type=='select-one'||myObj.type=='select-multiple'){
      if(args[i+2]==1&&myObj.selectedIndex/1==0){addErr=true}
    }else if (myObj.type=='textarea'){
      if(myV.lengthargs[i+1]){addErr=true}
    }
    if (addErr){myErr+='* '+args[i+3]+'\n'; addErr=false}
  }
  if (myErr!=''){alert('Les champs suivants sont obligatoires :\t\t\t\t\t\n\n'+myErr)}
  document.MM_returnValue = (myErr=='');
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// FUNCTION FILL FORM ATIPIC / LARS FORNELL DECEMBER 2008 COPYRIGHT V2.5
function checktable(x,error_mess,confirm_mess) {

	var mess 	= 0;

	for (var i=0;i<x.elements.length;i++)
	{


// CHECK FOR FIELDS WITH NUMBER, NAME THE ID WITH "num_" IN THE BEGINNING
		if (x.elements[i].id.match(/^num_/g)) {
			if (!x.elements[i].value.match(/[0-9]/g)) {
				mess = -1;
				x.elements[i].className = 'xlight';
			} else {
				x.elements[i].className = '';
			}
		 }

// CHECK FOR FIELDS WITH LESS THAN 2 CHARACTERS, NAME THE ID WITH "man_" IN THE BEGINNING

		if (x.elements[i].id.match(/^man_/g)) {
			if (x.elements[i].value.length < 2) {
				mess = -1;
				x.elements[i].className = 'xlight';
			} else {
				x.elements[i].className = '';
			}
		 }

// CHECK FOR SELECT FIELDS WITH THE VALUE 0, NAME THE ID WITH "mansel_" IN THE BEGINNING

		if (x.elements[i].id.match(/^mansel_/g)) {
			if (x.elements[i].value == 0) {
				mess = -1;
				x.elements[i].className = 'xlight';
			} else {
				x.elements[i].className = '';
			}
		 }

// CHECK FOR CHECKBOX FIELDS NI VALUE , NAME THE ID WITH "manchk_" IN THE BEGINNING

		if (x.elements[i].id.match(/^manchk_/g)) {
			if (!x.elements[i].checked) {
				mess = -1;
				document.getElementById(x.elements[i].name).className = 'achkf';
			} else {
				document.getElementById(x.elements[i].name).className = '';
			}
		 }

// CHECK FOR VALID EMAIL, NAME THE ID WITH "email_" IN THE BEGINNING

		if (x.elements[i].id.match(/^email_/g)) {
			if (!x.elements[i].value.match("^[\\w\.=-]+@[\\w\\.-]+\\.[a-zA-Z]{2,4}$")) {

				mess = -1;
				x.elements[i].className = 'xlight';
			} else {
				x.elements[i].className = '';
			}
		 }

// CHECK FOR FIELDS WITH THE VALID DATE VALUES, NAME THE ID WITH "date_" IN THE BEGINNING

		if (x.elements[i].id.match(/^date_/g)) {
	
	//	Match String for 4 digit year
	//	<< /(([1-9])|([1-3][0-9]))\/(([1-9])|(1[0-2]))\/[1-9]\d{3}/ >>
	//	Match String for 2 digit year
	//	<< /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/ >>
	
	
			if (!x.elements[i].value.match(/^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/)) {
				mess = -1;
				x.elements[i].className = 'xlight';
			} else {
				var datex = x.elements[i].value.split("/");
				var xndate = new Date(20 + datex[2],datex[1] - 1,datex[0]);
	
				if ( (xndate.getDate() == datex[0]) && (xndate.getMonth() == (datex[1] - 1)) ) {
					x.elements[i].className = '';
				} else {
					mess = -1;
					x.elements[i].className = 'xlight';			
				}
			}
		 }


	}

	if (mess) {
		alert(error_mess);

		return false;
	} else {
		if (confirm_mess != '') {
			if (confirm(confirm_mess)) {
				return true;
			} else {
				return false;
			}
		} else {
			return true;
		}
	}
}

function GP_popupConfirmMsg(msg) { //v1.0
  document.MM_returnValue = confirm(msg);
}


// FUNCTION FILL FORM ATIPIC / LARS FORNELL JUIN 2005 COPYRIGHT V1.1
function fillnumber(xLine,xRange,xName,xType) {
	var xelement;
	var xGelement = xName + '_' + xLine + '_0';
	for (var i=1;i<xRange;i++) {
		xelement = xName + '_' + xLine + '_' + i;

		if (xType == 1) {
			document.getElementById(xelement).value = document.getElementById(xGelement).value;
		} else if (xType == 2) {

			if (document.getElementById(xGelement).checked == true) {
				document.getElementById(xelement).checked = true;
			} else {
				document.getElementById(xelement).checked = false;
			}
		}


	}
}

///fillnumberDown(2,74,7,'hh',1);
// FUNCTION FILL FORM ATIPIC / LARS FORNELL JUIN 2005 COPYRIGHT V1.1
function fillnumberDown(xLine,xRange,xStep,xPos,xName) {
	var xelement;
	var xGelement;
	
	for (var i = xStep + xPos; i < xRange + xPos;) {
	
		for (var j = 0; j < xLine; j++) {

			xGelement = xName + '_' + j + '_' + xPos;
							
			xelement = xName + '_' + j + '_' + i;
	
			document.getElementById(xelement).value = document.getElementById(xGelement).value;
		}
		
		i = i + xStep;

	}
}


function xUupdateSelect(cal) {
	var date = cal.date;
	var selectMonth = document.getElementById("o_m");
	selectMonth.selectedIndex = date.getMonth();
	var selectDay = document.getElementById("o_d");
	selectDay.selectedIndex = (date.getDate() - 1);
	var selectYear = document.getElementById("o_y");
	selectYear.selectedIndex = (date.getFullYear() - today.getFullYear());
}

function xIupdateSelect(cal) {
	var date = cal.date;
	var selectMonth = document.getElementById("i_m");
	selectMonth.selectedIndex = date.getMonth();
	var selectDay = document.getElementById("i_d");
	selectDay.selectedIndex = (date.getDate() - 1);
	var selectYear = document.getElementById("i_y");
	selectYear.selectedIndex = (date.getFullYear() - today.getFullYear());
}


var startDate;
var endDate;
var ONEDAY = 3600 * 24;

function disallowDateBefore(date) {
	date = date.getTime();
	if ((startDate != null) && (date < (startDate + ONEDAY))) {
		//start date can't be prior to end date
		return true; 
	} 
	var now = new Date().getTime();
	if (date < (now - ONEDAY)) {
		//start date can't be prior to today
		return true;
	}

	return false;
}

/* 
* Can't choose days before today or before the
* start date
*/
function disallowDateAfter(date) {
	date = date.getTime();
	if ((endDate != null) && (date > (endDate - ONEDAY))) {
		//end date can't be before start date
		return true;
	} 

	var now = new Date().getTime();
	if (date < (now - ONEDAY)) {
		//end date can't be prior to today
		return true;
	}
	return false;
}

// FUNCTION SEND DATE TO CALENDER / LARS FORNELL NOVEMBRE 2005 COPYRIGHT V1.0
function xUSel(x) {
	x.xo_date.value = x.o_y.value + '-' + x.o_m.value + '-' + x.o_d.value;
	x.xi_date.value = x.i_y.value + '-' + x.i_m.value + '-' + x.i_d.value;
}



// FUNCTION COUNTRY PREFIX ATIPIC / LARS FORNELL NOVEMBRE 2005 COPYRIGHT V1.0
function country_code(x) {

	if ( ((x.mobile_touched.value == 0) || (x.mobile.value == '')) && (x.id_country.value != '0')) {

		var xid_country = x.id_country.value;
		var cust_array = xid_country.split('|');

		x.mobile.value = '+' + cust_array[1];

	}

}

function touched(x) {
	if (x.mobile.value != '') {
		x.mobile_touched.value = 1;
	} else {
		x.mobile_touched.value = 0;
	}	
}




// FUNCTION FILL FORM ATIPIC / LARS FORNELL JUIN 2005 COPYRIGHT V1.1
function fillnumber(xLine,xRange,xName,xType) {
	var xelement;
	var xGelement = xName + '_' + xLine + '_0';
	for (var i=1;i<xRange;i++) {
		xelement = xName + '_' + xLine + '_' + i;

		if (xType == 1) {
			document.getElementById(xelement).value = document.getElementById(xGelement).value;
		} else if (xType == 2) {

			if (document.getElementById(xGelement).checked == true) {
				document.getElementById(xelement).checked = true;
			} else {
				document.getElementById(xelement).checked = false;
			}
		}


	}
}

function xDFupdateSelect(cal) {
	var date = cal.date;
	var selectMonth = document.getElementById("df_m");
	selectMonth.selectedIndex = date.getMonth();
	var selectDay = document.getElementById("df_d");
	selectDay.selectedIndex = (date.getDate() - 1);
	var selectYear = document.getElementById("df_y");
	selectYear.selectedIndex = (date.getFullYear() - 2001);
}

function xDTupdateSelect(cal) {
	var date = cal.date;
	var selectMonth = document.getElementById("dt_m");
	selectMonth.selectedIndex = date.getMonth();
	var selectDay = document.getElementById("dt_d");
	selectDay.selectedIndex = (date.getDate() - 1);
	var selectYear = document.getElementById("dt_y");
	selectYear.selectedIndex = (date.getFullYear() - 2001);
}


// FUNCTION SEND DATE TO CALENDER / LARS FORNELL NOVEMBRE 2005 COPYRIGHT V1.0
function xDUSel(x) {
	x.xdf_date.value = x.df_y.value + '-' + x.df_m.value + '-' + x.df_d.value;
	x.xdt_date.value = x.dt_y.value + '-' + x.dt_m.value + '-' + x.dt_d.value;
}


function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		booking_enq011 = newImage("gfx_dev/booking_enq-11.gif");
		callback013 = newImage("gfx_dev/callback-13.gif");
		yourbooking017 = newImage("gfx_dev/yourbooking-17.gif");
		book_now019 = newImage("gfx_dev/book_now-19.gif");
		contact_us021 = newImage("gfx_dev/contact_us-21.gif");
		preloadFlag = true;
	}
}




function xswitch(id_logement,dispo_date) {

	var datex 	= dispo_date.split("/");
	var xndate	= new Date(datex[2],datex[1] - 1,datex[0]);
	var formdate	= leadingZero(xndate.getDate()) + '-' + leadingZero(xndate.getMonth() + 1) + '-' + xndate.getFullYear();

	var dispo	= document.getElementById('d' + formdate).value;

	// MAJ PRIX
	var prix	= document.getElementById('p' + getWeek(xndate) + '_' + (xndate.getMonth() + 1) + '_' + xndate.getFullYear()).value;
	var prix_promo	= document.getElementById('pp' + getWeek(xndate) + '_' + (xndate.getMonth() + 1) + '_' + xndate.getFullYear()).value;

// dispo = 2 EMPTY
// dispo = 1 DISPO
// dispo = 0 NOT DISPO

	if (dispo == 1) {
		document.getElementById('d' + formdate).value = 0;
		document.getElementById('c' + formdate).className = 'nodispo';
		dispo = 4;
	} else {
		document.getElementById('d' + formdate).value = 1;
		document.getElementById('c' + formdate).className = 'dispo';

		if (dispo == 0) {
			dispo = 1;
		}
	}

	
	var div = document.getElementById('wait_container');
	
	div.innerHTML = '<img src=\"../images/rel_interstitial_loading.gif\" />';
	
	var handleSuccess = function(o){
	
		if(o.responseText !== undefined){

			div.innerHTML = '';	
			}
		}
	var handleFailure = function(o){if(o.responseText !== undefined){}}
	var callback ={ success:handleSuccess, failure: handleFailure, argument: { }};


   	var request = YAHOO.util.Connect.asyncRequest('GET', '../inc/dispo_ajax.asp?id_logement=' + id_logement + '&dispo_date=' + dispo_date + '&dispo=' + dispo + '&prix=' + prix + '&prix_promo=' + prix_promo, callback);	

}




function xAddMonth(id_logement,dispo_date) {

	var datex	= dispo_date.split("/");
	var xndate	= new Date(datex[2],datex[1] - 1,datex[0]);

	var xDate	= new Date(xndate.getFullYear(),xndate.getMonth() + 1,xndate.getDate());
	xDate		= new Date(xDate.getFullYear(),xDate.getMonth(),xDate.getDate() - 1);
	var formdate	= "";


	for (var i=0;i<xDate.getDate();i++) {
	
		formdate = leadingZero(xndate.getDate() + i) + '-' + leadingZero(xndate.getMonth() + 1) + '-' + xndate.getFullYear();
	
		document.getElementById('d' + formdate).value = 1;
		document.getElementById('c' + formdate).className = 'dispo';
	}

	// MAJ PRIX

	var prix	= document.getElementById('p' + getWeek(xndate) + '_' + (xndate.getMonth() + 1) + '_' + xndate.getFullYear()).value;
	var prix_promo	= document.getElementById('pp' + getWeek(xndate) + '_' + (xndate.getMonth() + 1) + '_' + xndate.getFullYear()).value;

	xDate = xndate;

	var GoExit	= false;
	var xCmonth	= xndate.getMonth() + 1
	do
	{
		document.getElementById('p' + getWeek(xDate) + '_' + (xDate.getMonth() + 1) + '_' + xDate.getFullYear()).value	= prix;
		document.getElementById('pp' + getWeek(xDate) + '_' + (xDate.getMonth() + 1) + '_' + xDate.getFullYear()).value	= prix_promo;
				
		xDate.setDate(xDate.getDate() + 7); 
		
		if ((xDate.getMonth() + 1) != xCmonth) { // NEXT MONTH
			GoExit = true;
		}
	}
	while (!GoExit);



	var div = document.getElementById('wait_container');
	
	div.innerHTML = '<img src=\"../images/rel_interstitial_loading.gif\" />';
	
	var handleSuccess = function(o){
	
		if(o.responseText !== undefined){

			div.innerHTML = '';	
			}
		}
	var handleFailure = function(o){if(o.responseText !== undefined){}}
	var callback ={ success:handleSuccess, failure: handleFailure, argument: { }};


   	var request = YAHOO.util.Connect.asyncRequest('GET', '../inc/dispo_ajax.asp?id_logement=' + id_logement + '&dispo_date=' + dispo_date + '&dispo=3&prix=' + prix + '&prix_promo=' + prix_promo, callback);	

}



function xdelweek(id_logement,dispo_date) {

	var datex = dispo_date.split("/");
	var xndate = new Date(datex[2],datex[1] - 1,datex[0]);

	var formdate = "";
	var GoExit = false;

	// METTRE PRIX A ZERO
	document.getElementById('p' + getWeek(xndate) + '_' + (xndate.getMonth() + 1) + '_' + xndate.getFullYear()).value	= 0;
	document.getElementById('pp' + getWeek(xndate) + '_' + (xndate.getMonth() + 1) + '_' + xndate.getFullYear()).value	= 0;
	
	do
	{
		if (xndate.getDay() == 0) { // DIMANCHE
			GoExit = true;
		}
	
		formdate = leadingZero(xndate.getDate()) + '-' + leadingZero(xndate.getMonth() + 1) + '-' + xndate.getFullYear();
	
		document.getElementById('d' + formdate).value = 0;
	
		// POUR FERIER ET WEEKEND
		if (document.getElementById('w' + formdate).value == 1) {
			document.getElementById('c' + formdate).className = 'dayF'
		} else {
			document.getElementById('c' + formdate).className = 'day'
		}

		xndate.setDate(xndate.getDate() + 1); 
	}
	while (!GoExit);

	
	
	var div = document.getElementById('wait_container');
	
	div.innerHTML = '<img src=\"../images/rel_interstitial_loading.gif\" />';
	
	var handleSuccess = function(o){
	
		if(o.responseText !== undefined){

			div.innerHTML = '';	
			}
		}
	var handleFailure = function(o){if(o.responseText !== undefined){}}
	var callback ={ success:handleSuccess, failure: handleFailure, argument: { }};


   	var request = YAHOO.util.Connect.asyncRequest('GET', '../inc/dispo_ajax.asp?id_logement=' + id_logement + '&dispo_date=' + dispo_date + '&dispo=0&prix=0&prix_promo=0', callback);	

}

function leadingZero(nr)
{
	if (nr < 10) nr = "0" + nr;
	return nr;
}



function getWeek(xndate) {
	var newYear = new Date(xndate.getFullYear(),0,1);
	var day = newYear.getDay() - 1; //the day of week the year begins on
	day = (day >= 0 ? day : day + 7);
	var daynum = Math.floor((xndate.getTime() - newYear.getTime() - 
	(xndate.getTimezoneOffset()-newYear.getTimezoneOffset())*60000)/86400000) + 1;
	var weeknum;
	
	//if the year starts before the middle of a week
	if(day < 4) {
		weeknum = Math.floor((daynum+day-1)/7) + 1;
			if(weeknum > 52) {
			nYear = new Date(xndate.getFullYear() + 1,0,1);
			nday = nYear.getDay() - 1;
			nday = nday >= 0 ? nday : nday + 7;
			/*if the next year starts before the middle of
			the week, it is week #1 of that year*/
			weeknum = nday < 4 ? 1 : 53;
		}
	} else {
		weeknum = Math.floor((daynum+day-1)/7);
	}
	return weeknum;
}

function WriteError(Err_Description) {  // lars-gunnar.no	
	var handleSuccess = function(o){if(o.responseText !== undefined){}}
	var handleFailure = function(o){if(o.responseText !== undefined){}}
	var callback ={ success:handleSuccess, failure: handleFailure, argument: { }};
   	var request = YAHOO.util.Connect.asyncRequest('GET', '../inc/error_ajax.asp?Err_Description=' + Err_Description, callback);		
} 

function xFact_Livr(x) {

	if (x.livraison.checked) {
		x.adresse_livr.value	= x.adresse_fact.value;
		x.cp_livr.value		= x.cp_fact.value;
		x.ville_livr.value	= x.ville_fact.value;
		x.id_pays_livr.value	= x.id_pays_fact.value;
	} else {
		x.adresse_livr.value	= '';
		x.cp_livr.value		= '';
		x.ville_livr.value	= '';
		x.id_pays_livr.value	= 0;
	}
}	
