var properties={filterKey:"cfsearch",filterVal:"cfvalue"};function Vault(){this.customVars=[];this.getUrlVars=function(){var e=[];var g=[];var d;var c=0;var f=window.location.href.indexOf("?");if(f==-1){return[]}var a=window.location.href.slice(f+1).split("&");for(c;c<a.length;c++){d=a[c].split("=");e[unescape(d[0])]=unescape(d[1])}c=1;for(var b in e){if(b.match(properties.filterKey)){g[e[b]]=e[properties.filterVal+c];this.customVars[e[b]]=true;c++}else{if(!b.match(properties.filterVal)){g[b]=e[b]}}}return g};this.urlVars=this.getUrlVars();this.setVar=function(c,b,a){this.urlVars[c]=b;if(a){this.customVars[c]=true}};this.getVar=function(a){if(this.urlVars[a]){return this.urlVars[a]}else{return null}};this.getVars=function(){var d="";var e="";var c=0;var a=1;for(var b in this.urlVars){if(c==0){d+="?"}else{d+="&"}if(b in this.customVars){d+=properties.filterKey+a+"="+b+"&"+properties.filterVal+a+"="+this.urlVars[b];a++}else{d+=b+"="+this.urlVars[b]}c++}return d};this.reload=function(){var a=this.getVars();if(a){document.location.href=a}};this.redirect=function(a){var b=this.getVars();if(b){document.location.href=a+b}}}(function(e){e.fn.advancedSearch=function(i){var k=this;var i=e.extend({def_searchquery:"Enter Keywords Here..."},i);return this.each(function(){h(e(this));g(e(this))});function h(l){e("select",l).add("input",l).each(function(){var n=e(this).attr("name");var m=a.getVar(n);if(m!=""&&m!=null&&m!=i.def_searchquery){e(this).val(m)}})}function g(l){var m=e("form",l);m.submit(function(n){n.preventDefault()});if(e("input[name='searchquery']",l).exists()){e("input[name='searchquery']",l).keypress(function(n){if(n.which==13){j(m)}})}if(e("input[type=submit]",l).exists()){m.submit(function(n){j(m);n.preventDefault()})}else{if(e("input[type=button]",l).exists()){e("input[type=button]",l).click(function(n){j(m);n.preventDefault()})}}}function j(m){var l=m.attr("action");e("select",m).add("input[name=searchquery]",m).each(function(){var o=e(this).val();var n=e(this).attr("name");if(o!="-1"&&o!=""&&o!=i.def_searchquery){if(n!="catid"&&n!="searchPrice"&&n!="searchquery"){a.setVar(n,o,true)}else{a.setVar(n,o)}}});a.redirect(l)}};e.fn.brandSlider=function(j){var k=this;var i=0;var j=e.extend({interval:5000,speed:1000},j);return this.each(function(){var m=e(this);l(m);setTimeout(function(){h(m)},j.interval)});function l(n){var m=e("li",n);m.load(function(){var p=m.size();var o=m.outerWidth(true);n.css("width",(1+p)*o)})}function h(m){g(m);i=setTimeout(function(){h(m)},j.interval)}function g(m){var n=e("li",m).outerWidth(true);var p=e("li:first",m);var o=e("li:last",m);p.clone().appendTo(m);m.animate({left:-n},j.speed,function(){p.remove();m.css("left",0)})}};e.fn.checkRequired=function(){var h=e(this).find("form");var g=0;h.submit(function(){h.find(":input.required").each(function(){g=0;if(e(this).val()===""||e(this).val()==="Required"){e(this).addClass("error");e(this).val("Required");g=1}else{e(this).removeClass("error")}});if(g===1){return false}});h.find(":input.required").live("focus",function(){if(e(this).val()==="Required"){e(this).val("");e(this).removeClass("error")}})};e.fn.dropdowns=function(g){var h=this;var g=e.extend({},g);return this.each(function(){i(e(this))});function i(j){e("li a",j).each(function(){var l=e(this).parent().find("ul");var k=e(this);e(this).mouseenter(function(){l.show();k.addClass("hover")});e(this).mouseleave(function(){l.hide();k.removeClass("hover")});l.hover(function(){e(this).show();k.addClass("hover")});l.mouseleave(function(){e(this).hide();k.removeClass("hover")})})}};e.fn.filterAction=function(h){var i=this;var g=c();var h=e.extend({key:"cfsearch",value:"cfvalue"},h);return this.each(function(){if(e(this).is("select")){e(this).change(function(){j()})}else{if(e(this).is("div")){j()}else{e(this).click(function(){j()})}}});function j(){var l="";var n=null;var m=1;e("#Menu-Filter table").each(function(){var p=e(this).attr("id");var o=0;e(this).find("input:checked").each(function(){n=e(this).attr("name");if(o==0){l=d(l)+h.key+m+"="+p+"&"+h.value+m+"="+n;m++}else{l+=","+n}o++})});if(e("#Slider-Price-Range").exists()){price_left=e("#Slider-Price-Range").slider("values",0);price_right=e("#Slider-Price-Range").slider("values",1)}if(e("select[name=searchPrice]").exists()&&e("select[name=searchPrice]").val()!="-1"&&(!e("#Slider-Price-Range").exists()||g.searchPrice!=e("select[name=searchPrice]").val())){l=d(l)+"searchPrice="+e("select[name=searchPrice]").val()}else{if(price_min!=price_left||price_right!=price_max){n=price_left+"t"+price_right;l=d(l)+"searchPrice="+n}}if(categoryID!=""){l=d(l)+"catid="+categoryID}if(a.getVar("searchquery")!=null){l=d(l)+"searchquery="+a.getVar("searchquery")}if(g.itemsperpage=="99999"||e(".View-All").attr("name")=="clicked"){l=d(l)+"itemsperpage=99999"}if(e("select[name=SearchSortBy]").val()!="-1"){l=d(l)+"SearchSortBy="+e("select[name=SearchSortBy]").val()}k(l)}function k(l){e("#LoadingBG").css("top",e(document).scrollTop()).css("display","block");document.location.href=l}};e.fn.menuFilter=function(j){var k=this;var g=c();var i=b();var j=e.extend({key:"cfsearch",value:"cfvalue"},j);return this.each(function(){h(e(this))});function h(l){var n=1;while(true){if(g[j.key+n]&&g[j.key+n]){var m=g[j.value+n].split(",");for(var o in m){e("input[name='"+m[o]+"']",l).attr("checked",true);anchor_item=e("<a></a>").addClass("Filter-Close").attr("href",m[o]);new_item=e("<p></p>").addClass("Filter-Selection").text(m[o]);e("#Selection div").append(new_item).append(anchor_item);e("#td"+m[o]).addClass("hover");e("#th"+m[o]).addClass("hover")}n++;continue}break}if(n>1){e("#Selection",l).show();e("#Selection a",l).click(function(p){e("input[name="+e(this).attr("href")+"]",l).attr("checked",false);p.preventDefault()});e("#Selection a",l).filterAction()}e("input",l).filterAction();if(i){if(g.searchPrice){prices=g.searchPrice.split("t");prices[0]=parseInt(prices[0]);prices[1]=parseInt(prices[1]);if(prices[0]<=prices[1]){if(prices[0]>price_min&&prices[0]<price_max){price_left=prices[0]}if(prices[1]>price_min&&prices[1]<price_max){price_right=prices[1]}}}e("#Slider-Price-Range",l).slider({range:true,min:price_min,max:price_max,values:[price_left,price_right],slide:function(p,q){e("#Price-Left",l).html("&pound;"+q.values[0]);e("#Price-Right",l).html("&pound;"+q.values[1])},change:function(p,q){e(this).filterAction()}});e("#Price-Left",l).html("&pound;"+e("#Slider-Price-Range").slider("values",0));e("#Price-Right",l).html("&pound;"+e("#Slider-Price-Range").slider("values",1))}else{e("#Price",l).hide()}}};e.fn.productSuggestions=function(j){var k=null;var j=e.extend({dataFile:"!autocomplete.xml",suggestionsCallback:"master-callback-productsuggestions.html",minLength:2,delay:300,limit:5},j);h();return this.each(function(){e(this).autocomplete({source:k,minLength:j.minLength,delay:j.delay,position:{my:"left top",at:"left bottom"},open:function(l,m){i(this.value)},focus:function(l,m){this.value=m.item.value},select:function(l,m){e(this).parents("form:first").submit()}});g(e(this))});function h(){e.ajax({url:"/"+j.dataFile,dataType:"xml",async:false,success:function(l){k=e("item",l).map(function(){return e("title",this).text()}).get()}})}function g(l){$list=e("<div></div>").attr("id","Product-Suggestions").css("display","none").css("position","absolute").css("z-index","99999").appendTo(e("body"));var n=undefined;var p=0;var o=0;var m=null;l.keyup(function(){if(l.val().length<j.minLength){$list.hide();return}if(n!=undefined){clearTimeout(n)}e.ajax({url:"/"+j.suggestionsCallback+"?searchquery="+l.val()+"&searchmaxreturn="+j.limit,dataType:"html",success:function(q){m=q}});n=setTimeout(function(){offset=l.offset();p=offset.left;o=l.outerHeight()+offset.top;if(e(".ui-autocomplete").css("display")=="block"){o+=e(".ui-autocomplete").outerHeight()}if(e.trim(m).length>0){$list.html(m);$list.css("left",p+"px");$list.css("top",o+"px");$list.show()}},j.delay)});l.blur(function(){if(n!=undefined){clearTimeout(n)}n=setTimeout(function(){$list.hide()},100)})}function i(l){e("ul.ui-autocomplete li a").each(function(){e(this).html(e(this).html().replace(new RegExp(l.toLowerCase(),"gi"),'<span class="highlight">'+l.toLowerCase()+"</span>"))})}};e.fn.simpleLightBox=function(h){var g=e(this);g.click(function(i){i.preventDefault();if(e(".Simple-Lightbox").length>0){e(".Simple-Lightbox").remove()}e.ajax({url:h,dataType:"html",success:function(j){e("body").append(j);e(".Simple-Lightbox").fadeIn()}});e(".Simple-Lightbox").fadeIn()});e(".Simple-Lightbox-Close").live("click",function(){e(".Simple-Lightbox").fadeOut()})};e.fn.sortFilter=function(h){var h=e.extend({},h);return this.each(function(){g(e(this));e(this).change(i)});function g(j){e("select",j).each(function(){var l=e(this).attr("name");var k=a.getVar(l);if(k!=""&&k!=null){e(this).val(k)}})}function i(){e("select",this).each(function(){var k=e(this).val();var j=e(this).attr("name");if(k!="-1"&&k!=""){a.setVar(j,k)}a.reload()})}};e.fn.tabbedContainer=function(g){var i=this;var g=e.extend({},g);return this.each(function(){h(e(this))});function h(j){e(".Tabs a",j).each(function(k){e(this).click(function(n){var m=k;e(".Tabs a",j).each(function(o){if(o==m){e(this).addClass("Selected")}else{e(this).removeClass("Selected")}});e(".Tab-Content",j).each(function(o){if(o==m){e(this).removeClass("Deselected")}else{e(this).addClass("Deselected")}});var l=e(this).attr("href");if(l==""||l=="#"){n.preventDefault()}})});if(!e(".Tabs a",j).hasClass("Selected")){e(".Tabs a:first",j).addClass("Selected")}e(".Tab-Content:gt(0)",j).addClass("Deselected")}};e.fn.toggleContainer=function(h){var h=e.extend({},h);return this.each(function(){g(e(this))});function g(i){i.click(function(j){j.preventDefault();i.closest(".Content-Wide").slideToggle()})}};e.fn.toggleButton=function(){var h=e(this);var g=h.html();if(g=="Hide"){g="Show"}else{if(g=="Show"){g="Hide"}}h.toggleClass("Show").html(g);return this};e.fn.toggleContent=function(h){var h=e.extend({},h);return this.each(function(){g(e(this))});function g(i){i.click(function(j){j.preventDefault();i.toggleButton().closest(".Content-Wide").find(".Content-Wide-Content").slideToggle()})}};e.fn.viewAll=function(h){var h=e.extend({},h);return this.each(function(){g(e(this))});function g(i){i.click(function(j){j.preventDefault();a.setVar("itemsperpage",99999);a.reload()})}};function d(g){if(g==""){return g+"?"}else{return g+"&"}}function f(g){return decodeURIComponent(g.split("+").join(" "))}function c(){var g={};document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g,function(){g[f(arguments[1])]=f(arguments[2])});return g}e.fn.exists=function(){return e(this).length>0&&!e(this).is(":hidden")};function b(){price_min=Math.floor(price_min);price_left=Math.floor(price_left);price_max=Math.ceil(price_max);price_right=Math.ceil(price_right);if(price_min==price_max){return false}else{return true}}var a;e(document).ready(function(){a=new Vault();e("a[rel*=viewAll]").viewAll();e("div.Content-Wide a[rel*=toggleContainer]").toggleContainer();e("div.Content-Wide a[rel*=toggleContent]").toggleContent()})})(jQuery);

