var _ScrollContentTop=0;$(document).ready(function(){if(window.Settings.Booking||window.Settings.Events){window.InputCalendar=new InputCalendar("InputCalendar")}window.CurrentPage=new SearchPage();if($("#ScrollContent").length>0){_ScrollContentTop=$("#ScrollContent").offset().top}$(".Filters").show();$(window).bind("scroll",Window_Scroll);$(window).bind("unload",function(){window.CurrentPage.Dispose()});window.FormManager.Manage("df",window.CurrentPage.Search);window.FormManager.Manage("dt",window.CurrentPage.Search);window.FormManager.Manage("txtDateFrom",window.CurrentPage.Search);window.FormManager.Manage("txtQuery",window.CurrentPage.Search)});function SearchPage(){var D=1,v=2;var u=window.Settings.Events?30:100;var r=this;var k=new SearchEngine("RecordsContainer","/Ajax/BaseTool/Product.ashx",null,u,10,"rating",[],window.Translate.ErrorGlobalSearch);var w=[];var i=D;var p=(!window.Settings.Events)?new GMapBase():null;var t=new WindowControl();var h=0;var m=0;var s={};var c=[];var f=(window.Settings.Booking)?new RoomConfig("RoomConfig"):null;var l=1;var n=0;var b=document.getElementById("RecordsContainer");var F={Collection:[{Name:"DateFrom",Element:document.getElementById("txtDateFrom")},{Name:"DateTo",Element:document.getElementById("txtDateTo")},{Name:"Query",Element:document.getElementById("txtQuery")},{Name:"Tdb",Element:document.getElementById("cbTdb")},{Name:"Interval",Element:document.getElementById("slctInterval")},{Name:"Bookable",Element:document.getElementById("cbBooking")}],Get:function(I){for(var J=0;J<this.Collection.length;J++){if(this.Collection[J].Name==I){return this.Collection[J]}}return null}};$(k).bind("OnSearchEnd",a);$(k).bind("OnRenderEnd",q);if(p!==null){$(p).bind("OnMarkerClick",C)}if(AjaxMgr.GetBaseToolParams()==null){$(AjaxMgr).bind("OnBaseToolParamsLoaded",H)}else{H()}function H(){window.TopContent.InitClosed();var K=AjaxMgr.GetBaseToolParams();k.SetTemplate(((!window.Settings.Events)?"/Ajax/Templates/BaseToolSearch.aspx":"/Ajax/Templates/BaseToolSearchEvents.aspx")+"?l="+window.Settings.Lang+"&t="+window.Settings.Theme+"&u="+window.AjaxMgr.GetBaseToolUser()+"&p="+window.Settings.ProductPageUrl);if(p!==null){p.Init("RecordsMap",62.396396,17.525586,4);var J=new SingleButtonControl("GMapMaximize ThemeColor","<b>"+window.Translate.SearchMapMax+"</b>","<b>"+window.Translate.SearchMapMin+"</b>");$(J).bind("OnClick",function(){r.SwitchListMode()});p.AddControl(J)}K.Actn="search";K.l=window.Settings.Lang;if(window.Settings.Events){K.event="1";var I=F.Get("Interval").Element;s.df=F.Get("DateFrom").Element.value;s.iv=I.options[I.options.selectedIndex].value}K.pt=window.Settings.ProductType;k.SetGlobalSearchParams(K);k.SetOrder("rating");$(F.Get("Query").Element).autocomplete("/Ajax/BaseTool/Area.ashx?usr="+window.AjaxMgr.GetBaseToolUser(),{dataType:"json",parse:d,autoFill:false,cacheLength:30,max:8,delay:500,minChars:2,matchContains:true,mustMatch:false,matchSubset:true,selectFirst:false,width:124,formatItem:j,formatResult:j});$(F.Get("Query").Element).result(G);if(window.Settings.Filter){c=$.extend(c,window.Settings.Filter)}o();if(f!==null){f.Render()}$(b).loaderShow();r.Search()}this.Dispose=function(){A();if(p!==null){p.Dispose()}k.Dispose();k=null;p=null;r=null};this.Sort=function(I){k.SetOrder(I);this.Search()};this.SwitchEventView=function(I){if(!$("#"+I).hasClass("Selected")){l=(l==1)?2:1;k.SetTemplate((l==1?"/Ajax/Templates/BaseToolSearchEvents.aspx":"/Ajax/Templates/BaseToolSearchEventsDbD.aspx")+"?l="+window.Settings.Lang+"&t="+window.Settings.Theme+"&u="+window.AjaxMgr.GetBaseToolUser()+"&p="+window.Settings.ProductPageUrl);k.SetPageSize(l==1?10:30);k.SetPage(0);$("li",".ProductTabs").toggleClass("Selected");this.Search()}};this.FormatDate=function(J,I){var K=new Date(J).getDate()+" "+window.Translate.Months[new Date(J).getMonth()].substr(0,3);K+=" - "+new Date(I).getDate()+" "+window.Translate.Months[new Date(I).getMonth()].substr(0,3);return K};this.Search=function(I){s={};if(n>0){k.SetPage(0)}if(f!==null){s.df=F.Get("DateFrom").Element.value;s.dt=F.Get("DateTo").Element.value;s.rc=f.ToString()}if(window.Settings.Events){var J=F.Get("Interval").Element;s.df=F.Get("DateFrom").Element.value;s.iv=J.options[J.options.selectedIndex].value}s.q=F.Get("Query").Element.value;if(F.Get("Tdb").Element){s.HasTdb=F.Get("Tdb").Element.checked?1:0}if(F.Get("Bookable").Element){s.b=F.Get("Bookable").Element.checked?1:0}s.em=l;if(I!=null){if(c.FindAll("Property",I.Property).FindObj("Value",I.Value)==-1){c.push(I)}}for(var K=0;K<c.length;K++){var L=c[K];if(L.Multi){s[L.Property]=(s[L.Property]||"")+L.Value+","}else{s[L.Property]=L.Value}}B();$(b).loaderShow();n++;k.Search(s);if(i==D){if(I&&I.Property=="Areas"){g(I.Value)}else{g(s.q)}}};this.ViewPage=function(J,I){k.ViewPage(J);if(I){var K=document.getElementById("ctl00_divContentContainer");K.scrollIntoView?K.scrollIntoView(true):window.location.hash="#Content"}};this.SetRooms=function(I){f.SetRooms(I)};this.AddFavourite=function(I,K,J){window.Favourites.Add(K,J,window.Settings.Events?2:1);$(I).text(window.Translate.FavouriteSaved)};this.SwitchListMode=function(){if(i==D){$("#ctl00_cphMain_divCol2").hide();$("#ctl00_cphMain_divCol3").removeClass("QuarterCol").addClass("ThreeQuarterCol");$("#RecordsMap").css("height","500px");$(".TriggerBox").hide();p.AddControl(t);t.Hide();p.SetClustered(true);k.SetGlobalParam("fmt","map");k.SetCacheSize(0);k.SetPageSize(1500);k.SetSuppressRender(true);b=document.getElementById("RecordsMap")}else{$("#ctl00_cphMain_divCol3").removeClass("ThreeQuarterCol").addClass("QuarterCol");$("#ctl00_cphMain_divCol2").show();$("#RecordsMap").css("height","300px");p.RemoveControl(t);p.ClearMarkers(true);p.SetClustered(false);k.RemoveGlobalParam("fmt");k.SetCacheSize(u);k.SetPageSize(10);k.SetSuppressRender(false);b=document.getElementById("RecordsContainer")}p.Resized();i=(i==D)?v:D;this.Search()};this.PrintEvents=function(){var M=AjaxMgr.GetBaseToolParams();var N=c.FindObj("Property","Areas");var L=N>-1?c[N].Value:M.Areas;var J=c.FindObj("Property","Categories");var K=J>-1?c[J].Value:M.Categories;var I="/Pages/EventsPrint.aspx?id="+window.Settings.PageId+"&l="+window.Settings.Lang+"&df="+s.df+"&iv="+s.iv+"&aid="+L+"&cid="+K+"&q="+(s.q||"");OpenWindow(I,"winPrint",800,600)};function B(){$("#SelectedFilters").empty();for(var I=0;I<c.length;I++){$("#SelectedFilters").createAppend("a",{href:"javascript://Remove;",title:window.Translate.Remove},c[I].Name).bind("click",{Filter:c[I]},e)}}function E(J){var L=/\(\d+\)/gi;if(J.FilterCategories!==null&&(c.FindObj("Property","Categories")==-1||n==1)){$("#"+window.Settings.FilterUls[0]+" a.FilterLink").each(function(){var N=$(this).text();$(this).text(N.replace(L,"(0)"))});for(var K=0;K<J.FilterCategories.length;K++){var M=$("#Categories_"+J.FilterCategories[K].Id);var I=M.text();M.text(I.replace(L,"("+J.FilterCategories[K].Count+")"))}}if(J.FilterAreas!==null&&(c.FindObj("Property","Areas")==-1||n==1)){$("#"+window.Settings.FilterUls[1]+" a.FilterLink").each(function(){var N=$(this).text();$(this).text(N.replace(L,"(0)"))});for(K=0;K<J.FilterAreas.length;K++){M=$("#Areas_"+J.FilterAreas[K].Id);I=M.text();M.text(I.replace(L,"("+J.FilterAreas[K].Count+")"))}}}function A(){var K=["HasTdb","Order","b","df","dt","q","rc","sid","iv"];var I={PageId:window.Settings.PageId,Lang:window.Settings.Lang,Page:k.GetPage(),Search:{}};I.Filter=c||{};for(var L in s){if(K.Find(L)>-1&&typeof(s[L])!="undefined"&&s[L]!=null&&s[L]!="null"){I.Search[L]=s[L]}}var J=JSON.stringify(I);$.cookie("Search",J,{expires:new Date().add("h",1),path:"/",domain:window.Settings.Domain})}function o(){var I=$.cookie("ClearSearch");if(I!=null&&parseInt(I)==window.Settings.PageId){$.cookie("ClearSearch",null,{path:"/",domain:window.Settings.Domain});$.cookie("Search",null,{path:"/",domain:window.Settings.Domain});return}if($.cookie("Search")!=null){var J=JSON.parse($.cookie("Search"));if(J.PageId==window.Settings.PageId&&J.Lang==window.Settings.Lang){s=$.extend(s,J.Search);c=$.extend(c,J.Filter);k.SetPage(J.Page);if(J.Search.Order){k.SetOrder(J.Search.Order)}}}var M=GetQueryString("q");var N=GetQueryString("df");var L=GetQueryString("dt");var K=GetQueryString("rad");if(M!==null){s.q=M}if(N!==null){s.df=N}if(L!==null){s.dt=L}if(K!==null){f.SetAdults(0,K);s.rc=f.ToString()}if(s.rc){f=new RoomConfig("RoomConfig",s.rc)}if(s.q){$(F.Get("Query").Element).val(s.q)}if(s.df){$(F.Get("DateFrom").Element).val(s.df)}if(s.dt){$(F.Get("DateTo").Element).val(s.dt)}if(s.HasTdb&&s.HasTdb.toString()=="1"&&F.Get("Tdb").Element){F.Get("Tdb").Element.checked=true}if(s.b&&s.b.toString()=="1"){F.Get("Bookable").Element.checked=true}if(s.iv){$(F.Get("Interval").Element).val(s.iv)}}function a(I){if(typeof(I.Json.Error)!="undefined"){$("#JsError").html(window.Translate.ErrorDate+new Date().toFormat()).show();setTimeout(function(){$("#JsError").hide()},10000)}$(b).loaderHide();h=I.Json.Paging.TotalHits;k.SetParam("sid",I.Json.SearchId);if(I.Json.SearchId>0){window.Tracker.Event("Booking","SearchList","Hits",h)}E(I.Json)}function q(I){w=I.Items;if(p!==null){if(i==D){$("#RecordsContainer").find(".ProductListItem").each(function(J){$(this).bind("mouseover",{Index:J,Element:this},z);$(this).bind("mouseout",{Index:J,Element:this},z)})}x()}if(l){$(".PliCalendar").each(function(J){var K=new Date();K.parseFormat(s.df);var L=new EventCalendar($(this).attr("id"),w[J].Dates,K)})}}function z(I){p.MarkerHover(w[I.data.Index].Id)}function e(K){var I=-1;for(var J=0;J<c.length;J++){if(c[J].Property==K.data.Filter.Property&&c[J].Value==K.data.Filter.Value){I=J;break}}_RemovedFilter=true;c.Remove(I);r.Search();if(K.data.Filter.Property=="Areas"){g(false)}}function g(){if(typeof(arguments[0])=="boolean"&&!arguments[0]){$("#ctl00_cphMain_BoxTrigger").hide()}else{var K=window.AjaxMgr.GetBaseToolParams();var I=typeof(arguments[0])=="string"?0:arguments[0];var J=I==0?arguments[0]:"";window.AjaxMgr.ReqJSON("/ajax/Page.ashx",{actn:"trig",sa:K.Areas,a:I,q:J,l:window.Settings.Lang},false,y,null)}}function y(I){if($("#Trigger").length>0&&I.Heading&&(I.Heading!=""||I.Body!="")){$("#Trigger").empty().createAppend("a",{href:I.Url},["img",{src:I.Img,className:"TeaserImage"},null,"span",{className:"TeaserBody"},["h2",{},I.Heading,"span",{className:"TeaserText"},I.Body]]);$("#ctl00_cphMain_BoxTrigger").fadeIn("slow")}else{$("#ctl00_cphMain_BoxTrigger").hide()}}function d(K){var J=[];for(var I=0;I<K.length;I++){J.push({data:K[I],value:K[I].Name,result:K[I].Name})}window.AutoComplete=K.length>0;return J}function j(I){return I.Name}function G(L,K,J,I){if(K){$(F.Get("Query").Element).val("");r.Search({Name:J,Property:"Areas",Value:K.Id,Compare:"in"})}}function x(){p.ClearMarkers();var K=[];for(var J=0;J<w.length;J++){if(w[J].Latitude!="1000"&&w[J].Longitude!="1000"){var I={Icon:p.GetIcon("static",true)};if(i==v){I.Title=w[J].Name;I.Icon=p.GetIcon("cat"+w[J].Category,true)}K.push(p.CreateMarker(w[J].Id,w[J].Latitude,w[J].Longitude,I))}}if(i==D){p.AddMarkers(K)}else{p.AddClusteredMarkers(K)}if(K.length>0){p.CenterOnMarkers()}}function C(K){if(i==D){var I=w.FindObj("Id",K.Marker.Id);if(I>-1){var J=w[I];window.location=window.Settings.ProductPageUrl+"/"+J.Id+"/"+J.FriendlyUrl+"/"}}else{t.Load(K.Marker.Id)}}}function ExpandFilter(b,e){var d=$(b).parent().parent().parent().next("ul");if(d.length==0){d=$(b).parent().parent().parent().find("ul:first")}var c=d.toggleClass("Hidden").hasClass("Hidden");if(c){$(b).find("img").attr("src","/images/gui/search_filter_item_switch.png")}else{$(b).find("img").attr("src","/images/gui/search_filter_item_switch_on.png")}}function Window_Scroll(b){var a=0;if($(document).scrollTop()>_ScrollContentTop){a=$(document).scrollTop()-_ScrollContentTop}if($.browser.msie&&$.browser.version<=6){$("#ScrollContent").css("top",a)}else{$("#ScrollContent").animate({top:a},{duration:500,queue:false})}};
