$(document).ready(function(){$("ul#applyFilter").before('<p id="filterNoProducts">Sorry, there were no products found within this range.</p>').frescaFilter();setupNextPrevious();$("form.sortProducts select").change(function(){var a=$(this).find("option:selected").attr("value");sortProducts(a)});$("li#fto_feel").frescaFilterCloud();$("li#fwc_brand ul li").quicksearch({position:"before",attached:"li#fwc_brand ul",focusOnLoad:false,labelText:"Find a Brand:"});$("ul#applyFilter").before("<a id='resetFilters' class='pinkText'><strong>Clear All Filters</strong></a>");$("a#resetFilters").click(function(){location.reload(true)});if($("div#productsCont").length>0){sortByProductName()}});(function(a){a.fn.frescaFilter=function(p){var l=a(this);var d;var k;var j={};var o={};var g=0+a("div.productCont").length;if(g>0){l.find("li a").click(function(q){q.preventDefault();if(!a(this).hasClass("filterDisabled")){f(a(this));m();e()}});n();c()}function f(q){q.toggleClass("filterSelected");if(q.parents("li.filterGroup").find("a.filterSelected").length>0){q.parents("li.filterGroup").addClass("filterGroupActive")}else{q.parents("li.filterGroup").removeClass("filterGroupActive")}}function m(){a("div.productCont").removeClass("filterExclude","partialExclude");l.find(".filterGroupActive").each(function(){a("div.productCont").addClass("partialExclude");a(this).find("a.filterSelected").each(function(){omniFilterId(a(this).attr("id"),this);a("div."+a(this).attr("id")).removeClass("partialExclude")});a("div.partialExclude").addClass("filterExclude")})}function b(){var r,q;a("div.productCont").removeClass("priceExclude").each(function(u,t){r=parseInt(a(this).attr("class").split(" ")[1].replace(/fMAXPRICE/,"")*100);q=parseInt(a(this).attr("class").split(" ")[2].replace(/fMINPRICE/,"")*100);if(j.currentMinPrice>r||j.currentMaxPrice<q){a(this).addClass("priceExclude")}})}function h(){var q,r;a("div.productCont").removeClass("ageExclude").each(function(u,t){q=parseInt(a(this).attr("class").split(" ")[3].replace(/fMAXAGE/,"")*0.1);r=parseInt(a(this).attr("class").split(" ")[4].replace(/fMINAGE/,"")*0.1);if(o.currentMinAge>q||o.currentMaxAge<r){a(this).addClass("ageExclude")}})}function e(u){var r,v,q,t;var w=a("div.productCont");l.find("a").not(".sort").each(function(x){t=a(w).filter("."+a(this).attr("id")).not(".priceExclude");q=a(this).parents("li.filterGroup");a(q).siblings(".filterGroupActive").each(function(){a(this).find("a.filterSelected").each(function(){a(t).filter("."+a(this).attr("id")).addClass("partialInclude")});t=a(t).filter(".partialInclude").removeClass("partialInclude")});r=0+t.length;if(u!="priceFilter"&&r==0){a(this).removeClass("filterSelected")}(r>=1)?a(this).removeClass("filterDisabled").find("span").html(r):a(this).addClass("filterDisabled").find("span").html("0")});g=0+a(w).filter(":visible").length;(g==0)?a("p#filterNoProducts").show():a("p#filterNoProducts").hide();a("span.counterNumber").html(""+g+"");if(!a("#mainContentCont").hasClass("brandListing")){a("div#categoryCMSCont").hide()}setupNextPrevious()}function c(){l.prepend('<li class="filterGroup" id="fPRICE_SLIDE"><span class="filterTitle">Price Range</span><div class="sliderCont"><div id="priceSlider"><div id="leftSliderHandle" class="ui-slider-handle">&nbsp;</div><div id="rightSliderHandle" class="ui-slider-handle">&nbsp;</div><span id="sliderMinPrice">&nbsp;</span><span id="sliderMaxPrice">&nbsp;</span></div></div></li>');var v=a("div#minMaxPricing").attr("class");var t=v.split("_");j.minPrice=parseInt(t[0].replace(/MIN/,"")*100);j.maxPrice=parseInt(t[1].replace(/MAX/,"")*100);var q=j.minPrice;var r=j.maxPrice;a("span#sliderMinPrice").append("&pound;"+parseFloat(j.minPrice/100).toFixed(2));a("span#sliderMaxPrice").append("&pound;"+parseFloat(j.maxPrice/100).toFixed(2));var u=a("div#priceSlider").slider({min:j.minPrice,max:j.maxPrice,range:true,stepping:100,stop:function(x,w){var z=0;var y=0;if(typeof(j.currentMaxPrice)=="undefined"){z=j.maxPrice}else{z=j.currentMaxPrice}if(typeof(j.currentMinPrice)=="undefined"){y=j.minPrice}else{y=j.currentMinPrice}priceSliderOmniture(y,z,this);(w.handle.attr("id")==="leftSliderHandle")?j.currentMinPrice=w.value:j.currentMaxPrice=w.value;b();e("priceFilter")},slide:function(x,w){if(w.handle.attr("id")=="leftSliderHandle"){j.currentMinPrice=w.value;a("span#sliderMinPrice").html("&pound;"+parseFloat(j.currentMinPrice/100).toFixed(2))}else{j.currentMaxPrice=w.value;a("span#sliderMaxPrice").html("&pound;"+parseFloat(j.currentMaxPrice/100).toFixed(2))}}})}function n(){l.prepend('<li class="filterGroup" id="fAGE_SLIDE"><span class="filterTitle">Age</span><div class="sliderCont"><div id="ageSlider"><div id="leftSliderAgeHandle" class="ui-slider-handle">&nbsp;</div><div id="rightSliderAgeHandle" class="ui-slider-handle">&nbsp;</div><span id="sliderMinAge">&nbsp;</span><span id="sliderMaxAge">&nbsp;</span></div></div></li>');var t=a("div#minMaxAges").attr("class");var r=t.split("_");o.minAge=parseInt(r[0].replace(/MIN/,"")*0.1);o.maxAge=parseInt(r[1].replace(/MAX/,"")*0.1);a("span#sliderMinAge").append(parseFloat(o.minAge)*1);a("span#sliderMaxAge").append(parseFloat(o.maxAge)*1);var q=a("div#ageSlider").slider({min:o.minAge,max:o.maxAge,range:true,stepping:1,stop:function(w,u){var v=0;var x=0;if(typeof(o.currentMaxAge)=="undefined"){v=o.maxAge}else{v=o.currentMaxAge}if(typeof(o.currentMinAge)=="undefined"){x=o.minAge}else{x=o.currentMinAge}ageSliderOmniture(x,v,this);(u.handle.attr("id")==="leftSliderAgeHandle")?o.currentMinAge=u.value:o.currentMaxAge=u.value;h();e("ageFilter")},slide:function(v,u){if(u.handle.attr("id")=="leftSliderAgeHandle"){o.currentMinAge=u.value;a("span#sliderMinAge").html(parseFloat(o.currentMinAge)*1)}else{o.currentMaxAge=u.value;a("span#sliderMaxAge").html(parseFloat(o.currentMaxAge)*1)}}})}}})(jQuery);function omniFilterId(b,e){var a=b.toLowerCase();var d="";var c=s_gi(s_account);if(a.search("fwc_brand")!=-1){c.linkTrackVars="prop7";c.prop7=a.slice("fwc_brand".length);d="Guided Navigation:Brands"}if(a.search("fscent")!=-1){c.linkTrackVars="prop8";c.prop8=a.slice("fscent".length);d="Guided Navigation:Scent"}if(a.indexOf("fto_feel")!=-1){c.linkTrackVars="prop9";c.prop9=a.slice("fto_feel".length);d="Guided Navigation:To Feel"}c.tl(e,"o",d)}function priceSliderOmniture(a,b,d){var c="";a/=100;b/=100;s=s_gi(s_account);s.linkTrackVars="prop5";s.prop5=a+"-"+b;c="Guided Navigation:Price Range";s.tl(d,"o",c)}function ageSliderOmniture(a,b,d){var c="";s=s_gi(s_account);s.linkTrackVars="prop6";s.prop6=a+"-"+b;c="Guided Navigation:Age";s.tl(d,"o",c)}function sortByProductName(){var b=$("div.productCont");var c=[];var a;b.find("a.productBrand").each(function(){a=$(this).text();c.push(a+"|"+$(this).parents("div.productCont").attr("id"))});c=c.sort();for(i=0;i<c.length;i++){$("div#"+c[i].split("|")[1]).appendTo("div#productsCont")}}function sortProducts(b){var d=$("div.productCont");var e=[];var c;var a="priceAsc";d.find("span."+a).each(function(){c=$(this).text();e.push(c+"|"+$(this).parents("div.productCont").attr("id"))});function f(h,g){var h=h.split("|")[0];var g=g.split("|")[0];if(b=="priceDesc"){return g-h}else{return h-g}}e=e.sort(f);for(i=0;i<e.length;i++){$("div#"+e[i].split("|")[1]).appendTo("div#productsCont")}}function setupNextPrevious(){var b=$("div.productCont:visible img.productImg");var a="";if(b.length>1){$.each(b,function(c,d){a=a+$(d).attr("id").split("_")[1];if(c!=(b.length-1)){a=a+","}});$.cookie("nextPreviousIds",a,{expires:31,path:"/"})}}(function(a){a.fn.frescaFilterCloud=function(c){var d=a(this);var e,f;var b=0;d.find("a").each(function(){b=parseInt(a(this).find("span").text())+b});a("<p class='tagCloud cf'></p>").appendTo(a(d));d.find("a").each(function(){this.fontSize=(parseInt(a(this).find("span").text())/b)*1000;this.fontSize=Math.min(this.fontSize,300);this.fontSize=Math.max(this.fontSize,100);this.fontSize=this.fontSize+"%";a(this).css("font-size",this.fontSize).find("span").remove();this.filterText=a(this).text().replace("(","").replace(")","");a(this).text(this.filterText);a("p.tagCloud").append(a(this))}).end().find("ul").remove()}})(jQuery);
