var KB={Services:{},Cache:{}};KB.Cache.Set=function(a,b){this[a]=b;return this[a]};KB.Cache.Get=function(a){if(typeof this[a]!=="undefined")return this[a];else return null};KB.Cache.JQuery=function(a){if(typeof this[a]==="undefined")this[a]=$(a);return this[a]};KB.Services.Product=function(){var a=this._productService?this._productService:new ProductServiceProxy("/stores/manutd/services/ProductService.svc/");this._productService=a;return a};KB.Services.General=function(){var a=this._generalService?this._generalService:new GeneralServiceProxy("/stores/manutd/services/GeneralService.svc/");this._generalService=a;return a};KB.Services.Customer=function(){var a=this._customerService?this._customerService:new CustomerServiceProxy("/stores/manutd/services/CustomerService.svc/");this._customerService=a;return a};var header={curMenu:{},init:function(){var d=$("#headerNav"),b=$("a","#siteNav"),c=d.children("div");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/")))})}var a=$("#navMenuShadow");b.mouseenter(function(){$(this).prev().css("visibility","visible");$(this).addClass("siteNavActive");header.curMenu=c.eq(($("li","#siteNav").index($(this).parent())+1)/2-1);if(header.curMenu.html()!=""){var b=$(this).position().left-6;if(header.curMenu.width()>945-b)b=b-3-(header.curMenu.width()-$(this).width());if(b<10)b=10;header.curMenu.css("left",b).fadeIn(200);a.show().css("left",b+5).height(header.curMenu.height()+5).width(header.curMenu.width()+30)}});b.mouseleave(function(b){if(!header.determineHide(header.curMenu.get(0),b)){a.hide(0);header.curMenu.hide(0);$(this).prev().css("visibility","hidden");$(this).removeClass("siteNavActive")}});a.fadeTo(0,.6);c.mouseleave(function(){$("span","#siteNav").css("visibility","hidden");$("a","#siteNav").removeClass("siteNavActive");$(this).hide(0);a.hide(0)});$("#searchButton").click(function(){if($("#txt_search").attr("value")!="")window.location.href="/stores/manutd/products/product_browse.aspx?free_text="+encodeURIComponent($("#txt_search").attr("value"))});$("#txt_search").keypress(function(a){if(a.which&&a.which==13||a.keyCode&&a.keyCode==13){a.preventDefault();window.location.href="/stores/manutd/products/product_browse.aspx?free_text="+encodeURIComponent($(this).attr("value"));return false}else return true})},determineHide:function(c,b){b=window.event||b;var a=b.relatedTarget||b.toElement;while(a&&a!=c)try{a=a.parentNode}catch(d){a=c}if(a==c)return true;else return false}},home={imgID:{},timer:{},links:{},init:function(){home.imgID=1;home.links=$("a","#navbarlinks");home.links.each(function(){$(this).css("top",(home.links.index($(this))-1)*112).children("span").css("opacity",.7)});home.links.mouseenter(function(){$(this).children("span").addClass("linkhover")});home.links.mouseleave(function(){$(this).children("span").removeClass("linkhover")});home.links.show();home.links.filter(":first").css("opacity",0);$("a","#homepageSideBanners").click(function(){sc_trackLink("HPSideBnr"+$("#homepageSideBanners a").index(this),"eVar6")});$("a.promoimage","#homepageTopBanners").click(function(){sc_trackLink("HPTopBnr"+$("#homepageTopBanners a").index(this),"eVar6")})},tlmRotate:function(){this.timer=setTimeout(function(){home.tlmFireRotate()},9e3)},tlmFireRotate:function(){var a=tlma[tlma.length-home.imgID].image;$(new Image).load(function(){home.changeImg()}).attr("src",a)},changeImg:function(){var a=$("a.promoimage","#homepageTopBanners"),b,c=tlma[tlma.length-home.imgID];a.fadeOut(300,function(){a.find("img").attr("src",c.image);a.attr("href",c.link);a.find("img").attr("alt",c.title);a.find("img").attr("title",c.title)});home.links.each(function(){b=home.links.index($(this))+1;if(b-1==4-home.imgID)$(this).animate({top:"345px",opacity:0},500,"swing",function(){$(this).css("top","-115px")});else{if(b==4)b=0;$(this).animate({top:home.links.eq(b).css("top"),opacity:1},500,"swing")}});a.fadeIn(300);home.imgID=home.imgID+1;if(home.imgID>tlma.length)home.imgID=1;this.tlmRotate()}},browse={init:function(){var a=$(".refinementPanel .refinement","#productBrowseContainer");a.children("img, a").click(function(b){b.preventDefault();$(this).parent().next().slideToggle(250);var a=this.tagName=="img"?$(this):$(this).siblings("img");if(a.attr("src").indexOf("_expand")>0)a.attr("src",a.attr("src").match(/[^_]+/)+"_collapse.gif");else a.attr("src",a.attr("src").match(/[^_]+/)+"_expand.gif")})}},merchzones={init:function(){var a=$(".mzHead",KB.Cache.JQuery("#pageContent")).find("a");a.mouseover(function(){!$(this).parent().hasClass("mzAreaSelected")&&$(this).parent().addClass("mzAreaHover")});a.mouseout(function(){$(this).parent().removeClass("mzAreaHover")});merchzones.move(a.eq(a.length-1),true);a.click(function(a){a.preventDefault();merchzones.move($(this),false)})},move:function(g,h){var e=g.parents(".mzArea"),b=e.parent(),a=b.children(".mzArea"),i=a.index(e),d=g.height(),c=0;if(h){a.each(function(){if($(this).height()>c)c=$(this).height()});var f=c+d*(a.length-1);f>b.height()&&b.height(f)}a.each(function(){var e,f;e=a.index($(this));if(e<=i)f=e*d;else f=b.height()-(a.length-e)*d;if(!h)$(this).animate({top:f},500,"swing");else $(this).height(c).css({top:f,"z-index":(e+1)*10});$(this).find(".mzHead").removeClass("mzAreaSelected")});e.find("div.mzHead").addClass("mzAreaSelected")}},signup={defEmail:{},init:function(){this.defEmail="enter your email address";var a=$(".signUpBox",KB.Cache.JQuery("#pageContent"));a.val()==""&&a.val(signup.defEmail);a.focus(function(){$(this).val()==signup.defEmail&&$(this).val("")}).blur(function(){$(this).val()==""&&$(this).val(signup.defEmail)});$(".signUpButton",KB.Cache.JQuery("#pageContent")).click(function(){var a=$(".signUpBox").val(),b=/^[\w-\.]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,3}$/;if(b.test(a))KB.Services.Customer().AddCustomerToMailList(a,signup.onSignUpComplete,signup.onError);else signup.onSignUpComplete("Email address is invalid")})},onSignUpComplete:function(b){var a=$(".signUp div",KB.Cache.JQuery("#pageContent"));a.html(b).slideDown(400);setTimeout(function(){a.slideUp(400)},5e3)},onError:function(){var a=$(".signUp div",KB.Cache.JQuery("#pageContent"));a.html("Unfortunately an error has occured, please try again").slideDown(400);setTimeout(function(){a.slideUp(400)},5e3)}},sizechart_viewer={load:function(a){!KB.Cache.Get("chart")&&$.get("/stores/manutd/help/size_chart.html",function(b){KB.Cache.Set("chart",b);$(a).html(b);pagetabs.init("#sizecharttabs")})}},shadowViewer={elementHighlighted:{},init:function(){var a=$(".viewer",KB.Cache.JQuery("#pageContent"));a.each(function(){var a=$($(this).attr("rel"));a.css({position:"absolute",margin:"auto","z-index":"10001"})});a.click(function(g){var a=$($(this).attr("rel"));shadowViewer.elementHighlighted=a;g.preventDefault();var d=window.innerWidth||(window.document.documentElement.clientWidth||window.document.body.clientWidth),c=window.innerHeight||(window.document.documentElement.clientHeight||window.document.body.clientHeight),h=window.pageYOffset||(window.document.documentElement.scrollTop||window.document.body.scrollTop),f=Math.max(c/2-a.height()/2+h,0),e=d/2-a.width()/2,b=$.browser.msie?$('<iframe class="shadowDiv" src="/stores/common/products/block.html"></iframe>'):$('<div class="shadowDiv"></div>');b.height($("body").height());b.appendTo($("body"));b.css("opacity",.8).show(0);a.fadeIn(600).css("left",e-10).css("top",f)});$(".viewerClose",KB.Cache.JQuery("#pageContent")).click(function(){shadowViewer.elementHighlighted.fadeOut(300,function(){$(".shadowDiv").remove()})})}},pagetabs={init:function(a){var b=$(a).find(".tabheader ul li a");$(a).find(".tabcontent:first").show();b.filter(":first").addClass("tabselected");b.click(function(a){a.preventDefault;pagetabs.showTab($(this))})},showTab:function(c){var f=c.parents(".tabs"),g=f.find(".tabheader ul li a"),a=f.find(".tabcontent"),b=a.filter(":visible"),d=g.index(c),e=a.index(b);if(e!=d){b.fadeTo(300,0,function(){b.hide();a.eq(d).show().fadeTo(200,1)});g.eq(e).removeClass("tabselected");c.addClass("tabselected")}}},productplus={img:{},init:function(){$(".ppimg").click(function(b){b.preventDefault;var c=$(this).attr("rel"),a=$(this).parents(".ppItem");a.parent().children(".ppItem").removeClass("ppSelected");a.addClass("ppSelected");productplus.img=a.find(".ppImg").attr("src");var d=a.find(".ppVariation").val();KB.Services.Product().SetProductPlus(c,d,productplus.onPPComplete,productplus.onError)})},onPPComplete:function(a){a=a.replace("[IMG]","<img src='"+productplus.img+"' alt='' />");var b=$(".ppSelectedInfo");b.slideUp(400,function(){b.html(a);b.slideDown(400)})},onError:function(){$(".ppSelectedInfo").html("Unfortunately a promblem occured, please try again or come back later when the problem will hopefully be resolved")}};function content_loader(d,e,a){KB.Services.General().GetLeafContent(d,e,b,c);function b(b){b&&a.html(b)}function c(){a.html("")}}var basket={activeProduct:{},init:function(){var a=Sys.WebForms.PageRequestManager.getInstance();a.add_endRequest(basket.OnAddedToBasket);$(".productListATB").click(function(b){b.preventDefault();EnableUI.Toggle(false);basket.activeProduct=$(this).parents(".productListItem");var c=$(this).attr("rel"),a=0;if(basket.activeProduct.find(".productListSizes").get(0))a=parseInt(basket.activeProduct.find(".productListSizes").val(),10);KB.Services.Product().AddToBasket(c,a,0,"","",0,basket.onATBComplete,basket.onError)});basket.setFeedbacks()},setFeedbacks:function(){$(".shiplink").mousedown(function(){content_loader(892,"shipping_info_85",$("#deliveryinfo div"))});$(".removeItem").click(function(a){a.preventDefault();basket.feedback($(this),"Please wait while this item is removed from your basket")});$(".decreaseItem, .increaseItem").click(function(){basket.feedback($(this),"Please wait while this item is updated")})},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='5' align='center' style='background-color:#F2F2F2'><img src='/stores/manutd/artwork/common/interface/loader_bar_v1.gif' alt='loading' /><p>"+c+"</p></td>");__doPostBack(b.attr("name"),"")},onATBComplete:function(a){if(a){var b=$("."+a.ProductID+a.VariationID);if(b.length>0)b.html("<td align='center' valign='middle' style='background-color:#F2F2F2;height:105px;width:120px;'><img src='/stores/product_images/"+a.ImageName+"?width=100&amp;height=100' alt='"+a.Description+"' style='height:100px;width:100px;border-width:0px;' /></td><td colspan='5' align='center' style='background-color:#F2F2F2'><img src='/stores/manutd/artwork/common/interface/loader_bar_v1.gif' alt='loading' /><p>Please wait while <em>'"+a.Description+"'</em> is added to your basket</p></td>");else{$(".basketContents").append($("<tr style='display:none'><td align='center' valign='middle' style='background-color:#F2F2F2;height:105px;width:120px;'><img src='/stores/product_images/"+a.ImageName+"?width=100&amp;height=100' alt='"+a.Description+"' style='height:100px;width:100px;border-width:0px;' /></td><td colspan='5' align='center' style='background-color:#F2F2F2'><img src='/stores/manutd/artwork/common/interface/loader_bar_v1.gif' alt='loading' /><p>Please wait while <em>'"+a.Description+"'</em> is added to your basket</p></td></tr>"));b=$(".basketContents").find("tr:last");b.fadeIn(600)}var c=b.offset().top+b.height();if(parseInt(c,10)>$(window).height()+$(window).scrollTop())$("html,body").animate({scrollTop:c-$(window).height()+10},500,function(){__doPostBack("ctl00_ContentMain_basket1_up_basket","ExternalATB")});else __doPostBack("ctl00_ContentMain_basket1_up_basket","ExternalATB")}else{alert("There was a problem adding the current selection to the basket");EnableUI.Toggle(true)}},onError:function(){alert("Unfortunately an error has occured, please try again");EnableUI.Toggle(true)},OnAddedToBasket:function(){shadowViewer.init();basket.setFeedbacks()}},register={init:function(){$(".countryDropDown",KB.Cache.JQuery("#pageContent")).change(function(){var a=$(".line5");if($(this).val()==93)a.val("N/A").attr("disabled","disabled");else{a.removeAttr("disabled");a.val()=="N/A"&&a.val("")}})}},proddetails={pdArea:{},nameBox:{},numberBox:{},sizeDD:{},init:function(){pdArea=$("#productDetailInfo");nameBox=$("input.pdNameBox",pdArea);numberBox=$("input.pdNumberBox",pdArea);sizeDD=$("select.pdSizes",pdArea);$("#sizechartlink").mousedown(function(){sizechart_viewer.load("#sizechart div")});$("#returnsinfolink").mousedown(function(){content_loader(897,"returnsinfoFull85",$("#returnsinfo div"))});$("#ukdeliveryinfolink").mousedown(function(){content_loader(897,"delinfo_UKFull85",$("#ukdeliveryinfo div"))});$("#overseasdeliveryinfolink").mousedown(function(){content_loader(897,"delinfo_OverseasFull85",$("#overseasdeliveryinfo div"))});$("#showdesc").click(function(){pagetabs.showTab($("#productdetailtabs div.tabheader ul li a").eq(0));scrollTo(0,1e4)});$("#showreturn").click(function(){pagetabs.showTab($("#productdetailtabs div.tabheader ul li a").eq(2));scrollTo(0,1e4)});$("#showdelivery").click(function(){pagetabs.showTab($("#productdetailtabs div.tabheader ul li a").eq(1));scrollTo(0,1e4)});sizeDD.change(function(){var c=parseInt($(this).val(),10),d=$("span.pdNameBoxMax",pdArea),e=10,a;if(c>0){var b=0;while(b<=productdetail.variations.length-1){if(productdetail.variations[b].VariationId==c){a=productdetail.variations[b];break}b++}}$("span.pdAvailability",pdArea).html(a.Availability);if(nameBox.get(0)){nameBox.attr("maxLength",a.MaxLetters);d.text(a.MaxLetters);if(printingChoices.Name.length>a.MaxLetters){printingChoices.Name=printingChoices.Name.substring(0,a.MaxLetters);nameBox.val(printingChoices.Name)}}proddetails.priceUpdate()});sizeDD.load(function(){proddetails.priceUpdate()});nameBox.keypress(function(a){var b=a.which?a.which:event.keyCode,c=/[a-zA-Z\s\'\.]/;!c.test(String.fromCharCode(b))&&b>41&&a.preventDefault()});nameBox.keyup(function(){this.value=this.value.replace(/[^a-zA-Z\s\'\.]/g,"");if(printingChoices.Name!=this.value){printingChoices.Name=this.value;proddetails.priceUpdate()}});numberBox.keypress(function(a){var b=a.which?a.which:event.keyCode,c=/([0-9])/;!c.test(String.fromCharCode(b))&&b>41&&a.preventDefault()});numberBox.keyup(function(){this.value=this.value.replace(/[^0-9\.]/g,"");if(printingChoices.Number!=this.value){printingChoices.Number=this.value;proddetails.priceUpdate()}})},priceUpdate:function(){var f=0,b=0,a=0,g,h=productdetail.variations,c=productdetail.printingitems,d,e;if(sizeDD.get(0))g=parseInt(sizeDD.val(),10);else g=0;if(g===0)d=productdetail;else while(a<=h.length-1){if(h[a].VariationId==g){d=h[a];break}a++}f=d.PriceActual;if(nameBox.get(0)&&printingChoices.Name!=""){a=0;while(a<=c.length-1){if(c[a].PrintingTypeID==1){e=c[a];break}a++}b=b+e.PriceActual}else if(numberBox.get(0)&&printingChoices.Number!=""){a=0;while(a<=c.length-1){if(c[a].PrintingTypeID==2||c[a].PrintingTypeID==8){e=c[a];break}a++}if(e.PrintingTypeID==8)b=b+e.PriceActual*printingChoices.Number.length;else b=b+e.PriceActual}var i=$(".pdBadges",pdArea).val();if(i)if(i>0){a=0;while(a<=c.length-1){if(c[a].PrintingID==i){e=c[a];break}a++}b=b+e.PriceActual}if(printingChoices.Name!=""||printingChoices.Number!="")personalised=1;printingChoices.Price=parseFloat(b).toFixed(2);$("span.pdPrintingPrice",pdArea).text(pagedetails.currency+parseFloat(b).toFixed(2));$("span.pdProductPrice",pdArea).text(pagedetails.currency+parseFloat(f).toFixed(2));if(d.PriceWas>0){var j=parseFloat(d.PriceWas)-parseFloat(f),k=parseInt((parseFloat(d.PriceWas)-parseFloat(f))/parseFloat(d.PriceWas)*100,10);$("span.pdPreviousPrice",pdArea).show().text("was "+pagedetails.currency+parseFloat(d.PriceWas).toFixed(2)+"    save "+pagedetails.currency+j.toFixed(2)+"("+k+"%)")}else $("span.pdPreviousPrice",pdArea).hide().text("");$("span.pdTotalPrice",pdArea).text(pagedetails.currency+parseFloat(f+b).toFixed(2))},closeSizeChart:function(){shadowViewer.elementHighlighted.hide(300,function(){$(".shadowDiv").remove()})}};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()});