var _or,_otemplist;var page=0;var _osortorder=true;var _opriceascending=true;var _oratingascending=true;var _onameascending=true;var _oresortascending=true;var _ofeaturedascending=true;var _opricesortid="pricesort";var _oratingsortid="ratingsort";var _onamesortid="namesort";var _ofeaturedsortid="featuredsort";var _oresortsortid="resortsort";var _olastsortid=_opricesortid;var _ocurrentsortid=_opricesortid;_or=new Array();_otemplist=new Array();function GetOffersSearchStatus(){try{_offerResultsProxy.GetSearchStatus(getSessionId(),"SpecialOfferSearchStatus",GetOffersSearchStatus_Callback,OnResultsPageError)}catch(a){LogError("SpecailOfferResults.js - GetSearchStatus(): "+a,navigator.appName,navigator.appVersion)}}function GetOffersSearchStatus_Callback(d){try{if(d==null){var b,c;b=getOffersSearchingContainer();c=getOffersLostSessionPanel();b.style.display="none";c.style.display="block"}else{if(d==completeStatus){GetOffersResults()}else{setTimeout("GetOffersSearchStatus()",500)}}}catch(a){LogError("SpecailOfferResults.js - GetSearchStatus_CallBack(Result): "+a)}}function GetOffersResults(){try{_offerResultsProxy.GetResults(getSessionId(),GetOffersResults_Callback,OnResultsPageError)}catch(a){LogError("SpecailOfferResults.js - GetResults(): "+a)}}function GetOffersResults_Callback(Result){eval(Result);if($.historyCurrentHash){try{$.OffersSearch._overlay.show();_offerResultsProxy.GetSearchCriteria(getSessionId(),GetSearchCriteria_Callback,OnResultsPageError)}catch(ex){LogError("SpecailOfferResults.js - GetSearchCriteria(): "+ex)}}$("#offerSortControls").SortArrows();SetProcessRequired()}function GetSearchCriteria_Callback(Result){eval(Result)}function GetUserSearchResults(){try{var b=getOffersSearchingContainer();b.style.display="block";_offerResultsProxy.ProcessUserCriteria(getSessionId(),getSpecialOffersSearchCriteria(),GetUserSearchResults_Callback,OnResultsPageError);$.historyLoad(getSpecialOffersSearchCriteriaHash())}catch(a){}}function GetUserSearchResults_Callback(Result){eval(Result);$("#offerSortControls").ResetSortArrows();SetProcessRequired()}function OnResultsPageError(a){LogError("SpecailOfferResults.js - OnResultsPageError(Result): "+a.message)}function processOffersResults(b){try{var e,f,a,d;e=getOffersSearchingContainer();f=getOffersResultsContainer();a=getOffersNoResultsPanel();_noResultsLeftPanel=getOffersNoResultsLeftPanel();_or=new Array();_otemplist=new Array();if(b==null||b.offers.length==0){e.style.display="none";a.style.display="block"}else{for(d=0;d<b.offers.length;d++){aso(d,b.offers[d]);_otemplist.push(d)}e.style.display="none";f.style.display="block";redrawOffersPage();$.Pagination.SetTotalsToggle(_or.length,$("#_offerPaginationControls"));if(b.offers.length==0){_noResultsLeftPanel.style.display="block"}else{_noResultsLeftPanel.style.display="none"}}_showProcessingDiv=true}catch(c){LogError("SpecailOfferResults.js - processResults(specailOffers): "+c)}}function redrawOffersPage(){var b=parseInt($get("_currentOfferPage").value);$(".offerPageLinks").Pagination({current:b,redrawFunction:redrawOffersPage,currentList:_otemplist,resultCountTotal:$(".offerCountTotal"),showAllToggle:$(".showAllOffersToggle"),lastPageId:"_lastOfferPage",currentPageId:"_currentOfferPage",pageSizeId:"_offerPageSize"});var d=$get("_offerPageSize").value;setHtml("#_specailOffers",v2js_OffersResultsTemplate(GetOffersResultsContext()));setHtml("#_offers",v2js_OffersResultsTemplate(GetOffersResultsContext()));var c=$(".showingOfferResult");var a=(_or.length<b*d)?_or.length:b*d;c.find("#offerCountStart").text(((b-1)*d)+1);c.find("#offerCountEnd").text(a);c.find("#offerCountTotal").text(_or.length);if(a==_or.length){c.find("#showAllOffersToggle").text($.Pagination.PagedText())}else{c.find("#showAllOffersToggle").text($.Pagination.NonPagedText())}}function GetOffersResultsContext(){var a=$get("_offerPageSize").value;var d=(a*($get("_currentOfferPage").value-1));var c=new Array();while(d<(a*$get("_currentOfferPage").value)&&d<_otemplist.length){c.push(_otemplist[d]);d++}var b={specialOfferIndexes:c};b.specialOfferIndexes.RetrieveOffer=function(e){return _or[e]};b.specialOfferIndexes.GetCurrency=function(){return _currency};return b}function aso(a,b){_or[a]=new Array();_or[a]=b}function sortoffername(){if(_olastsortid==_onamesortid){_osortorder=(_osortorder?false:true)}else{_osortorder=_onameascending}_ocurrentsortid=_onamesortid;function a(d,c){var g=_or[d].displayName;var f=_or[c].displayName;var e=g.localeCompare(f);if(e==0){e=priceCompare(_or[d].cheapestPrice)-priceCompare(_or[c].cheapestPrice)}if(!_osortorder){return 0-e}else{return e}}_otemplist.sort(a);_olastsortid=_onamesortid;_onameascending=(_onameascending?false:true)}function sortprice(){if(_olastsortid==_opricesortid){_osortorder=(_osortorder?false:true)}else{_osortorder=_opriceascending}_ocurrentsortid=_opricesortid;function a(d,c){var i=_or[d];var h=_or[c];var g=priceCompare(i.cheapestPrice)-priceCompare(h.cheapestPrice);if(g==0){var f="";var e="";g=i.starRating.localeCompare(h.starRating)}if(!_osortorder){return 0-g}else{return g}}_otemplist.sort(a);_olastsortid=_opricesortid;_opriceascending=(_opriceascending?false:true)}function sortofferrating(){if(_olastsortid==_oratingsortid){_osortorder=(_osortorder?false:true)}else{_osortorder=_oratingascending}_ocurrentsortid=_oratingsortid;function a(e,d){var c=_or[e];var i=_or[d];var h=c.starRating.localeCompare(i.starRating);if(h==0){var g="";var f="";h=priceCompare(c.cheapestPrice)-priceCompare(i.cheapestPrice)}if(!_osortorder){return 0-h}else{return h}}_otemplist.sort(a);_olastsortid=_oratingsortid;_oratingascending=(_oratingascending?false:true)}function sortresort(){if(_olastsortid==_oresortsortid){_osortorder=(_osortorder?false:true)}else{_osortorder=_oresortascending}_ocurrentsortid=_oresortsortid;function a(d,c){var h=_or[d];var f=_or[c];var i=h.resortName.localeCompare(f.resortName);if(i==0){var g="";var e="";i=priceCompare(h.cheapestPrice)-priceCompare(f.cheapestPrice)}if(!_osortorder){return 0-i}else{return i}}_otemplist.sort(a);_olastsortid=_oresortsortid;_oresortascending=(_oresortascending?false:true)}function sortfeatured(){if(_olastsortid==_ofeaturedsortid){_osortorder=(_osortorder?false:true)}else{_osortorder=_ofeaturedascending}_ocurrentsortid=_ofeaturedsortid;function a(d,c){var i=_or[d];var h=_or[c];var g=i.featuredHotel.localeCompare(h.featuredHotel);if(g==0){var f="";var e="";g=priceCompare(i.cheapestPrice)-priceCompare(h.cheapestPrice)}if(!_osortorder){return 0-g}else{return g}}_otemplist.sort(a);_olastsortid=_ofeaturedsortid;_oresortascending=(_ofeaturedascending?false:true)};