if(typeof(Dynamicweb)=="undefined"){var Dynamicweb=new Object()}if(typeof(Dynamicweb.Frontend)=="undefined"){Dynamicweb.Frontend=new Object()}Dynamicweb.Frontend.Hashtable=function(){this._data={}};Dynamicweb.Frontend.Hashtable.prototype.get_data=function(){return this._data};Dynamicweb.Frontend.Hashtable.prototype.get=function(a){return this._data[a]};Dynamicweb.Frontend.Hashtable.prototype.contains=function(b){var c=null;var a=false;if(b){c=this.get(b);a=c!=null;if(a&&typeof(c.toLowerCase)!="undefined"){a=c.length>0}}return a};Dynamicweb.Frontend.Hashtable.prototype.set=function(a,b){this._data[a]=b};Dynamicweb.Frontend.Hashtable.prototype.merge=function(a){var c=null;if(a){if(typeof(a.get_data)=="function"){c=a.get_data()}else{c=a}for(var b in a){if(typeof(a[b])!="function"&&!this._data[b]){this.set(b,a[b])}}}};Dynamicweb.Frontend.Document=function(){};Dynamicweb.Frontend.Document.Current=new Dynamicweb.Frontend.Document();Dynamicweb.Frontend.Document._offset=function(){};Dynamicweb.Frontend.Document._offset.initialize=function(){var h=document.body;var a=document.createElement("div");var d=document.createElement("div");var c=null,b=null,i=null,e=null;var f=parseFloat(jQuery.css(h,"marginTop"))||0;var g='<div style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;"><div></div></div><table style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;" cellpadding="0" cellspacing="0"><tr><td></td></tr></table>';Dynamicweb.Frontend.Document.Current.style(a,{position:"absolute",top:"0px",left:"0px",margin:"0px",border:"0px",width:"1px",height:"1px",visibility:"hidden"});a.innerHTML=g;d.style.width=d.style.paddingLeft="1px";h.appendChild(d);h.insertBefore(a,h.firstChild);Dynamicweb.Frontend.Document._offset.boxModel=(d.offsetWidth===2);c=a.firstChild;b=c.firstChild;e=c.nextSibling.firstChild.firstChild;Dynamicweb.Frontend.Document._offset.doesNotAddBorder=(b.offsetTop!==5);Dynamicweb.Frontend.Document._offset.doesAddBorderForTableAndCells=(e.offsetTop===5);b.style.position="fixed";b.style.top="20px";Dynamicweb.Frontend.Document._offset.supportsFixedPosition=(b.offsetTop===20||b.offsetTop===15);b.style.position=b.style.top="";c.style.overflow="hidden";c.style.position="relative";Dynamicweb.Frontend.Document._offset.subtractsBorderForOverflowNotVisible=(b.offsetTop===-5);Dynamicweb.Frontend.Document._offset.doesNotIncludeMarginInBodyOffset=(h.offsetTop!==f);h.removeChild(a);h.removeChild(d);h=a=c=b=i=e=null;Dynamicweb.Frontend.Document._offset.initialize=function(){}};Dynamicweb.Frontend.Document._offset.getWindow=function(b){var a=null;if(b){if(typeof(b.setInterval)!="undefined"){a=b}else{if(b.nodeType==9){a=b.defaultView||b.parentWindow}}}return a};Dynamicweb.Frontend.Document._offset.offset=function(h){var i=null;var p=h;var s={top:0,left:0};var t=null,q=null;var o=/^t(?:able|d|h)$/i;var b=null,m=null;var k=null,d=null;var j=null,c=null,l=null,r=null;var a=null,f=null,g=null;if("getBoundingClientRect" in document.documentElement){if(p&&p!==p.ownerDocument.body){try{i=p.getBoundingClientRect()}catch(n){}t=p.ownerDocument;q=t.documentElement;j=t.body;c=Dynamicweb.Frontend.Document._offset.getWindow(t);l=q.clientTop||j.clientTop||0;r=q.clientLeft||j.clientLeft||0;b=(c.pageYOffset||Dynamicweb.Frontend.Document._offset.boxModel&&q.scrollTop||j.scrollTop);m=(c.pageXOffset||Dynamicweb.Frontend.Document._offset.boxModel&&q.scrollLeft||j.scrollLeft);s.top=i.top+b-l;s.left=i.left+m-r}}else{Dynamicweb.Frontend.Document._offset.initialize();a=p.offsetParent,f=p;t=p.ownerDocument,g,q=t.documentElement;j=t.body,k=t.defaultView;d=k?k.getComputedStyle(p,null):p.currentStyle;s.top=p.offsetTop,s.left=p.offsetLeft;while((p=p.parentNode)&&p!==j&&p!==q){if(Dynamicweb.Frontend.Document._offset.supportsFixedPosition&&d.position==="fixed"){break}g=k?k.getComputedStyle(p,null):p.currentStyle;s.top-=p.scrollTop;s.left-=p.scrollLeft;if(p===a){s.top+=p.offsetTop;s.left+=p.offsetLeft;if(Dynamicweb.Frontend.Document._offset.doesNotAddBorder&&!(Dynamicweb.Frontend.Document._offset.doesAddBorderForTableAndCells&&o.test(p.nodeName))){s.top+=parseFloat(g.borderTopWidth)||0;s.left+=parseFloat(g.borderLeftWidth)||0}f=a;a=p.offsetParent}if(Dynamicweb.Frontend.Document._offset.subtractsBorderForOverflowNotVisible&&g.overflow!=="visible"){s.top+=parseFloat(g.borderTopWidth)||0;s.left+=parseFloat(g.borderLeftWidth)||0}d=g}if(d.position==="relative"||d.position==="static"){s.top+=j.offsetTop;s.left+=j.offsetLeft}if(Dynamicweb.Frontend.Document._offset.supportsFixedPosition&&d.position==="fixed"){s.top+=Math.max(q.scrollTop,j.scrollTop);s.left+=Math.max(q.scrollLeft,j.scrollLeft)}}return s};Dynamicweb.Frontend.Document.prototype.get_url=function(){var a=location.href;var b=a.indexOf("#");if(b>=0){a=a.substring(0,b)}a+=((a.indexOf("?")>0?"&":"?")+"t="+(new Date().getTime()));return a};Dynamicweb.Frontend.Document.prototype.get_isIE=function(){var a=false;if(typeof(Prototype)!="undefined"){a=Prototype.Browser.IE}else{if(typeof(jQuery)!="undefined"){a=jQuery.browser.msie}}return a};Dynamicweb.Frontend.Document.prototype.error=function(a){var b=null;if(typeof(Error)!="undefined"){b=new Error();b.message=a;b.description=a;throw (b)}else{throw (a)}};Dynamicweb.Frontend.Document.prototype.tag=function(b){var a="";if(b){if(b.tagName){a=b.tagName}else{if(b.nodeName){a=b.nodeName}else{if(b.length&&b.length>0){a=this.tag(b[0])}}}if(a){a=a.toLowerCase()}}return a};Dynamicweb.Frontend.Document.prototype.element=function(b){var a=null;if(typeof(b)=="string"){if(typeof(jQuery)!="undefined"){a=$("#"+b)}else{if(typeof(Prototype)!="undefined"){a=$(b)}}}else{a=$(b)}return a};Dynamicweb.Frontend.Document.prototype.id=function(b){var a=null;if(typeof(b)=="string"){a=b}else{if(b.id){a=b.id}else{if(b.length&&b.length>0){a=b[0].id}}}return a};Dynamicweb.Frontend.Document.prototype.addClass=function(b,a){b=this.element(b);if(b){if(b.addClassName){b.addClassName(a)}else{if(b.addClass){b.addClass(a)}}}};Dynamicweb.Frontend.Document.prototype.removeClass=function(b,a){b=this.element(b);if(b){if(b.removeClassName){b.removeClassName(a)}else{if(b.removeClass){b.removeClass(a)}}}};Dynamicweb.Frontend.Document.prototype.attribute=function(f,b,c){var a="";var d=this.element(f);if(b){if(typeof(c)=="undefined"){if(d.attr){a=d.attr(b)}else{if(d.readAttribute){a=d.readAttribute(b)}else{if(d.getAttribute){a=d.getAttribute(b)}}}}else{a=c;if(d.attr){d.attr(b,c)}else{if(d.writeAttribute){d.writeAttribute(b,c)}else{if(d.setAttribute){d.setAttribute(b,c)}}}}}if(typeof(a)=="undefined"){a=""}return a};Dynamicweb.Frontend.Document.prototype.offset=function(b){var a={top:0,left:0};b=this.element(b);if(b){if(typeof(Prototype)!="undefined"){a=Dynamicweb.Frontend.Document._offset.offset(b)}else{if(b.offset){a=b.offset()}}}return a};Dynamicweb.Frontend.Document.prototype.width=function(a){return this.dimension(a,"Width",value)};Dynamicweb.Frontend.Document.prototype.height=function(b,a){return this.dimension(b,"Height",a)};Dynamicweb.Frontend.Document.prototype.dimension=function(f,d,c){var a=0;var b=null;var e=null;f=this.element(f);if(f){e=f;if(f.length&&f.length>0){e=f[0]}if(typeof(c)=="undefined"){a=e["offset"+d]}else{b=new Object();b[d.toLowerCase()]=parseInt(c)+"px";this.style(e,b)}}return a};Dynamicweb.Frontend.Document.prototype.select=function(c,a){var b=[];if(c&&a){if(c.find){b=c.find(a)}else{if(c.select){b=c.select(a)}}}return b};Dynamicweb.Frontend.Document.prototype.next=function(c,a){var b=null;c=this.element(c);if(c&&c.next){b=c.next(a);if(b!=null&&b.length&&b.length>0){b=b[0]}}if(b&&typeof(b.length)!="undefined"&&b.length==0){b=null}return b};Dynamicweb.Frontend.Document.prototype.previous=function(c,a){var b=null;c=this.element(c);if(c){if(c.prev){b=c.prev(a)}else{if(c.previous){b=c.previous(a)}}if(b!=null&&b.length&&b.length>0){b=b[0]}}if(b&&typeof(b.length)!="undefined"&&b.length==0){b=null}return b};Dynamicweb.Frontend.Document.prototype.up=function(c,a){var b=null;c=this.element(c);if(c){if(c.is&&c.is(a)){b=c}else{if(c.match&&c.match(a)){b=c}}if(!b){if(c.up){b=c.up(a)}else{if(c.parent){b=c.parent(a);if(b!=null&&b.length&&b.length>0){b=this.element(b[0])}}}}}return b};Dynamicweb.Frontend.Document.prototype.down=function(c,a){var b=null;c=this.element(c);if(c){if(c.down){b=c.down(a)}else{if(c.children){b=c.children(a);if(b!=null&&b.length&&b.length>0){b=this.element(b[0])}}}}return b};Dynamicweb.Frontend.Document.prototype.style=function(c,b){var a="";c=this.element(c);if(c){if(typeof(b)=="string"){if(c.getStyle){a=c.getStyle(b)}else{if(c.css){a=c.css(b)}}}else{if(c.setStyle){c.setStyle(b)}else{if(c.css){c.css(b)}}}}return a};Dynamicweb.Frontend.Document.prototype.clone=function(c,a){var b=null;c=this.element(c);if(c){b=c.clone(!!a)}return b};Dynamicweb.Frontend.Document.prototype.append=function(b,a){b=this.element(b);if(b){if(b.appendChild){b.appendChild(a)}else{if(b.append){b.append(a)}}}};Dynamicweb.Frontend.Document.prototype.observe=function(d,a,c){if(d&&a&&c){if(typeof(Event)!="undefined"&&Event.observe){Event.observe(d,a,c)}else{if(!d.bind){try{d=this.element(d)}catch(b){}}if(d.bind){d.bind(a,c)}}}};Dynamicweb.Frontend.Document.prototype.stopObserving=function(d,a,c){if(d&&a&&c){if(typeof(Event)!="undefined"&&Event.stopObserving){Event.stopObserving(d,a,c)}else{if(!d.unbind){try{d=this.element(d)}catch(b){}}if(d.unbind){d.unbind(a,c)}}}};Dynamicweb.Frontend.Document.prototype.eventTarget=function(b){var a=null;if(b){if(typeof(Event)!="undefined"&&Event.element){a=Event.element(b)}else{a=b.target}}return a};Dynamicweb.Frontend.Document.prototype.stopEvent=function(a){if(a){if(typeof(Event)!="undefined"&&Event.stop){Event.stop(a)}else{if(a.stopPropagation){a.stopPropagation()}}}};Dynamicweb.Frontend.Document.prototype.ready=function(a){Dynamicweb.Frontend.InstantSearch._checkFramework();if(typeof(Event)!="undefined"&&Event.observe){this.element(document).observe("dom:loaded",a)}else{if(this.element(document).ready){this.element(document).ready(a)}}};Dynamicweb.Frontend.Document.prototype.text=function(b){var a="";if(b){a=b.innerText?b.innerText:b.textContent}if(!a){a=""}return a};Dynamicweb.Frontend.Document.prototype.html=function(c,b){var a="";if(c){if(typeof(jQuery)!="undefined"){if(typeof(b)=="undefined"){a=this.element(c).html()}else{a=b;this.element(c).html(b)}}else{if(typeof(b)=="undefined"){a=c.innerHTML}else{a=b;c.innerHTML=b}}}if(!a){a=""}return a};Dynamicweb.Frontend.Document.prototype.value=function(f,a){var e="";var j="";var g="";var h=[];var d=null;var c=null;if(f){j=this.tag(f);d=this.element(f);if(d.length&&d.length>0){c=d[0]}else{c=d}if(typeof(a)=="undefined"){if(j=="input"){g=this.attribute(c,"type");if(g=="button"||g=="submit"){h[0]=this.attribute(d,"value")}else{if(g=="image"){h[0]=this.attribute(d,"src")}else{h[0]=c.value}}}else{if(j=="select"){if(c.options&&c.options.length>0){if(c.multiple){for(var b=0;b<c.options.length;b++){if(c.options[b].selected){h[h.length]=c.options[b].value}}}else{if(c.selectedIndex>=0&&c.selectedIndex<c.options.length){h[0]=c.options[c.selectedIndex].value}}}}else{if(j=="textarea"||j=="button"){h[0]=Dynamicweb.Frontend.Document.Current.text(c)}}}}else{if(j=="input"){g=this.attribute(c,"type");if(g=="button"||g=="submit"){this.attribute(d,"value",a)}else{if(g=="image"){this.attribute(d,"src",a)}else{c.value=a}}}else{if(j=="select"){if(c.options&&c.options.length>0){for(var b=0;b<c.options.length;b++){if(c.options[b].value==a){c.options[b].selected=true;if(!c.multiple){break}}}}}else{if(j=="textarea"||j=="button"){this.html(c,a)}}}}}for(var b=0;b<h.length;b++){if(h[b]){e+=h[b];if(b<(h.length-1)){e+=","}}}return e};Dynamicweb.Frontend.Document.prototype.data=function(f,d){var e="";var c={};var b=new Object();var a="data-dw";if(!d){d={}}if(f){e=this.id(f);if(e){if(!window._elementData){window._elementData=new Dynamicweb.Frontend.Hashtable()}if(typeof(d.suffix)!="undefined"){a+=("-"+d.suffix)}c=window._elementData.get(e);if(typeof(d.value)=="undefined"){if(c){b=c.get(a)}if(b==null){b=new Object()}}else{b=d.value;if(c==null){c=new Dynamicweb.Frontend.Hashtable()}c.set(a,d.value);window._elementData.set(e,c)}}}return b};Dynamicweb.Frontend.Document.prototype.serializeForm=function(b){var a={};var c=[];b=this.element(b);if(b){if(b.serializeArray){c=b.serializeArray();$.each(c,function(){if(a[this.name]){if(!a[this.name].push){a[this.name]=[a[this.name]]}a[this.name].push(this.value||"")}else{a[this.name]=this.value||""}})}else{if(b.serialize){a=b.serialize(true)}}}return a};Dynamicweb.Frontend.Document.prototype.deserialize=function(c){var a=new Object();if(c&&typeof(c)=="string"){try{if(c.evalJSON){a=c.evalJSON()}else{if(typeof(jQuery)!="undefined"&&jQuery.parseJSON){a=jQuery.parseJSON(c)}}}catch(b){}}return a};Dynamicweb.Frontend.Document.prototype.postAsync=function(a,b){if(!b){b={}}if(!b.parameters){b.parameters={}}if(!b.onComplete){b.onComplete=function(){}}if(a){if(typeof(Ajax)!="undefined"&&Ajax.Request){new Ajax.Request(a,{method:"post",parameters:b.parameters,onComplete:b.onComplete})}else{if($.ajax){$.ajax({type:"POST",url:a,data:b.parameters,complete:b.onComplete})}}}};Dynamicweb.Frontend.SuggestionBox=function(b,a){this._e=Dynamicweb.Frontend.Document.Current.element(b);this._attachTo=Dynamicweb.Frontend.Document.Current.element(a);this._data=[];this._current=null;this._query="";this._itemTemplate=null;this._emptyListTemplate=null};Dynamicweb.Frontend.SuggestionBox.prototype.get_container=function(){return this._e};Dynamicweb.Frontend.SuggestionBox.prototype.get_isVisible=function(){return Dynamicweb.Frontend.Document.Current.style(this.get_container(),"display").toLowerCase()!="none"};Dynamicweb.Frontend.SuggestionBox.prototype.get_itemTemplate=function(){return this._itemTemplate};Dynamicweb.Frontend.SuggestionBox.prototype.set_itemTemplate=function(a){this._itemTemplate=a};Dynamicweb.Frontend.SuggestionBox.prototype.get_emptyListTemplate=function(){return this._emptyListTemplate};Dynamicweb.Frontend.SuggestionBox.prototype.set_emptyListTemplate=function(a){this._emptyListTemplate=a};Dynamicweb.Frontend.SuggestionBox.prototype.get_query=function(){return this._query};Dynamicweb.Frontend.SuggestionBox.prototype.set_query=function(a){this._query=a};Dynamicweb.Frontend.SuggestionBox.prototype.get_current=function(){return this._current};Dynamicweb.Frontend.SuggestionBox.prototype.set_current=function(a){if(this._current!=null){Dynamicweb.Frontend.Document.Current.removeClass(this._current,"dw-suggestion-item-active")}this._current=a;if(this._current!=null){Dynamicweb.Frontend.Document.Current.addClass(this._current,"dw-suggestion-item-active")}};Dynamicweb.Frontend.SuggestionBox.prototype.get_attachTo=function(){return this._attachTo};Dynamicweb.Frontend.SuggestionBox.prototype.set_attachTo=function(a){this._attachTo=a};Dynamicweb.Frontend.SuggestionBox.prototype.get_data=function(){if(!this._data){this._data=[]}return this._data};Dynamicweb.Frontend.SuggestionBox.prototype.populateResults=function(f,d){var a=this;var e=null;var g=this.get_container();this._data=f;if(!this._data){this._data=[]}d=d||function(){};Dynamicweb.Frontend.Document.Current.html(g,"");if(this._data.length==0){if(this.get_emptyListTemplate()){Dynamicweb.Frontend.Document.Current.append(g,Dynamicweb.Frontend.Document.Current.clone(this.get_emptyListTemplate(),true))}}else{if(this.get_itemTemplate()){for(var b=0;b<this._data.length;b++){e=Dynamicweb.Frontend.Document.Current.clone(this.get_itemTemplate(),true);Dynamicweb.Frontend.Document.Current.html(e,this._data[b]);Dynamicweb.Frontend.Document.Current.observe(e,"click",function(c){a.set_current(Dynamicweb.Frontend.Document.Current.eventTarget(c));a.updateTextboxValue();a.hide();if(Dynamicweb.Frontend.InstantSearchSettings.Global.getIsEnabled(a.get_attachTo(),"search")){Dynamicweb.Frontend.InstantSearch._onInstantSearchWrapper(c,a.get_attachTo())}});Dynamicweb.Frontend.Document.Current.observe(e,"mouseover",function(c){a.set_current(Dynamicweb.Frontend.Document.Current.eventTarget(c))});Dynamicweb.Frontend.Document.Current.observe(e,"mouseout",function(c){a.set_current(null)});d(this,{template:e,data:this._data[b]});Dynamicweb.Frontend.Document.Current.append(g,e)}}}};Dynamicweb.Frontend.SuggestionBox._ie_timeoutID=0;Dynamicweb.Frontend.SuggestionBox._ie_dimension={width:document.documentElement.clientWidth,height:document.documentElement.clientHeight};Dynamicweb.Frontend.SuggestionBox.prototype.show=function(){var d=null;var f=this.get_container();var e=this.get_attachTo();var a=function(c){if(c.type=="resize"&&Dynamicweb.Frontend.Document.Current.get_isIE()){if(Dynamicweb.Frontend.SuggestionBox._ie_timeoutID){clearTimeout(Dynamicweb.Frontend.SuggestionBox._ie_timeoutID)}Dynamicweb.Frontend.SuggestionBox._ie_timeoutID=setTimeout(function(){if(Dynamicweb.Frontend.SuggestionBox._ie_dimension.width!=document.documentElement.clientWidth||Dynamicweb.Frontend.SuggestionBox._ie_dimension.height!=document.documentElement.clientHeight){Dynamicweb.Frontend.SuggestionBox.hideAll();Dynamicweb.Frontend.SuggestionBox._ie_dimension={width:document.documentElement.clientWidth,height:document.documentElement.clientHeight}}},10)}else{Dynamicweb.Frontend.SuggestionBox.hideAll()}};var b=a;a._dimensions={width:document.body.clientWidth,height:document.body.clientHeight};if(f&&e){if(Dynamicweb.Frontend.Document.Current.html(f).length>0){Dynamicweb.Frontend.Document.Current.stopObserving(window,"resize",a);Dynamicweb.Frontend.Document.Current.stopObserving(document.body,"click",b);Dynamicweb.Frontend.Document.Current.observe(window,"resize",a);Dynamicweb.Frontend.Document.Current.observe(document.body,"click",b);d=Dynamicweb.Frontend.Document.Current.offset(e);if(d){Dynamicweb.Frontend.Document.Current.style(f,{display:"block",position:"absolute","z-index":"999",left:d.left+"px",top:d.top+Dynamicweb.Frontend.Document.Current.height(e)-1+"px"})}}}};Dynamicweb.Frontend.SuggestionBox.prototype.tryNavigate=function(c){var a=true;var b=null;if(this.get_isVisible()){if(c==40){b=this.next()}else{if(c==38){b=this.previous()}else{a=false}}this.set_current(b);if(a&&b==null){if(this.get_attachTo()){this.updateTextboxValue(this.get_query())}}else{this.updateTextboxValue()}}else{a=false}return a};Dynamicweb.Frontend.SuggestionBox.prototype.next=function(){var b=null;var a=null;if(this.get_current()==null){a=Dynamicweb.Frontend.Document.Current.select(this.get_container(),".dw-suggestion-item");if(a!=null){b=a[0]}}else{b=Dynamicweb.Frontend.Document.Current.next(this.get_current(),".dw-suggestion-item")}return b};Dynamicweb.Frontend.SuggestionBox.prototype.previous=function(){var b=null;var a=null;if(this.get_current()==null){a=Dynamicweb.Frontend.Document.Current.select(this.get_container(),".dw-suggestion-item");if(a!=null){b=a[a.length-1]}}else{b=Dynamicweb.Frontend.Document.Current.previous(this.get_current(),".dw-suggestion-item")}return b};Dynamicweb.Frontend.SuggestionBox.prototype.hide=function(){var a=this.get_container();if(a){Dynamicweb.Frontend.Document.Current.style(a,{display:"none"})}};Dynamicweb.Frontend.SuggestionBox.prototype.updateTextboxValue=function(d){var e=this.get_current();var a=this.get_attachTo();if(a){if(typeof(d)!="undefined"){Dynamicweb.Frontend.Document.Current.value(a,d)}else{if(e){Dynamicweb.Frontend.Document.Current.value(a,Dynamicweb.Frontend.Document.Current.text(e))}}try{a.focus()}catch(b){}}};Dynamicweb.Frontend.SuggestionBox.prototype._getTemplate=function(a){var b=null;var d=this.get_container();if(d){b=Dynamicweb.Frontend.Document.Current.down(d,a);if(b){b=Dynamicweb.Frontend.Document.Current.clone(b,true)}}return b};Dynamicweb.Frontend.SuggestionBox.retrieve=function(b,a){b=b?b.toString():"";if(!window._suggestionBoxes){window._suggestionBoxes=[]}if(!window._suggestionBoxes[b]){window._suggestionBoxes[b]=new Dynamicweb.Frontend.SuggestionBox(b,a);window._suggestionBoxes[b].set_itemTemplate(window._suggestionBoxes[b]._getTemplate(".dw-suggestion-item"));window._suggestionBoxes[b].set_emptyListTemplate(window._suggestionBoxes[b]._getTemplate(".dw-no-suggestions"))}return window._suggestionBoxes[b]};Dynamicweb.Frontend.SuggestionBox.retrieveAll=function(){if(!window._suggestionBoxes){window._suggestionBoxes=[]}return window._suggestionBoxes};Dynamicweb.Frontend.SuggestionBox.hideAll=function(){var a=Dynamicweb.Frontend.SuggestionBox.retrieveAll();for(var b in a){if(a[b]&&typeof(a[b].hide)=="function"){a[b].hide()}}};Dynamicweb.Frontend.SearchResultItemTemplate=function(a){this._container=Dynamicweb.Frontend.Document.Current.element(a);this._isVisible=true;if(this._container){this._container=Dynamicweb.Frontend.Document.Current.clone(this._container,true);this._cleanContainer=Dynamicweb.Frontend.Document.Current.clone(this._container,true)}};Dynamicweb.Frontend.SearchResultItemTemplate.prototype.reset=function(){this._container=Dynamicweb.Frontend.Document.Current.clone(this._cleanContainer,true)};Dynamicweb.Frontend.SearchResultItemTemplate.prototype.get_container=function(){return this._container};Dynamicweb.Frontend.SearchResultItemTemplate.prototype.get_isVisible=function(){return this._isVisible};Dynamicweb.Frontend.SearchResultItemTemplate.prototype.set_isVisible=function(a){this._isVisible=!!a};Dynamicweb.Frontend.SearchResultItemTemplate.prototype.field=function(b,c){var a="";var d=null;if(b){b=b.toLowerCase();d=Dynamicweb.Frontend.Document.Current.select(this.get_container(),".dw-search-result-"+b);if(d!=null&&d.length>0){d=Dynamicweb.Frontend.Document.Current.element(d[0]);if(Dynamicweb.Frontend.Document.Current.tag(d)=="a"){if(typeof(c)=="undefined"){a=Dynamicweb.Frontend.Document.Current.attribute(d,"href")}else{a=c;Dynamicweb.Frontend.Document.Current.attribute(d,"href",a)}}else{if(Dynamicweb.Frontend.Document.Current.tag(d)=="img"){if(typeof(c)=="undefined"){a=Dynamicweb.Frontend.Document.Current.attribute(d,"src")}else{a=c;Dynamicweb.Frontend.Document.Current.attribute(d,"src",a)}}else{if(typeof(c)=="undefined"){a=Dynamicweb.Frontend.Document.Current.text(d)}else{a=c;Dynamicweb.Frontend.Document.Current.html(d,a)}}}}}return a};Dynamicweb.Frontend.SearchResultsContainer=function(b){var a=null;this._query="";this._data=[];this._container=Dynamicweb.Frontend.Document.Current.element(b);this._itemTemplate=null;this._emptyListTemplate=null;if(this._container){a=Dynamicweb.Frontend.Document.Current.select(this.get_container(),".dw-search-result");if(a!=null&&a.length>0){this._itemTemplate=new Dynamicweb.Frontend.SearchResultItemTemplate(a[0])}a=Dynamicweb.Frontend.Document.Current.select(this.get_container(),".dw-no-results");if(a!=null&&a.length>0){this._emptyListTemplate=Dynamicweb.Frontend.Document.Current.clone(a[0],true);Dynamicweb.Frontend.Document.Current.style(this._emptyListTemplate,{display:"block"})}}};Dynamicweb.Frontend.SearchResultsContainer.prototype.get_query=function(){return this._query};Dynamicweb.Frontend.SearchResultsContainer.prototype.set_query=function(a){this._query=a};Dynamicweb.Frontend.SearchResultsContainer.prototype.get_container=function(){return this._container};Dynamicweb.Frontend.SearchResultsContainer.prototype.get_itemTemplate=function(){return this._itemTemplate};Dynamicweb.Frontend.SearchResultsContainer.prototype.set_itemTemplate=function(a){this._itemTemplate=a};Dynamicweb.Frontend.SearchResultsContainer.prototype.get_emptyListTemplate=function(){return this._emptyListTemplate};Dynamicweb.Frontend.SearchResultsContainer.prototype.set_emptyListTemplate=function(a){this._emptyListTemplate=a};Dynamicweb.Frontend.SearchResultsContainer.prototype.get_data=function(){if(!this._data){this._data=[]}return this._data};Dynamicweb.Frontend.SearchResultsContainer.prototype.populateResults=function(f,d){var a=null;var e=null;var h=this.get_container();d=d||function(){};if(h){Dynamicweb.Frontend.Document.Current.html(h,"");this._data=f;if(this._data&&this._data.length>0){for(var b=0;b<this._data.length;b++){this.get_itemTemplate().reset();for(var g in this._data[b]){this.get_itemTemplate().field(g,this._data[b][g])}Dynamicweb.Frontend.Document.Current.style(this.get_itemTemplate().get_container(),{display:"block"});a={template:this.get_itemTemplate(),data:this._data[b]};d(this,a);if(a.template.get_isVisible()){Dynamicweb.Frontend.Document.Current.append(h,a.template.get_container())}}}else{if(this.get_emptyListTemplate()){Dynamicweb.Frontend.Document.Current.append(h,Dynamicweb.Frontend.Document.Current.clone(this.get_emptyListTemplate(),true))}}}};Dynamicweb.Frontend.SearchResultsContainer.retrieve=function(a){a=a?a.toString():"";if(!window._searchContainers){window._searchContainers=[]}if(!window._searchContainers[a]){window._searchContainers[a]=new Dynamicweb.Frontend.SearchResultsContainer(a)}return window._searchContainers[a]};Dynamicweb.Frontend.InstantSearchSettings=function(){this._pageID=0;this._paragraphID=0;this._delay=250;this._isEnabled={}};Dynamicweb.Frontend.InstantSearchSettings.Global=new Dynamicweb.Frontend.InstantSearchSettings();Dynamicweb.Frontend.InstantSearchSettings.prototype.get_pageID=function(){return this._pageID};Dynamicweb.Frontend.InstantSearchSettings.prototype.set_pageID=function(a){this._pageID=a};Dynamicweb.Frontend.InstantSearchSettings.prototype.get_url=function(){return this._url};Dynamicweb.Frontend.InstantSearchSettings.prototype.set_url=function(a){this._url=a};Dynamicweb.Frontend.InstantSearchSettings.prototype.get_paragraphID=function(){return this._paragraphID};Dynamicweb.Frontend.InstantSearchSettings.prototype.set_paragraphID=function(a){this._paragraphID=a};Dynamicweb.Frontend.InstantSearchSettings.prototype.get_delay=function(){return this._delay};Dynamicweb.Frontend.InstantSearchSettings.prototype.set_delay=function(a){this._delay=a};Dynamicweb.Frontend.InstantSearchSettings.prototype.load=function(a){if(!a){a={}}if(typeof(a.pageID)!="undefined"){this.set_pageID(parseInt(a.pageID))}if(typeof(a.paragraphID)!="undefined"){this.set_paragraphID(parseInt(a.paragraphID))}if(typeof(a.delay)!="undefined"){this.set_delay(parseInt(a.delay))}if(typeof(a.url)!="undefined"){this.set_url(a.url)}};Dynamicweb.Frontend.InstantSearchSettings.prototype.setIsEnabled=function(f,a,d){var c=[];var g=Dynamicweb.Frontend.Document.Current.id(f);d=!!d;if(g&&a){if(!this._isEnabled){this._isEnabled={}}if(!this._isEnabled[a]){this._isEnabled[a]=[]}if(d&&!this.getIsEnabled(f,a)){this._isEnabled[a][this._isEnabled[a].length]=g}else{if(!d&&this.getIsEnabled(f,a)){for(var b=0;b<this._isEnabled[a].length;b++){if(this._isEnabled[a][b]!=g){c[c.length]=this._isEnabled[a][b]}}this._isEnabled[a]=c}}}};Dynamicweb.Frontend.InstantSearchSettings.prototype.getIsEnabled=function(d,b){var a=false;var f=Dynamicweb.Frontend.Document.Current.id(d);if(f&&b){if(!this._isEnabled){this._isEnabled={}}if(this._isEnabled[b]&&this._isEnabled[b].length){for(var c=0;c<this._isEnabled[b].length;c++){if(this._isEnabled[b][c]==f){a=true;break}}}}return a};Dynamicweb.Frontend.InstantSearch=function(){};Dynamicweb.Frontend.InstantSearch.setup=function(a){Dynamicweb.Frontend.InstantSearch._checkFramework();Dynamicweb.Frontend.InstantSearchSettings.Global.load(a)};Dynamicweb.Frontend.InstantSearch.warmUp=function(c){var a=null;var b=null;var d=function(){};if(c==null||typeof(c)=="undefined"){c={}}if(!c.pageID){c.pageID=Dynamicweb.Frontend.InstantSearchSettings.Global.get_pageID()}if(!c.paragraphID){c.paragraphID=Dynamicweb.Frontend.InstantSearchSettings.Global.get_paragraphID()}d=c.onComplete||function(){};if(c.url){a=c.url}else{if(Dynamicweb.Frontend.InstantSearchSettings.Global.get_url()){a=Dynamicweb.Frontend.InstantSearchSettings.Global.get_url()}else{a=Dynamicweb.Frontend.Document.Current.get_url()}}b=new Dynamicweb.Frontend.Hashtable();b.set("ID",c.pageID);b.set("PID",c.paragraphID);b.set("InstantSearchType","WarmUp");Dynamicweb.Frontend.Document.prototype.postAsync(a,{parameters:b.get_data(),onComplete:function(e){d(e)}})};Dynamicweb.Frontend.InstantSearch.setEnableSuggestions=function(d,b,f){var g=null;var a="";var c=null;Dynamicweb.Frontend.InstantSearch._checkFramework();g=Dynamicweb.Frontend.Document.Current.element(d);c=g;if(f&&f.triggerID){c=Dynamicweb.Frontend.Document.Current.element(f.triggerID);Dynamicweb.Frontend.Document.Current.attribute(c,"data-dwtriggers",Dynamicweb.Frontend.Document.Current.id(g))}a=Dynamicweb.Frontend.InstantSearch._getChangeEvent(c);if(g){if(Dynamicweb.Frontend.Document.Current.tag(g).toLowerCase()!="input"||Dynamicweb.Frontend.Document.Current.attribute(g,"type").toLowerCase()!="text"){Dynamicweb.Frontend.Document.Current.error("Suggested queries can only be enabled on the existing textbox element.")}else{Dynamicweb.Frontend.Document.Current.stopObserving(c,a,Dynamicweb.Frontend.InstantSearch._onSuggestWrapper);Dynamicweb.Frontend.InstantSearchSettings.Global.setIsEnabled(g,"suggest",b);if(f&&f.triggerID){Dynamicweb.Frontend.InstantSearchSettings.Global.setIsEnabled(f.triggerID,"suggest",b)}if(b){if(f){if(!f.delay||f.delay<0){f.delay=Dynamicweb.Frontend.InstantSearchSettings.Global.get_delay()}}Dynamicweb.Frontend.Document.Current.data(Dynamicweb.Frontend.Document.Current.id(g),{value:f,suffix:"suggest"});Dynamicweb.Frontend.Document.Current.observe(c,a,Dynamicweb.Frontend.InstantSearch._onSuggestWrapper)}}}};Dynamicweb.Frontend.InstantSearch.setEnableInstantSearch=function(d,b,f){var g=null;var a="";var c=null;Dynamicweb.Frontend.InstantSearch._checkFramework();g=Dynamicweb.Frontend.Document.Current.element(d);c=g;if(f&&f.triggerID){c=Dynamicweb.Frontend.Document.Current.element(f.triggerID);Dynamicweb.Frontend.Document.Current.attribute(c,"data-dwtriggers",Dynamicweb.Frontend.Document.Current.id(g))}a=Dynamicweb.Frontend.InstantSearch._getChangeEvent(c);if(g){Dynamicweb.Frontend.Document.Current.stopObserving(c,a,Dynamicweb.Frontend.InstantSearch._onInstantSearchWrapper);Dynamicweb.Frontend.InstantSearchSettings.Global.setIsEnabled(g,"search",b);if(b){if(f){if(!f.delay||f.delay<0){f.delay=Dynamicweb.Frontend.InstantSearchSettings.Global.get_delay()}}Dynamicweb.Frontend.Document.Current.data(Dynamicweb.Frontend.Document.Current.id(g),{value:f,suffix:"search"});Dynamicweb.Frontend.Document.Current.observe(c,a,Dynamicweb.Frontend.InstantSearch._onInstantSearchWrapper)}}};Dynamicweb.Frontend.InstantSearch.suggest=function(m,h){var f="";var c=null;var j=null;var d=null;var i=null;var n="";var q="";var k=m;var p=null;var g=null;var o=false;var a=null;var e=null;var l=null;if(!h){h={}}p=h.onComplete||function(){};l=h.onItemDataBound||function(){};g=p;e=l;if(k){a=Dynamicweb.Frontend.Document.Current.data(Dynamicweb.Frontend.Document.Current.id(k),{suffix:"suggest"});if(!a){a={}}if(typeof(a.onComplete)=="function"){g=function(s,r){p(s,r);a.onComplete(s,r)}}if(typeof(a.onItemDataBound)=="function"){e=function(s,r){l(s,r);a.onItemDataBound(s,r)}}j=Dynamicweb.Frontend.SuggestionBox.retrieve(a.boxID,Dynamicweb.Frontend.Document.Current.id(k));f=Dynamicweb.Frontend.Document.Current.value(k);if(Dynamicweb.Frontend.InstantSearch._stateChanged(k,"suggest")&&a.boxID){o=true;a.value=f;Dynamicweb.Frontend.Document.Current.data(Dynamicweb.Frontend.Document.Current.id(k),{value:a,suffix:"suggest"})}if(f&&o){i=new Dynamicweb.Frontend.Hashtable();if(a.url){c=a.url}else{if(Dynamicweb.Frontend.InstantSearchSettings.Global.get_url()){c=Dynamicweb.Frontend.InstantSearchSettings.Global.get_url()}else{c=Dynamicweb.Frontend.Document.Current.get_url()}}q=Dynamicweb.Frontend.Document.Current.attribute(k,"name");i.set("ID",a.pageID?a.pageID:Dynamicweb.Frontend.InstantSearchSettings.Global.get_pageID());i.set("PID",a.paragraphID?a.paragraphID:Dynamicweb.Frontend.InstantSearchSettings.Global.get_paragraphID());i.set("o","json");i.set("InstantSearchType","Suggest");i.set("Caller",q);n=Dynamicweb.Frontend.InstantSearch._queryParam("GroupID");if(n){i.set("GroupID",n)}if(a.request){for(var b in a.request){i.set(b,a.request[b])}}d=Dynamicweb.Frontend.Document.Current.up(k,"form");if(d!=null){i.merge(Dynamicweb.Frontend.Document.Current.serializeForm(d))}if(!i.contains(q)){i.set(q,Dynamicweb.Frontend.Document.Current.value(k))}if(a.progressID){Dynamicweb.Frontend.Document.Current.style(a.progressID,{display:"block"})}Dynamicweb.Frontend.Document.prototype.postAsync(c,{parameters:i.get_data(),onComplete:function(s){var r=Dynamicweb.Frontend.Document.Current.deserialize(s.responseText);if(a.progressID){Dynamicweb.Frontend.Document.Current.style(a.progressID,{display:"none"})}if(r){if(j){j.set_query(f);j.populateResults(r.Data,e);j.show()}g(this,{executed:true,data:r.Data})}else{g(this,{executed:true,data:[]})}}})}else{g(this,{executed:false,data:[]})}}else{g(this,{executed:false,data:[]})}};Dynamicweb.Frontend.InstantSearch.search=function(k,h){var f="";var c=null;var d=null;var j=null;var n="";var q="";var l=false;var i=null;var p=null;var g=null;var o=false;var a=null;var e=null;var m=null;if(!h){h={}}p=h.onComplete||function(){};m=h.onItemDataBound||function(){};g=p;e=m;if(k){l=(Dynamicweb.Frontend.Document.Current.tag(k)=="form");a=Dynamicweb.Frontend.Document.Current.data(Dynamicweb.Frontend.Document.Current.id(k),{suffix:"search"});if(!a){a={}}if(typeof(a.onComplete)=="function"){g=function(s,r){p(s,r);a.onComplete(s,r)}}if(typeof(a.onItemDataBound)=="function"){e=function(s,r){m(s,r);a.onItemDataBound(s,r)}}i=Dynamicweb.Frontend.SearchResultsContainer.retrieve(a.contentID);f=Dynamicweb.Frontend.Document.Current.value(k);if(Dynamicweb.Frontend.InstantSearch._stateChanged(k,"search")&&a.contentID){o=true;a.value=f;Dynamicweb.Frontend.Document.Current.data(Dynamicweb.Frontend.Document.Current.id(k),{value:a,suffix:"search"})}if((f||l)&&o){j=new Dynamicweb.Frontend.Hashtable();if(a.url){c=a.url}else{if(Dynamicweb.Frontend.InstantSearchSettings.Global.get_url()){c=Dynamicweb.Frontend.InstantSearchSettings.Global.get_url()}else{c=Dynamicweb.Frontend.Document.Current.get_url()}}q=Dynamicweb.Frontend.Document.Current.attribute(k,"name");j.set("ID",a.pageID?a.pageID:Dynamicweb.Frontend.InstantSearchSettings.Global.get_pageID());j.set("PID",a.paragraphID?a.paragraphID:Dynamicweb.Frontend.InstantSearchSettings.Global.get_paragraphID());j.set("o","json");j.set("InstantSearchType","Search");n=Dynamicweb.Frontend.InstantSearch._queryParam("GroupID");if(n){j.set("GroupID",n)}if(q){j.set("Caller",q)}if(a.request){for(var b in a.request){j.set(b,a.request[b])}}d=Dynamicweb.Frontend.Document.Current.up(k,"form");if(d!=null){j.merge(Dynamicweb.Frontend.Document.Current.serializeForm(d))}if(!j.contains(q)&&q){j.set(q,Dynamicweb.Frontend.Document.Current.value(k))}if(a.progressID){Dynamicweb.Frontend.Document.Current.style(a.progressID,{display:"block"})}Dynamicweb.Frontend.Document.prototype.postAsync(c,{parameters:j.get_data(),onComplete:function(s){var r=Dynamicweb.Frontend.Document.Current.deserialize(s.responseText);if(a.progressID){Dynamicweb.Frontend.Document.Current.style(a.progressID,{display:"none"})}if(r){if(i){i.set_query(f);i.populateResults(r.Data,e)}g(this,{executed:true,data:r.Data})}else{g(this,{executed:true,data:[]})}}})}else{g(this,{executed:false,data:[]})}}else{g(this,{executed:false,data:[]})}};Dynamicweb.Frontend.InstantSearch._onSuggestWrapper=function(f){var c=null;var a="";var d=0;var g=null;var b=false;var h=Dynamicweb.Frontend.Document.Current.eventTarget(f);if(h){a=Dynamicweb.Frontend.Document.Current.attribute(h,"data-dwtriggers");if(a){h=Dynamicweb.Frontend.Document.Current.element(a)}if(h){g=Dynamicweb.Frontend.Document.Current.data(Dynamicweb.Frontend.Document.Current.id(h),{suffix:"suggest"});if(!g){g={}}c=Dynamicweb.Frontend.SuggestionBox.retrieve(g.boxID,Dynamicweb.Frontend.Document.Current.id(h));if(c){b=c.tryNavigate(f.keyCode);if(!b){c.hide()}}d=parseInt(g.timeoutID);if(d){clearTimeout(d)}if(!b){d=setTimeout(function(){Dynamicweb.Frontend.InstantSearch.suggest(h)},parseInt(g.delay))}g.timeoutID=d;Dynamicweb.Frontend.Document.Current.data(Dynamicweb.Frontend.Document.Current.id(h),{value:g,suffix:"suggest"})}}};Dynamicweb.Frontend.InstantSearch._onInstantSearchWrapper=function(f,d){var a="";var b="";var c=0;var g=null;var h=Dynamicweb.Frontend.Document.Current.eventTarget(f);if(d){h=d}if(h){a=Dynamicweb.Frontend.Document.Current.tag(h);if(a=="form"||(a=="input"&&Dynamicweb.Frontend.Document.Current.attribute(h,"type")=="submit")){Dynamicweb.Frontend.Document.Current.stopEvent(f)}if(!d){b=Dynamicweb.Frontend.Document.Current.attribute(h,"data-dwtriggers");if(b){h=Dynamicweb.Frontend.Document.Current.element(b)}}g=Dynamicweb.Frontend.Document.Current.data(Dynamicweb.Frontend.Document.Current.id(h),{suffix:"search"});if(!g){g={}}c=parseInt(g.timeoutID);if(c){clearTimeout(c)}c=setTimeout(function(){Dynamicweb.Frontend.InstantSearch.search(h)},parseInt(g.delay));g.timeoutID=c;Dynamicweb.Frontend.Document.Current.data(Dynamicweb.Frontend.Document.Current.id(h),{value:g,suffix:"search"})}};Dynamicweb.Frontend.InstantSearch._stateChanged=function(f,d){var a=true;var c="";var b="";var e=null;if(f&&d){b=Dynamicweb.Frontend.Document.Current.tag(f);c=Dynamicweb.Frontend.Document.Current.attribute(f,"type");if(b=="form"||b=="button"){a=true}else{if(b=="input"&&(c=="button"||c=="submit")){a=true}else{e=Dynamicweb.Frontend.Document.Current.data(Dynamicweb.Frontend.Document.Current.id(f),{suffix:d});if(e&&typeof(e.value)!="undefined"){a=e.value.toLowerCase()!=Dynamicweb.Frontend.Document.Current.value(f).toLowerCase()}}}}return a};Dynamicweb.Frontend.InstantSearch._getChangeEvent=function(d){var b="";var a="";var c="";if(d){a=Dynamicweb.Frontend.Document.Current.tag(d).toLowerCase();if(a=="input"){c=Dynamicweb.Frontend.Document.Current.attribute(d,"type").toLowerCase();if(c=="text"||c=="password"){b="keyup"}else{b="click"}}else{if(a=="select"||a=="textarea"){b="change"}else{if(a=="form"){b="submit"}else{b="click"}}}}return b};Dynamicweb.Frontend.InstantSearch._queryParam=function(b){var a="";var d=null;var c=null;if(b){b=b.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");d=new RegExp("[\\?&]"+b+"=([^&#]*)");c=d.exec(window.location.href);if(c!=null){a=decodeURIComponent(c[1].replace(/\+/g," "))}}return a};Dynamicweb.Frontend.InstantSearch._checkFramework=function(){if(typeof(Prototype)=="undefined"&&typeof(jQuery)=="undefined"){Dynamicweb.Frontend.Document.Current.error("Either Prototype or jQuery is required for the instant search to work.")}};
