$(document).ready(function(){if($.cookie("wardrobe")!=null){$.fresca.initProdDiv()}else{$("#myWardrobeContentsCont").append('<div id="wardrobeHeader"><div class="emptyWardrobe">You do not have any products in your Wardrobe. Please click here to <a href="/" class="returnHome">return to the home page</a>.</div>')}$("input#buyOutfit").click(function(){var a=false;$("div.wardrobeItemOptions").find("select").each(function(){if($(this).attr("value")){a=true}});if(a){$("input[name='forwardName']").remove();$("form#addToBag").attr("action","/pws/UpdateBasket.ice").submit()}else{$("div.errorCont").html("ERROR - Please select the sizes of the products you wish to add to your basket.");return false}})});(function(a){a.fresca={updateText:"Updating",popups:[],initProdDiv:function(){var c=a.cookie("wardrobe");var b=new Array();b=c.split(",");a("#myWardrobeContentsHeader").append('<div id="wardrobeHeader">You have '+b.length+' items in your Wardrobe. Select the sizes of the products you want to add to your basket and then click the BUY THIS OUTFIT button.</div><div class="errorCont"></div>');a(b).each(function(e){var d=new Array();d.loaded=false;var f=b[e];f=f.split("_");f=f[1];d.url="/pws/AJProductDetails.ice?layout=wardrobe.product.layout&ProductID="+f;a("#myWardrobeContentsCont").append('<div id="wardrobeBlk'+f+'" class="smlProductDetailCont">&nbsp;</div>');d.wardrobeBlk=a("div#wardrobeBlk"+f);d.wardrobeBlk.css("display","none");a.fresca.popups.push(d)});a.fresca.createPopups()},createPopups:function(){a.each(a.fresca.popups,function(c,b){a.fresca.loadPopupContent(b,b.url)})},loadPopupContent:function(b,c){b.wardrobeBlk.css("display","block");a.fresca.getLoaderContent(b);a.ajax({url:c,success:function(e){var d=e.indexOf('<div class="wardrobeInfo">');if(d>=0){b.wardrobeBlk.empty().append(e)}else{b.wardrobeBlk.empty().append("<p id='homePopUpError'>Sorry, this product is does not exist.</p>")}},error:function(d,f,e){id=c.split("ProductID=");id=id[1];consol.log(id);b.wardrobeBlk.empty().append("<div id='wardrobeProductDetails'><img id='mainProductImage' width='111' alt='Out of stock' src='/pws/images/catalogue/products/"+id+"/small/"+id+"_1.jpg' class=''/><div class='wardrobeInfo'><p id='homePopUpError'>Sorry, this product is currently out of stock.</p></div><div class='wardrobeWhatToDo'><a href='javascript:void(0); removeFromMyWardrobe("+id+");' class='removeFromMyWardrobe'>Remove from My Wardrobe</a></div></div>")}})},getLoaderContent:function(b){b.wardrobeBlk.empty();b.wardrobeBlk.append('<div class="loaderImg" id="loader'+b.id+'"><img src="/pws/images/preloader.gif" alt="activity indicator"/></div>')}}})(jQuery);function removeFromMyWardrobe(d){var c="";var c="";var e=$.cookie("wardrobe");var b=new Array();b=e.split(",");document.getElementById("wardrobeBlk"+d).style.display="none";if(b.length>1){for(i=0;i<b.length;i++){CookieProd_ID=b[i].split("_");CookieProd_ID=CookieProd_ID[1];if(CookieProd_ID!=d){if(c.length>0){c+=","}c+=b[i]}}$.cookie("wardrobe",c,{expires:31,path:"/"});var a=c.split(",");$("#wardrobeHeader").empty();$("#wardrobeHeader").append("You have "+a.length+" items in your Wardrobe. View details and add the product you want to your basket.")}else{$.cookie("wardrobe",null,{path:"/"});$("#wardrobeHeader").empty();$("#wardrobeHeader").append('<div class="emptyWardrobe">You do not have any products in your Wardrobe. Please click here to <a href="/" class="returnHome">return to the home page</a>.</div>')}loadWardrobePopout()};
