function affCalendar(chps)
{
	urlCalendar = "";
	document.getElementById("calendardu").style.visibility = 'hidden';
	document.getElementById("calendardu").innerHTML = "";
	//document.getElementById("calendarau").style.visibility = 'hidden';
	//document.getElementById("calendarau").innerHTML = "";
	if(document.getElementById("du"))
	{
		if(document.getElementById("du").value != " jj/mm/aaaa" && document.getElementById("du").value != "")
		{
			urlCalendar = "/_includes/asp/calendar.asp?chps="+chps+"&dateLimite="+document.getElementById("du").value;
		}else{
			urlCalendar = "/_includes/asp/calendar.asp?chps="+chps;
		}
	}else{
		urlCalendar = "/_includes/asp/calendar.asp?chps="+chps;
	}
	//alert(urlCalendar);
	loadPage(urlCalendar,'calendar'+chps);
}

function select_date(dat,cible){
	document.getElementById(cible).value=dat;
	document.getElementById("calendar"+cible).style.visibility = 'hidden';
	document.getElementById("calendar"+cible).innerHTML = "";
}

function closeCalendar(cible)
{
	document.getElementById("calendar"+cible).style.visibility = 'hidden';
	document.getElementById("calendar"+cible).innerHTML = "";
}

function validFormCalendar(chps)
{
	loadPage("/_includes/asp/calendar.asp?chps="+chps+"&START_MONTH="+document.getElementById("START_MONTH").options[document.getElementById("START_MONTH").selectedIndex].value+"&START_YEAR="+document.getElementById("START_YEAR").options[document.getElementById("START_YEAR").selectedIndex].value,"calendar"+chps);
}

function loadPage(url,cible)
{
	//Changement du contenu
	var xhr_object = null; 
	document.getElementById(cible).innerHTML = 'Loading...';
	document.getElementById(cible).style.visibility = 'visible';
	//document.getElementById(cible).innerHTML = "";
 
	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; 
	} 
 
	xhr_object.open("GET", url, true);
	
	xhr_object.onreadystatechange = function() 
	{ 
	   if(xhr_object.readyState == 4)
	   {
	   		document.getElementById(cible).innerHTML = xhr_object.responseText;
			document.getElementById(cible).style.visibility = 'visible';
		}
	} 
	 
	xhr_object.send(null); 
}

function validRechMotResa()
{
	msgalertMot = ""

	if (document.getElementById("du").value == "")
	{
		msgalertMot = msgalertMot + "- Arrival date\n"
	}else{
		
		var tabMonth=new Array;
		tabMonth[0] = "01";
		tabMonth[1] = "02";
		tabMonth[2] = "03";
		tabMonth[3] = "04";
		tabMonth[4] = "05";
		tabMonth[5] = "06";
		tabMonth[6] = "07";
		tabMonth[7] = "08";
		tabMonth[8] = "09";
		tabMonth[9] = "10";
		tabMonth[10] = "11";
		tabMonth[11] = "12";		
		
		jourResa = document.getElementById("du").value		
		dateJour = new Date();
		heureJour = dateJour.getHours()+"."+dateJour.getMinutes()+dateJour.getSeconds();
		valJour =dateJour.getDate()+"/"+tabMonth[dateJour.getMonth()]+"/"+dateJour.getFullYear();
		if(valJour.length == 9)
		{
			valJour = "0"+valJour	
		}
		if (jourResa == valJour  && heureJour >16)
		{
			msgalertMot2 = "If you want to make a booking for the same day you do need to make your reservation before 4.00 PM (local time of the hotel).\n Should you wish to book your room after this deadline, please ring the hotel.\n"
		}
		jourTest = getDate(jourResa);
				
		if (jourTest < dateJour)
		{
			msgalertMot = "- Arrival date (dd/mm/yyyy)\n";
		}
	}
	
	if (document.getElementById("nb_nuit").value == "")
	{
		msgalertMot = msgalertMot + "- Number of night \n"
	}
	
	if (document.getElementById("nb_pers").value == "")
	{
		msgalertMot = msgalertMot + "- Number of person(s)\n"
	}
	
	if(msgalertMot != "")
	{
		msgalertMot = "Field empty :\n"+msgalertMot
		alert(msgalertMot)
		return false;
	}
	else
	{
		return true;
	}
}

function choixMois(id_chb,nb_nuit,nb_pers){
	window.open('/popup_pack.asp?id_chb='+id_chb+'&nb_nuit='+nb_nuit+'&nb_pers='+nb_pers,'','resizable=no,location=no, width=320, height=200, menubar=no, status=no, scrollbars=yes, menubar=no, top=125, left=150');
}

function getDate(strDate)
{	  
	day = strDate.substring(0,2);
	month = strDate.substring(3,5);
	year = strDate.substring(6,10);
	d = new Date(0);
	d.setDate(day);
	d.setMonth(month-1);
	d.setFullYear(year); 
	return d;  
  }