';
html += '
'+searchBoxTranslations['s_recent_searches']+'
';
$.each(extraLatestSearches, function() {
var id = this[0];
var name = this[1];
var countryCode = this[2];
var start = this[3];
var end = this[4];
var url = this[5];
var country = CountryNames[countryCode];
html += '
' + name + ', ' + country;
if (start != 0) {
html += '
' + start + ' / ' + end;
}
html += '
'
});
html += '
';
return $(html).get(0);
};
function receiveData(q, data, isTopCities) {
if (data) {
$input.removeClass(options.loadingClass);
results.innerHTML = "";
if ($.browser.msie) {
$results.append(document.createElement('iframe'));
}
var hData = dataToDom(data);
if (isTopCities) {
var div = document.createElement("div");
div.innerHTML = '
";
return html;
}
function setupCloseButton()
{
$("#popup_locations .close").click(function(){
$("#popup_locations").hide();
});
}
function locationsBuildCountrySelection()
{
var cols = 1;
var html = '';
html += addCloseButton(html);
html += '';
// top countries
html += '
'+searchBoxTranslations['s_top_countries']+'
';
for(var i = 0; i < LocationNames.length; i+=4) {
if (LocationNames[i+3] == 3) {
html += '
' + LocationNamesNoHTML[i] + '';
}
}
html += '
';
// top cities
html += '
'+searchBoxTranslations['s_top_cities']+'
';
for(var i = 0; i < extraTopCities.length; i++) {
var place = extraTopCities[i];
if (typeof(placeIDByOrdinal[place]) != "undefined") {
var h = placeIDByOrdinal[place];
html += '
' + LocationNamesNoHTML[h] + '';
}
}
html += '
';
var i = 0;
var c = 0;
var genCol = function() {
while (i < LocationNames.length && c < 24) {
if (LocationNames[i+3] == 0 || LocationNames[i+3] == 3) {
html += '' + LocationNamesNoHTML[i] + '
';
c++;
}
i+=4;
}
c = 0;
cols++;
};
html += ''+searchBoxTranslations['s_all_countries']+'
'; genCol(); html += '';
if (i < LocationNames.length) { html += '
'; genCol(); html += ''; }
if (i < LocationNames.length) { html += '
'; genCol(); html += ''; }
if (i < LocationNames.length) { html += '
'; genCol(); html += ''; }
sizeForLocColumns(cols);
$('#popup_locations').html(html);
if ($.browser.msie && $.browser.version == '6.0') {
// we put a styled iframe behind the calendar so HTML SELECT elements don't show through
$('#popup_locations').prepend(document.createElement('iframe'));
}
setupCloseButton();
}
function locationsBuildCitySelection(code, start)
{
var cols = 2;
var html = '';
html += addCloseButton(html);
html += '';
html += ''+searchBoxTranslations['s_all_regions']+'
';
for(var i = 0; i < LocationNames.length; i+=4) {
if (LocationNames[i+3] == 1 && LocationNames[i+2] == code) {
html += '
' + LocationNamesNoHTML[i] + '';
}
}
html += '
';
var i = 0;
if (start !== false) {
i = start;
}
var c = 0;
var genCol = function() {
while (i < LocationNames.length && c < 24) {
if ((LocationNames[i+3] == 2 || LocationNames[i+3] == 4) && LocationNames[i+2] == code) {
html += '' + LocationNamesNoHTML[i] + '
';
c++;
}
i+=4;
}
c = 0;
cols++;
};
html += ''+searchBoxTranslations['s_all_cities']+'
';
genCol();
if (start !== false && start != 0) {
// doesn't fit, add a page link
html += '
'+searchBoxTranslations['s_prev']+'';
}
html += '
';
if (i < LocationNames.length) { html += '
'; genCol(); html += ''; }
if (i < LocationNames.length) { html += '
'; genCol(); html += ''; }
if (i < LocationNames.length) {
html += '';
}
sizeForLocColumns(cols);
$('#popup_locations').html(html);
if ($.browser.msie && $.browser.version == '6.0') {
// we put a styled iframe behind the calendar so HTML SELECT elements don't show through
$('#popup_locations').prepend(document.createElement('iframe'));
}
setupCloseButton();
}
function locationsSelectedLoc(locID, name)
{
//$('#locationID').val(locID);
setSearchLocationID(locID);
$('#searchInput').val(name);
$('#popup_locations').hide();
}
//////////////////////////////////////////////////////////////////////////
function setSearchLocationID(id)
{
var directEnter = $('#searchInput').attr('directenter') == 'true';
searchLocationID = id;
if (id !== false) {
$('#searchButton,#searchButton_r').removeClass('submit_disabled');
} else {
$('#searchButton,#searchButton_r').addClass('submit_disabled');
}
if (directEnter) {
genericSearchButtonAction();
}
}
function searchFindPos(obj) {
var curleft = obj.offsetLeft || 0;
var curtop = obj.offsetTop || 0;
while (obj = obj.offsetParent) {
curleft += obj.offsetLeft;
curtop += obj.offsetTop;
}
return {x:curleft,y:curtop};
}
/******************************************************/
/* calendar 2.0 */
/******************************************************/
window.SplendiaCalendar = function(displayElement, extraCSS, triggers, callbacks) {
var thisCalendar = this;
this.displayElement = displayElement;
this.extraCSS = extraCSS;
this.callbacks = callbacks;
this.singleMonth = false;
this.noHide = false;
this.noSelection = false;
this.dispMap = false;
$.each(triggers, function(i, val) {
$(val).click(function() {
thisCalendar.toggle();
return false;
});
});
this.$node = false;
}
window.SplendiaCalendar.prototype = {
setSingleMonth: function(v) {
this.singleMonth = v;
},
setDispMap: function(v) {
this.dispMap = v;
},
setNoHide: function(v) {
this.noHide = v;
},
setNoSelection: function(v) {
this.noSelection = v;
},
toggle: function() {
this.prebuild();
if (this.$node.css('display') == 'none') {
$('.sc_container_abs').hide();
this.show();
} else {
this.hide();
}
},
prebuild: function() {
if (this.$node === false) {
this.$node = $('');
$('body').append(this.$node);
this.$node.click(function() { return false; });
}
this.reposition();
},
findPos: function(obj) {
obj = $(obj).get(0);
var curleft = obj.offsetLeft || 0;
var curtop = obj.offsetTop || 0;
while (obj = obj.offsetParent) {
curleft += obj.offsetLeft
curtop += obj.offsetTop
}
return {x:curleft,y:curtop};
},
reposition: function() {
// get the position of the input field right now (in case the DOM is shifted)
var pos = this.findPos(this.displayElement);
// reposition
this.$node.css({
//width: parseInt(iWidth) + "px",
top: (pos.y + $(this.displayElement).get(0).offsetHeight) + "px",
left: pos.x + "px"
});
},
hide: function() {
this.$node.hide();
},
show: function() {
this.render();
this.$node.show();
},
parseDate: function(d) {
var c = d.split('/');
var d = parseInt(c[0], 10) - 1;
var m = parseInt(c[1], 10) - 1;
var y = parseInt(c[2], 10) + 2000;
return { 'day' : d, 'month' : m, 'year' : y };
},
nextMonth: function(year, month) {
month++;
if (month > 11) {
year++;
month = 0;
}
return { 'year' : year, 'month' : month };
},
prevMonth: function(year, month) {
month--;
if (month < 0) {
year--;
month = 11;
}
return { 'year' : year, 'month' : month };
},
renderInline: function(preNode) {
this.$node = preNode;
this.render();
},
render: function() {
var base = this.parseDate(this.callbacks.getToday());
var selected = this.callbacks.getSelected();
if (selected != false) {
base = this.parseDate(selected);
}
this.renderMonth(base);
},
renderMonth: function(base) {
//var pager = page > 0 ? '' : '';
var today = this.parseDate(this.callbacks.getToday());
var prev = this.prevMonth(base.year, base.month);
if (!this.singleMonth) {
prev = this.prevMonth(prev.year, prev.month);
}
var next = this.nextMonth(base.year, base.month);
if (!this.singleMonth) {
next = this.nextMonth(next.year, next.month);
}
if (!this.singleMonth) {
var zeroBased = today.month + today.year*12;
var leftParity = ((base.month + base.year*12) - zeroBased) % 2;
if (leftParity == 1) {
base = this.prevMonth(base.year, base.month);
}
}
var nextYear = this.parseDate(this.callbacks.getToday());
nextYear.year++;
var pager = today.year == base.year && today.month == base.month ? '' : '';
if (this.singleMonth) {
var base2 = this.nextMonth(base.year, base.month);
var nextYear2 = this.nextMonth(nextYear.year, nextYear.month);
pager += (base2.year >= nextYear2.year && base2.month > nextYear2.month) ? '' : '';
}
var html = '' + pager + this.callbacks.getMonthName(base.month) + ' ' + base.year + '
';
html += this.generateMonth(base.year, base.month);
html += '
';
base = this.nextMonth(base.year, base.month);
var pager = base.year >= nextYear.year && base.month >= nextYear.month ? '' : '';
if (!this.singleMonth) {
html += '' + pager + this.callbacks.getMonthName(base.month) + ' ' + base.year + '
';
html += this.generateMonth(base.year, base.month);
html += '
';
}
if (!this.noHide) {
html += '';
}
this.$node.html(html);
var thisCalendar = this;
if (this.singleMonth) {
$('.month_left .pagerL', this.$node).click(function() {
thisCalendar.renderMonth(prev);
});
$('.month_left .pagerR', this.$node).click(function() {
thisCalendar.renderMonth(next);
});
} else {
$('.month_left .pager', this.$node).click(function() {
thisCalendar.renderMonth(prev);
});
$('.month_right .pager', this.$node).click(function() {
thisCalendar.renderMonth(next);
});
}
if (!this.noSelection) {
$('.cl', this.$node).click(function() {
thisCalendar.callbacks.selectionMade($(this).attr('spdate'));
thisCalendar.hide();
});
}
if (!this.noHide) {
$('.sc_footer .close', this.$node).click(function() {
thisCalendar.hide();
});
}
},
day1Offset: function(year, month) {
var d = new Date(year, month, 1);
var d = d.getDay() - 1;
return d >= 0 ? d : 6;
},
daysInMonth: function(year, month) {
return 32 - new Date(year, month, 32).getDate();
},
dayOfYear: function (d) {
var yn = d.getFullYear();
var mn = d.getMonth();
var dn = d.getDate();
var d1 = new Date(yn,0,1,12,0,0); // noon on Jan. 1
var d2 = new Date(yn,mn,dn,12,0,0); // noon on input date
var ddiff = Math.round((d2-d1)/864e5);
return ddiff;
},
buildSPDate: function(year, month, day) {
var d = '' + (day + 1);
var m = '' + (month + 1);
if (d.length == 1) d = '0' + d;
if (m.length == 1) m = '0' + m;
return '' + d + '/' + m + '/' + ('' + year).substring(2, 4);
},
generateMonth: function(year, month) {
var selected = this.callbacks.getSelected();
if (selected == false)
selected = -9999;
else {
selected = this.parseDate(selected);
if (selected.month == month && selected.year == year)
selected = selected.day;
else
selected = -9999;
}
var today = this.parseDate(this.callbacks.getToday());
var cutoffDay = -9999;
if (today.month == month && today.year == year) {
cutoffDay = today.day;
}
var i = -this.day1Offset(year, month);
var n = this.daysInMonth(year, month);
var absI = -today.day;
if (year == today.year && month == today.month) {
absI = 0;
}
var curr = { 'year' : today.year, 'month' : today.month };
while (!(year == curr.year && month == curr.month)) {
absI += this.daysInMonth(curr.year, curr.month);
curr = this.nextMonth(curr.year, curr.month);
}
var html = '';
html += '';
var j = 0;
while (j < 7) {
html += '| '+this.callbacks.getDayName(j)+' | ';
j++;
}
html += '
';
var h = 0;
while (h < 6) {
html += '';
for (var j = 0; j < 7; j++, i++) {
if (i < n && i >= 0) {
var klass = 'noday';
if (i >= cutoffDay) {
klass = 'cl';
if (i == selected && this.dispMap == false)
klass += " sel";
else
klass += " day";
if (this.dispMap != false && absI >= 0) {
if (absI <= 365)
klass += this.dispMap[absI] == 1 ? " av" : " noav";
else
klass += " noav";
//klass += (absI % 5 == 0) ? " av" : " noav";
}
absI++;
}
var spdate = this.buildSPDate(year, month, i);
html += '| ' + (i + 1) + ' | ';
} else
html += ' | ';
}
html += '
';
h++;
}
html += '
';
return html;
}
};
//$(document).ready(function()
SplendiaSoftReadyHandlers.push(function()
{
// do not run the search setup if there is no search box
if (typeof(window['searchMode']) == "undefined" ) {
return;
}
var popup = document.createElement('div');
popup.setAttribute('id', 'popup_locations');
var input = document.getElementById('searchInput');
// BUGFIX: Stop looking at input, when it doesnt exist
if(input){
var pos = searchFindPos(input);
$(popup).hide().css({
top: (pos.y + input.offsetHeight + 4) + "px",
left: pos.x + "px"
});
}
$('body').append(popup);
window.initialDatestart = searchBoxStartDate;
window.initialDateend = searchBoxEndDate;
$('#searchInput').attr('mode', 'dest');
function setSearchMode(mode) {
if (mode == searchMode)
return;
setSearchLocationID(false);
if (mode == "destination") {
if (searchDefaultLocationID !== false) {
setSearchLocationID(searchDefaultLocationID);
$('#searchInput').val(searchDefaultLocationName);
} else {
$('#searchInput').val($('#searchInput').attr('titled'));
}
$('#radio_destination').attr('class', 'radio_selected');
$('#radio_hotel').attr('class', 'radio_unselected');
//$('#searchInput').val($('#searchInput').attr('titled'));
$('#searchInput').attr('mode', 'dest');
$('#searchInput').animate({ width : '169px' }, 'normal', function() { $('#popup_locations_trigger').show('normal'); } );
$('.search_box .submit').val(searchBoxTranslations['s_search']);
searchMode = "destination";
currentSearchNames = LocationNamesNA;
currentSearchDisplays = LocationNames;
currentSearchNameOnly = LocationNamesNoHTML;
currentSearchSkip = 4;
} else {
$('#radio_destination').attr('class', 'radio_unselected');
$('#radio_hotel').attr('class', 'radio_selected');
$('#searchInput').val($('#searchInput').attr('titleh'));
$('#searchInput').attr('mode', 'hotel');
$('#popup_locations_trigger').hide('normal', function() { $('#searchInput').animate({ width : '182px' }, 'normal'); });
$('#popup_locations').hide();
$('.search_box .submit').val(searchBoxTranslations['s_book']);
searchMode = "hotel";
currentSearchNames = HotelNamesNA;
currentSearchDisplays = HotelNames;
currentSearchNameOnly = HotelNamesNoHTML;
currentSearchSkip = 4;
}
//$("#searchInput")[0].autocompleter.flushCache();
}
currentSearchNames = LocationNamesNA;
currentSearchDisplays = LocationNames;
currentSearchNameOnly = LocationNamesNoHTML;
currentSearchSkip = 4;
$('#searchInput').autocompleteArray(
[ 'filler' ],
{
delay:10,
minChars:1,
matchSubset:1,
onItemSelect:selectItem,
onFindValue:findValue,
autoFill:false,
maxItemsToShow:20,
selectOnly:1,
selectFirst:1,
width: extraLatestSearches.length > 0 ? '450px' : '255px'
}
);
// location popup ////////////////////////////////////////////////////////
$('#popup_locations_trigger,#top_dest_more').click(function () {
searchDataDelegate();
if (searchHasPreselCountry != false) {
locationsBuildCitySelection(searchHasPreselCountry, false);
} else {
locationsBuildCountrySelection();
}
$('#popup_locations').toggle();
});
// room selector ////////////////////////////////////////////////////////
$('#rooms_selector').click(function() {
$('#rooms_list').slideToggle('fast');
});
$('#rooms_selector_r').click(function() {
$('#rooms_list_r').slideToggle('fast');
});
//$('#rooms_selector li a,#rooms_selector_r li a').click(function(ev) {
$('.room_selector_room_e').click(function(ev) {
var t = $(ev.target).text();
$('#rooms_selected,#rooms_selected_r').text(t);
searchBoxRooms = t.substring(0, 1);
$('#rooms_list,#rooms_list_r').hide();
return false;
});
// adults selector ////////////////////////////////////////////////////////
$('#adults_selector').click(function() {
$('#adults_list').slideToggle('fast');
});
$('#adults_selector_r').click(function() {
$('#adults_list_r').slideToggle('fast');
});
//$('#adults_selector li a,#adults_selector_r li a').click(function(ev) {
$('.adults_selector_room_e').click(function(ev) {
var t = $(ev.target).text();
$('#adults_selected,#adults_selected_r').text(t);
searchBoxAdults = t.substring(0, 1);
$('#adults_list,#adults_list_r').hide();
return false;
});
$('#radio_destination').click(function(ev) {
$('.autoclosing_popup').hide();
setSearchMode("destination");
return false;
});
$('#radio_hotel').click(function(ev) {
$('.autoclosing_popup').hide();
setSearchMode("hotel");
return false;
});
genericSearchButtonAction = function(ev) {
if (searchLocationID !== false) {
var dA = '';
var dE = '';
var dR = '&rooms=' + searchBoxRooms;
var dAd = '&adults=' + searchBoxAdults;
if (searchBoxStartDate !== false && searchBoxEndDate !== false) {
dA = '&datestart=' + searchBoxStartDate;
dE = '&dateend=' + searchBoxEndDate;
}
window.location = '/index.php?resource=redirector&component=RedirectStaticSearch&mode=' + searchMode + '&searchlist_id=' + searchLocationID + dA + dE + dR + dAd;
} else {
$('#searchInput').animate({ backgroundColor: 'rgb(254,239,131)' }, 120)
.animate( { backgroundColor: 'white' }, 120)
.animate( { backgroundColor: 'rgb(254,239,131)' }, 120)
.animate( { backgroundColor: 'white' }, 120)
.animate( { backgroundColor: 'rgb(254,239,131)' }, 120)
.animate( { backgroundColor: 'white' }, 120);
}
}
$('#searchButton').click(genericSearchButtonAction);
// the hotel page always submits an hotel search, not a location search
hotelPageSearchButtonActionProto = function(scrollToRooms) {
if (searchFixedHotel !== false) {
var dA = '';
var dE = '';
var dR = '&rooms=' + searchBoxRooms;
var dAd = '&adults=' + searchBoxAdults;
if (searchBoxStartDate !== false && searchBoxEndDate !== false) {
dA = '&datestart=' + searchBoxStartDate;
dE = '&dateend=' + searchBoxEndDate;
}
var dS = scrollToRooms ? '&roomscroll=1' : '';
window.location = '/index.php?resource=redirector&component=RedirectStaticSearch&mode=hotel' + '&searchlist_id=' + searchFixedHotel + dA + dE + dR + dAd + dS;
}
};
hotelPageSearchButtonAction = function() {
hotelPageSearchButtonActionProto(false);
};
$('#searchButton_r').click(function() { hotelPageSearchButtonActionProto(true); } );
// setup is done, now use initial params to set saved state /////////////
if (searchBoxStartDate !== false || searchBoxEndDate !== false) {
newDateInterval();
}
// avoid changes to nights display in the booking tab
searchFirstIntervalCalc = false;
if (searchMode != 'destination') {
$('#radio_destination').attr('class', 'radio_unselected');
$('#radio_hotel').attr('class', 'radio_selected');
$('#popup_locations_trigger').hide();
$('#searchInput').css('width', '182px');
$('.search_box .submit').val(searchBoxTranslations['s_book']);
searchMode = "hotel";
currentSearchNames = HotelNamesNA;
currentSearchDisplays = HotelNames;
currentSearchNameOnly = HotelNamesNoHTML;
currentSearchSkip = 4;
}
// init location
setSearchLocationID(searchLocationID);
// calendar 2.0
var callbacksBase = function() { };
callbacksBase.prototype = {
getMonthName: function(month) {
return datepickerRegional.monthNames[month];
},
getDayName: function(day) {
if (day == 6)
return datepickerRegional.dayNamesMin[0];
return datepickerRegional.dayNamesMin[day+1];
},
getClose: function() {
return searchBoxTranslations['s_close'];
},
getToday: function() {
return searchBoxTodayDate;
}
};
var callbacksS = new callbacksBase();
callbacksS.getSelected = function() {
return searchBoxStartDate;
}
callbacksS.getLabel = function() {
return searchBoxTranslations['s_date_arr'];
}
callbacksS.selectionMade = function(selected) {
resetStartDate(selected);
newDateIntervalProto(true);
}
var callbacksE = new callbacksBase();
callbacksE.getSelected = function() {
return searchBoxEndDate;
}
callbacksE.getLabel = function() {
return searchBoxTranslations['s_date_dep'];
}
callbacksE.selectionMade = function(selected) {
resetEndDate(selected);
newDateIntervalProto(false);
}
var cal1 = new SplendiaCalendar('#datestart', '', ['#datestart', '#fake-trigger-start'], callbacksS);
var cal2 = new SplendiaCalendar('#dateend', '', ['#dateend', '#fake-trigger-end' ], callbacksE);
var cal3 = new SplendiaCalendar('#datestart_r', '', ['#datestart_r', '#fake-trigger-start_r'], callbacksS);
var cal4 = new SplendiaCalendar('#dateend_r', '', ['#dateend_r', '#fake-trigger-end_r' ], callbacksE);
var damnIE6 = function () {
if ($.browser.msie && $.browser.version == '6.0') {
$('select').toggle();
}
};
/*
var startPickerOnScreen = false;
var endPickerOnScreen = false;
var startPickerOnScreen2 = false;
var endPickerOnScreen2 = false;
$('#fake-trigger-start').click(function() {
if (startPickerOnScreen) {
$('#datestart').datepicker('hide');
} else {
$('#datestart').datepicker('show');
}
});
$('#fake-trigger-end').click(function() {
if (endPickerOnScreen) {
$('#dateend').datepicker('hide');
} else {
$('#dateend').datepicker('show');
}
});
$('#fake-trigger-start_r').click(function() {
if (startPickerOnScreen2) {
$('#datestart_r').datepicker('hide');
} else {
$('#datestart_r').datepicker('show');
}
});
$('#fake-trigger-end_r').click(function() {
if (endPickerOnScreen2) {
$('#dateend_r').datepicker('hide');
} else {
$('#dateend_r').datepicker('show');
}
});
$("#datestart").datepicker({
duration: '',
dateFormat: 'dd/mm/y',
firstDay: 1,
numberOfMonths: 2,
changeMonth: false,
changeYear: false,
mandatory: true,
showOn: "focus",
minDate: new Date(),
maxDate: '+1y',
beforeShow: function () { damnIE6(); startPickerOnScreen = true; },
onClose: function() { damnIE6(); startPickerOnScreen = false; },
onSelect: function(date) { resetStartDate(date); newDateIntervalProto(true) }
});
$("#datestart_r").datepicker({
duration: '',
dateFormat: 'dd/mm/y',
firstDay: 1,
numberOfMonths: 2,
changeMonth: false,
changeYear: false,
mandatory: true,
showOn: "focus",
minDate: new Date(),
maxDate: '+1y',
beforeShow: function () { damnIE6(); startPickerOnScreen2 = true; },
onClose: function() { damnIE6(); startPickerOnScreen2 = false; },
onSelect: function(date) { resetStartDate(date); newDateIntervalProto(true) }
});
$("#dateend").datepicker({
duration: '',
dateFormat: 'dd/mm/y',
firstDay: 1,
numberOfMonths: 2,
changeMonth: false,
changeYear: false,
mandatory: true,
showOn: "focus",
minDate: new Date(),
maxDate: '+1y',
beforeShow: function () { damnIE6(); endPickerOnScreen = true; },
onClose: function() { damnIE6(); endPickerOnScreen = false; },
onSelect: function(date) { resetEndDate(date); newDateIntervalProto(false) }
});
$("#dateend_r").datepicker({
duration: '',
dateFormat: 'dd/mm/y',
firstDay: 1,
numberOfMonths: 2,
changeMonth: false,
changeYear: false,
mandatory: true,
showOn: "focus",
minDate: new Date(),
maxDate: '+1y',
beforeShow: function () { damnIE6(); endPickerOnScreen2 = true; },
onClose: function() { damnIE6(); endPickerOnScreen2 = false; },
onSelect: function(date) { resetEndDate(date); newDateIntervalProto(false) }
});
*/
});