var currentGroup=1;var currentPosition=0;$(document).ready(function(){setupNextPreviousProduct();if($("div#collectionCarousel").length){handleTheLookPagination();$("ul.collectionCarousel li a").unbind("click").click(function(){var b=$(this);if(b.hasClass("firstLink")){var c=(b.children().attr("src"))}else{var c=b.prev().children().attr("src")}var a=b.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:a,success:function(e){var g=e.indexOf("<div id='getTheLook'>");var f=e.indexOf("</body>");if(g>=0&&f>=0){page_data=e.substring(g+21,f-6);function d(){var h=false;$("select[name = 'sku']").each(function(){if($(this).parent().find("select.selectSize").attr("value")==""){h=true}});if(!h){$("div.gtlSizeError").hide()}}$("img.getTheLookLoader").hide();$("div#getTheLook").html(page_data).prepend('<div id="lookTheOutfitManikin"><img src="'+c+'"/></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();d()});$("input#buyThisOutfit").unbind("click").click(function(i){var h=$("select[name = 'sku']").length;if(h<1){$("div.gtlError").show();return false}$("select[name = 'sku']").each(function(){if($(this).parent().find("select.selectSize").attr("value")==""){$("div.gtlSizeError").show();i.preventDefault()}})});$("div.lookTheOutfitProduct select").change(function(){d()});$("div.addToFittingRoom img").click(function(){var l=$("div#theLookFittingRoomCont input:checked");if(l.length<1&&$("div#fittingRoomError").length==0){$(this).parent().after("<div id='fittingRoomError'>Please ensure you've selected an item</div>")}if(l.length>0){var k=$(this).parent().attr("href");for(var h=0;h<l.length;h++){var j=$(l[h]).attr("id").split("_")[2];if(h==0){k+=j}else{k+=(","+j)}}window.location=k}return false})}},error:function(d,f,e){$("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")}});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")}};