var currentGroup=1;var currentPosition=0;$(document).ready(function(){setupNextPreviousProduct();if($("div#collectionCarousel").length){handleTheLookPagination();$("ul.collectionCarousel li a").unbind("click").click(function(){var d=$(this);if(d.hasClass("firstLink")){var e=(d.children().attr("src"))}else{var e=d.prev().children().attr("src")}var c=d.attr("href");$("div#getTheLook").show("slow");$("p#counter").animate({marginTop:"375px"},"slow");$("div#getTheLook").append('<img class="getTheLookLoader" src="/pws/images/px_Loader.gif" alt="loading" />');$("img.getTheLookLoader").css({position:"relative",top:"235px",left:"400px"});$.ajax({url:c,success:function(g){var i=g.indexOf("<div id='getTheLook'>");var h=g.indexOf("</body>");if(i>=0&&h>=0){page_data=g.substring(i+21,h-6);function f(){var j=false;$("select[name = 'sku']").each(function(){if($(this).parent().find("select.selectSize").attr("value")==""){j=true}});if(!j){$("div.gtlSizeError").hide()}}$("img.getTheLookLoader").hide();$("div#getTheLook").html(page_data).prepend('<div id="lookTheOutfitManikin"><img src="'+e+'"/></div>');$("div.lookTheOutfitProduct:last").css("border","none");$("span.close").css("z-index",9999);$("span.close img").unbind("click").click(function(){$("div#getTheLook").hide("slow");$("p#counter").animate({marginTop:"5px"},"slow")});$("select.selectSize").unbind("change").change(function(){if($(this).next().attr("checked")){}else{$(this).attr("name","sku");$(this).next().attr("checked","checked");$("div.gtlError").hide()}});$("input.selectOutfitItem").unbind("click").click(function(){if($(this).attr("checked")){$(this).siblings(".selectSize").attr("name","sku");$("div.gtlError").hide()}else{$(this).siblings(".selectSize").removeAttr("name")}$("div.gtlError").hide();f()});$("input#buyThisOutfit").unbind("click").click(function(k){var j=$("select[name = 'sku']").length;if(j<1){$("div.gtlError").show();return false}$("select[name = 'sku']").each(function(){if($(this).parent().find("select.selectSize").attr("value")==""){$("div.gtlSizeError").show();k.preventDefault()}})});$("div.lookTheOutfitProduct select").change(function(){f()});$("div.addToFittingRoom img").click(function(){var m=$("div#theLookFittingRoomCont input:checked");if(m.length<1&&$("div#fittingRoomError").length==0){$(this).parent().after("<div id='fittingRoomError'>Please ensure you've selected an item</div>")}if(m.length>0){var l=$(this).parent().attr("href");for(var j=0;j<m.length;j++){var k=$(m[j]).attr("id").split("_")[2];if(j==0){l+=k}else{l+=(","+k)}}window.location=l}return false})}},error:function(f,h,g){$("div#getTheLook").html("<p>Sorry, an error has occured. </p>").append('<span class="close"><img src="/pws/images/px_Close3.gif"/></span>')}});return false}).css("cursor","pointer")}if($.cookie("view_format")!=null){var a=$.cookie("view_format");$("#viewing_format").find("a."+a).addClass("current")}$("#viewing_format a").click(function(){var c=$(this);$("#viewing_format a").removeClass("current");$.cookie("view_format",c.attr("class"),{expires:31,path:"/"});c.addClass("current");window.location.reload();return false});if($("#productsCont").length>0){var b=$("#productsCont").attr("class");if(b.length>0){b="."+b;$("#viewing_format").find(b).addClass("current")}}$(".filterHeader, #fPRICE_SLIDE .heading").click(function(){if($(this).hasClass("hiddenFilter")){$(this).removeClass("hiddenFilter").css({"background-image":"url(/pws/images/bg_filter_header_arrow_right.gif)","background-position":"170px 4px"}).parent("li").find("ul, .sliderCont").slideDown()}else{$(this).addClass("hiddenFilter").css({"background-image":"url(/pws/images/bg_filter_header_arrow_down.gif)","background-position":"168px 7px"}).parent("li").find("ul, .sliderCont").slideUp()}})});function lastCategory(a){$.cookie("lastCategory",a,{expires:31,path:"/"})}function setupNextPreviousProduct(){var b=$("div#productsCont img.productImg");var a="";var c=true;if(b.length>1){$.each(b,function(d,e){if(c){a=a+$(e).attr("id").split("_")[1];c=false}else{a=a+","+$(e).attr("id").split("_")[1]}});$.cookie("nextPreviousIds",a,{expires:31,path:"/"})}}function handleTheLookPagination(){$("ul.collectionCarousel li:first").css("margin-left","10px");if($("ul.collectionCarousel li").length>4){productGroups=Math.ceil($("ul.collectionCarousel li").length/4);$("span#scrollRight").css("visibility","visible").css("cursor","pointer");$("span#scrollRight").unbind("click").click(function(){currentGroup++;currentPosition-=753;$("span#scrollLeft").css("visibility","visible");$("ul.collectionCarousel").animate({marginLeft:currentPosition},1000);if(currentGroup==productGroups){$(this).css("visibility","hidden")}});$("span#scrollLeft").unbind("click").click(function(){currentGroup--;currentPosition+=753;$("span#scrollRight").css("visibility","visible");$("ul.collectionCarousel").animate({marginLeft:currentPosition},1000);if(currentGroup==1){$(this).css("visibility","hidden")}})}else{$("span#previous, span#next").css("visibility","hidden")}};
