/*    HTTP Host:  static.ak.fbcdn.net                                          */
/*    Generated:  February 9th 2010 9:59:32 PM PST                             */
/*      Machine:  10.16.140.108                                                */
/*       Source:  Backing Store                                                */
/*     Location:  js/aa2i2ed5ij484c0w.pkg.js h:3zwdtwl0                        */
/*       Locale:  nu_ll                                                        */
/*         Path:  js/aa2i2ed5ij484c0w.pkg.js                                   */

if (window.CavalryLogger) { CavalryLogger.start_js(["js\/aa2i2ed5ij484c0w.pkg.js"]); }

function UIErrorForm(_L0,_L1,_L2,_L3,_L4){this.container=_L1;if(!is_empty(_L2)){this.form=$(_L2);this.form.listen('submit',coalesce(_L4,this.onSubmit).bind(this));}this.errorMap=_L0;this.displayedErrors={};this.endpoint=_L3;}UIErrorForm.prototype={attachError:function(_L0,_L1){if(!(_L0 in this.errorMap)){var _L2=DOM.find(this.container,'div[id="error_box_div"]');var _L3=$N('h2',{className:'"main_message'},HTML(_L1));var _L4=DOM.scry(this.container,'div[id="error_div"]')[0];if(_L4){DOM.appendContent(_L4,_L3);}else{_L4=$N('div',{id:'error_div',className:"UIMessageBox error"},_L3);DOM.setContent(_L2,_L4);}return;}var _L5=DOM.find(this.container,'div[id="'+this.errorMap[_L0]+'_div"]');var _L6=DOM.find(this.container,'[id="'+this.errorMap[_L0]+'"]');this.displayedErrors[_L0]=true;var _L4=$N('div',{className:'UIErrorForm_Flag_Inner'},_L1);var _L7=$N('div',{className:'UIErrorForm_Flag',id:_L0},_L4);var _L8=_L5.offsetWidth+2;var _L9=_L8+'px';var _La=(_L8+7)+'px';var _Lb=intl_locale_is_rtl()?'right':'left';_L7.setStyle(_Lb,_La);DOM.insertAfter(_L6,_L7);CSS.addClass(_L5,'UIErrorForm_ErrorField');animation(_L7).from(_Lb,_La).to(_Lb,_L9).duration(300).ease(function(p){return -1*Math.sin(11*p);}).go();},toggleError:function(_L0,_L1){if(this.displayedErrors[_L0]==_L1)return;var _L2=DOM.find(this.container,'div[id="'+_L0+'"]');var _L3=DOM.find(this.container,'div[id="'+this.errorMap[_L0]+'_div"]');if(_L1){CSS.addClass(_L3,'UIErrorForm_ErrorField');CSS.removeClass(_L2,'hidden_elem');}else{CSS.removeClass(_L3,'UIErrorForm_ErrorField');CSS.addClass(_L2,'hidden_elem');}this.displayedErrors[_L0]=_L1;},clearErrors:function(){for(var _L0 in this.displayedErrors)this.toggleError(_L0,false);var _L1=DOM.scry(this.container,'div[id="error_box_div"]')[0];if(_L1)DOM.empty(_L1);},displayErrors:function(_L0){this.clearErrors();if(!_L0)return;for(var _L1 in _L0)if(_L1 in this.displayedErrors){this.toggleError(_L1,true);}else this.attachError(_L1,_L0[_L1]);},errorHandler:function(_L0){var _L1=_L0.getPayload();this.displayErrors(_L1);},onSubmit:function(){var _L0=serialize_form(this.form);var req=new AsyncRequest().setURI(this.endpoint).setData(_L0).setHandler(this.clearErrors.bind(this)).setErrorHandler(this.errorHandler.bind(this));req.send();return false;}};
function UICreditCardForm(_L0,_L1,_L2,_L3,_L4){this.parent.construct(this,_L0,_L1,_L2,'/ajax/payment/CreditCardFormResponse.php',null);this.errorStrings=_L3;this.postURI=_L4;}UICreditCardForm.extend('UIErrorForm');UICreditCardForm.prototype={onSubmit:function(){if(this.validate()){var _L0=serialize_form(this.form);var req=new AsyncRequest().setURI(this.endpoint).setData(_L0).setHandler(this.post_register_card.bind(this)).setErrorHandler(this.errorHandler.bind(this));req.send();}return false;},post_register_card:function(_L0){this.clearErrors();if(this.postURI){var _L1=serialize_form(this.form);_L1.cc_id=_L0.getPayload().cc_id;dynamic_post(this.postURI,_L1);}},validate_zip_for_country:function(){var _L0=DOM.find(this.container,'select[name="cc_countryCode"]').value;var zip=trim(DOM.find(this.container,'input[name="cc_zip"]').value);if(_L0=='US'){if(zip.match(/^[0-9]{5}(-[0-9]{4}){0,1}$/)){return zip;}else if(zip.match(/^[0-9]{9}$/)){zip=zip.slice(0,5)+'-'+zip.slice(5);return zip;}}else if(_L0=='CA'){var _L2=zip.length;if(_L2>=3&&zip.match(/^[a-zA-Z][0-9][a-zA-z]/)){return zip;}else if(_L2==7&&zip.match(/[0-9][a-zA-Z][0-9]$/))return zip;}else return zip;return null;},validate_state_for_country:function(){var _L0=DOM.find(this.container,'select[name="cc_countryCode"]').value;var _L1=trim(DOM.find(this.container,'input[name="cc_state"]').value);if((_L0=='US'||_L0=='CA')&&_L1==='')return null;return _L1;},validate:function(){var _L0={};var _L1={};var _L2=DOM.scry(this.container,'input[id="for_edit"]')[0];var _L3=DOM.scry(this.container,'input[id="fewer_fields"]')[0];_L1['cc_cvv2']='CC_CVV2_INVALID';if(!_L2){_L1['cc_firstName']='CC_NO_FIRSTNAME';_L1['cc_lastName']='CC_NO_LASTNAME';_L1['cc_creditCardNumber']='CC_NO_NUMBER';}if(!_L3){_L1['cc_street']='CC_NO_STREET';_L1['cc_city']='CC_NO_CITY';}for(var _L4 in _L1){var _L5=DOM.scry(this.container,'input[name="'+_L4+'"]')[0];if(_L5&&_L5.value.length<=0)_L0[_L4]=_L1[_L4];}if(!_L3){var zip=this.validate_zip_for_country();if(zip===null)_L0['cc_zip']='CC_NO_ZIP';var _L7=this.validate_state_for_country();if(_L7===null)_L0['cc_state']='CC_NO_STATE';}var _L8=DOM.find(this.container,'select[name="cc_expMonth"]').value;var _L9=DOM.find(this.container,'select[name="cc_expYear"]').value;if(isNaN(_L8)||_L8<1||_L8>12||isNaN(_L9)||_L9<2009||_L9>2099)_L0['cc_expYear']='CC_INVALID_YEAR';var now=new Date();var _Lb=now.getMonth()+1;var _Lc=now.getFullYear();if(_L9<_Lc||(_L9==_Lc&&_L8<_Lb))_L0['cc_expYear']='CC_EXPIRED_ALREADY';if(!('cc_cvv2' in _L0)){var _Ld=DOM.find(this.container,'input[name="cc_cvv2"]').value;if(_Ld.length<3||_Ld.length>4||isNaN(_Ld))_L0['cc_cvv2']='CC_CVV2_INVALID';}if(!_L2&&!('cc_creditCardNumber' in _L0)){cc_number=DOM.find(this.container,'input[name="cc_creditCardNumber"]').value;if(isNaN(cc_number)){_L0['cc_creditCardNumber']='CC_INVALID_NUMBER_BAD_CHARS';}else if(cc_number.length<13){_L0['cc_creditCardNumber']='CC_INVALID_NUMBER';}else if(!this.validateCCNumber(cc_number)){_L0['cc_creditCardNumber']='CC_BAD_CARD_NUMBER';}else if(!this.validateCCType(cc_number))_L0['cc_creditCardNumber']='CC_CARD_TYPE_NOT_VALID';}var _Le=DOM.scry(this.container,'input[name="cc_save_required"]')[0];var _Lf=DOM.scry(this.container,'checkbox[name="cc_save_cc"]')[0];if(_Le&&_Le.value&&_Lf&&!_Lf.value)_L0['save_required']='CC_SAVE_REQUIRED';if(is_empty(_L0))return true;var _L10={};for(_L4 in _L0){var _L11=_L0[_L4];_L10[_L11]=this.errorStrings[_L11];}this.displayErrors(_L10);return false;},validateCCNumber:function(s){if(s.match(/[a-zA-Z]/))return false;s=s.replace(/[^0-9]/gi,"");var _L1=s.split('').reverse();var _L2='';for(var i=0;i<_L1.length;i++){var c=parseInt(_L1[i],10);if(i%2!=0)c=c*2;_L2=_L2+c;}var n=0;for(i=0;i<_L2.length;i++)n=n+parseInt(_L2.charAt(i),10);return (n!=0&&n%10==0);},getCCType:function(_L0){var bin=_L0.substr(0,6);if(bin.match(/^5[1-5]/)){return 77;}else if(bin.match(/^4/)){return 86;}else if(bin.match(/^3[47]/)){return 65;}else if(bin.match(/^35(2[8-9]|[3-8])/)){return 74;}else if(bin.match(/^(6011|65|64[4-9]|622([2-8]|1[3-9]|12[6-9]|9[0-1]|92[0-5]))/)){return 68;}else if(bin.match(/^30[0-5]/))return 64;return 85;},validateCCType:function(s){var _L1=DOM.scry(this.container,'input[name="supported_cards"]')[0];if(!_L1||_L1.value.match(this.getCCType(s)))return true;return false;}};
function require_password_confirmation(_L0,_L1){if((!getCookie('sid')||getCookie('sid')=='0')||getCookie('pk')){_L0();return;}require_password_confirmation.onsuccess=_L0;require_password_confirmation.oncancel=_L1;(new pop_dialog()).show_ajax_dialog('/ajax/password_check_dialog.php');}
GiftCredits={PLACE_APP:'app',PLACE_GIFTSHOP:'giftshop',getPrompt:function(_L0,_L1,_L2,_L3,_L4,_L5,_L6,_L7){GiftCredits.main('/ajax/giftcredits/prompt.php',_L0,_L1,_L2,_L3,_L4,_L5,_L6,_L7);},main:function(_L0,_L1,_L2,_L3,_L4,_L5,_L6,_L7,_L8){_L2=!_L2?0:_L2;var _L9={deadbeef:2386512837,app_id:_L1,api_key:_L7,receiver:_L2,order_info:JSON.encode(_L3),place:_L6||GiftCredits.PLACE_APP,back_url:_L4};var _La=function(_Lf){Dialog.getCurrent().setUserData(_Lf.getPayload().userData);ErrorDialog.showAsyncError(_Lf);};var _Lb=new AsyncRequest(_L0).setData(_L9).setErrorHandler(_La);if(_L8)_Lb.setContextData(_L8,'application_'+_L1);var _Lc=new Dialog().setAsync(_Lb);var _Ld=function(){if(_L5){var _Lf=_Lc.getUserData();var arg=null;if(_Lf)if(_Lf['fbpayments_data']){arg=JSON.decode(_Lf['fbpayments_data']);}else if(_Lf['fbpayments_error'])arg=JSON.decode(_Lf['fbpayments_error']);if(arg)_L5(arg);}};var _Le=function(){if(_L5){var arg={'error_code':kError_FBPayments_UserCanceled,'error_message':'User canceled the order.'};_L5(arg);}_Lc.setCloseHandler(null);};_Lc.setCancelHandler(_Le).setCloseHandler(_Ld).show();}};GiftCreditsFullPage={postData:null,displayData:null,onsubmit:function(_L0,url,_L2,_L3){DOMScroll.scrollTo(new Vector2(0,0,'document'),false);var _L4=GiftCreditsFullPage.postData;copy_properties(_L4,serialize_form(_L0.form));var _L5=function(_L7){if(_L7){_L3.clearErrors();_L4.cc_id=_L7.getPayload().cc_id;}show('loading_payment');hide('payment_footer');hide('payment_body_and_buttons');_L4.popup_window_cc=_L2;var _L8=new AsyncRequest(url).setData(_L4);if(_L2){var _L9=function(_L7){var _La=_L7.getPayload();window.opener.GiftCreditsDialog.composeConfirmationDialogForPopUpCC(_La.title,_La.label,_La.body,_La.callback_js);window.opener.GiftCreditsDialog.checkAndClosePopUpWinForCC();};}else var _L9=function(_L7){hide('checkout_cart');$('loading_payment').setContent(HTML(_L7.getPayload().body));};_L8.setHandler(_L9);_L8.setErrorHandler(function(_L7){payload=_L7.getPayload();if(payload){hide('gift_credits_body');$('order_error_msg').setContent(HTML(payload.body));$('back_button').setContent(HTML(payload.button));show('order_error_msg');show('back_button');}});_L8.send();};if(!_L3){_L5(null);return false;}if(!_L3.validate())return false;var req=new AsyncRequest().setURI(_L3.endpoint).setData(_L4).setHandler(_L5.bind(this)).setErrorHandler(_L3.errorHandler.bind(_L3));req.send();},onPaymentMethodSelected:function(_L0){if(_L0){$('payment').setContent(HTML(this.displayData['stored_credit_card_details_'+_L0]));}else $('payment').setContent(HTML(this.displayData.payment_method_new_cc));}};GiftCreditsDialog={popUpWinForCC:null,checkAndClosePopUpWinForCC:function(){if(GiftCreditsDialog.popUpWinForCC){GiftCreditsDialog.popUpWinForCC.close();GiftCreditsDialog.popUpWinForCC=null;}},getPaymentMethod:function(){if(ge('giftcredits_form')){var _L0=$('giftcredits_form');var _L1=serialize_form(_L0);return _L1.payment_method;}return 0;},getCreditsAmount:function(){if(ge('giftcredits_form')){var _L0=$('giftcredits_form');var _L1=serialize_form(_L0);return _L1.add_num_credits;}return 0;},_asyncReq:function(_L0,uri,_L2){var _L3=function(_L5){Dialog.getCurrent().setUserData(_L5.getPayload().userData);ErrorDialog.showAsyncError(_L5);};var _L4=new AsyncRequest().setURI(uri).setData(_L2).setMethod(_L0).setErrorHandler(_L3).setReadOnly(_L0=='GET');Dialog.getCurrent().setAsync(_L4);return false;},onSubmitWithEnoughCredit:function(_L0,_L1){return GiftCreditsDialog._asyncReq('POST',_L1,_L0);},onSubmitWithCCId:function(_L0,_L1,_L2,_L3){var _L4=_L0;_L4.add_num_credits=_L2;_L4.cc_id=_L3;return GiftCreditsDialog._asyncReq('POST',_L1,_L4);},onSubmitNoCC:function(_L0,_L1,_L2,_L3){var _L4=_L0;_L4.add_num_credits=_L1;if(!_L3){dynamic_post(_L2,_L4);return false;}else{GiftCreditsDialog.checkAndClosePopUpWinForCC();var _L5=650;var _L6=500;var _L7=0;var top=0;if(window.screenLeft){_L7=window.screenLeft;top=window.screenTop;}else if(window.screenX){_L7=window.screenX;top=window.screenY;}var _L9=Vector2.getViewportDimensions().x;var _La=Vector2.getViewportDimensions().y;var _Lb=_L7+(_L9-_L5)/2;var _Lc=top+(_La-_L6)/2;GiftCreditsDialog.popUpWinForCC=window.open('','creditcardWindow','location=yes, top='+_Lc+',left='+_Lb+',width='+_L5+',height='+_L6+'resizable=yes,scrollbars=yes',true);if(!GiftCreditsDialog.popUpWinForCC){_L4.pop_up_get_blocked=true;dynamic_post(_L2,_L4);}else dynamic_post(_L2,_L4,'creditcardWindow');return false;}},onSubmitFromPrompt:function(_L0,_L1,_L2,_L3,_L4){if(!ge('payment_body_amount')){var _L5=_tx("Please select a payment method and amount.");(new ErrorDialog()).showError(_tx("\u9519\u8bef"),_L5);}else if(GiftCreditsDialog.getPaymentMethod()=='mobile'){GiftCreditsDialog.onSubmitUseMobile(_L0);}else GiftCreditsDialog.onSubmitUseCreditCard(_L0,_L1,_L2,_L3,_L4,null);},updatePricepoints:function(_L0,_L1){var _L2=function(_L6){if(ge('payment_body_amount')){var _L3=$('payment_body_amount');_L3.parentNode.removeChild(_L3);}$('payment_body_method').parentNode.appendContent(HTML(_L6.getPayload()));show(Dialog.getCurrent().getButtonElement('add_credits'));};if(ge('payment_body_amount')){var _L3=$('payment_body_amount');_L3.parentNode.removeChild(_L3);}var _L4={'method':GiftCreditsDialog.getPaymentMethod(),'amount':_L0,'appid':_L1};var req=new AsyncRequest().setURI('/ajax/giftcredits/pricepoints.php').setData(_L4).setHandler(_L2.bind(this)).send();},onSubmitUseMobile:function(_L0){hide('gift_cart');hide(Dialog.getCurrent().getButtonElement('add_credits'));var _L1=function(_L5){$('gift_cart').parentNode.appendContent(HTML(_L5.getPayload()));};var _L2=function(_L5){Dialog.getCurrent().hide();ErrorDialog.showAsyncError(_L5);};var _L3={'url':GiftCreditsDialog.getCreditsAmount(),'post_data':_L0};var req=new AsyncRequest().setURI('/ajax/giftcredits/zong-begin.php').setData(_L3).setHandler(_L1.bind(this)).setErrorHandler(_L2.bind(this)).send();},onSubmitUseCreditCard:function(_L0,_L1,_L2,_L3,_L4,_L5){var _L6=GiftCreditsDialog.getPaymentMethod();var _L5=(_L5==null)?GiftCreditsDialog.getCreditsAmount():_L5;if(_L6){if(_L3){GiftCreditsDialog.onSubmitWithCCId(_L0,_L1,_L5,_L6);}else require_password_confirmation(GiftCreditsDialog.onSubmitWithCCId.bind(null,_L0,_L1,_L5,_L6));}else GiftCreditsDialog.onSubmitNoCC(_L0,_L5,_L2,_L4);},onloadMobileIframe:function(){hide('zong-loading');},onMobileComplete:function(_L0){GiftCreditsDialog._asyncReq('POST','/ajax/giftcredits/mobile.php',{transactionRef:_L0});},selected_stored_cc:function(_L0,_L1,_L2){hide('redirect_message');var _L3=Dialog.getCurrent().getButtonElement('add_credits');_L3.value=_L0;if(_L1>0)GiftCreditsDialog.updatePricepoints(_L1,_L2);},selected_new_cc:function(_L0,_L1,_L2){show('redirect_message');var _L3=Dialog.getCurrent().getButtonElement('add_credits');_L3.value=_L0;if(_L1>0)GiftCreditsDialog.updatePricepoints(_L1,_L2);},selected_mobile:function(_L0,_L1,_L2){hide('redirect_message');var _L3=Dialog.getCurrent().getButtonElement('add_credits');_L3.value=_L0;if(_L1>0)GiftCreditsDialog.updatePricepoints(_L1,_L2);},showLearnMoreDialog:function(){var _L0=new AsyncRequest('/ajax/giftcredits/learn.php');new Dialog().setAsync(_L0).show();},composeConfirmationDialogForPopUpCC:function(_L0,_L1,_L2,_L3){Dialog.getCurrent().setTitle(_L0).setBody(_L2).setButtons({name:'ok',label:_L1,handler:_L3}).show();}};
function GiftsMall(_L0,_L1,_L2,_L3){this.root=_L0;this.directory=_L1;this.current=_L2;this.home=_L2;this.virtualGiftsId=this.root.find('.VIRTUAL-GIFTS').id;var _L4=this.root.find('div.dark_loaded').childNodes||[];to_array(_L4).map(function(_L5){hide(_L5);this.root.appendChild(_L5);}.bind(this));this.switchTo(_L3);Arbiter.subscribe(GiftsMall.SWITCH_TO,function(_L5,_L6){var id=_L6.id||this.home;this.directory[id]&&this.switchTo(id);}.bind(this));}GiftsMall.prototype={switchTo:function(id){if(!this.directory[id])return;var _L1=this.current;if(id==_L1)return;GiftshopController.log('switchTo-'+id);Arbiter.inform(GiftsMall.SET_PURCHASE_BUTTON,{enable:false,buttonText:_tx("Buy Gift")},Arbiter.BEHAVIOR_STATE);GiftStoreManager.getInstance().clearAppOrderInfo();if(typeof this.directory[id].virtualGiftsTag=='number'){GiftshopController.selectBrowseTag(this.directory[id].virtualGiftsTag);GiftStoreManager.getInstance().resetSku();}if(this.directory[id].isVirtualGiftsShortcut)id=this.virtualGiftsId;if(ge(id)){}else if(this.directory[id].html){this.root.appendContent(HTML(this.directory[id].html));hide(id);}else return;this.fadeTo(_L1,id);this.current=id;if(this.directory[_L1].isIframe)DOM.remove(_L1);Arbiter.inform(GiftsMall.SWITCHED_TO,{sender:this,prev:_L1,id:id},Arbiter.BEHAVIOR_STATE);return true;},fadeTo:function(_L0,_L1){show(_L1);hide(_L0);},getCrumbs:function(id){id=id||this.current;var _L1=[];while(id){_L1.push({title:this.directory[id].title,onclick:(id!=this.current)&&this.switchTo.curry(id).bind(this)});id=this.directory[id].parent;}return _L1.reverse();},isIframe:function(id){return this.directory[id].isIframe;}};GiftsMall.SWITCH_TO='GiftsMall.SWITCH_TO';GiftsMall.SWITCHED_TO='GiftsMall.SWITCHED_TO';GiftsMall.SET_PURCHASE_BUTTON='GiftsMall.SET_PURCHASE_BUTTON';function Breadcrumb(_L0){this.root=_L0;this.root.addClass('gifts_mall_breadcrumb');Arbiter.subscribe(GiftsMall.SWITCHED_TO,function(_L1,_L2){this.update(_L2.sender.getCrumbs());}.bind(this));}Breadcrumb.prototype={update:function(_L0){if(!_L0.length)return;this.root.setContent('');for(var i=0;i<_L0.length;++i){var _L2=_L0[i];var _L3=i?'not_first':'first';this.root.appendContent($N(_L2.onclick?'a':'span',{className:_L3,onclick:_L2.onclick||bagofholding},htmlize(_L2.title)));}}};function GiftsMallFullPage(){this.submitButton=$('giftshop_continue_button');new Breadcrumb($('gifts_full_page_breadcrumb'));Arbiter.subscribe(GiftsMall.SWITCHED_TO,function(_L0,_L1){GiftshopController.forcePublicPrivacy(_L1.sender.isIframe(_L1.id));});this.submitButton.listen('click',function(){if(!this.submitButton.hasClass('UIButton_Disabled'))GiftshopController.onclickSubmit();return false;}.bind(this));Arbiter.subscribe(GiftsMall.SET_PURCHASE_BUTTON,function(_L0,_L1){if(_L1.enable!=undefined)this.submitButton.conditionClass('UIButton_Disabled',!_L1.enable);if(_L1.buttonText!=undefined)this.submitButton.find('.UIButton_Text').setContent(_L1.buttonText);}.bind(this));}copy_properties(GiftsMallFullPage.prototype,{onSubmit:function(){var _L0=serialize_form(this.form);var _L1=$(this.form.message);_L0.message=(_L1.getControl&&trim(_L1.getControl().getValue()))||'';var _L2=_L0.receiver;delete _L0.receiver;var _L3=URI.getRequestURI().removeQueryData(['ref']).toString();GiftshopController.initOrder(_L2,_L0,_L3);}});
function GiftshopController(){}GiftshopController.giftsAppId=2386512837;GiftshopController.giftsApiKey='baf530df1c0ee03c86f5f55b2e6ca3e1';GiftshopController.maxMessageLength=200;GiftshopController.selectBrowseTag=function(_L0){if(ge('giftshop_search_option_input'))$('giftshop_search_option_input').scry('a.token').each(DOM.remove);var _L1=$('giftshop_tag_options');set_form_select_value(_L1,_L0);_L1.onchange();};GiftshopController.initialize=function(_L0,_L1,_L2,_L3,_L4){GiftshopController.cachedPages={};GiftshopController.currentSettings={};GiftshopController.setCurrentSettings(_L2);GiftshopController.setCachedPage(_L0,_L1,_L3);GiftshopController.user=_L4;GiftshopController.forcePublicPrivacy(false);GiftshopController.numSkusPerPage=_L1;};GiftshopController.buildHashkeyCachedPages=function(_L0,_L1){var _L2=JSON.encode(GiftshopController.getCurrentSettings());var _L3=[_L0,_L1,_L2].join(':');return _L3;};GiftshopController.setCachedPage=function(_L0,_L1,_L2){var _L3=GiftshopController.buildHashkeyCachedPages(_L0,_L1);GiftshopController.cachedPages[_L3]=_L2;GiftshopController.lastPage=_L3;};GiftshopController.getCachedPage=function(_L0,_L1){var _L2=GiftshopController.buildHashkeyCachedPages(_L0,_L1);return GiftshopController.cachedPages[_L2]||null;};GiftshopController.getCurrentSettings=function(){return GiftshopController.currentSettings;};GiftshopController.getCurrentSettingByKey=function(key){return GiftshopController.currentSettings[key]||null;};GiftshopController.setCurrentSettings=function(_L0){GiftshopController.currentSettings=_L0;};GiftshopController.setCurrentSettingByKey=function(key,_L1){GiftshopController.currentSettings[key]=_L1;};GiftshopController.updateComposerButtonText=function(_L0){Arbiter.inform(GiftsMall.SET_PURCHASE_BUTTON,{buttonText:_L0?_tx("Give Gift"):_tx("Buy Gift")});};GiftshopController.enablePurchaseButton=function(_L0){Arbiter.inform(GiftsMall.SET_PURCHASE_BUTTON,{enable:_L0});};GiftshopController.set_item_category=function(_L0){if(!_L0){GiftshopController.log('selected category 0');}else GiftshopController.log('selected category '+_L0);var _L1=GiftshopController.getCurrentSettingByKey('tag_id');var _L2='giftshop_top_tag_'+(_L1?_L1:'');var _L3='giftshop_top_tag_'+(_L0?_L0:'');var _L4='giftshop_top_tag_';};GiftshopController.reset_item_category=GiftshopController.set_item_category.bind(null,null);GiftshopController.search_addtag=function(_L0,_L1,_L2){GiftshopController.findgifts_by_tag(_L0,_L1,_L2.i);};GiftshopController.findgifts_by_tag=function(_L0,_L1,_L2){this.enablePurchaseButton(false);GiftshopController.set_item_category(_L2);GiftshopController.setCurrentSettingByKey('tag_id',_L2);GiftStoreManager.getInstance().updatePager();};GiftshopController.search_removetag=function(_L0,_L1,_L2){GiftshopController.reset_item_category();GiftshopController.setCurrentSettingByKey('tag_id',null);GiftStoreManager.getInstance().updatePager();};GiftshopController.skuPrices={};GiftshopController.addSkuPrices=function(_L0){copy_properties(GiftshopController.skuPrices,_L0);};GiftshopController.getSkuPrice=function(sku){return GiftshopController.skuPrices[sku];};GiftshopController.setAutoExpandedMode=function(_L0){GiftshopController.isAutoExpanded=_L0;};GiftshopController.getAutoExpandedMode=function(){return GiftshopController.isAutoExpanded;};GiftshopController.composer=null;GiftshopController.getComposer=function(){return GiftshopController.composer||null;};GiftshopController.fallBackStatusUpdate=function(){var _L0=GiftshopController.getComposer();if(_L0)_L0.reset(true,false,false).post();};GiftshopController.focusMessageInput=function(){var _L0=GiftshopController.getComposer();if(_L0){var _L1=_L0.focusInput();}else $('message').focus();};GiftshopController.initOrder=function(_L0,_L1,_L2,_L3,_L4){_L4=true;var _L5;var _L6;var gsm=GiftStoreManager.getInstance();if(!gsm)return;var _L8=gsm.getAppOrderInfo();copy_properties(_L1,_L8.order_info);_L6=_L8.api_key;if(!_L6){if(GiftshopController.getAutoExpandedMode()){GiftshopController.fallBackStatusUpdate();}else GiftshopController.log('gsh:select-gift '+_L1.sku);return;}var _L9=(_L6==GiftshopController.giftsApiKey)&&!GiftshopController.getSkuPrice(_L1.sku);if(!_L0){GiftshopController.log('gsh:select-receiver '+_L1.sku);_L5=_tx("\u8bf7\u4e3a\u4f60\u7684\u793c\u7269\u9009\u62e9\u4e00\u4e2a\u63a5\u6536\u8005.");DOMScroll.scrollTo(new Vector2(0,0,'document'),false);}else if(!_L1.message&&!_L4){GiftshopController.log('gsh:include-message '+_L1.sku);new Dialog().setTitle(_tx("Write Message")).setBody(_tx("Would you like to write a message to send with your gift?")).setButtons([Dialog.newButton('Yes',_tx("Write Message"),null,GiftshopController.focusMessageInput),Dialog.newButton('No',_tx("Send Anyway"),'inputaux',function(){GiftshopController.initOrder(_L0,_L1,_L2,_L3,true);})]).show();return;}else if(_L1.message.length>GiftshopController.maxMessageLength){GiftshopController.log('gsh:message-too-long '+_L1.sku);var _La=_L1.message.length-GiftshopController.maxMessageLength;_L5=_tx("Your message is too long by {number} characters.",{'number':_La});}if(_L5){new ErrorDialog().showError(_tx("\u9519\u8bef"),_L5);return;}_L1.source=_L1.source||'';_L1.ref=_L1.ref||URI.getRequestURI().getQueryData().ref||'';if(_L9){var _Lb=new AsyncRequest('/ajax/giftshop/free_gifts.php').setData({order_info:JSON.encode(_L1),receiver:_L0,back_url:_L2});if(_L3)_Lb.setContextData(_L3,'application_'+_L6);new Dialog().setAsync(_Lb).show();return;}GiftshopController.enablePurchaseButton(false);GiftCredits.getPrompt(null,_L0,_L1,_L2,GiftshopController.enablePurchaseButton.curry(true),GiftCredits.PLACE_GIFTSHOP,_L6,_L3);};GiftshopController.onclickSubmit=function(_L0){var _L1=serialize_form($('giftshop_form'));_L1['message']=($('message').getControl&&trim($('message').getControl().getValue()))||'';var _L2=_L1['receiver'];delete _L1['receiver'];var _L3=URI.getRequestURI().removeQueryData(['ref']).toString();GiftshopController.initOrder(_L2,_L1,_L3);_L0&&_L0.kill();};GiftshopController.updateNumCredits=function(_L0,_L1){if(ge('giftshop_num_credits_balance_holder'))$('giftshop_num_credits_balance_holder').setContent(_L0);if(ge('giftshop_num_credits_holder'))$('giftshop_num_credits_holder').setContent(_L1);};function gift_recipient_onfound(_L0){if(!_L0){$('receiver').value='';$('recipient_pic').style.backgroundImage='';$('recipient_pic').style.height='0px';$('recipient_pic').style.width='0px';}else{$('receiver').value=_L0.i;$('recipient_pic').style.backgroundImage='url('+_L0.it+')';$('recipient_pic').style.height='50px';$('recipient_pic').style.width='50px';}return true;}copy_properties(GiftStoreManager,{_instance:null,getAndUpdateInstance:function(_L0,_L1,_L2,_L3,_L4){if(!this._instance)this._instance=new GiftStoreManager(_L0,_L1,_L2,_L3);this._instance.update(_L3);return this._instance;},getInstance:function(){return this._instance;}});function GiftStoreManager(_L0,_L1,_L2,_L3){this.embedded_store=$(_L0);onunloadRegister(bind(this,function(){DOM.remove(this.embedded_store);delete GiftStoreManager._instance;}),true);this.pageOffset=_L1;this.perPage=_L2;this.totalPages=_L3;this.prevSelect=null;this.initialize();this.initPager();this.addGiftListeners();}GiftStoreManager.prototype.updatePager=function(){this.pager.setOffset(0);this.changePage(0);};GiftStoreManager.prototype.initialize=function(_L0,_L1,_L2){this.giftsGrid=DOM.find(this.embedded_store,'div#gifts_grid');this.storeFooter=DOM.find(this.embedded_store,'div#store_footer');};GiftStoreManager.prototype.update=function(_L0){this.totalPages=_L0||this.totalPages;this.pager.setTotal(this.totalPages);};GiftStoreManager.prototype.initPager=function(){this.pager=new UIPager(this.totalPages,1,this.pageOffset,this.changePage.bind(this));this.pagerspan=DOM.find(this.embedded_store,'div#giftstore_pager');this.pagerspan.appendChild(this.pager.getRoot());this.pager.setSummaryTextHandler(this.getSummaryText.bind(this));};GiftStoreManager.prototype.getSummaryText=function(_L0,_L1,_L2){return _tx("Page {current} of {total}",{'current':_L0+1,'total':_L1});};GiftStoreManager.prototype.setTotalPages=function(_L0){GiftStoreManager.getInstance().totalPages=_L0;GiftStoreManager.getInstance().pager.setTotal(_L0);};GiftStoreManager.prototype.addGiftListeners=function(){var _L0=DOM.scry(this.giftsGrid,'div.gift_outer.instock');for(var i=0;i<_L0.length;i++){_L0[i].listen('click',this.giftOnClick.bind(this,_L0[i]));_L0[i].listen('mouseover',this.giftOnMouseOver.bind(this,_L0[i]));_L0[i].listen('mouseout',this.giftOnMouseOut.bind(this,_L0[i]));}};GiftStoreManager.prototype.changePage=function(_L0){this.pageOffset=_L0;if(_L0<0||_L0>this.totalPages)return;var _L1=this.perPage*_L0;GiftshopController.log('changed to page starting at '+_L1+' with '+this.perPage+' per page');var _L2=function(_L3){this.setTotalPages(_L3.total_pages);DOM.replace(this.giftsGrid,HTML(_L3.gifts_grid));this.giftsGrid=DOM.find(this.embedded_store,'div#gifts_grid');this.addGiftListeners();}.bind(this);var _L3=GiftshopController.getCachedPage(_L1,this.perPage);if(_L3){_L2(_L3);return;}DOM.setContent(this.giftsGrid,'');this.giftsGrid.addClass('gifts_loading');this.paginate(_L1,this.perPage,_L2);};GiftStoreManager.prototype.paginate=function(_L0,_L1,_L2){var _L3={start:_L0,per_page:_L1};copy_properties(_L3,GiftshopController.getCurrentSettings());new AsyncRequest().setURI('/ajax/giftshop/browse.php').setData(_L3).setHandler(function(_L4){var _L5=_L4.getPayload();if(_L2)_L2(_L5);GiftshopController.setCachedPage(_L0,_L1,_L5);}).send();};GiftStoreManager.prototype.giftOnClick=function(_L0,_L1){var sku=_L0.getAttribute('sku');GiftshopController.updateComposerButtonText(GiftshopController.getSkuPrice(sku));if(this.prevSelect!=_L0){GiftshopController.log('selected SKU '+sku);if(this.prevSelect)GiftshopController.changeGiftOuterClass(this.prevSelect,'gift_outer');}GiftshopController.changeGiftOuterClass(_L0,'gift_outer_onclick');this.prevSelect=_L0;this.setAppOrderInfo(GiftshopController.giftsApiKey,{sku:sku},true);_L1&&_L1.kill();};GiftStoreManager.prototype.resetSku=function(){if(this.prevSelect)GiftshopController.changeGiftOuterClass(this.prevSelect,'gift_outer');this.prevSelect=null;};GiftStoreManager.prototype.giftOnMouseOver=function(_L0,_L1){if(this.prevSelect!=_L0)GiftshopController.changeGiftOuterClass(_L0,'gift_outer_onmouseover');_L1.kill();};GiftshopController.changeGiftOuterClass=function(_L0,_L1){var _L2={'gift_outer':0,'gift_outer_onmouseover':0,'gift_outer_onclick':0};_L2[_L1]=1;for(var c in _L2)if(!_L2[c]){CSS.removeClass(_L0,c);}else CSS.addClass(_L0,c);};GiftStoreManager.prototype.giftOnMouseOut=function(_L0,_L1){if(this.prevSelect!=_L0)GiftshopController.changeGiftOuterClass(_L0,'gift_outer');_L1.kill();};GiftStoreManager.prototype.getAppOrderInfo=function(){return {api_key:this.appOrderApiKey||null,order_info:this.appOrderInfo||{}};};GiftStoreManager.prototype.setAppOrderInfo=function(_L0,_L1,_L2){if(!_L0)return;if(_L1){this.appOrderApiKey=_L0;this.appOrderInfo=_L1;}if(_L2!==null)GiftshopController.enablePurchaseButton(_L2);};GiftStoreManager.prototype.clearAppOrderInfo=function(){this.appOrderApiKey=null;this.appOrderInfo={};};GiftshopController.forcePublicPrivacy=function(_L0){if(ge('delivery_info')&&ge('platform_gift_privacy_txt')){var _L1=$('delivery_info');var _L2=$('platform_gift_privacy_txt');if(_L0){hide(_L1);show(_L2);var _L3=$('gift_privacy_type_0');_L3.checked=true;}else{show(_L1);hide(_L2);}}};GiftshopController.resetForm=function(){$('message').value='';$('gift_privacy_type_0').checked=true;!($('friend_selector').typeahead)&&$('friend_selector').focus();$('friend_selector').typeahead.clear();$('friend_selector').typeahead.blur();gift_recipient_onfound();GiftStoreManager.getInstance().resetSku();};GiftshopController.option_select_tag=function(obj,_L1,_L2){GiftshopController.findgifts_by_tag(0,_L2,get_form_select_value(obj));};GiftshopController.log=function(_L0){var sep='\001';var _L2=Math.floor((new Date()).getTime()/1000);var arr=new Array(_L2,GiftshopController.user,_L0);var _L4=arr.join(sep);scribe_log('giftshop',_L4);};
function FBPay(){}copy_properties(FBPay.prototype,{registerServiceForIFrame:function(){var _L0={'submitOrder':{'asyncMethod':this.onSubmitOrderRequest},'updateGiftshopOrder':{'asyncMethod':this.onUpdateGiftshopOrderRequest},'submitGiftshopOrder':{'asyncMethod':this.onSubmitGiftshopOrderRequest}};this._rpcServer=new FB.XdComm.XdRpcServer('PaymentsServer',_L0);},onSubmitOrderRequest:function(arg,_L1,_L2){var _L3=arg['app_id'];var _L4=arg['order_info'];var _L5=arg['receiver'];var _L6=arg['next_url'];var _L7=arg['api_key'];GiftCredits.getPrompt(_L3,_L5,_L4,_L6,_L1,null,_L7);},onUpdateGiftshopOrderRequest:function(arg,_L1,_L2){var _L3=arg['order_info']||null;var _L4=null;arg['price']!==undefined&&(_L4=arg['price']);var _L5=null;arg['ready']!==undefined&&(_L5=arg['ready']);GiftStoreManager.getInstance().setAppOrderInfo(arg.api_key,_L3,_L5);},onSubmitGiftshopOrderRequest:function(){var _L0=GiftshopController.getComposer();if(_L0){_L0.getData();}else GiftshopController.onclickSubmit();}});

if (window.Bootloader) { Bootloader.done(["js\/aa2i2ed5ij484c0w.pkg.js"]); }