// Calendar functions //

function UpdateFromDrop(){
	month=document.getElementById("arriving_month").value
	//MonthYearSplit = month.split(',');
	//document.getElementById("month").value=MonthYearSplit[0]
	//document.getElementById("year").value=MonthYearSplit[1]
}
function updateSelect(cal) {
	var date = cal.date;
	SetToday(date);
	UpdateFromDrop();
}
function y2k(number) { return (number < 1000) ? number + 1900 : number; }
function SetToday(date){
	day="00"+date.getDate()+""; mon="00"+(date.getMonth()+1*1)+""; year=(y2k(date.getYear()))+"";
	Tdate = day.substring(day.length-2,4)+"/"+mon.substring(mon.length-2,4)+"/"+year.substring(year.length-4,4)
	document.getElementById("date").value=Tdate
	//update dropdowns//
	var selectMonth = document.getElementById("arriveMonth");
	selectMonth.selectedIndex = date.getMonth();
	var selectDay = document.getElementById("arriveDate");
	selectDay.selectedIndex = (date.getDate() - 1);
	var selectYear = document.getElementById("arriveYear");
	selectYear.selectedIndex = (date.getFullYear() - 2007);
}

  Calendar.setup(
    {
		inputField  :	"date",         // ID of the input field
		ifFormat    :	"%d/%m/%y",    // the date format
		button      :	"trigger_cal",       // ID of the button
		onUpdate	:	updateSelect,
		showsTime	:	false      //don't show time, only date
    }
  );




