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,119,320,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; } } }*/ }, syncDatesNEW: function(dropYearMonthObj, dropDayObj, dropYearMonthNextObj, dropDayNextObj,dropfinalNextyearObj, days){ this.dropYearMonth = dropYearMonthObj; this.dropDay = dropDayObj; this.dropYearMonthNext = dropYearMonthNextObj; this.dropDayNext = dropDayNextObj; this.nights = days; this.dropfinalnextyear=dropfinalNextyearObj; this.handleSyncDates(); }, 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]%300 + ''; }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 = $('#datef').offset(); myCalendar.calX=pos.left; myCalendar.calY=pos.top+$('#datef').height(); 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 = $('#datef1').offset(); myCalendar.calX = pos.left; myCalendar.calY = pos.top+$('#datef1').height(); 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.syncDatesNEW($('#date1m'), $('#date1d'), $('#date2m'), $('#date2d'),$('#datef1'), $("#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').offset(); 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 = $('#tr_cal22').offset(); myCalendar.calX=pos.left; myCalendar.calY=pos.top; 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()); }