/* WSGC Copyright */
dojo.provide("wsgc");if(!dojo._hasResource["dojo.regexp"]){dojo._hasResource["dojo.regexp"]=true;dojo.provide("dojo.regexp");dojo.regexp.escapeString=function(_1,_2){return _1.replace(/([\.$?*!=:|{}\(\)\[\]\\\/^])/g,function(ch){if(_2&&_2.indexOf(ch)!=-1){return ch;}return "\\"+ch;});};dojo.regexp.buildGroupRE=function(_4,re,_6){if(!(_4 instanceof Array)){return re(_4);}var b=[];for(var i=0;i<_4.length;i++){b.push(re(_4[i]));}return dojo.regexp.group(b.join("|"),_6);};dojo.regexp.group=function(_9,_a){return "("+(_a?"?:":"")+_9+")";};}if(!dojo._hasResource["dojo.cookie"]){dojo._hasResource["dojo.cookie"]=true;dojo.provide("dojo.cookie");dojo.cookie=function(_b,_c,_d){var c=document.cookie;if(arguments.length==1){var _f=c.match(new RegExp("(?:^|; )"+dojo.regexp.escapeString(_b)+"=([^;]*)"));return _f?decodeURIComponent(_f[1]):undefined;}else{_d=_d||{};var exp=_d.expires;if(typeof exp=="number"){var d=new Date();d.setTime(d.getTime()+exp*24*60*60*1000);exp=_d.expires=d;}if(exp&&exp.toUTCString){_d.expires=exp.toUTCString();}_c=encodeURIComponent(_c);var _12=_b+"="+_c,_13;for(_13 in _d){_12+="; "+_13;var _14=_d[_13];if(_14!==true){_12+="="+_14;}}document.cookie=_12;}};dojo.cookie.isSupported=function(){if(!("cookieEnabled" in navigator)){this("__djCookieTest__","CookiesAllowed");navigator.cookieEnabled=this("__djCookieTest__")=="CookiesAllowed";if(navigator.cookieEnabled){this("__djCookieTest__","",{expires:-1});}}return navigator.cookieEnabled;};}if(!dojo._hasResource["wsgc.js.MobileUtils"]){dojo._hasResource["wsgc.js.MobileUtils"]=true;dojo.provide("wsgc.js.MobileUtils");dojo.declare("wsgc.js.MobileUtils",null,{constructor:function(_15,_16){this._savedCartCookie=_15;this._sessionCartCookie=_16;this._registerSearchFieldEvents();this._scrollToPaymentPageErrors();this._registerSVCApply();this._registerCreditCardFieldEvents();this._registerInterstitialEvents();this._setBasketCount();this._registerPlaceOrder();this._registerSVCLRC();this._registerPromoRemove();this._registerPromotionsSignInEvents();this._registerPaymentGiftCardEvents();this._registerPromoApplyEvents();dojo.connect(dojo.byId("cartForm"),"onsubmit",function(evt){dojo.query(".delete-item").forEach("item.disabled = true");return true;});dojo.query("#cart .updateQuantity").onclick(function(evt){document.cartForm.submit();});dojo.query("#cart .deleteItem").onclick(function(evt){var _1a=this.name;document.cartForm[_1a].value="true";document.cartForm.submit();});dojo.query(".checkoutButton").forEach(function(_1b){dojo.connect(_1b,"onclick",function(evt){dojo.stopEvent(evt);dojo.byId("checkout").value="true";dojo.byId("cartForm").submit();});});this._orientationListener();this.shopAndSearchRefineDropdowns();this.submitSearchButton();this.accordion();this.layover();this.pipMoreImages();this.offsiteInterstitial();dojo.connect(dojo.byId("mobileToFullSite"),"onclick",this,"handleFullSiteClick");dojo.query("a[class^='full-site']").forEach(function(_1d){dojo.connect(_1d,"onclick",this,"handleFullSiteClick");},this);},DEFAULT_SEARCH_TEXT:"Keyword or Item #",_savedCartCookie:"",_sessionCartCookie:"",formSubmitted:false,LEAVING_MOBILE_MESSAGE:"We're sorry, but the page you are trying to access is on our Full Site. Do you want to continue to the Full Site?",SEARCH_ERROR_TEXT:"Please enter a keyword or phrase in order to search.",_setBasketCount:function(){var _1e=dojo.cookie(this._sessionCartCookie.toUpperCase());if(typeof _1e=="undefined"){_1e=dojo.cookie(this._savedCartCookie.toUpperCase());}if((typeof _1e=="undefined")||(_1e.split("|").length<4)){return;}var _1f=_1e.split("|")[3];if(_1f>0){dojo.query("#cart-summary a")[0].innerHTML="Cart ("+_1f+")";var _20=document.createElement("div");_20.appendChild(document.createTextNode("("+_1f+")"));dojo.addClass(_20,"count");dojo.query("#footer-cart a").forEach(function(_21){_21.appendChild(_20);});}},_registerSearchFieldEvents:function(){var _22=dojo.byId("search-field");if(_22){dojo.connect(_22,"onfocus",this,function(evt){if(evt.currentTarget.value===""){_22.value="";}});}},_registerInterstitialEvents:function(){var _24=null;dojo.query("form.interstitialForm .btn-edit, form.interstitialForm #btn-edit").forEach(function(_25){dojo.connect(_25,"onclick",this,"_handleInterstitialEditClick");},this);dojo.query("#pip-interstitial .breadcrumb-back").forEach(function(_26){dojo.connect(_26,"onclick",this,"_handleInterstitialEditClick");},this);if(dojo.query(".interstitialForm .btn-continue, .interstitialForm #btn-continue").length>0){_24=dojo.query(".interstitialForm .btn-continue, .interstitialForm #btn-continue")[0];dojo.connect(_24,"onclick",this,"_handleInterstitialContinueClick");}},_registerSVCApply:function(){var _27=dojo.byId("applysvc");if(!_27){return;}dojo.connect(_27,"onclick",function(evt){var _29=dojo.byId("svcApply");_29.value="yes";});},_registerPlaceOrder:function(){var _2a=dojo.byId("placeOrderButton");if(!_2a){return;}dojo.connect(_2a,"onclick",this,function(evt){if(this.formSubmitted){evt.preventDefault();}else{dojo.byId("placeOrder").value="yes";this.formSubmitted=true;}});},_scrollToPaymentPageErrors:function(){var _2c=dojo.byId("paymentInformation");if(!_2c){return;}var _2d=dojo.byId("promotionsErrors");var _2e=dojo.byId("svcError");var _2f=dojo.byId("displayPromoBlock");var _30=dojo.byId("discountsApplied");var _31=dojo.byId("ccError");if(_2d){if(dojo.query(".promotions-block").length>0){dojo.query(".promotions-block")[0].scrollIntoView(true);}}else{if(_2e&&dojo.trim(_2e.innerHTML)!==""){if(dojo.query(".svc-lrc-block").length>0){dojo.query(".svc-lrc-block")[0].scrollIntoView(true);}}else{if(_31&&dojo.trim(_31.innerHTML)!==""){if(dojo.query(".payment-information-block").length>0){dojo.query(".payment-information-block")[0].scrollIntoView(true);}}else{if(_2f&&dojo.trim(_2f.innerHTML)!==""){if(dojo.query(".promotions-block").length>0){dojo.query(".promotions-block")[0].scrollIntoView(true);}}else{if(_30&&dojo.trim(_30.innerHTML)!==""){if(dojo.query(".svc-lrc-block").length>0){dojo.query(".svc-lrc-block")[0].scrollIntoView(true);}}}}}}var _32=dojo.byId("creditCard.payType");if(_32.value==8){dojo.attr("creditCard.cardExpMonth","disabled",true);dojo.attr("creditCard.cardExpYear","disabled",true);dojo.attr("creditCard.cardVerificationNumber","disabled",true);}},_registerCreditCardFieldEvents:function(){var _33=dojo.byId("creditCard.payType");if(!_33){return;}dojo.connect(_33,"onchange",dojo.hitch(this,function(evt){var _35=evt.target.value;var _36=dojo.byId("creditCard.cardExpMonth");var _37=dojo.byId("creditCard.cardExpYear");var _38=dojo.byId("creditCard.cardVerificationNumber");var _39=dojo.byId("allowZeroExp");if(_35==="8"){_36.selectedIndex=0;dojo.attr(_36,"disabled",true);_37.selectedIndex=0;dojo.attr(_37,"disabled",true);dojo.attr(_38,"disabled",true);_39.value="Y";}else{dojo.attr(_36,"disabled",false);dojo.attr(_37,"disabled",false);dojo.attr(_38,"disabled",false);_39.value="N";}}));},handleFullSiteClick:function(evt){evt.preventDefault();if(confirm(this.LEAVING_MOBILE_MESSAGE)){dojo.cookie(config.sitePref,"full",{domain:config.cookieSubDomain,path:"/"});window.location=evt.currentTarget.href;}},_handleInterstitialEditClick:function(evt){dojo.stopEvent(evt);evt.preventDefault();dojo.byId("isEditMode").value="1";this._postInterstitialForm();},_handleInterstitialContinueClick:function(evt){dojo.stopEvent(evt);dojo.byId("isEditMode").value="0";this._postInterstitialForm();},_postInterstitialForm:function(){if(dojo.query(".interstitialForm").length>0){var _3d=dojo.query(".interstitialForm")[0];_3d.submit();}},_registerSVCLRC:function(){var _3e="";dojo.query(".removeSVCLRCButton").forEach(function(_3f){dojo.connect(_3f,"onclick",function(evt){if(!dojo.attr(evt.currentTarget,"svcnumber")){return false;}_3e=dojo.attr(evt.currentTarget,"svcnumber");dojo.byId("removeSvcLrc").value=_3e;return true;});});},_registerPromoRemove:function(){var _41="";dojo.query(".removePromoButton").forEach(function(_42){dojo.connect(_42,"onclick",function(evt){if(!dojo.attr(evt.currentTarget,"promoCode")){return false;}_41=dojo.attr(evt.currentTarget,"promoCode");dojo.byId("releasePromo").value=_41;return true;});});},_writeMultiBuyItemsToField:function(){if(dojo.byId("productGroupIds")&&this._multi_buy_items){dojo.byId("productGroupIds").value=this._multi_buy_items.join(",");}},_registerPromotionsSignInEvents:function(){var _44=dojo.byId("apply-tax-exemption");if(!_44){return;}var _45=dojo.byId("yesexemption");var _46=dojo.byId("noexemption");dojo.connect(_45,"onclick",function(evt){dojo.byId("termsBlock").className="";dojo.query(".message").forEach("item.className='hide';");});dojo.connect(_46,"onclick",function(evt){dojo.byId("termsBlock").className="hide";dojo.query(".message").forEach("item.className='hide';");});dojo.connect(dojo.byId("accepttoc"),"onclick",function(evt){dojo.query(".message").forEach("item.className='hide';");});if(dojo.byId("yesexemption").checked&&dojo.byId("accepttoc").checked){dojo.query(".message").forEach("item.className='hide';");}if(dojo.byId("noexemption").checked){dojo.query(".message").forEach("item.className='hide';");dojo.query("#termsBlock").forEach("item.className='hide';");}},_registerPaymentGiftCardEvents:function(){var _4a=dojo.byId("base-gift-display");if(!_4a){return;}var _4b=dojo.byId("has-gift-cards");var _4c=dojo.byId("no-gift-cards");if((dojo.byId("svcError"))||(dojo.byId("discountsApplied"))){_4b.checked="checked";dojo.byId("extended-gift-display").className="show";}dojo.connect(_4b,"onclick",function(evt){dojo.byId("extended-gift-display").className="show";});dojo.connect(_4c,"onclick",function(evt){if(dojo.byId("discountsApplied")){_4b.checked="checked";dojo.byId("remove-cards").className="show";}else{dojo.byId("extended-gift-display").className="hide";}});},_registerPromoApplyEvents:function(){var _4f=dojo.byId("applyPromoBlock");if(_4f){var _50=dojo.byId("applyPromo");if(_50){dojo.connect(_50,"onclick",function(evt){dojo.byId("promoApply").value="yes";});}}else{return;}},_orientationListener:function(){dojo.body().className=window.orientation==Math.abs(90)?"horizontal":"vertical";dojo.connect(dojo.body(),"onorientationchange",null,function(evt){dojo.body().className=window.orientation==Math.abs(90)?"horizontal":"vertical";});},shopAndSearchRefineDropdowns:function(){dojo.query("#shop-select select, #search-results #sort-container select").forEach(function(_53){dojo.connect(_53,"onchange",function(evt){window.location=evt.currentTarget.value;});});},submitSearchButton:function(){dojo.query("#search button[type='submit']").forEach(function(_55){dojo.connect(_55,"click",this,function(evt){evt.preventDefault();if(dojo.byId("search-field")){var _57=dojo.trim(dojo.byId("search-field").value);if(_57===""||_57===this.DEFAULT_SEARCH_TEXT){dojo.query("#search ul").forEach("document.removeChild(item);");var ul=document.createElement("ul");var li=document.createElement("li");dojo.addClass(ul,"error");dojo.addClass(li,"message");li.appendChild(document.createTextNode(this.SEARCH_ERROR_TEXT));ul.appendChild(li);dojo.place(ul,"search","first");return false;}}dojo.byId("search").submit();});},this);},offsiteInterstitial:function(){dojo.query("a[href^='http']:not(.full-site):not(#mobileToFullSite):not([href^='"+config.mAppUrl+"']):not([href^='"+config.mSecureAppUrl+"']):not([href*='pbteen.com']):not([href*='potterybarn.com'])").forEach(function(_5a){dojo.connect(_5a,"click",this,function(evt){evt.preventDefault();if(confirm(this.LEAVING_MOBILE_MESSAGE)){window.location=evt.currentTarget.href;}else{evt.stopPropagation();return false;}});},this);},accordion:function(){var _5c=function(ele){var _5e=dojo.clone(ele);dojo.addClass(_5e,"clone");dojo.place(_5e,ele,"before");dojo.style(_5e,"height","auto");var _5f=dojo.contentBox(_5e).h+"px";_5e.parentNode.removeChild(_5e);return _5f;};dojo.query(".expandable.open + section").forEach(function(ele){dojo.style(ele,"height",dojo.contentBox(ele).h+"px");});dojo.query(".expandable").onclick(function(evt){evt.preventDefault();if(dojo.hasClass(this,"open")){dojo.removeClass(this,"open");var _62=dojo.query(".expandable").indexOf(this);var _63=dojo.query(".expandable + section");var _64=_63[_63.length-1-_62];dojo.style(_64,"height",0);this.innerHTML=this.innerHTML.replace("Hide","View");}else{if(!dojo.hasClass(this,"friendly")){dojo.query(".expandable").removeClass("open");dojo.query(".expandable + section").style("height",0);setTimeout(function(_65){var _66=_65.offsetTop;var _67=document.body.scrollTop;var _68=window.innerHeight;if(!((_67<_66)&&(_66<(_67+_68)))){window.scrollTo(0,_66-20);}},500,evt.currentTarget);}dojo.addClass(this,"open");this.innerHTML=this.innerHTML.replace("View","Hide");var _64=dojo.query(".expandable.open + section").forEach(function(ele){dojo.style(ele,{"padding-left":"10px","padding-right":"10px"});dojo.style(ele,"height",_5c(ele));});}return false;});},layover:function(){dojo.query("a.layoverTrigger[href^='#']").onclick(function(evt){var _6b=dojo.byId(this.href.split("#")[1]);if(_6b&&dojo.hasClass(_6b,"layover")){evt.stopPropagation();evt.preventDefault();dojo.style(_6b,{"height":document.height-window.pageYOffset+"px","padding-top":window.pageYOffset+"px"});dojo.addClass(_6b,"open");}});dojo.query(".layover, .layover .close").onclick(function(evt){if(evt.target==evt.currentTarget){evt.stopPropagation();evt.preventDefault();dojo.query(".layover").removeClass("open");}});},pipMoreImages:function(){var _6d=dojo.query("#pip-detail>#more-images ul.image-set li");if(_6d.length>1){dojo.query("#nextImage, #prevImage").onclick(function(evt){evt.stopPropagation();evt.preventDefault();var _6f=evt.currentTarget.id=="nextImage"?1:-1;var _70=_6d.indexOf(_6d.filter(".open")[0]);var _71=_70+_6f;if(_71>=_6d.length){_71=0;}else{if(_71<0){_71=_6d.length-1;}}_6d.at(_70).removeClass("open");_6d.at(_71).addClass("open");dojo.query("p.total-pages .current")[0].innerHTML=_71+1;});}}});}if(!dojo._hasResource["dojox.xml.parser"]){dojo._hasResource["dojox.xml.parser"]=true;dojo.provide("dojox.xml.parser");dojox.xml.parser.parse=function(str){if(dojo.isIE){var _73=new ActiveXObject("Microsoft.XMLDOM");_73.async="false";_73.loadXML(str);var pe=_73.parseError;if(pe.errorCode!==0){throw new Error("Line: "+pe.line+"\n"+"Col: "+pe.linepos+"\n"+"Reason: "+pe.reason+"\n"+"Error Code: "+pe.errorCode+"\n"+"Source: "+pe.srcText);}return _73;}else{var _75=new DOMParser();var _73=_75.parseFromString(str,"text/xml");var de=_73.documentElement;var _77="http://www.mozilla.org/newlayout/xml/parsererror.xml";if(de.nodeName=="parsererror"&&de.namespaceURI==_77){var _78=de.getElementsByTagNameNS(_77,"sourcetext")[0];if(!_78){_78=_78.firstChild.data;}throw new Error("Error parsing text "+_73.documentElement.firstChild.data+" \n"+_78);}return _73;}};}

