var KB=new KitbagObjects("chelsea"),header={curMenu:{},init:function(){var d=$("#headerNav"),b=$("a","#siteNav"),c=d.find(".navMenu"),a=$("#navMenuShadow");if(document.location.protocol=="https:"){b.each(function(){var a=$(this).attr("href");$(this).attr("href","http://"+document.location.hostname+a.substr(a.indexOf("/stores/")))});c.find("a").each(function(){var a=$(this).attr("href");$(this).attr("href","http://"+document.location.hostname+a.substr(a.indexOf("/stores/")))});$("#pageHeader a").each(function(){var a=$(this).attr("href");$(this).attr("href","http://"+document.location.hostname+a.substr(a.indexOf("/stores/")))})}b.live("mouseenter",function(){$(this).addClass("siteNavActive").prev().css("visibility","visible");header.curMenu=c.eq(b.index($(this)));if(header.curMenu.html()!=null&&$(this).attr("class").indexOf("NoChild")==-1){var d=$(this).position().left-6;if(header.curMenu.width()>945-d){header.curMenu.css("right",3).fadeIn(200);a.show().css({right:0,left:""})}else{header.curMenu.css("left",d).fadeIn(200);a.show().css("left",d+5)}a.height(header.curMenu.height()+3).width(header.curMenu.width()+30)}});b.live("mouseleave",function(b){if(!$(b.relatedTarget).hasClass("navMenu")&&$(b.relatedTarget).parents(".navMenu").length==0){a.hide(0);header.curMenu&&header.curMenu.hide(0);$(this).prev().css("visibility","hidden");$(this).removeClass("siteNavActive")}});c.live("mouseleave",function(){$("span","#siteNav").css("visibility","hidden");$("a","#siteNav").removeClass("siteNavActive");$(this).hide(0);a.hide(0)});a.fadeTo(0,.6);$("#searchButton").click(function(){if($("#txt_search").attr("value")!="")window.location.href="/stores/chelsea/products/product_browse.aspx?free_text="+encodeURIComponent($("#txt_search").attr("value"))});$("#txt_search").focus(function(){if(this.defaultValue==this.value)this.value=""}).blur(function(){if(this.value=="")this.value=this.defaultValue}).autocomplete("/stores/chelsea/services/ProductService.svc/ProductsSearch",{dataType:"json",minChars:3,scrollHeight:220,width:400,resultCount:true,formatItem:function(a){return"<img src='"+a.Img+"' /><div> "+a.Des+"<br />"+a.Price+"</div><div style='float:none;clear:both'></div>"},formatResult:function(){return""},parse:function(b){var a=b.d;return $.map(a,function(a){return{data:a,value:a.Des,result:a.Des}})}}).result(function(b,a){if(a.Pid>0)location.href="/stores/chelsea/products/product_details.aspx?pid="+a.Pid;else if(a.Pid==0)location.href="/stores/chelsea/products/product_browse.aspx?free_text="+a.Des});$(".danilolink").click(function(a){a.preventDefault();shadowViewer.highlight({resourceURL:"/stores/chelsea/help/danilo.htm?"+$(this).attr("href"),width:450,height:215,elementToHighlight:".daniloHighlightDiv"});return false})}},home={imgID:{},timer:{},links:{},init:function(){$(".homepageSU").kb_signup();$("#homepageMz").kb_accordian();if($("#promoimage").length>0){$("#promoimage").data("animating",false);$("#tlmanext").click(function(){clearTimeout(home.timer);home.tlmFireRotate()});home.imgID=tlma.length-1;$("#navbarbg, #promodescbg").css("opacity",.8);if(tlma[0].desc=="")$("#promodescbg, #promodesc").hide(0);else{$("#promodescbg, #promodesc").show(0);$("#promodesc").children("span").html(tlma[0].title);$("#promodesc").find("a").attr("href",tlma[0].link).html(tlma[0].desc)}home.links=$("a","#navbarlinks");home.links.each(function(){$(this).css("top",(home.links.index($(this))-1)*75)});home.links.live("mouseenter",function(){$(this).children("span").addClass("linkhover")});home.links.live("mouseleave",function(){$(this).children("span").removeClass("linkhover")});home.links.show();home.links.filter(":first").css("opacity",0);$("a","#homepageSideBanners").click(function(){sc_trackLink("HPSideBnr"+$("a","#homepageSideBanners").index(this),"eVar6")});$("a","#homepageBottomBanners").click(function(){sc_trackLink("HPBottomBnr"+$("a","#homepageBottomBanners").index(this),"eVar6")});$("a.promoimage","#homepageTopBanners").click(function(){sc_trackLink("HPTopBnr"+$("a.promoimage","#homepageTopBanners").index(this),"eVar6")})}},tlmRotate:function(){if($("#promoimage").length>0)home.timer=setTimeout(function(){home.tlmFireRotate()},9e3)},tlmFireRotate:function(){var a=tlma[home.imgID].image;$("#promoimage").data("animating")==false&&$(new Image).load(function(){home.changeImg()}).attr("src",a)},changeImg:function(){var a=tlma[home.imgID];$("#promoimage").data("animating",true).fadeOut(300,function(){$(this).find("img").attr("src",a.image).attr("alt",a.title).attr("title",a.title);$(this).attr("href",a.link).fadeIn(300);if(a.desc=="")$("#promodescbg, #promodesc").hide(0);else{$("#promodescbg, #promodesc").show(0);$("#promodesc").children("span").html(a.title);$("#promodesc").find("a").attr("href",a.link).html(a.desc)}});home.links.each(function(){if(home.links.index($(this))==home.imgID)$(this).animate({top:"345px",opacity:0},500,"swing",function(){$(this).css("top","-75px");$("#promoimage").data("animating",false)});else $(this).animate({top:"+=75px",opacity:1},500,"swing")});home.imgID-=1;if(home.imgID<0)home.imgID=tlma.length-1;this.tlmRotate()}},browse={init:function(){$(".browseMerchZones","#lpTable").kb_accordian({grow:true});var a=$(".refinementPanel .refinement","#productBrowseContainer");a.children("a").click(function(a){a.preventDefault();$(this).parent().next().slideToggle(250)});$(".navSU").kb_signup();$(".colourway a").mouseover(function(){var a=$(this).parents(".productListItem"),f=a.find(".productListImage img"),e=a.children(".productListLink").find("a"),d=a.children(".productListPrice").find("span:last"),b={};b.img=f.attr("src");b.desc=e.html();b.price=d.html();!a.data("orig")&&a.data("orig",b);var c=window["colour"+$(this).attr("rel")];f.attr("src",c.ImageURL);e.html(c.Description);d.html(c.PriceString)});$(".productListColours").mouseleave(function(){var b=$(this).parents(".productListItem"),c=b.find(".productListImage img"),a=b.data("orig");a&&a.img!=c.attr("src")&&c.fadeTo(200,.5,function(){$(this).attr("src",a.img).fadeTo(600,1);b.find(".productListLink a").html(a.desc);b.find(".productListPrice span:last").html(a.price)})})}};function ValueChangedHandler(){showProgress();$("input:submit").click()}function showProgress(){$("#productBrowseNav").block({message:'<img src="/stores/chelsea/artwork/common/interface/loader_v1.gif" />',overlayCSS:{backgroundColor:"#fff",opacity:.6}});$(".productListImage").block({message:'<img src="/stores/chelsea/artwork/common/interface/loader_v1.gif" />',overlayCSS:{backgroundColor:"#fff",opacity:.6}})}var basket={init:function(){$("#basketRight").kb_accordian({grow:true});$(".productListATB").click(function(c){c.preventDefault();EnableUI.Toggle(false);var a=$(this).parents(".productListItem"),d=$(this).attr("rel"),b=0;if(a.find(".productListSizes").get(0))b=parseInt(a.find(".productListSizes").val(),10);KB.Services.Product().AddToBasket(d,b,0,"","",0,basket.onATBComplete,basket.onError)});$(".shiplink").live("mousedown",function(){$(this).queue(function(){$("#deliveryinfo div").kb_content({branch:892,leaf:"shipping_info_88"})}).dequeue});$(".removeItem").live("click",function(a){a.preventDefault();basket.feedback($(this),"Please wait while this item is removed from your basket");__doPostBack($(this).attr("name"),"")});$(".decreaseItem, .increaseItem").live("click",function(){basket.feedback($(this),"Please wait while this item is updated");__doPostBack($(this).attr("name"),"")});basket.giftWrap.init()},refreshContents:function(){__doPostBack($("div[id*=up_basket]").attr("id"),"BasketRefresh")},feedback:function(b,c){var a=b.parents("tr");a.find("td:gt(0)").remove();a.find("td:first").css("background-color","#F2F2F2");a.append("<td colspan='6' align='center' style='background-color:#F2F2F2'><img src='/stores/chelsea/artwork/common/interface/loader_bar_v1.gif' alt='loading' /><p>"+c+"</p></td>")},onATBComplete:function(a){if(a){var b=$("."+a.ProductID+a.VariationID),c="<td align='center' valign='middle' style='background-color:#F2F2F2;height:105px;width:120px;'><img src='http://images.kitbag.com/"+a.ImageName+"?width=100&amp;height=100' alt='"+a.Description+"' style='height:100px;width:100px;border-width:0px;' /></td><td colspan='6' align='center' style='background-color:#F2F2F2'><img src='/stores/chelsea/artwork/common/interface/loader_bar_v1.gif' alt='loading' /><p>Please wait while <em>'"+a.Description+"'</em> is added to your basket</p></td>";if(b.length>0)b.html(c);else b=$("<tr style='display:none' />").html(c).fadeIn(600).appendTo($(".basketContents"));var d=b.offset().top+b.height();if(parseInt(d,10)>$(window).height()+$(window).scrollTop())$("html,body").animate({scrollTop:d-$(window).height()+10},500,function(){basket.refreshContents()});else basket.refreshContents()}else{alert("There was a problem adding the current selection to the basket");EnableUI.Toggle(true)}},onError:function(){alert("Unfortunately an error has occurred, please try again");EnableUI.Toggle(true)},giftWrap:{init:function(){basket.giftWrap.enableGWCheckBoxes();var a=Sys.WebForms.PageRequestManager.getInstance();a.add_endRequest(function(){basket.giftWrap.enableGWCheckBoxes()});$(".chkGiftWrap").live("click",function(){var a=$(this).find("input");shadowViewer.highlight({resourceURL:"/stores/chelsea/help/giftwrap/giftwrap_enter.htm",width:640,height:550});$(".gw_charsmax").text(KB.GiftWrap.taglength);if(a.is(":checked")){$(".gw_text").data("bskItem",$(this).attr("rel")).focus();$(".gw_add").show()}else{$(".gw_text").data("bskItem",$(this).attr("rel")).attr("readonly","true").val($(".giftwrapmsg"+$(this).attr("rel")).html().replace(KB.GiftWrap.emptymsg,""));$(".gw_remove").show()}$(".gw_cancel").data({chkBoxID:a.attr("id")});basket.giftWrap.giftTagCalculateChars();$(".gw_price").html("£"+KB.GiftWrap.price)});$(".editGiftTag").live("click",function(){shadowViewer.highlight({resourceURL:"/stores/chelsea/help/giftwrap/giftwrap_enter.htm",width:640,height:550});$(".gw_charsmax").text(KB.GiftWrap.taglength);$(".gw_text").data("bskItem",$(this).attr("rel")).show().val($(".giftwrapmsg"+$(this).attr("rel")).html().replace(KB.GiftWrap.emptymsg,"")).focus();$(".gw_edit").show();basket.giftWrap.giftTagCalculateChars()});$(".gw_info").live("click",function(){shadowViewer.highlight({resourceURL:"/stores/chelsea/help/giftwrap/giftwrap_info.htm",width:520,height:310});$(".gw_price").html("£"+KB.GiftWrap.price)});$(".gw_cancel").live("click",function(){shadowViewer.hide();var a=$("#"+$(this).data("chkBoxID")).eq(0);if(a.attr("checked"))a.attr("checked",false);else a.attr("checked",true)});$(".gw_add").live("click",function(){if($(".gw_text").eq(0).val().length>KB.GiftWrap.taglength)basket.giftWrap.giftTagCalculateChars();else{EnableUI.Toggle(false);KB.Services.Basket().InsertPrintingItem($(".gw_text").data("bskItem"),16,1,KB.GiftWrap.name,0,KB.GiftWrap.price,basket.giftWrap.giftWrapAddedSuccess,basket.giftWrap.giftWrapError)}});$(".gw_edit").live("click",function(){var a=$(this).siblings(".gw_text").eq(0).val();if(a.length>KB.GiftWrap.taglength)basket.giftWrap.giftTagCalculateChars();else{EnableUI.Toggle(false);KB.Services.Basket().UpdatePrintingItem($(".gw_text").data("bskItem"),17,a,basket.giftWrap.giftWrapSuccess,basket.giftWrap.giftWrapError)}});$(".gw_remove").live("click",function(){EnableUI.Toggle(false);KB.Services.Basket().RemovePrintingItem($(".gw_text").data("bskItem"),17,basket.giftWrap.giftTagRemovedSuccess,basket.giftWrap.giftWrapError)});$(".gw_removeall").live("click",function(){EnableUI.Toggle(false);KB.Services.Basket().RemovePrintingItemsByType(17,basket.giftWrap.giftTagAllRemovedSuccess,basket.giftWrap.giftWrapError)});$(".gw_cancelcountry").live("click",function(){shadowViewer.hide();var a=$(".countrySelector");if(a.length>0){$(".countrySelector option[value='204']").attr("selected","selected");basket.refreshContents()}});$("body").delegate(".countrySelector","change",function(){var c=KB.GiftWrap.countries.split(","),b=$(".countrySelector").eq(0).val(),a=$(".chkGiftWrap input:checked").length;a>0&&$.inArray(b,c)<0&&shadowViewer.highlight({resourceURL:"/stores/chelsea/help/giftwrap/giftwrap_restrictions.htm",width:520,height:310})});$(".gw_text").live("keydown",function(){var a=$(".gw_text").eq(0);if(a.val().length>KB.GiftWrap.taglength)return false}).live("keyup",function(){var a=$(".gw_text").eq(0);a.val(a.val().substring(0,KB.GiftWrap.taglength));basket.giftWrap.giftTagCalculateChars()})},enableGWCheckBoxes:function(){$(".chkGiftWrap input").attr("disabled",false);$(".chkGiftWrap").attr("disabled",false)},giftTagCalculateChars:function(){var a=$(".gw_text").eq(0).val();$(".gw_charsused").html(a.length);$(".gw_charsremaining").html(KB.GiftWrap.taglength-a.length)},giftWrapSuccess:function(){basket.feedback($(".chkGiftWrap[rel='"+$(".gw_text").data("bskItem")+"']"),"Altering gift wrap selection on this item");shadowViewer.hide({callback:basket.refreshContents()})},giftWrapError:function(){alert("There was a problem with the operation");EnableUI.Toggle(true)},giftWrapAddedSuccess:function(){KB.Services.Basket().InsertPrintingItem($(".gw_text").data("bskItem"),17,1,$(".gw_text").eq(0).val(),0,0,basket.giftWrap.giftWrapSuccess,basket.giftWrap.giftWrapError)},giftTagRemovedSuccess:function(){KB.Services.Basket().RemovePrintingItem($(".gw_text").data("bskItem"),16,basket.giftWrap.giftWrapSuccess,basket.giftWrap.giftWrapError)},giftTagAllRemovedSuccess:function(){KB.Services.Basket().RemovePrintingItemsByType(16,basket.giftWrap.giftWrapSuccess,basket.giftWrap.giftWrapError)}}},sizechart_viewer={load:function(a){!KB.Cache.Get("chart")&&$.get("/stores/chelsea/help/size_chart.html",function(b){KB.Cache.Set("chart",b);$(a).html(b);$("#sizecharttabs").kb_tabs()})}},productplus={img:{},init:function(){$(".ppimg").click(function(b){b.preventDefault;var a=$(this).parents(".ppItem");a.addClass("ppSelected").siblings(".ppItem").removeClass("ppSelected");productplus.img=a.find(".ppImg").attr("src");KB.Services.Product().SetProductPlus($(this).attr("rel"),a.find(".ppVariation").val(),productplus.onPPComplete,productplus.onError)});$("#ppSelectedInfo").live("click",function(){KB.Services.Product().RemoveProductPlus(productplus.onPPRemoveComplete,productplus.onError)})},onPPComplete:function(a){a=a.replace("[IMG]","<img src='"+productplus.img+"' alt='' />");$("#ppSelectedInfo").slideUp(400).queue(function(){$(this).html(a+"<br/><a><img src='/stores/chelsea/artwork/english/interface/buttons/button_cancel.gif' /></a>").dequeue()}).slideDown(400)},onPPRemoveComplete:function(){$("#ppSelectedInfo").slideUp(400).queue(function(){$(".ppItem").removeClass("ppSelected");$(this).html("<p>You have not yet made a selection</p>").dequeue()}).slideDown(200)},onError:function(){$("#ppSelectedInfo").html("Unfortunately a problem occurred, please try again or come back later when the problem will hopefully be resolved")}};function s7jsonResponse(b){var c="",e=0,a=0,f=0;for(c in b){e=b[c].indexOf(";",0);a=b[c].indexOf(",",0);if(a==-1)a=b[c].length;while(e>0){f++;var d=b[c].substring(e+1,a).replace("Findel/","");d=d.substring(d.indexOf("-")+1);var g=productdetail.ImageURL.substring(productdetail.ImageURL.lastIndexOf("/")+1,productdetail.ImageURL.lastIndexOf("-")+1)+d;$("<img/>").data("imgname",g).attr("src","http://images.kitbag.com/"+g+".jpg?width=90&height=90&quality=95").appendTo("#pdMultiImages");if(f==4)break;e=b[c].indexOf(";",a);a=b[c].indexOf(",",a+1);if(a==-1)a=b[c].length}}f<2&&$("#pdMultiImages img").hide(0)}var productDetailOptions={pdAreaSelector:"#productDetailInfo",pdTabsSelector:"#pdTabs",pdNavSelector:"productDetailNav",pdSignUpSelector:"#productdetailsSU",OnInit:function(){shadowViewer.init();proddetails.UnbindDefaults();$("#sizechartlink").mousedown(function(){$(this).queue(function(){sizechart_viewer.load("#sizechart div")}).dequeue()});$("#returnsinfolink").mousedown(function(){$(this).queue(function(){$("#returnsinfo div").kb_content({branch:897,leaf:"returnsinfoFull88"})}).dequeue()});$("#ukdeliveryinfolink").mousedown(function(){$(this).queue(function(){$("#ukdeliveryinfo div").kb_content({branch:897,leaf:"delinfo_UKFull88"})}).dequeue()});$("#overseasdeliveryinfolink").mousedown(function(){$(this).queue(function(){$("#overseasdeliveryinfo div").kb_content({branch:897,leaf:"delinfo_OverseasFull88"})}).dequeue()});$("#showdesc").click(function(){$(".tabheader a","#pdTabs").eq(0).click();scrollTo(0,1e4)});$("#showreturn").click(function(){$(".tabheader a","#pdTabs").eq(2).click();scrollTo(0,1e4)});$("#showdelivery").click(function(){$(".tabheader a","#pdTabs").eq(1).click();scrollTo(0,1e4)})}},orderDetails={init:function(){$(".shiplink").live("mousedown",function(){$(this).queue(function(){$("#deliveryinfo .content").kb_content({branch:892,leaf:"shipping_info_88"})}).dequeue});$(".shipOptions input:checked").parents("tr").css("background-color","#EEE");var a=Sys.WebForms.PageRequestManager.getInstance();a.add_endRequest(function(){orderDetails.init()})},showInvalidGiftWrapMsg:function(){shadowViewer.highlight({resourceURL:"/stores/chelsea/help/giftwrap/giftwrap_restrictions.htm",width:520,height:310})}};function goSort(c){var b=document.getElementById(c).value,a=baseurlwithoutsort,d=a+"&sort_option="+b;window.location.href=d}$(document).ready(function(){header.init();try{$("#aspnetForm").validate()}catch(a){}});
