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-2024','Dec-2024','Jan-2025','Feb-2025','Mar-2025','Apr-2025','May-2025','Jun-2025','Jul-2025','Aug-2025','Sep-2025','Oct-2025','Nov-2025','Dec-2025','Jan-2026','Feb-2026','Mar-2026','Apr-2026','May-2026','Jun-2026','Jul-2026','Aug-2026','Sep-2026','Oct-2026','Nov-2026','Dec-2026','Jan-2027','Feb-2027','Mar-2027','Apr-2027','May-2027','Jun-2027','Jul-2027','Aug-2027','Sep-2027','Oct-2027'), monthDates: new Array('202411','202412','202501','202502','202503','202504','202505','202506','202507','202508','202509','202510','202511','202512','202601','202602','202603','202604','202605','202606','202607','202608','202609','202610','202611','202612','202701','202702','202703','202704','202705','202706','202707','202708','202709','202710'), monthMatrix: new Array( new Array(0,0,0,0,101,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,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), 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,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,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), 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,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,0,0,0,0,0,0,0,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,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,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) ), 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]-300) || $(this.dropDay).val()==(thisMonth[rw]-200)) ) box = " style='border:1px solid black'"; var clickDate = (this.monthDates[month]*100 + thisMonth[rw]); if(thisMonth[rw]>300) print_string += '' + thisMonth[rw]%300 + ''; else 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(); myCalendar.calX=pos.left; myCalendar.calY=pos.top; myCalendar.open_cal2($('#date1m'), $('#date1d'), $('#datef'), $('#date2m'), $('#date2d'), $('#datef1'), $("#nights").val()); } function openCal2(obj) { myCalendar.element = $('#calendar'); var pos = $('#hbook_cal2').offset(); myCalendar.calX = pos.left; myCalendar.calY = pos.top; 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').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()); } function AopenCal1(obj) { myCalendar.element = $('#calendar'); var pos = $('#hbook_cal1').offset(); myCalendar.calX=pos.left; myCalendar.calY=pos.top; myCalendar.open_cal2($('#Adate1m'), $('#Adate1d'), $('#Adatef'), $('#Adate2m'), $('#Adate2d'), $('#Adatef1')); } function AopenCal2(obj) { myCalendar.element = $('#calendar'); var pos = $('#hbook_cal2').offset(); myCalendar.calX = pos.left; myCalendar.calY = pos.top; myCalendar.open_cal2($('#Adate2m'), $('#Adate2d'),$('#Adatef1'), $('#Adate1m'), $('#Adate1d'),$('#Adatef')); } function calcCal1(){ myCalendar.element = $('#calendar'); myCalendar.syncDates($('#Adate1m'), $('#Adate1d'), $('#Adate2m'), $('#Adate2d')); } function calcCal2() { myCalendar.element = $('#calendar'); myCalendar.syncDates($('#Adate2m'), $('#Adate2d'), $('#Adate1m'), $('#Adate1d')); } function tr_AopenCal1(obj) { myCalendar.element = $('#calendar1'); var pos = $('#tr_cal11').offset(); myCalendar.calX=pos.left; myCalendar.calY=pos.top; //myCalendar.open_cal1($('tr_Adate1m'), $('tr_Adate1d')); myCalendar.open_cal2($('#tr_Adate1m'), $('#tr_date1d'),$('#datecf1'), $('#tr_date2m'), $('#tr_date2d'),$('#datecf2')); } function tr_AopenCal2(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')); } function calcHotelCal1() { myCalendar.syncDates($('#Ahbook_date1m'), $('#Ahbook_date1d'), $('#Ahbook_date2m'), $('#Ahbook_date2d')); } function calcHotelCal2() { myCalendar.syncDates($('#Ahbook_date2m'), $('#Ahbook_date2d'), $('#Ahbook_date1m'), $('#Ahbook_date1d')); }