/*************************************************** DOM OBJECT AND CURSOR POSITION OBJECT / METHODS ***************************************************/ var mouseX, mouseY; function Position(o) { this.obj = o; this.x=0; this.y=0; this.getSize = getObjSize; } function getObjSize() { this.w = this.obj.offsetWidth; this.h = this.obj.offsetHeight; } function getObjPosition(objId) { var o=document.getElementById(objId); var pos=new Position(o); var offsetX = 0; var offsetY = 0; while (o) { offsetX += o.offsetLeft; offsetY += o.offsetTop; o = o.offsetParent; } pos.x = offsetX; pos.y = offsetY; pos.getSize(); return pos; } function getMouseXY(e) { if (document.all) { // grab the x-y pos.s if browser is IE mouseX = window.event.clientX + document.documentElement.scrollLeft; mouseY = window.event.clientY + document.documentElement.scrollTop; } else { // grab the x-y pos.s if browser is not IE mouseX = e.pageX; mouseY = e.pageY; } return true; } function showAtMousePos(content, divObj) { // optional 3rd and 4th arguments : offsetX, offsetY var offsetX = (arguments.length > 2) ? mouseX + arguments[2] : mouseX; var offsetY = (arguments.length > 3) ? mouseY + arguments[3] : mouseY; divObj.innerHTML = content; divObj.style.left = offsetX + 'px'; divObj.style.top = offsetY + 'px'; divObj.style.visibility = 'visible'; } function changeHtmlContent(elementid, content) { var el = document.getElementById(elementid); if (document.all) { el.innerHTML = content; } else if (document.getElementById) { var rng = document.createRange(); rng.setStartBefore(el); var htmlFrag = rng.createContextualFragment(content); while (el.hasChildNodes()) { el.removeChild(el.lastChild); } el.appendChild(htmlFrag); } if (arguments.length > 2) { el.style.display = arguments[2]; } return true; } function injectScript(scriptText) { var scrpt = document.createElement('script'); scrpt.setAttribute('type', 'text/javascript'); scrpt.text = scriptText; document.body.appendChild(scrpt); } /* ****************************************************** dynamictable object methods - a div-based pseudo table manipulated using the DOM ****************************************************** */ dynamictable.prototype.create = dt_create; dynamictable.prototype.addrow = dt_add_row; dynamictable.prototype.deleterow = dt_delete_row; dynamictable.prototype.shiftRowsUp = dt_shift_rows_up; dynamictable.prototype.shiftRowsDown = dt_shift_rows_down; dynamictable.prototype.attachStylesheet = dt_attach_stylesheet; function dynamictable(id) { this.id = id; this.numRows = 0; this.rowsById = new Array(); this.rowsByPos = new Array(); var d; if (d = document.getElementById(id)) { this.obj = d; } else { this.create(id); } } function dt_create(id) { var newElement = document.createElement('div'); newElement.id = id; document.body.appendChild(newElement); this.obj = newElement; } function dt_add_row(id) { // optional second argument for position to insert row element : default 0 = end // optional third argument for class name of row element : default 'dt_tablerow' var newElement = document.createElement('div'); newElement.id = id; newElement.className = (arguments.length > 2) ? arguments[2] : 'dt_tablerow'; var pos = (arguments.length > 1) ? arguments[1] : 0; if ((this.numRows == 0) || (pos == 0) || (pos > this.numRows)) // insert at the end { this.obj.appendChild(newElement); this.numRows++; this.rowsById[id] = this.numRows; this.rowsByPos[this.numRows] = id; return newElement; } else if (pos < 0) // insert at a reversed offset from the end { pos = (Number(pos) + this.numRows >= 0) ? (Number(pos) + this.numRows + 1) : 1; } var oldElement = document.getElementById(this.rowsByPos[pos]); this.obj.insertBefore(newElement, oldElement); this.shiftRowsUp(pos); this.rowsByPos[pos] = id; this.rowsById[id] = pos; return newElement; } function dt_shift_rows_up(pos) { if (pos <= this.numRows) { var rowId; for (var i=this.numRows + 1; i > pos; i--) { rowId = this.rowsByPos[i-1]; this.rowsByPos[i] = rowId; this.rowsById[rowId] = i; } this.numRows++; } } function dt_delete_row() { var id, pos, ditchNode; if (arguments.length > 0) { id = arguments[0]; pos = this.rowsById[id]; } else if (this.numRows>0) { pos = this.numRows; id = this.rowsByPos[pos]; } var ditchNode = document.getElementById(id); this.obj.removeChild(ditchNode); this.shiftRowsDown(pos); return true; } function dt_shift_rows_down(pos) { if (pos <= this.numRows) { var rowId = this.rowsByPos[pos]; delete this.rowsById[rowId]; for (var i=pos; icalendarObj.maxStayLength)) { inputObj.value = 1; } calendarObj.setPeriod(inputObj.value); calendarObj.generateSelectedDays(); cp_callback(calendarObj.dateString()); } var f2b_search_cal; /* -----------------------*/ // JavaScript Document calendar.prototype.maxStayLength=99; calendar.prototype.weeks=[]; calendar.prototype.getWeek=c_getWeek; calendar.prototype.getMonth=c_getMonth; calendar.prototype.setDateDescriptors=c_setDateDescriptors; calendar.prototype.populateWeeks=c_populateWeeks; calendar.prototype.addHeader=c_addHeader; calendar.prototype.addMonthDays=c_addMonthDays; calendar.prototype.addFooter=c_addFooter; calendar.prototype.dayStrings=['Monday','Tuesday','Wedneday','Thursay','Friday','Saturday','Sunday']; calendar.prototype.monthStrings=['January','February','March','April','May','June','July','August','September', 'October','November','December']; function calendar(month,year,selectedDays) { //internally uses js 0-11 range for months var date=new Date(); this.today = {} this.today.d = date.getDate(); this.today.m = date.getMonth(); this.today.y = date.getFullYear(); this.selectedDays=selectedDays; this.month = (month!=undefined) ? (month-1) : this.today.m; this.year = (year!=undefined) ? year : this.today.y; this.setDateDescriptors(); this.isThisMonth = ((this.month==this.today.m) && (this.year==this.today.y)); if (this.isThisMonth) { firstOfThisMonth = Date.UTC(this.today.y,this.today.m,1,0, 0, 0, 0 ); this.monthIsInPast = (firstOfThisMonth > this.firstOfMonth); } this.populateWeeks(); this.weekPointer = this.weekOfFirst; } function c_getWeek() { // week will be array [week num] [day of week] = calendar date (1..31) // where day of week [1..7] = [Mon..Sun] if (week = this.weeks[this.weekPointer]) { this.weekPointer++; return week; } this.weekPointer = this.weekOfFirst; return false; } function c_getMonth(offset) { // month will be stdClass .m = month, .y = year month = {} if (!isNaN(offset)) { ts = Date.UTC(this.year,this.month,1,0,0,0,0); today=Date.UTC(this.today.y,this.today.m,1,0,0,0,0); if (ts >= today) { month.y = ts.getFullYear(); month.m = ts.getMonth(); return month; } } else if (offset == 'today') { month.y = Date().getFullYear; month.m = Date().getFullMonth; return month; } return false; } function c_setDateDescriptors() // only called by constructor { this.firstOfMonth = Date.UTC(this.year,this.month,1, 0, 0,0,0); firstDate=new Date(this.year,this.month,1, 0, 0,0,0,0); this.dayOfFirst = firstDate.getDay(); if (this.dayOfFirst==0) this.dayOfFirst=7; //fix so that day of week corresponds to iso-8601 this.daysInMonth = daysInMonth(this.month,this.year); previousMonth=new Date(this.firstOfMonth - 604800000); // -1 week from first to avoid daylight savings issues this.daysInPrevMonth=daysInMonth(previousMonth.getMonth(),previousMonth.getYear()) this.weekOfFirst=firstDate.getWeek(); this.lastOfMonth = Date(this.year,this.month,this.daysInMonth,0, 0, 0,0 ); this.monthString = this.monthStrings[this.month]+' '+this.year; //this.firstOfMonthStr = date('Y-m-d', this.firstOfMonth); //this.lastOfMonthStr = date('Y-m-d', this.lastOfMonth); return true; } function c_populateWeeks() // only called by constructor { this.weeks=[]; w = this.weekOfFirst; wd = this.dayOfFirst; if (wd > 1) { var date = this.daysInPrevMonth; for (leadingwd=wd-1; leadingwd; leadingwd--) { day = {}; //day.date = date; day.date=''; day.displayClass = 'othermonth'; if (this.weeks[w]==undefined) this.weeks[w]=[]; this.weeks[w][leadingwd] = day; date--; } } for (d=1; d<=this.daysInMonth; d++) { day = {}; day.date = d; day.displayClass = (this.isThisMonth) ? ((d < this.today.d) ? 'pastday' : 'day') : (this.monthIsInPast ? 'pastday' : 'day'); if (this.selectedDays[this.year+'-'+this.month+'-'+d]) day.displayClass='selectedday'; if (this.weeks[w]==undefined) this.weeks[w]=[]; this.weeks[w][wd] = day; if (wd%7) { wd++; } else { w++; wd = 1; } } if (wd > 1) { d=1; while (wd<=7) { day = {}; //day.date = d; day.date=''; day.displayClass = 'othermonth'; this.weeks[w][wd] = day; wd++; d++; } } return true; } function c_formatMonth(date) { var month; month=(date.getMonth()+1).toString(); month=(month.length==1)?('0'+month):month; return month; } function c_addLeadingZero(str) { str=''+str; return (str.length==1)?'0'+str:str; } function c_addHeader(container) { var today,header; calName='f2b_search_cal'; today=new Date(); thisMonth=new Date(this.year,this.month,1,1,0,0,0,0); lastMonthDate=new Date(thisMonth.getFullYear(),(thisMonth.getMonth()-1),1,0,0,0,0); nextMonthDate=new Date(thisMonth.getFullYear(),(thisMonth.getMonth()+1),1,0,0,0,0); if (lastMonthDate.getYear()==today.getYear() && lastMonthDate.getMonth()>'); innerSpan.appendChild(txt); outerSpan.appendChild(innerSpan); header.appendChild(outerSpan); } span=document.createElement('div'); span.className='pseudolink'; span.id=calName+'_calendarMonth'; /* onclick="'+calName+'.showMonthDD(this.id, '+y+','+m+')">*/ span.innerHTML=calMonth; header.appendChild(span); container.appendChild(header); weekHeader=document.createElement('DIV'); weekHeader.className='weekHeader'; days=['Mon','Tue','Wed','Thu','Fri','Sat','Sun']; for (i=0;i= 0 ? day : day + 7); var daynum = Math.floor((this.getTime() - newYear.getTime() - (this.getTimezoneOffset()-newYear.getTimezoneOffset())*60000)/86400000) + 1; var weeknum; //if the year starts before the middle of a week if(day < 4) { weeknum = Math.floor((daynum+day-1)/7) + 1; if(weeknum > 52) { nYear = new Date(this.getFullYear() + 1,0,1); nday = nYear.getDay() - dowOffset; nday = nday >= 0 ? nday : nday + 7; /*if the next year starts before the middle of the week, it is week #1 of that year*/ weeknum = nday < 4 ? 1 : 53; } } else { weeknum = Math.floor((daynum+day-1)/7); } return weeknum; }; function daysInMonth(iMonth, iYear) { return 32 - new Date(iYear, iMonth, 32).getDate(); } // Function found at Simon Willison's weblog - http://simon.incutio.com/ // function addLoadEvent2() { window.f2b_oldonload=window.onload; window.onload=f2b_init; } function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function'){ window.onload = func; } else { window.onload = function(){ oldonload(); func(); } } } var w_id=45; var w_tkn='5iHHeHNwCPcIJLJKg7JRwkjAsJNu8g6baebm6SR7jw5FhnMcWadKKZoUcm93c' var resultPage='https://portal.freetobook.com/widget-redir'; var calendarUrl='https://www.freetobook.com/resource/calendarPopupv2/calendar.php'; var basePath='https://www.freetobook.com/affiliates/dynamicWidget'; var defaultCheckIn = 'Apr 04,2024'; var defaultPeriod=1; var f2b_stylesheet='widget-css.php?w_id=45&w_tkn=5iHHeHNwCPcIJLJKg7JRwkjAsJNu8g6baebm6SR7jw5FhnMcWadKKZoUcm93c'; var f2b_widget_openWindow=false; var f2b_widget_blockAvailability=false; var f2b_widget_style='thin'; var f2b_enable_ga=false; var f2b_analytics_type='none'; addLoadEvent2('f2b_init');