(function($){var cache=[];preLoadImages=function(){var args_len=arguments.length;for(var i=args_len;i--;){var cacheImage=document.createElement("img");cacheImage.src=arguments[i];cache.push(cacheImage)}};AddProductExtras=function(){platform.fixes.productAttributes();platform.fixes.productGrouping();platform.fixes.wishLists()};selectMenu=function(menu,item){if(item==undefined){return}$("li:eq("+item+")",menu).addClass("current")};alertError=function(msg){$(".alertMessage.error").each(function(){$(this).remove()});var theError=$('<p class="alertMessage error"><strong>Error</strong>: '+msg+"</p>");theError.appendTo("body").click(function(){$(this).remove()});window.setTimeout(function(){theError.fadeOut("slow",function(){theError.remove()})},3000)};alertMsg=function(msg){$(".alertMessage").each(function(){$(this).remove()});var theAlert=$('<h3 class="alertMessage">'+msg+"</h3>");theAlert.appendTo("body").click(function(){$(this).remove()});window.setTimeout(function(){theAlert.fadeOut("slow",function(){theAlert.remove()})},2500)};var platform={fixes:{productGrouping:function(){if($(".grouping option").length<1){return}var groupingColour="";var groupingSize="";var groupingId="";groupingChange=function(e){var theParent=$(e.currentTarget).parents("li")[0];groupingColour=$("input:checked",theParent).val();groupingSize=$("select",theParent).val();var productStr=groupingColour+" - "+groupingSize;if($("option:contains('"+productStr+"')",$(theParent).prev()).length){$("option:contains('"+productStr+"')",$(theParent).prev()).attr("selected","selected")}else{if($(e.currentTarget).hasClass("radioColour")){alertMsg("No stock for size ("+groupingSize+") in "+groupingColour+" Please confirm size.");$("option:contains('"+groupingColour+" - ')",$(theParent).prev()).attr("selected","selected")}else{$("option:contains(' - "+groupingSize+"')",$(theParent).prev()).attr("selected","selected");alertMsg("No stock for colour "+groupingColour+" in size ("+groupingSize+") Please confirm colour.")}}$("select",$(theParent).prev()).trigger("change")};$("li.grouping").each(function(){groupingId=$("select",this).attr("id");if($("#"+groupingId+"_Sizes").length||!groupingId||$("option:contains('$')",this).length>0){return}$(this).css({position:"absolute",left:"-9999px"});$(this).after('<li class="attributesGroup"><div class="productAttributes"><div class="catProductAttributeGroup"><div class="catProdAttributeTitle">Size</div><div class="catProdAttributeItem"><select id="'+groupingId+'_Sizes"></select></div></div><div class="catProductAttributeGroup"><div class="catProdAttributeTitle">Colour</div><div class="catProdAttributeItem" id="'+groupingId+'_Colours"></div></div></div></li>');$("option",this).each(function(){groupingSize=$(this).text().split(" - ")[1];if(!$("select#"+groupingId+"_Sizes option[value='"+groupingSize+"']").length){$('<option value="'+groupingSize+'">'+groupingSize+"</option>").appendTo("select#"+groupingId+"_Sizes")}groupingColour=$(this).text().split(" - ")[0];if(!$("#"+groupingId+"_Colours input[value='"+groupingColour+"']").length){$('<input type="radio" name="'+groupingId+'_Colours" value="'+groupingColour+'" /><span>'+groupingColour+" </span>").appendTo("#"+groupingId+"_Colours")}if($(this).attr("selected")){$("#"+groupingId+"_Sizes option[value='"+groupingSize+"']").attr("selected","selected");$("#"+groupingId+"_Colours input[value='"+groupingColour+"']").attr("checked","checked")}})});$(".attributesGroup select").bind("change",groupingChange);platform.fixes.productAttributes();$(".attributesGroup .radioColour").bind("click",function(e){groupingChange(e);$(this).trigger("mouseout")})},validateCart:function(){if(typeof ValidateCart!=="function"){return}var _alert=window.alert;var fnc=ValidateCart;ValidateCart=function(){window.alert=function(msg){if(msg==="ERROR: Please choose a valid shipping option."){alertError("Please choose a valid shipping option.")}else{if(msg==="ERROR: Please select a shipping charge for your order."){alertError("Please select a shipping charge for your order.")}else{if(msg==="ERROR: Please enter in your Zip/Postcode to calculate shipping costs for your order."){alertError("Please enter in your Postcode/Zip to calculate shipping costs for your order.")}else{_alert(msg)}}}};var res=fnc.apply(this,arguments);window.alert=_alert;return res}},pagination:function(){$(".pages, #pagination").contents().filter(function(){if(this.nodeType===3){var str=this.nodeValue.replace(/^\s+|\s+|\s+$/g,"");if(str>0){$(this).wrap('<span class="current"/>')}}})},drawProduct:function(){if(typeof DrawProduct!=="function"){return}var fnc=DrawProduct;DrawProduct=function(){fnc.apply(this,arguments);platform.fixes.productAttributes();platform.fixes.productGrouping();platform.fixes.wishLists()}},addToCart:function(){if(typeof AddToCart!=="function"){return}var fnc=AddToCart;var _alert=window.alert;AddToCart=function(){window.alert=function(msg){alertMsg("+ "+msg)};fnc.apply(this,arguments);window.alert=_alert}},applyDiscount:function(){if(typeof ApplyDiscountCode!=="function"){return}var _alert=window.alert;var fnc=ApplyDiscountCode;ApplyDiscountCode=function(){window.alert=function(msg){alertError(msg)};fnc.apply(this,arguments);window.alert=_alert}},applyVoucher:function(){if(typeof ApplyGiftVoucher!=="function"){return}var _alert=window.alert;var fnc=ApplyGiftVoucher;ApplyGiftVoucher=function(){window.alert=function(msg){alertError(msg)};fnc.apply(this,arguments);window.alert=_alert}},updateShipping:function(){if(typeof UpdateShipping!=="function"){return}var fnc=UpdateShipping;var _alert=window.alert;UpdateShipping=function(){window.alert=function(msg){if(msg==="Shipping option removed successfully."||msg==="Shipping option selected successfully."){return}alertMsg(msg)};fnc.apply(this,arguments);window.alert=_alert}},cartUpdate:function(){if(typeof UpdateItemQuantity!=="function"){return}var _UpdateItemQuantity=UpdateItemQuantity;var _alert=window.alert;UpdateItemQuantity=function(){window.alert=function(){};_UpdateItemQuantity.apply(window,arguments);$("#catCartDetails a.cartLink:contains('empty')").html("Your shopping cart is empty. Go back").attr("href","/shop");window.alert=_alert};$("#main-nav-cart>a").click(function(e){e.preventDefault();window.location=$(this).attr("href")})},cartSummary:function(){if($(".cartSummaryLink").length<1){$(".cartSummaryItem").text("Your shopping cart is empty")}},wishLists:function(){$(".shop-product-small a.favoritelink").each(function(){var t=$(this).text();if(t=="Add to Favorites"){$(this).text("+ wishlist")}if(t=="Remove from Favorites"){$(this).text("- wishlist")}});$(".shop-product-large a.favoritelink").each(function(){var t=$(this).text();if(t=="Add to Favorites"){$(this).text("Add to wishlist")}if(t=="Remove from Favorites"){$(this).text("Remove from wishlist")}})},loginSummary:function(){if($("#usrchk").text()==="0"){$("#newUser").show();$("#header-nav>li strong").text("Welcome Guest")}},productAttributes:function(){$(".productAttributes input[type=radio]:visible").each(function(){$(this).hide();var swatchPath="/img/swatches/";var theColour=$(this).next().text();var att=theColour.toLowerCase();att=att.replace(/^\s+|\s+|\s+$/g,"");$(this).next().html($("<div>"+att+"</div>").css("background-image","url("+swatchPath+att+".jpg)"));$(this).next().addClass("radioColour").bind("click",function(){var radioGroup=$(this).prev().attr("name");$("input[name="+radioGroup+"]").next().attr("class","radioColour radioUnchecked");$(this).attr("class","radioColour radioChecked");$(this).prev().attr("checked","checked")}).bind("mouseenter mouseover",function(){var swatch=$("#colourSwatch");swatch.css({left:($(this).position().left-79)+"px",top:($(this).position().top-150)+"px"}).html('<div class="swatch"><img src="'+swatchPath+att+'.jpg" /></div>'+theColour);$("#colourSwatch:hidden").show()}).bind("mouseleave mouseout",function(){$("#colourSwatch").hide()});$(this).bind("click",function(){$(this).next().trigger("click")});if($(this).attr("checked")){$(this).next().trigger("click")}if(!$("input[name="+$(this).attr("name")+"]:checked").val()){$("input[name="+$(this).attr("name")+"]").eq(0).trigger("click")}});if($("#usrchk").text()==="1"){$("#reviews button").bind("click",function(e){e.preventDefault();$(".comment-form").show()});$(".comment-form").hide()}else{$(".comment-form").remove();$("#reviews button").bind("click",function(e){e.preventDefault();alertMsg("Please log in before adding a review")})}$("option:contains('Please select')").remove();$(".shop-product-large .image>img").each(function(){$(this).wrap('<a href="'+$(this).attr("src")+'"></a>');$(this).after($('<div class="icon zoom" />'));$(this).parent().fancybox({titleShow:false,padding:0,centerOnScroll:"true"})});$(".shop-product-large .questions a:gt(0)").each(function(){$(this).fancybox({autoDimensions:false,width:480,height:"auto",titleShow:false,hideOnContentClick:false,centerOnScroll:"true"})});if($("#productype").text().length){$(".shop-product-large .questions a:eq(0)").attr("href","/sizing-chart-"+$("#productype").text()).fancybox({autoDimensions:false,width:480,height:"auto",titleShow:false,hideOnContentClick:false,centerOnScroll:"true"})}}}};$(document).ready(function(){preLoadImages("/img/bg/swatchBox.png");$("input[type=text]").placehold({placeholderClassName:"placeholder"});platform.fixes.cartUpdate();platform.fixes.validateCart();platform.fixes.cartSummary();platform.fixes.wishLists();platform.fixes.loginSummary();platform.fixes.updateShipping();platform.fixes.applyDiscount();platform.fixes.applyVoucher();var addThisServices={services_compact:"www.polyvore.com,facebook,twitter,digg,email,google,myspace,more",ui_click:"true"};if(typeof addthis_config!="undefined"){$.extend(addthis_config,addThisServices)}else{addthis_config=addThisServices}var current=(window.location.pathname).split("/");current=current.slice(1);if(typeof AddToCart==="function"){var collection=$(".shop-menu-collection").next();var apparel=$(".shop-menu-apparel").next();var forWho=$(".shop-menu-for").next();var selectedCollection,selectedFor,selectedApparel;var collectionLevel,forLevel,apparelLevel;jQuery.each(current,function(i,n){if(n=="chic"||n=="life"||n=="movement"){selectedCollection=n}if(n=="womens"||n=="mens"||n=="childrens"){selectedFor=n}if(n=="tops"||n=="bottoms"||n=="dresses"||n=="accessories"){selectedApparel=n}switch(n){case"chic":collectionLevel=0;break;case"life":collectionLevel=1;break;case"movement":collectionLevel=2;break;case"womens":forLevel=0;break;case"mens":forLevel=1;break;case"childrens":forLevel=2;break;case"tops":apparelLevel=0;break;case"bottoms":apparelLevel=1;break;case"dresses":apparelLevel=2;break;case"accessories":apparelLevel=3;break;default:break}});selectMenu(collection,collectionLevel);selectMenu(forWho,forLevel);selectMenu(apparel,apparelLevel);var shopPath="";if(selectedFor){shopPath+=selectedFor+"/"}if(selectedApparel&&selectedApparel!="accessories"){shopPath+=selectedApparel+"/"}$("a",collection).each(function(){var thisCollection=$(this).attr("href").split("/");if($(this).parent().hasClass("current")){$(this).attr("href","/shop/"+shopPath)}else{$(this).attr("href","/shop/"+thisCollection[2]+"/"+shopPath)}if((thisCollection[2]=="chic"&&selectedFor=="mens")||selectedFor=="childrens"){$(this).attr("href","/shop/"+thisCollection[2]+"/")}});shopPath="";if(selectedCollection){shopPath+=selectedCollection+"/"}$("a",forWho).each(function(){var thisFor=$(this).attr("href").split("/");if($(this).parent().hasClass("current")){$(this).attr("href","/shop/"+shopPath)}else{$(this).attr("href","/shop/"+shopPath+thisFor[2]+"/")}if(selectedApparel&&selectedApparel!="accessories"){$(this).attr("href",$(this).attr("href")+selectedApparel+"/");if(thisFor[2]=="mens"&&selectedApparel=="dresses"){$(this).attr("href","/shop/"+shopPath+thisFor[2]+"/")}}if((selectedCollection=="chic"&&thisFor[2]=="mens")||(thisFor[2]=="childrens"&&selectedCollection)){$(this).attr("href","/shop/"+thisFor[2]+"/")}});shopPath="";if(selectedCollection){shopPath+=selectedCollection+"/"}if(selectedFor){shopPath+=selectedFor+"/"}$("a",apparel).each(function(){var thisApparel=$(this).attr("href").split("/");if($(this).parent().hasClass("current")){$(this).attr("href","/shop/"+shopPath)}else{$(this).attr("href","/shop/"+shopPath+thisApparel[2]+"/")}if(thisApparel[2]=="accessories"){$(this).attr("href","/shop/"+thisApparel[2]+"/")}if(thisApparel[2]=="dresses"&&selectedFor=="mens"){$(this).attr("href","/shop/"+thisApparel[2]+"/")}});$('<div id="colourSwatch"></div>').appendTo("body");platform.fixes.drawProduct();platform.fixes.productAttributes();platform.fixes.productGrouping();platform.fixes.addToCart();platform.fixes.pagination()}var rotations=5;var activeContainer=1;var currentImg=Math.floor(Math.random()*rotations)+1;var animating=false;var currentZindex=2;var navigate=function(direction){if(animating){return}if(direction=="next"){currentImg++;if(currentImg==rotations+1){currentImg=1}}else{currentImg--;if(currentImg==0){currentImg=rotations}}var currentContainer=activeContainer;activeContainer=(activeContainer==1)?2:1;showImage(currentImg,currentContainer,activeContainer)};var showImage=function(imageNum,currentContainer,activeContainer){animating=true;var bgPos="0";if(imageNum>1){bgPos="-"+(382*(imageNum-1))+"px"}$("#heroImg"+currentContainer).css({"z-index":currentZindex});$("#heroImg"+activeContainer).css({"background-image":"url(img/hero/hero-home-"+imageNum+".jpg)",display:"block","z-index":currentZindex-1});$("#heroImg"+currentContainer).fadeOut(1500,function(){animating=false})};if($(".hero.home").length>0){preLoadImages("img/hero/hero-home-2.jpg","img/hero/hero-home-3.jpg","img/hero/hero-home-4.jpg","img/hero/hero-home-5.jpg");navigate("next");var interval;var slideshowSpeed=6000;interval=setInterval(function(){navigate("next")},slideshowSpeed)}})})(jQuery);
