function Calendar_initialize(h, a, l, e, c, f, d, m, j, n, o, k, i) { var b = "smBuscadores.ELEGIR_FECHA"; Init_Localizations(); var g = $("." + l + ":first")[0]; addCalendar(h + "_1", b, c, e, a, null, k, g); addCalendar(h + "_2", b, d, f, a, null, i, g); setWidth(90, 15, 1); updateDateCombos_OnChange(a, e, c, f, d, m, j, n, o) } function getDateFromCombos(a, b) { if (a.selectedIndex == 0 && b.selectedIndex > 0) a.selectedIndex = 1; var d = NaN, g = a.options[a.selectedIndex].value, c = b.options[b.selectedIndex].value.split("-"), e = c[0], f = c[1]; if (a.selectedIndex > 0 && b.selectedIndex > 0) d = new Date(f, e - 1, g); return d } function adaptahasta(form, arvl_day, arvl_mnthyr, dprt_day, dprt_mnthyr, txtArrival, txtDeparture) { var comboDayIni = eval("document." + form + "." + arvl_day), comboMonthYearIni = eval("document." + form + "." + arvl_mnthyr), comboDayEnd = eval("document." + form + "." + dprt_day), comboMonthYearEnd = eval("document." + form + "." + dprt_mnthyr), today = new Date; today = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 0, 0, 0); var dFrom = getDateFromCombos(comboDayIni, comboMonthYearIni), dTo = getDateFromCombos(comboDayEnd, comboMonthYearEnd); if (!isNaN(dFrom)) { if (dFrom < today) dFrom = today; loadDate(DateAdd(dFrom.getDate(), dFrom.getMonth(), dFrom.getFullYear(), 0, 0, 0), comboDayIni, comboMonthYearIni, txtArrival); if (isNaN(dTo) || dFrom >= dTo) { loadDate(DateAdd(dFrom.getDate(), dFrom.getMonth(), dFrom.getFullYear(), 1, 0, 0), comboDayEnd, comboMonthYearEnd, txtDeparture); dTo = getDateFromCombos(comboDayEnd, comboMonthYearEnd) } } if (!isNaN(dTo) && dTo <= today) { loadDate(DateAdd(today.getDate(), today.getMonth(), today.getFullYear(), 1, 0, 0), comboDayEnd, comboMonthYearEnd, txtDeparture); dTo = getDateFromCombos(comboDayEnd, comboMonthYearEnd) } var dFrom2 = NaN; if (!isNaN(dFrom)) dFrom2 = dFrom.getTime() + 54432e5; if (!isNaN(dTo) && dTo > today) datePrevious = dTo; else datePrevious = NaN } function update_nights(tr_nights, lbl_nights, form, arvl_day, arvl_mnthyr, dprt_day, dprt_mnthyr) { var comboDayIni = eval("document." + form + "." + arvl_day), comboMonthYearIni = eval("document." + form + "." + arvl_mnthyr), comboDayEnd = eval("document." + form + "." + dprt_day), comboMonthYearEnd = eval("document." + form + "." + dprt_mnthyr), trNights = document.getElementById(tr_nights), lblNights = document.getElementById(lbl_nights), arvlx_monthyear = comboMonthYearIni.value.split("-"), dprtx_monthyear = comboMonthYearEnd.value.split("-"), n_nights = subtractDates(comboDayIni.value, arvlx_monthyear[0], arvlx_monthyear[1], comboDayEnd.value, dprtx_monthyear[0], dprtx_monthyear[1]); if (n_nights > 0) { trNights.style.display = ""; lblNights.innerHTML = n_nights + " " + set_nights_text(n_nights); lblNights.style.visibility = "visible" } else { trNights.style.display = "none"; lblNights.innerHTML = ""; lblNights.style.visibility = "hidden" } } function fixPreviousDate(form, dprt_day, dprt_mnthyr) { var comboDayEnd = eval("document." + form + "." + dprt_day), comboMonthYearEnd = eval("document." + form + "." + dprt_mnthyr), day = comboDayEnd.options[comboDayEnd.selectedIndex].value, mnthyr = comboMonthYearEnd.options[comboMonthYearEnd.selectedIndex].value.split("-"), mnth = mnthyr[0], year = mnthyr[1]; if (day != "" && mnthyr != "") datePrevious = new Date(year, mnth - 1, day) } function updateDateCombos_OnFocus(a, c, b, e, d, i, g, j, k, h, f) { adaptahasta(a, c, b, e, d, h, f); update_nights(i, g, a, c, b, e, d); printLayerWeekDay(j, a, b, c); correctDate2(a, c, b); printLayerWeekDay(k, a, d, e) } function updateDateCombos_OnChange(a, c, b, e, d, i, g, j, k, h, f) { adaptahasta(a, c, b, e, d, h, f); update_nights(i, g, a, c, b, e, d); printLayerWeekDay(j, a, b, c); correctDate2(a, c, b); printLayerWeekDay(k, a, d, e) } function validateDateForm() { (!validateCombos() || !validateDates()) && clearFields(); submitForm() } function validateDateForm_NoSubmit() { combosOK = validateCombos(); datesOK = validateDates(); !(combosOK && datesOK) && clearFields(); datesOK && submitForm() } function validateCombos() { return document.searchForm.arvl_day.value != "" && document.searchForm.arvl_mnthyr.value != "" && document.searchForm.dprt_day.value != "" && document.searchForm.dprt_mnthyr.value != "" ? true : false } function validateDates() { var a = validateDate(today); if (document.all) event.returnValue = a; return a } function clearFields() { document.searchForm.dia_en.value = ""; document.searchForm.mes_en.value = ""; document.searchForm.anyo_en.value = ""; document.searchForm.dia_sa.value = ""; document.searchForm.mes_sa.value = ""; document.searchForm.anyo_sa.value = "" } function submitForm() { document.searchForm.submit() } function loadDateSession() { var a = "", b = false, f = a, c = a, e = a; if (f != a && c != a && e != a) { var g = a, h = a, d = a; if (g != a && h != a && d != a) { loadDate(DateAdd(new Number(f), new Number(c) - 1, new Number(e), 0, 0, 0), document.searchForm.arvl_day, document.searchForm.arvl_mnthyr); loadDate(DateAdd(new Number(g), new Number(h) - 1, new Number(d), 0, 0, 0), document.searchForm.dprt_day, document.searchForm.dprt_mnthyr); b = true } } return b } function cargarFechasServidor() { day = new Number("20"); mnth = new Number("3") - 1; anio = new Number("2007"); loadDate(DateAdd(day, mnth, anio, 0, 0, 0), document.searchForm.arvl_day, document.searchForm.arvl_mnthyr); loadDate(DateAdd(day, mnth, anio, 1, 0, 0), document.searchForm.dprt_day, document.searchForm.dprt_mnthyr) } function validateForm() { if (document.searchForm.areatwo.value == "") { var c = "4317;4368;4750;4838", b = c.split(";"), a = false; for (i = 0; i < b.length && !a; i++) if (document.searchForm.areaone.options[document.searchForm.areaone.selectedIndex].value == b[i]) a = true; if (a) { alert("Please select the destination you would like to search"); return } } validateDateForm_NoSubmit() } function correctDate2(form_name, day_field, month_year_field) { var comboDay = eval("document." + form_name + "." + day_field), comboMnth = eval("document." + form_name + "." + month_year_field), day = comboDay.options[comboDay.selectedIndex].value, date_comp = comboMnth.options[comboMnth.selectedIndex].value.split("-"), month = date_comp[0] - 1, year = date_comp[1]; if (day != "" && month != "" && year != "" && month != "-1") { for (var optionDayZero = 0, i = 0; i < comboDay.length; i++) if (comboDay.options[i].value == "") optionDayZero++; for (var optionMnthZero = 0, j = 0; j < comboMnth.length; j++) if (comboMnth.options[j].value == "") optionMnthZero++; var a_date = new Date(year, month, day); day = a_date.getDate(); month = a_date.getMonth() + 1; year = a_date.getFullYear(); var mesanyo = month + "-" + year; eval("document." + form_name + "." + day_field + ".selectedIndex = " + (day - 1 + optionDayZero)); for (var j = 0; j < comboMnth.length; j++) { var temp = comboMnth.options[j].value.split("-"); if (month == temp[0] && year == temp[1]) { eval("document." + form_name + "." + month_year_field + ".selectedIndex = " + j); return } } } } function selectData(a, c) { try { for (var b = 0; b < a.length; b++) if (a.options[b].value == c) { a.options[b].selected = true; $(a); break } } catch (d) { } } function loadDate(d, b, a, c) { loadDateSeparator(d, b, a, "/", c) } function loadDateSeparator(a, d, b, c, e) { var a = a.split(c); selectData(d, a[0]); selectData(b, "" + a[1] + "-" + a[2]); $("#" + e).val(a[0] + "-" + a[1] + "-" + a[2]) } function subtractDates(j, h, i, g, e, f) { var d = new Date(h + "/" + j + "/" + i), c = new Date(e + "/" + g + "/" + f), a = c.getTime() - d.getTime(), b = Math.round(a / 864e5); return b };