/*
This contains all the vars for the namespace */
/* Get current date*/
var my_date = new Date();
var b_gg_today = my_date.getDate();
var b_mm_today = my_date.getMonth() + 1;
var b_yy_today = my_date.getFullYear();
var sp = sp || {};
sp.vars = {};
sp.vars.errors = {
destinationErrorMsg: objectL10n.destinationErrorMsg,
tooManyDays: objectL10n.tooManyDays,
dateInThePast: objectL10n.dateInThePast,
cObeforeCI: objectL10n.cObeforeCI
};
sp.vars.gen = {
b_todays_date: b_yy_today + '-' + b_mm_today + '-' + b_gg_today
};
booking = {};
booking.env = {};
sp.variables = {
calendar_nextMonth: objectL10n.nextMonth,
calendar_prevMonth: objectL10n.calendar_prevMonth,
calendar_closeCalendar: objectL10n.calendar_closeCalendar,
calendar_url: '',
months: [objectL10n.january, objectL10n.february, objectL10n.march,
objectL10n.april, objectL10n.may, objectL10n.june, objectL10n.july,
objectL10n.august, objectL10n.september, objectL10n.october, objectL10n.november,
objectL10n.december
],
days: [objectL10n.mo, objectL10n.tu, objectL10n.we, objectL10n.th, objectL10n
.fr, objectL10n.sa, objectL10n.su
],
b_is_searchbox: true
};
// TODO: Sort all of the naming out. Once all of the products have been consolidated the name space needs cleaning up to stay consistent.
sp.gen = {
difference: function(a, b) {
return Math.abs(a - b);
},
id: function(elm) {
return (elm) ? document.getElementById(elm) : false;
}
};
// Calender
calendar = new Object();
tr = new Object();
var filaMonth;
function showCalendar(img, cal, dt, frm, m, y, d) {
var d = document;
if (d.getElementById) {
var c = d.getElementById(cal),
i = d.getElementById(img),
f = d.getElementById(frm);
calendar.calfrm = frm;
calendar.cal = c;
calendar.caldt = dt;
calendar.calf = f;
var my = f[dt + '_month'].value.split("-");
y = my[0];
m = my[1];
d = f[dt + '_day'].value;
buildCal(y, m, d);
var l = 0;
var t = 0;
aTag = i;
do {
aTag = aTag.offsetParent;
l += aTag.offsetLeft;
t += aTag.offsetTop;
} while (aTag.offsetParent && aTag.tagName != 'body');
var left = i.offsetLeft + l;
var top = i.offsetTop + t + i.offsetHeight + 2;
// Adding a class for the check in and check out.
jQuery(c).attr('class', "b_popup " + dt);
if (sp.variables.b_is_ie6) {
if (sp.variables.b_action === "index") {
left = i.offsetLeft + 140;
top = i.offsetTop + 290;
}
if (sp.variables.b_action === "hotel") {
left = i.offsetLeft + 160;
top = i.offsetTop + 150;
}
if (sp.variables.b_action.match(/city|region|landmark|country|place/g)) {
left = i.offsetLeft + 160;
top = i.offsetTop + 150;
}
}
if (sp.variables.b_is_searchbox) {
var bWidth = jQuery("#b_searchboxInc").width(),
cWidth = jQuery(c).innerWidth(),
bHeight = jQuery("#b_searchboxInc").height(),
cHeight = jQuery(c).innerHeight();
if ((cWidth + left) >= bWidth) {
left = left - sp.gen.difference((cWidth + left), bWidth);
}
var container;
if (container = document.getElementById('container')) {
if (container.offsetHeight <= 180) {
top = "-35";
} else {
if ((cHeight + top) >= bHeight) {
top = top - sp.gen.difference((cHeight + top), bHeight);
if ((cWidth + (left + 10)) < bWidth) {
left = left + 10;
}
}
}
} else {
if ((cHeight + top) >= bHeight) {
top = top - sp.gen.difference((cHeight + top), bHeight);
if ((cWidth + (left + 10)) < bWidth) {
left = left + 10;
}
}
}
}
c.style.position = "absolute";
c.style.left = left + 'px';
c.style.top = top + 'px';
c.style.display = "block";
}
}
function closeCal() {
calendar.cal.style.display = 'none';
}
function buildCal(y, m, d) {
var daysInMonth = [31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
td = new Date();
if (!y) {
y = td.getFullYear();
}
if (!m) {
m = td.getMonth() + 1;
}
if (!d) {
d = td.getDate;
}
var frm = calendar.calfrm;
var dt = calendar.caldt;
var mDate = new Date(y, m - 1, 1);
var firstMonthDay = mDate.getDay();
daysInMonth[1] = (((mDate.getFullYear() % 100 != 0) && (mDate.getFullYear() %
4 == 0)) || (mDate.getFullYear() % 400 == 0)) ? 29 : 28;
var today = (y == td.getFullYear() && m == td.getMonth() + 1) ? td.getDate() :
0;
var t = '
';
var flm = td.getMonth() + 1;
var flyr = td.getFullYear();
for (p = 0; p <= 11; p++) {
if (flm == m) {
filaMonth = p;
}
flm++;
if (flm > 12) {
flm = 1;
flyr++;
}
}
t += '
';
if (filaMonth == 0) {
t += ' < ';
} else {
t += ' < ';
}
if (!sp.variables.b_hide_month_dd) {
t +=
' ';
}
if (filaMonth == 11) {
t += ' > ';
} else {
t += ' > ';
}
t += '
';
t += '
';
for (dn = 0; dn < 7; dn++) {
var cl = '';
if ((dn % 7 == 5) || (dn % 7 == 6)) {
cl += ' b_calWeekend';
}
t += '
' + sp.variables.days[dn] + '
';
}
t += '
';
// Make the previous and next months dates appear.
if (sp.variables.full_dates) {
var getPrevMonth = (m - 1) - 1,
prevMonth = daysInMonth[getPrevMonth],
newMonth = 1;
}
for (i = 1; i <= 42; i++) {
var x = i - (firstMonthDay + 6) % 7,
prevM = 0,
nextM;
// This out puts the days in the month
if (x > daysInMonth[m - 1] || x < 1) {
if (sp.variables.full_dates) {
prevM = (x < 1) ? 1 : 0;
nextM = (x > daysInMonth[m - 1]) ? 1 : 0;
}
x = (!sp.variables.full_dates) ? ' ' : (x >= daysInMonth[m - 1]) ?
newMonth++ : (prevMonth - x);
}
var cl = '';
var href = 0;
if ((i % 7 == 0) || (i % 7 == 6)) {
cl += ' b_calWeekend';
}
if (x > 0) {
var xDay = new Date(y, m - 1, x);
if ((xDay.getFullYear() == y) && (xDay.getMonth() + 1 == m) && (xDay.getDate() ==
d)) {
cl += ' b_calSelected';
href = 1;
}
if ((xDay.getFullYear() == td.getFullYear()) && (xDay.getMonth() == td.getMonth()) &&
(xDay.getDate() == td.getDate())) {
cl += ' b_calToday';
href = 1;
} else {
if (xDay > td && !prevM || sp.variables.full_dates && nextM && !prevM) {
cl += (nextM) ? 'nextMonth b_calFuture' : ' b_calFuture';
href = 1;
} else {
if (xDay < td || sp.variables.full_dates && prevM) {
cl += ' b_calPast'
}
}
}
};
t += '
';
if (href) {
t += '' + x + '';
} else {
t += x;
}
t += '