var weekdays_sunday="Su";
var weekdays_monday="Mo";
var weekdays_tuesday="Tu";
var weekdays_wednesday="We";
var weekdays_thursday="Th";
var weekdays_friday="Fr";
var weekdays_saturday="Sa";
var albamonthname=new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
var today_day="Today";
var numberNights = 2;
var numberYears = 3;
var imgDir = "/media/";
var departDateUpdate = 1;
var wdArray = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
var aNumDays = new Array (31,0,31,30,31,30,31,31,30,31,30,31);
function calendarCallback(day, month, year, objName, formName) {
if(objName == "calendarArrive"){
document.forms[formName].arrival_day.selectedIndex = day-1;
document.forms[formName].from_mon.selectedIndex = month-1;
document.forms[formName].arrival_year.selectedIndex = year - document.forms[formName].arrival_year.options[0].text;
updateDates(document.forms[formName]);
}else{  //objName == calendarDepart
document.forms[formName].departure_day.selectedIndex = day-1;
document.forms[formName].departure_month.selectedIndex = month-1;
document.forms[formName].departure_year.selectedIndex = year - document.forms[formName].departure_year.options[0].text;
}
}
function updateDates(form) {
//check Leap Year
if(form.from_mon.selectedIndex==1)  {
var leapYear  = new Date (form.arrival_year.options[form.arrival_year.selectedIndex].text,form.from_mon.selectedIndex+1,1);
var leapYear  = new Date (leapYear  - (24*60*60*1000));
var numDaysInMonth = leapYear.getDate();
}else{
var numDaysInMonth = aNumDays[form.from_mon.selectedIndex];
}
// Update departure date only when loading the form and/or departDateUpdate is set to 1
if(departDateUpdate == 1) {
var selectDate = new Date(form.arrival_year.options[form.arrival_year.selectedIndex].text, form.from_mon.selectedIndex, form.arrival_day.selectedIndex);
var setDate = new Date(selectDate.getTime() + ((numberNights+1) * 86400000));
var setDay = setDate.getDate();
var setMonth = setDate.getMonth();
var setYear = setDate.getFullYear() - form.arrival_year.options[0].text;
var checkinDate = new Date(form.arrival_year.options[form.arrival_year.selectedIndex].text,form.from_mon.selectedIndex,form.arrival_day.selectedIndex+1);
var checkoutDate = new Date(form.departure_year.options[form.departure_year.selectedIndex].text,form.departure_month.selectedIndex,form.departure_day.selectedIndex+1);
if(setYear == form.departure_year.length) {
form.departure_day.options[30].selected=1;
form.departure_month.options[11].selected=1;
form.departure_year.options[form.departure_year.length-1].selected=1;
} else {
form.departure_day.options[setDay-1].selected=1;
form.departure_month.options[setMonth].selected=1;
form.departure_year.options[setYear].selected=1;
}
}
}