var MONTHS_SHORT2 = ["January", "February", "March", "April", "May", "June","July", "August", "September", "October", "November", "December"]; var MONTHS_DAYS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31]; function hotel_setArrival(date, fullmonth) { today = '2024-04-27'; if (date < today) { date = today; } year = date.charAt(0) + date.charAt(1) + date.charAt(2) + date.charAt(3); month = date.charAt(5) + date.charAt(6); day = date.charAt(8) + '' + date.charAt(9); if (day > MONTHS_DAYS[month-1]) day = MONTHS_DAYS[month-1]; //nagy dátum beállítása myarr_date = document.getElementById("hotel_arr_date"); myarr_date.value = day + '-' + month + '-' + year; myarr_day = document.getElementById("hotel_arr_day"); for (i=0;i<31;i++) { myarr_day.options[i]=null; } for (i=0;i 12) { aktmonth = 1*i-12; aktyear = 1*globalyear+1; } if (i > 24) { aktmonth = 1*i-24; aktyear = 1*globalyear+2; } if ((aktmonth == month) && (aktyear == year)) selectedmonth = j; myarr_month.options[j]=null; myarr_month.options[j]=new Option(MONTHS_SHORT2[1*aktmonth-1] + ' '+ aktyear,aktyear + ''+ aktmonth); j++; } myarr_month.options[selectedmonth].selected=true; } function hotel_setDeparture(date, fullmonth) { today = '2024-04-28'; if (date < today) { date = today; } //alert(date); year = date.charAt(0) + date.charAt(1) + date.charAt(2) + date.charAt(3); month = date.charAt(5) + date.charAt(6); day = date.charAt(8) + '' + date.charAt(9); if (day > MONTHS_DAYS[month-1]) day = MONTHS_DAYS[month-1]; //nagy dátum beállítása mydep_date = document.getElementById("hotel_dep_date"); mydep_date.value = day + '-' + month + '-' + year; mydep_day = document.getElementById("hotel_dep_day"); for (i=0;i<31;i++) { mydep_day.options[i]=null; } for (i=0;i<1*fullmonth;i++) { mydep_day.options[i]=new Option(1*i+1,1*i+1); } mydep_day.options[day-1].selected=true; mydep_month = document.getElementById("hotel_dep_month"); j = 0; globalmonth = 04; globalyear = 2024; for (i=globalmonth;i<1*globalmonth+12;i++) { aktmonth = i; aktyear = globalyear; if (i > 12) { aktmonth = 1*i-12; aktyear = 1*globalyear+1; } if (i > 24) { aktmonth = 1*i-24; aktyear = 1*globalyear+2; } //alert(aktyear); if ((aktmonth == month) && (aktyear == year)) selectedmonth = j; mydep_month.options[j]=null; mydep_month.options[j]=new Option(MONTHS_SHORT2[aktmonth-1] + ' '+ aktyear,aktyear + ''+ aktmonth); j++; } mydep_month.options[selectedmonth].selected=true; } function hotel_changeArrDate() { myarr_day = document.getElementById("hotel_arr_day"); myarr_month = document.getElementById("hotel_arr_month"); myarr_month_text = myarr_month.options[myarr_month.selectedIndex].value; day = myarr_day.options[myarr_day.selectedIndex].value; year = myarr_month_text.charAt(0) + myarr_month_text.charAt(1) + myarr_month_text.charAt(2) + myarr_month_text.charAt(3); month = myarr_month_text.charAt(4) + myarr_month_text.charAt(5); //biztosan frissiteni kell az érkezést arrdate = year; if (month < 10) { arrdate = arrdate + '-0' + month; } else { arrdate = arrdate + '-' + month; } if (day < 10) { arrdate = arrdate + '-0' + day; } else { arrdate = arrdate + '-' + day; } //alert(arrdate); globaldate = '2025-03-31'; globaldate2 = '2025-03-30'; globalday2 = '30'; if (globaldate == arrdate) { arrdate = globaldate2; arrday = globalday2; } hotel_setArrival(arrdate, MONTHS_DAYS[month-1]); day = myarr_day.options[myarr_day.selectedIndex].value; year = myarr_month_text.charAt(0) + myarr_month_text.charAt(1) + myarr_month_text.charAt(2) + myarr_month_text.charAt(3); month = myarr_month_text.charAt(4) + myarr_month_text.charAt(5); //csak akkor módosítjuk a távozás dátumát, ha az megelőzi az érkezést mydep_day = document.getElementById("hotel_dep_day"); mydep_month = document.getElementById("hotel_dep_month"); mydep_month_text = mydep_month.options[mydep_month.selectedIndex].value; depnowday = mydep_day.options[mydep_day.selectedIndex].value; depnowyear = mydep_month_text.charAt(0) + mydep_month_text.charAt(1) + mydep_month_text.charAt(2) + mydep_month_text.charAt(3); depnowmonth = mydep_month_text.charAt(4) + mydep_month_text.charAt(5); // alert(day +'<'+ depnowday); if (1*year < 1*depnowyear) return; if ((1*year == 1*depnowyear) && (1*month < 1*depnowmonth)) return; if ( (1*year == 1*depnowyear) && (1*month==1*depnowmonth) && (1*day < 1*depnowday)) return; //alert(year + '-' + month + '-' + day); depday = 1*day + 1; depmonth = month; depyear = year; if ( (month<12) && (MONTHS_DAYS[month-1] == day)) { //nem december és hónap vége van depday = 1; depmonth = 1*month+1; depyear = 1*year; } if ((month == 12) && (MONTHS_DAYS[month-1] == day)) { //december és hónap vége van depday = 1; depmonth = 1; depyear = 1*year + 1; } depdate = depyear; if (depmonth < 10) { depdate = depdate + '-0' + depmonth; } else { depdate = depdate + '-' + depmonth; } if (depday < 10) { depdate = depdate + '-0' + depday; } else { depdate = depdate + '-' + depday; } //alert(depdate); hotel_setDeparture(depdate, MONTHS_DAYS[depmonth-1]); } function hotel_changeDepDate() { myarr_day = document.getElementById("hotel_arr_day"); myarr_month = document.getElementById("hotel_arr_month"); myarr_month_text = myarr_month.options[myarr_month.selectedIndex].value; arrday = myarr_day.options[myarr_day.selectedIndex].value; arryear = myarr_month_text.charAt(0) + myarr_month_text.charAt(1) + myarr_month_text.charAt(2) + myarr_month_text.charAt(3); arrmonth = myarr_month_text.charAt(4) + myarr_month_text.charAt(5); mydep_day = document.getElementById("hotel_dep_day"); mydep_month = document.getElementById("hotel_dep_month"); mydep_month_text = mydep_month.options[mydep_month.selectedIndex].value; depday = mydep_day.options[mydep_day.selectedIndex].value; depyear = mydep_month_text.charAt(0) + mydep_month_text.charAt(1) + mydep_month_text.charAt(2) + mydep_month_text.charAt(3); depmonth = mydep_month_text.charAt(4) + mydep_month_text.charAt(5); //biztosan frissiteni kell az távozást depdate = depyear; if (depmonth < 10) { depdate = depdate + '-0' + 1*depmonth; } else { depdate = depdate + '-' + 1*depmonth; } if (depday < 10) { depdate = depdate + '-0' + 1*depday; } else { depdate = depdate + '-' + 1*depday; } //alert(depdate); globaldate = '2024-04-01'; globaldate2 = '2024-04-02'; if (globaldate == depdate) { depdate = globaldate2; depday = 2; } arrdate = arryear; if (arrmonth < 10) { arrdate = arrdate + '-0' + 1*arrmonth; } else { arrdate = arrdate + '-' + 1*arrmonth; } if (arrday < 10) { arrdate = arrdate + '-0' + 1*arrday; } else { arrdate = arrdate + '-' + 1*arrday; } hotel_setDeparture(depdate, MONTHS_DAYS[1*depmonth-1]); return; if (arrdate < depdate) return; //minden ok //változtatni kell az érkezést is sajna arrday = 1*depday - 1; arrmonth = depmonth; arryear = depyear; if ( (depmonth>0) && (depday == 1)) { //nem január és hónap eleje arrday = 31; //a beállíátsnál úgyis a hónap végére módosítja a függvény arrmonth = 1*depmonth-1; arryear = 1*depyear; } if ((month == 0) && (depday == 1)) { //január és hónap eleje van arrday = 31; arrmonth = 12; arryear = 1*depyear - 1; } arrdate = arryear; if (arrmonth < 10) { arrdate = arrdate + '-0' + 1*arrmonth; } else { arrdate = arrdate + '-' + 1*arrmonth; } if (arrday < 10) { arrdate = arrdate + '-0' + 1*arrday; } else { arrdate = arrdate + '-' + 1*arrday; } //alert(arrdate); hotel_setArrival(arrdate, MONTHS_DAYS[arrmonth-1]); } function hotel_checkDateValidity() { myarr_day = document.getElementById("hotel_arr_day"); myarr_month = document.getElementById("hotel_arr_month"); myarr_month_text = myarr_month.options[myarr_month.selectedIndex].value; arrday = myarr_day.options[myarr_day.selectedIndex].value; arryear = myarr_month_text.charAt(0) + myarr_month_text.charAt(1) + myarr_month_text.charAt(2) + myarr_month_text.charAt(3); arrmonth = myarr_month_text.charAt(4) + myarr_month_text.charAt(5); mydep_day = document.getElementById("hotel_dep_day"); mydep_month = document.getElementById("hotel_dep_month"); mydep_month_text = mydep_month.options[mydep_month.selectedIndex].value; depday = mydep_day.options[mydep_day.selectedIndex].value; depyear = mydep_month_text.charAt(0) + mydep_month_text.charAt(1) + mydep_month_text.charAt(2) + mydep_month_text.charAt(3); depmonth = mydep_month_text.charAt(4) + mydep_month_text.charAt(5); //biztosan frissiteni kell az távozást depdate = depyear; if (depmonth < 10) { depdate = depdate + '-0' + 1*depmonth; } else { depdate = depdate + '-' + 1*depmonth; } if (depday < 10) { depdate = depdate + '-0' + 1*depday; } else { depdate = depdate + '-' + 1*depday; } //alert(depdate); globaldate = '2024-04-01'; globaldate2 = '2024-04-02'; if (globaldate == depdate) { depdate = globaldate2; depday = 2; } arrdate = arryear; if (arrmonth < 10) { arrdate = arrdate + '-0' + 1*arrmonth; } else { arrdate = arrdate + '-' + 1*arrmonth; } if (arrday < 10) { arrdate = arrdate + '-0' + 1*arrday; } else { arrdate = arrdate + '-' + 1*arrday; } if (arrdate < depdate) return true; //minden ok return false; } var startDate; var endDate; var ONEDAY = 3600 * 24; function hotel_resetDates() { startDate = endDate = null; } function hotel_filterDates1(cal) { var date = cal.date; startDate = date.getTime() /* If they haven't chosen an end date before we'll set it to the same date as the start date This way if the user scrolls in the start date 5 months forward, they don't need to do it again for the end date. */ if (endDate == null) { Zapatec.Calendar.setup({ inputField : "arrivalDate", button : "button8b", // What will trigger the popup of the calendar ifFormat : "%b %d, %Y", date : startDate, showsTime : false, //no time dateStatusFunc : hotel_disallowDateBefore, //the function to call onUpdate : filterDates2 }); } } function hotel_filterDates2(cal) { var date = cal.date; endDate = date.getTime() } function hotel_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 hotel_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; } Zapatec.Calendar.setup({ firstDay : 1, inputField : "hotel_arr_date", // id of the input field button : "hotel_arr_button", // What will trigger the popup of the calendar ifFormat : "%d-%m-%Y", // format of the input field: Mar 18, 2005 showsTime : false, //no time dateStatusFunc : hotel_disallowDateAfter, //the function to call onUpdate : hotel_updateArr }); Zapatec.Calendar.setup({ firstDay : 1, inputField : "hotel_dep_date", button : "hotel_dep_button", // What will trigger the popup of the calendar ifFormat : "%d-%m-%Y", // format of the input field: Mar 18, 2005 showsTime : false, //no time dateStatusFunc : hotel_disallowDateBefore, //the function to call onUpdate : hotel_updateDep }); function hotel_updateArr(cal) { var date = cal.date; year = date.getFullYear(); month = date.getMonth() + 1; day = date.getDate(); if (month < 10) month = '0' + month; if (day < 10) day = '0'+day; fulldate = year + '-' + month + '-' + day; hotel_setArrival(fulldate, MONTHS_DAYS[date.getMonth()]); hotel_changeArrDate(); startDate = date.getTime(); } function hotel_updateDep(cal) { var date = cal.date; year = date.getFullYear(); month = date.getMonth() + 1; day = date.getDate(); if (month < 10) month = '0' + month; if (day < 10) day = '0'+day; fulldate = year + '-' + month + '-' + day; //alert(fulldate); hotel_setDeparture(fulldate, MONTHS_DAYS[date.getMonth()]); hotel_changeDepDate(); } function hotel_Reserv() { document.hotelbooking.action = "/booking/booking-1a.php"; if (hotel_checkDateValidity() == false) { alert('Your departure date has to be later than your arrival date. Please check your dates and try again!'); return false; } rooms = 1*(1*(document.hotelbooking.spec_num_single.options[document.hotelbooking.spec_num_single.selectedIndex].value) + 1*(document.hotelbooking.spec_num_double.options[document.hotelbooking.spec_num_double.selectedIndex].value) + 1*(document.hotelbooking.spec_num_triple.options[document.hotelbooking.spec_num_triple.selectedIndex].value)); if (rooms > 0) { if (rooms > 4) { alert("You can book maximum 4 rooms at a time!"); return false; } return true; } else { alert("Please select at least one room!"); return false; } } //******************************************* //INICIALIZÁLÁS hotel_setArrival('2024-04-27', '30'); hotel_setDeparture('2024-04-28', '30');