(function(a){a.fresca={disableClick:function(b){a(b).unbind("click");a(b).click(function(c){c.preventDefault()})},updateText:"Updating",popups:[],initPopup:function(b){a("body").append('<div id="product_details_popup"/>');a("#product_details_popup").css({display:"none",position:"absolute",zIndex:6001});a(b).each(function(d,e){var c=new Array();c.trigger=a(this);c.id=a(this).attr("id");c.width=840;c.height=422;c.url="/pws/ProductDetails.ice?layout=productdetails.pop.layout&ProductID="+c.id+"&tabInfo=true&page=ProductDetails";c.container=a("#product_details_popup");c.block=a("body");a.fresca.popups.push(c);a.fresca.createPopupAction(c)})},createPopupAction:function(b){b.trigger.click(function(c){a.fresca.showPopup(b,c,a.fresca.getPopupTop(b),a.fresca.getPopupLeft(b));return false})},getPopupHeight:function(b){var c=parseInt(b.width*0.4);return c},getPopupLeft:function(c){var b=(parseInt(a(window).width())-c.width)/2;return b},getPopupTop:function(){var b=150+a(window).scrollTop();return b},getPopupWidth:function(){var b=parseInt(a("#top_nav").width()*0.84);return b},showPopup:function(d,i,f,c,g){d.container.css({display:"block",top:f,left:c,width:d.width,height:d.height,position:"absolute"}).addClass("loading");var b=f+d.height;var h=a("#main_cont").height();d.container.css({visibility:"visible"});a.fresca.loadPopupContent(d,d.url,g);if(!g){d.block.block()}},hidePopup:function(b){b.container.css({display:"none",top:"0",left:"0"});b.block.unblock();a(window).unbind("keyup")},loadPopupContent:function(b,c,d){a.fresca.getLoaderContent(b);a.ajax({url:c,success:function(f){var e=f.indexOf("<!-- product pop-up success -->");if(e>=0){b.container.empty().removeClass("loading").append(f);a.fresca.createInteractions(b)}else{b.container.empty().removeClass("loading").append("<p class='out_of_stock cufon'>Sorry, this product is currently out of stock.</p>");addCloseButton("#product_details_popup");Cufon.replace("#product_details_popup .cufon")}if(d){a(b.container).find("#product_close").bind("click",function(g){try{closingPopup(g)}catch(h){}a(b.container).remove();try{popupClosed(g)}catch(h){}g.preventDefault()})}else{a(b.container).find("#product_close").bind("click",function(g){a.fresca.hidePopup(b);g.preventDefault()})}a(window).bind("keyup",function(g){if(g.keyCode=="27"){a.fresca.hidePopup(b)}});a.fresca.createFormAction(b)},error:function(e,g,f){b.container.empty().removeClass("loading").append("<p class='error_occurred cufon'>Sorry, an error has occurred.</p>");Cufon.replace("#product_details_popup .cufon");addCloseButton("#product_details_popup")}})},createFormAction:function(c){function b(e){e="<em>"+e+"</em>";a(c.container).find("#response").removeClass("loading").empty().append(e).fadeIn()}function d(){a(c.container).find("#add_to_wishlist").click(function(g){var f=a(g.target).attr("href");try{a.ajax({type:"GET",url:f,beforeSend:function(){a(c.container).find("#response").addClass("loading")},success:function(j){var i=a(j).find("#view_wishlist");if(i.length>0){var e=a(j).find("#response").html();b(e);a(c.container).find("#add_to_wishlist").parent("div").html(i)}else{if(e==null){document.location=f}}}})}catch(h){if(window.console){console.warn("Error, "+h)}}g.preventDefault()})}a(c.container).find("#product_selection").ajaxForm({beforeSubmit:function(){var e=false;a("#size_selection input").each(function(){if(a(this).attr("checked")){e=true}});a(".message").addClass("loading");if(e){c.submitting=true;a(c.container).find("#add_to_bag").fadeTo(500,0.5).attr("disabled",true)}else{b("Please ensure you've selected a size");return false}},success:function(g,h){var f=a(g).find("#response").html();b(f);a.global.loadMiniBasket();c.submitting=false;a.global.enableSubmit()},error:function(f,g,e){a.global.enableSubmit()}});d()},createInteractions:function(b){a.product.selectSize();a("#main_image").frescaZoom();a.product.alternativeViews(".next_button",".previous_button","#main_image",false);a.product.fullScreenMode();a.global.preventDoubleSubmit();a.product.showProductInformation();popupLink()},getLoaderContent:function(b){b.container.empty()},hideInList:function(b){a(b).animate({width:"0px",opacity:0},function(){a(this).css({display:"none"})})},revealProducts:function(){a(".name a").click(function(b){b.preventDefault()});a(".name .more_than_3").click(function(e){var b=a(e.target);var c=b.attr("title");departmentPath="[title="+c+"]";var d={};d.imageWidth=[];d.imageList=[];if(b.hasClass("showProducts")){a(departmentPath).each(function(f,h){var g=a(h);if(g.hasClass("hidden")){d.imageWidth.push(g.width());d.imageList.push(g)}});b.removeClass("showProducts").addClass("hideProducts");a.fresca.expandList(d);changeText("Close",e.target);animateTo(a(e.target).parents("li"));e.preventDefault()}else{a(departmentPath).each(function(f,h){var g=a(h);if(g.hasClass("hidden")){d.imageWidth.push(g.width());d.imageList.push(g)}});b.removeClass("hideProducts").addClass("showProducts");a.fresca.shrinkList(d);changeText("View all ("+parseInt(d.imageList.length+3,10)+")",e.target);e.preventDefault()}})},expandList:function(c){var b=c.imageList.length;var d=10;if(b>10){d=b}a(c.imageList).each(function(e,g){var f=a(g);f.css({width:"0px"});f.animate({width:c.imageWidth[e]},d*50,function(){f.css({display:"block"})})})},shrinkList:function(b){a(b.imageList).each(function(c,e){var d=a(e);d.animate({width:"0px"},function(){d.css({display:"none",width:b.imageWidth[c]})})})},imageSlider:function(){var d=255+150;var c=true;function b(j){try{c=false;var i=800;var g=parseInt(a("#looks").css("left"),10);var f=Math.abs(g-j);if(f>3000){i=Math.abs(f/2)}a("#looks").stop().animate({left:j},i,function(e){c=true})}catch(h){if(window.console){console.warn("Error moving looks, "+h)}}}a("#thumbnails li").each(function(e,f){a(this).bind("click",function(h){var g=(e-1)*d;b(-g)})});a(".controls").each(function(e,f){a(this).bind("click",function(h){if(c){var g=parseInt(a("#looks").css("left"),10);if(a(h.target).hasClass("move_right")){if(g>-4455){b(g-d)}}else{if(g<0){b(g+d)}}}h.preventDefault()})})},hideLooks:function(){a("#hide_thumbnails").bind("click",function(c){var b=c.target;if(a("#thumbnails").hasClass("hidden")){a("#thumbnails").fadeIn(800).removeClass("hidden");changeText("Hide all looks",b)}else{a("#thumbnails").fadeOut(800).addClass("hidden");changeText("Show all looks",b)}})}}})(jQuery);function changeText(c,b){try{if(typeof c==="string"){$(b).animate({opacity:0.3},400,function(d){$(b).html(c);$(b).animate({opacity:1},400)})}else{throw"string required; not "+typeof c}}catch(a){if(window.console){console.warn("Error changing text, "+a)}}}function productOverlay(b){try{if(typeof b=="number"){var a=new Array();var a=new Array();a.trigger=false;a.id=b;a.width=840;a.height=422;a.url="/pws/ProductDetails.ice?layout=productdetails.pop.layout&ProductID="+a.id+"&tabInfo=true&page=ProductDetails";a.container=$("<div id=product_details_popup></div>");a.block=$("body");$("body").append(a.container);$.fresca.showPopup(a,false,$.fresca.getPopupTop(a),$.fresca.getPopupLeft(a),true)}else{throw"invalid product id"}}catch(c){if(window.console){console.warn("Error with product overlay, "+c)}}}YUI().use("imageloader",function(c){var h=new c.ImgLoadGroup({className:"imgload-accessories"});h.addTrigger("#reveal_accessories","mouseover");var j=new c.ImgLoadGroup({className:"imgload-brands"});j.addTrigger("#reveal_brands","mouseover");var a=new c.ImgLoadGroup({className:"imgload-coats"});a.addTrigger("#reveal_coats","mouseover");var b=new c.ImgLoadGroup({timeLimit:2,className:"imgload-dresses"});b.addTrigger("#reveal_dresses","mouseover");var d=new c.ImgLoadGroup({className:"imgload-jackets"});d.addTrigger("#reveal_jackets","mouseover");var g=new c.ImgLoadGroup({className:"imgload-jeans"});g.addTrigger("#reveal_jeans","mouseover");var l=new c.ImgLoadGroup({className:"imgload-jersey"});l.addTrigger("#reveal_jersey","mouseover");var e=new c.ImgLoadGroup({className:"imgload-knitwear"});e.addTrigger("#reveal_knitwear","mouseover");var f=new c.ImgLoadGroup({className:"imgload-sale"});f.addTrigger("#reveal_sale","mouseover");var i=new c.ImgLoadGroup({className:"imgload-skirts"});i.addTrigger("#reveal_skirts","mouseover");var m=new c.ImgLoadGroup({className:"imgload-tops"});m.addTrigger("#reveal_tops","mouseover");var k=new c.ImgLoadGroup({className:"imgload-trousers"});k.addTrigger("#reveal_trousers","mouseover")});$(window).bind("load",function(a){if($("#category_list").length>0||$("#collections").length>0){$.fresca.disableClick(".product_link");$.fresca.initPopup(".product")}if($("#category_list").length>0){$.fresca.revealProducts()}if($("#collections").length>0){$.fresca.initPopup(".product_link");$.fresca.imageSlider();$.fresca.hideLooks();$(".png_fix").pngfix()}if($(".ly_searchresults").length>0||$("body").hasClass("ly_basket")||$("body").hasClass("ly_vieworderdetails")||$("body").hasClass("ly_viewwishlist")||$("body").hasClass("ly_paymentdetails")){$.fresca.initPopup(".product_link")}});