var categoryHeading="";String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")};(function(a){a.fn.frescaFilter=function(){var h=this;function k(){h.find("li.filterLink a").each(function(n){var m=a("div.productCont").filter("."+a(this).attr("id"));if(m.length==0){a(this).hide();a(this).parent().hide()}});a(h).find("li a").click(function(m){m.preventDefault();if(!a(this).hasClass("filterDisabled")){b(a(this));i();c();l(a(this))}});function l(o){var q="";var n="(remove)";var p=o.attr("id").toUpperCase();if(p.indexOf("DESIGNER")>0){var m=o.text();if(m.indexOf(n)>0){q=m.replace(n,"")}else{q=categoryHeading}a("h1").html(q);document.title="Buy "+q.toUpperCase()+" from Matches Fashion";a("meta").each(function(){if(a(this).attr("name")=="description"){a(this).attr("content",q.toUpperCase()+" available from Matches Fashion online with a 14 day returns policy. Matches Fashion, home to designer fashion.")}})}}a("a#filterResetLink").click(function(m){m.preventDefault();g()});a("div.sortBy input#btnSort").remove();a("form#sortProducts select").change(function(n){var m=a(this).find("option:selected").attr("value");e(m)})}function b(l){l.toggleClass("filterSelected");l.parent("li").toggleClass("filterSelected");l.find("span").html()==="(remove)"?l.find("span").html(""):l.find("span").html("(remove)");if(l.parents("li.filterGroup").find("a.filterSelected").length>0){l.parents("li.filterGroup").addClass("filterGroupActive")}else{l.parents("li.filterGroup").removeClass("filterGroupActive")}}function i(){a("div.productCont").removeClass("filterExclude","partialExclude").css("display","block");h.find(".filterGroupActive").each(function(){a("div.productCont").addClass("partialExclude");a(this).find("a.filterSelected").each(function(){a("div."+a(this).attr("id")).removeClass("partialExclude")});a("div.partialExclude").css("display","none")})}function c(){var m;var l;var n=0;h.find("li.filterLink a").each(function(o){m=a("div.productCont").filter("."+a(this).attr("id"));l=a(this).parents("li.filterGroup");a(l).siblings(".filterGroupActive").each(function(){a(this).find("a.filterSelected").each(function(){a(m).filter("."+a(this).attr("id")).addClass("partialInclude")});m=a(m).filter(".partialInclude").removeClass("partialInclude")});n=m.length;if(n>0){a(this).removeClass("filterDisabled")}else{a(this).removeClass("filterSelected").addClass("filterDisabled")}})}function e(l){var m=[];a("div.productCont").each(function(o){var q={};q.el=a(this);if(l==="atitle_keyword"){q.sortValue=a(this).find("h3.prodDesc a").text()}else{var p=a(this).attr("class").split(" ");for(var o=0;o<p.length;o++){var n=p[o].trim();if(n.substring(0,6)==="fPRICE"){q.sortValue=new Number(parseInt(n.replace(/fPRICE/,""),10));break}}}m.push(q)});switch(l){case"atitle_keyword":m=f(m);break;case"aPWS_GB_GBP_min":m=j(m);break;case"dPWS_GB_GBP_max":m=d(m);break;default:break}a("div#productsCont").empty();a.each(m,function(n){a("div#productsCont").append(this.el)})}function f(o){for(var n=0;n<o.length;n++){for(var l=0;l<(o.length-1);l++){if(o[l].sortValue>o[l+1].sortValue){var m=o[l+1];o[l+1]=o[l];o[l]=m}}}return o}function j(o){for(var n=0;n<o.length;n++){for(var l=0;l<(o.length-1);l++){if(o[l].sortValue>o[l+1].sortValue){var m=o[l+1];o[l+1]=o[l];o[l]=m}}}return o}function d(o){for(var n=0;n<o.length;n++){for(var l=0;l<(o.length-1);l++){if(o[l].sortValue<o[l+1].sortValue){var m=o[l+1];o[l+1]=o[l];o[l]=m}}}return o}function g(){a("li.filterSelected").removeClass("filterSelected");a("a.filterSelected span").html("");a("a.filterSelected").removeClass("filterSelected");a("li.filterGroupActive").removeClass("filterGroupActive");a("a.filterDisabled").removeClass("filterDisabled");a("div.productCont").css("display","block")}k()}})(jQuery);$(document).ready(function(){$(".scrollPane").jScrollPane({scrollbarWidth:6,animateTo:true});if($.cookie("sessFastFilterOn")=="true"){categoryHeading=$("h1").html();if($("div.productCont").length>0){$("ul#applyFilter").frescaFilter()}}$(".filterCollapse").click(function(){var c=$(this);var b=c.parents("li.filterGroup").find("ul");if(b.is(".scrollPane")){b=b.parent("div.jScrollPaneContainer")}b.toggle();c.toggleClass("closed");if(c.is(".closed")){c.attr("src",c.attr("src").replace(".gif","_1.gif"))}else{c.attr("src",c.attr("src").replace("_1.gif",".gif"))}});var a=$("li.filterGroup li.selected").parent("ul.scrollPane");a.each(function(b){var c=$(this).find("li.selected").position().top;$(this)[0].scrollTo(c-90)})});(function(f){var e=["DOMMouseScroll","mousewheel"];f.event.special.mousewheel={setup:function(){if(this.addEventListener){for(var a=e.length;a;){this.addEventListener(e[--a],d,false)}}else{this.onmousewheel=d}},teardown:function(){if(this.removeEventListener){for(var a=e.length;a;){this.removeEventListener(e[--a],d,false)}}else{this.onmousewheel=null}}};f.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}});function d(b){var h=[].slice.call(arguments,1),a=0,c=true;b=f.event.fix(b||window.event);b.type="mousewheel";if(b.wheelDelta){a=b.wheelDelta/120}if(b.detail){a=-b.detail/3}h.unshift(b,a);return f.event.handle.apply(this,h)}})(jQuery);