var Class = { create: function(param) { var cls = function() { if (this.initialize) this.initialize(); }; cls.prototype = param; if (cls.initialize) cls.initialize(); return cls; } } var Calendar = Class.create({ initialize: function(){ this.calX = 0; this.calY = 0; this.dropYearMonth = null; this.dropDay = null; this.dropYearMonthNext = null; this.dropDayNext = null; this.currentMonth = 0; }, dayHeaders: new Array('M','T','W','T','F','S','S'), months: new Array('Nov-2017','Dec-2017','Jan-2018','Feb-2018','Mar-2018','Apr-2018','May-2018','Jun-2018','Jul-2018','Aug-2018','Sep-2018','Oct-2018','Nov-2018','Dec-2018','Jan-2019','Feb-2019','Mar-2019','Apr-2019','May-2019','Jun-2019','Jul-2019','Aug-2019','Sep-2019','Oct-2019','Nov-2019','Dec-2019','Jan-2020','Feb-2020','Mar-2020','Apr-2020','May-2020','Jun-2020','Jul-2020','Aug-2020','Sep-2020','Oct-2020'), monthDates: new Array('201711','201712','201801','201802','201803','201804','201805','201806','201807','201808','201809','201810','201811','201812','201901','201902','201903','201904','201905','201906','201907','201908','201909','201910','201911','201912','202001','202002','202003','202004','202005','202006','202007','202008','202009','202010'), monthMatrix: new Array( new Array(0,0,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,219,120,21,22,23,24,25,26,27,28,29,30,0,0,0,0,0,0,0,0,0,0), new Array(0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,0,0,0,0,0,0,0), new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,0,0,0,0,0,0,0,0,0,0,0), new Array(0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,0,0,0,0,0,0,0,0,0,0,0), new Array(0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,0,0,0,0,0,0,0,0), new Array(0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,0,0,0,0,0,0), new Array(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,0,0,0,0,0,0,0,0,0,0), new Array(0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,0,0,0,0,0,0,0,0), new Array(0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,0,0,0,0,0), new Array(0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,0,0,0,0,0,0,0,0,0), new Array(0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,0,0,0,0,0,0,0), new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,0,0,0,0,0,0,0,0,0,0,0), new Array(0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,0,0,0,0,0,0,0,0,0), new Array(0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,0,0,0,0,0,0), new Array(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,0,0,0,0,0,0,0,0,0,0), new Array(0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,0,0,0,0,0,0,0,0,0,0), new Array(0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,0,0,0,0,0,0,0), new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,0,0,0,0,0,0,0,0,0,0,0,0), new Array(0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,0,0,0,0,0,0,0,0,0), new Array(0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,0,0,0,0,0,0,0), new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,0,0,0,0,0,0,0,0,0,0,0), new Array(0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,0,0,0,0,0,0,0,0), new Array(0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,0,0,0,0,0,0), new Array(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,0,0,0,0,0,0,0,0,0,0), new Array(0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,0,0,0,0,0,0,0,0), new Array(0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,0,0,0,0,0), new Array(0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,0,0,0,0,0,0,0,0,0), new Array(0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,0,0,0,0,0,0,0,0), new Array(0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,0,0,0,0,0), new Array(0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,0,0,0,0,0,0,0,0,0,0), new Array(0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,0,0,0,0,0,0,0), new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,0,0,0,0,0,0,0,0,0,0,0,0), new Array(0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,0,0,0,0,0,0,0,0,0), new Array(0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,0,0,0,0,0,0), new Array(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,0,0,0,0,0,0,0,0,0,0,0), new Array(0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,0,0,0,0,0,0,0,0) ), handleSyncDates: function(){ this.fixDays(this.dropYearMonth,this.dropDay); if( this.dropYearMonthNext && this.dropDayNext && this.nights ) { if( this.nights>0 ) this.handleSyncDatesF(); else this.handleSyncDatesB(); } }, fixDays: function(dropYearMonth, dropDay){ var day = $(dropDay).val(); var mday_index = 0; $(this.monthDates).each(function(index,value){ if( value==$(dropYearMonth).val() ) mday_index=index; }); var mday = this.monthMatrix[mday_index]; var min = 31; $(mday).each(function(index,value){ if( value>0 && value0 && value<32 ) max=value; }); if( daymax ) $(dropDay).val(max); }, handleSyncDatesF: function(){ var day = parseInt($(this.dropDay).val()); var nights = this.nights; for(var i=0; i0) { j++; if( j==mday.length || mday[j]==0 ) { i++; if( i==this.monthDates.length ) { i--; j--; break; } else { mday = this.monthMatrix[i]; j = 0; while(j=0; i--) if( this.monthDates[i] == $(this.dropYearMonth).val() ) { var mday = this.monthMatrix[i]; for(var j=mday.length-1; j>=0; j--) { if(mday[j] == day) { while(nights<0) { j--; if( j<0 || mday[j]==0 || mday[j]>31 ) { i--; if( i==-1 ) { i++; j++; break; } else { mday = this.monthMatrix[i]; j = mday.length-1; while(j>=0 && mday[j]==0) j--; } } nights ++; } $(this.dropYearMonthNext).val(this.monthDates[i]); $(this.dropDayNext).val(mday[j]); return; } } }*/ }, syncDates: function(dropYearMonthObj, dropDayObj, dropYearMonthNextObj, dropDayNextObj, days){ this.dropYearMonth = dropYearMonthObj; this.dropDay = dropDayObj; this.dropYearMonthNext = dropYearMonthNextObj; this.dropDayNext = dropDayNextObj; this.nights = days; this.handleSyncDates(); }, move_month: function(dir){ if (dir==1) { ++this.currentMonth; this.draw_calendar(); } else { --this.currentMonth; this.draw_calendar(); } }, handle_click: function(isoIn){ isoIn = "" + isoIn; $(this.dropDay).val(parseInt(isoIn.substring(6,8),10)); $(this.dropYearMonth).val(isoIn.substring(0,6)); $(this.dropfinalyear).val(isoIn.substring(6,8)+"/"+ isoIn.substring(4,6)+"/"+ isoIn.substring(0,4)); this.handleSyncDates(); this.hide_calendar(); }, open_cal1: function(dropYearMonthObj, dropDayObj){ this.dropYearMonth = dropYearMonthObj; this.dropDay = dropDayObj; this.dropYearMonthNext = null; this.dropDayNext = null; this.nights = 0; for (i=0;i0) tmpHtml = '<<'; else tmpHtml = ' '; table_top += '' + tmpHtml + '\n'; table_top += '' + this.months[month] + '\n'; if(month<(this.monthMatrix.length-1)) tmpHtml = '>>'; else tmpHtml = ' '; table_top += '' + tmpHtml + '\n'; table_top += '\n'; table_top += '\n'; table_top += '\n'; for (dh=0;dh'; table_top += '\n'; table_top += '\n'; print_string = ''; thisMonth = this.monthMatrix[month]; for (rw=0;rw<42;rw++) { if (rw!=0 && rw!=(thisMonth.length-1) && (rw%7==0)) print_string += "\n"; if (thisMonth[rw]!=0) { var box = ""; if( this.monthDates[month]==$(this.dropYearMonth).val() && ($(this.dropDay).val()==thisMonth[rw] || $(this.dropDay).val()==(thisMonth[rw]-200)) ) box = " style='border:1px solid black'"; var clickDate = (this.monthDates[month]*100 + thisMonth[rw]); if (thisMonth[rw]>200) print_string += '' + thisMonth[rw]%200 + ''; //print_string += '' + thisMonth[rw]%200 + ''; else if (thisMonth[rw]>100) print_string += '' + thisMonth[rw]%100 + ''; else print_string += '' + thisMonth[rw] + ''; } else print_string += ' '; } print_string += '\n'; print_string += 'close\n'; print_string += '\n'; this.element.html(table_top + print_string); $(this.element).css({'left':this.calX+'px', 'top':this.calY+'px'}); $(this.element).show(); } }); var myCalendar = new Calendar(); function openCal1(obj) { myCalendar.element = $('#calendar'); var pos = $('#hbook_cal1').offset(); var otpos = $('#datef').offset(); var otlipos = $('li.resv').position(); myCalendar.calX=otpos.left-pos.left+otlipos.left+10; myCalendar.calY=pos.top+otlipos.top+22; if ($("#nights").val()==0) { $("#nights").val(7); } myCalendar.open_cal2($('#date1m'), $('#date1d'), $('#datef'), $('#date2m'), $('#date2d'), $('#datef1'), $("#nights").val()); } function openCal2(obj) { myCalendar.element = $('#calendar'); var pos = $('#hbook_cal2').offset(); var otpos = $('#datef1').offset(); var otlipos = $('li.resv').position(); myCalendar.calX = otpos.left-pos.left+otlipos.left+10; myCalendar.calY = pos.top+otlipos.top+22; if ($("#datef").val()=='Check In') { alert("Please Select Check In First"); return false; } myCalendar.open_cal2($('#date2m'), $('#date2d'),$('#datef1'), $('#date1m'), $('#date1d'),$('#datef'), -$("#nights").val()); } function calcCal1(){ myCalendar.element = $('#calendar'); myCalendar.syncDates($('#date1m'), $('#date1d'), $('#date2m'), $('#date2d'), $("#nights").val()); } function calcCal2() { myCalendar.element = $('#calendar'); myCalendar.syncDates($('#date2m'), $('#date2d'), $('#date1m'), $('#date1d'), -$("#nights").val()); } function tr_openCal1(obj) { myCalendar.element = $('#calendar1'); var pos = $('#tr_cal11').position(); //var poscardate = $('#datecf1').position(); var cardatepickup = $('#cardatepickup').position(); //alert(pos.left); //alert(poscardate.left); //alert(cardatepickup.left); myCalendar.calX=pos.left; myCalendar.calY=pos.top; //myCalendar.open_cal1($('tr_date1m'), $('tr_date1d')); myCalendar.open_cal2($('#tr_date1m'), $('#tr_date1d'),$('#datecf1'), $('#tr_date2m'), $('#tr_date2d'),$('#datecf2'), 1); } function tr_openCal2(obj) { myCalendar.element = $('#calendar1'); var pos = $('#datecf2').offset(); var cardatereturn = $('#cardatereturn').position(); alert(pos.left); alert(cardatereturn.left); myCalendar.calX=cardatereturn.left-pos.left; myCalendar.calY=pos.top+10; myCalendar.open_cal2($('#tr_date2m'), $('#tr_date2d'),$('#datecf2'), $('#tr_date1m'), $('#tr_date1d'),$('#datecf1'), -1); } function calcHotelCal1() { myCalendar.syncDates($('#hbook_date1m'), $('#hbook_date1d'), $('#hbook_date2m'), $('#hbook_date2d'), $('#hbook_nights').val()); } function calcHotelCal2() { myCalendar.syncDates($('#hbook_date2m'), $('#hbook_date2d'), $('#hbook_date1m'), $('#hbook_date1d'), -$('#hbook_nights').val()); } function openCal1Addons(obj) { myCalendar.element = $('#calendar'); var pos = $('#hbook_cal1').offset(); var otpos = $('#datef').offset(); var otlipos = $('#dateaddon').position(); myCalendar.calX=otpos.left-pos.left+175; myCalendar.calY=pos.top+otlipos.top+78; if ($("#nights").val()==0) { $("#nights").val(7); } myCalendar.open_cal2($('#date1m'), $('#date1d'), $('#datefaddons'), $('#date2m'), $('#date2d'), $('#datef1'), $("#nights").val()); } function openCal2Addons(obj) { myCalendar.element = $('#calendar'); var pos = $('#hbook_cal2').offset(); var otpos = $('#datef1').offset(); var otlipos = $('#dateaddon1').position(); myCalendar.calX = otpos.left-pos.left+otlipos.left-29; myCalendar.calY = pos.top+otlipos.top+78; if ($("#datef").val()=='Check In') { alert("Please Select Check In First"); return false; } myCalendar.open_cal2($('#date2m'), $('#date2d'),$('#datef1addons'), $('#date1m'), $('#date1d'),$('#datef'), -$("#nights").val()); } function tr_openCal1CarDate(obj) { myCalendar.element = $('#calendarcar'); var pos = $('#datecf1car').position(); //var cardatepickup = $('#cardatepickup').position(); myCalendar.calX=pos.left; myCalendar.calY=pos.top+27; //myCalendar.open_cal1($('tr_date1m'), $('tr_date1d')); myCalendar.open_cal2($('#tr_date1m'), $('#tr_date1d'),$('#datecf1car'), $('#tr_date2m'), $('#tr_date2d'),$('#datecf2'), 1); } function tr_openCal2CarDate(obj) { myCalendar.element = $('#calendarcar'); var pos = $('#datecf2car').offset(); //var cardatereturn = $('#cardatereturn').position(); myCalendar.calX=pos.left; myCalendar.calY=pos.top+27; myCalendar.open_cal2($('#tr_date2m'), $('#tr_date2d'),$('#datecf2car'), $('#tr_date1m'), $('#tr_date1d'),$('#datecf1'), -1); } function tr_openCal1Transfer(obj) { myCalendar.element = $('#calendar1transfer'); var pos = $('#tr_caltransfer').position(); //var cardatepickup = $('#cardatepickup').position(); myCalendar.calX=pos.left; myCalendar.calY=pos.top+50; //myCalendar.open_cal1($('tr_date1m'), $('tr_date1d')); myCalendar.open_cal2($('#tr_date1m'), $('#tr_date1d'),$('#tr_caltransfer'), $('#tr_date2m'), $('#tr_date2d'),$('#datecf2'), 1); } function tr_openCal2Transfer(obj) { myCalendar.element = $('#calendar1transfer'); var pos = $('#tr_caltransfer2').position(); //var cardatepickup = $('#cardatepickup').position(); myCalendar.calX=pos.left; myCalendar.calY=pos.top+50; //myCalendar.open_cal1($('tr_date1m'), $('tr_date1d')); myCalendar.open_cal2($('#tr_date1m'), $('#tr_date1d'),$('#tr_caltransfer'), $('#tr_date2m'), $('#tr_date2d'),$('#datecf2'), 1); } function openCal1Bookmob(obj) { myCalendar.element = $('#calendarmob'); var pos = $('#datefbookmob').offset(); //var otpos = $('#datef').offset(); //var otlipos = $('#dateaddon').position(); //alert(pos.left); myCalendar.calX=pos.left; myCalendar.calY=pos.top+20; if ($("#nights").val()==0) { $("#nights").val(7); } myCalendar.open_cal2($('#date1m'), $('#date1d'), $('#datefbookmob'), $('#date2m'), $('#date2d'), $('#datef1'), $("#nights").val()); } function openCal2Bookmob(obj) { myCalendar.element = $('#calendarmob'); var pos = $('#datef1bookmob').offset(); //var otpos = $('#datef1').offset(); //var otlipos = $('#dateaddon1').position(); myCalendar.calX = pos.left; myCalendar.calY = pos.top+20; if ($("#datef").val()=='Check In') { alert("Please Select Check In First"); return false; } myCalendar.open_cal2($('#date2m'), $('#date2d'),$('#datef1bookmob'), $('#date1m'), $('#date1d'),$('#datef'), -$("#nights").val()); } function openCal1AddonsBookmob(obj) { myCalendar.element = $('#calendarmob'); var pos = $('#datefaddonsmob').offset(); //var otpos = $('#datef').offset(); //var otlipos = $('#dateaddon').position(); //alert(pos.left); myCalendar.calX=pos.left; myCalendar.calY=pos.top+20; if ($("#nights").val()==0) { $("#nights").val(7); } myCalendar.open_cal2($('#date1m'), $('#date1d'), $('#datefaddonsmob'), $('#date2m'), $('#date2d'), $('#datef1'), $("#nights").val()); } function openCal2AddonsBookmob(obj) { myCalendar.element = $('#calendarmob'); var pos = $('#datef1addonsmob').offset(); //var otpos = $('#datef1').offset(); //var otlipos = $('#dateaddon1').position(); myCalendar.calX = pos.left; myCalendar.calY = pos.top+20; if ($("#datef").val()=='Check In') { alert("Please Select Check In First"); return false; } myCalendar.open_cal2($('#date2m'), $('#date2d'),$('#datef1addonsmob'), $('#date1m'), $('#date1d'),$('#datef'), -$("#nights").val()); }