var BRAND_NAME="Lemonade";var ARTICLE_AND_BRAND_NAME="a Lemonade";var MINIMUM_AGE=13;var Gigya;var gigyaUser={};dojo.addOnLoad(function(){Gigya=Gigya||new Lemon_Gigya();if((typeof (badtoken)!="undefined")&&(badtoken==true)){dojo.byId("messageDlgMsg").innerHTML=dojo.byId("badtokenTpl").innerHTML;dijit.byId("messageDlg").show();}if((typeof (resetPwToken)!="undefined")&&(resetPwToken.length>0)){dijit.byId("resetPwDlg").show();}updateTemplate();var _1=dojo.byId("loginEmail");var _2=dojo.byId("loginPassword");var _3=dojo.byId("loginForgotEmail");addEnterCallback(_2,validateUser);addEnterCallback(_3,validateResetPw);dojo.connect(_2,"onkeypress",clearLoginError);dojo.connect(_3,"onkeypress",clearLoginError);dojo.connect(_1,"onkeypress",clearLoginError);var _4=dojo.byId("newUserBirthYear");var _5=dojo.byId("newUserBirthMonth");var _6=dojo.byId("newUserBirthDay");var _7=function(){setDaysInMonth(_4,_5,_6);};dojo.connect(_5,"onchange",_7);dojo.connect(_5,"onkeypress",_7);dojo.connect(_4,"onchange",_7);dojo.connect(_4,"onkeypress",_7);if(dojo.byId("resetPwDlg")!=null){dojo.connect(dojo.byId("resetPwButton"),"onclick",setNewPassword);addEnterCallback(dojo.byId("resetPwConfirm"),setNewPassword);}if(Gigya.isEnabled()){gigya.services.socialize.addEventHandlers(Gigya.config,{onLogin:_gigyaLoginHandler,onLogout:Gigya.logEvent});}});function clearLoginError(ev){dojo.byId("forgotPassError").innerHTML="";dojo.byId("loginError").innerHTML="";dojo.byId("registrationError").innerHTML="";};function resetDialog(){if((devMode==true)&&Gigya.isEnabled()){dojo.byId("loginUnlinkAccts").style.display="inline";dojo.byId("joinUnlinkAccts").style.display="block";}clearLoginError();dojo.byId("gigyaLoginWidget").style.display="";dojo.byId("initialLoginPanel").style.display="";dojo.byId("joinButton").style.display="";dojo.byId("loginButton").style.display="";dojo.byId("loginNormalPrompt").style.display="";dojo.byId("registerUnlinkedAccount").style.display="";dojo.byId("facebookConfirmation").style.display="none";dojo.byId("joinAndLinkButton").style.display="none";dojo.byId("loginAndLinkButton").style.display="none";dojo.byId("loginLinkAccountsPrompt").style.display="none";dojo.byId("loginLinkAccountsExplanation").style.display="none";dojo.byId("loginRegistrationPanel").style.display="none";dojo.byId("registerAndLinkAccounts").style.display="none";dojo.byId("socialNetLoggedInNotLinked").style.display="none";dojo.byId("socialNetLoginBar").style.display="none";};function displayRegErrors(_8){var _9=dojo.byId("invalidEntriesText").innerHTML;dojo.byId("newUserNicknameLabel").style.color="black";dojo.byId("newUserPasswordLabel").style.color="black";dojo.byId("newUserConfirmPasswordLabel").style.color="black";dojo.byId("newUserEmailLabel").style.color="black";dojo.byId("newUserBirthdateLabel").style.color="black";dojo.byId("newUserOperatorAgreementLabel").style.color="black";dojo.byId("newUserPrivacyPolicyLabel").style.color="black";for(var _a in _8){switch(_8[_a]){case "nickname":dojo.byId("newUserNicknameLabel").style.color="red";break;case "passwordInvalid":_9=dojo.byId("passwordLengthText").innerHTML;dojo.byId("newUserPasswordLabel").style.color="red";dojo.byId("newUserConfirmPasswordLabel").style.color="red";break;case "passwordMismatch":_9=dojo.byId("passwordsDontMatchText").innerHTML;dojo.byId("newUserPasswordLabel").style.color="red";dojo.byId("newUserConfirmPasswordLabel").style.color="red";break;case "emailInvalid":case "emailempty":dojo.byId("newUserEmailLabel").style.color="red";break;case "nodate":dojo.byId("newUserBirthdateLabel").style.color="red";break;case "invaliddate":_9=dojo.byId("invalidBirthdateText").innerHTML;dojo.byId("newUserBirthdateLabel").style.color="red";break;case "tooyoung":_9=dojo.byId("notOldEnoughText").innerHTML;dojo.byId("newUserBirthdateLabel").style.color="red";break;case "operatorterms":dojo.byId("newUserOperatorAgreementLabel").style.color="red";break;case "privacyterms":dojo.byId("newUserPrivacyPolicyLabel").style.color="red";break;}}dojo.byId("registrationError").innerHTML=_9;};function _gigyaLoginHandler(_b){gigyaUser=_b.user;if(gigyaUser==undefined){devError("Gigya Socialize returned no user object");return;}if(gigyaUser.isSiteUID){var _c=dojox.dtl.filter.strings.addslashes(currentDestination);Lemon_Authorize.gigyaValidateLogin({eventObj:_b,destination:_c},function(_d){if(_d.status="OK"){currentDestination="";dijit.byId("mainLoginDialog").hide();window.top.location=_c;}else{var _e;if(_d.status=="bad_sig"){_e=dojo.byId("gigyaBrokenText").innerHTML.replace(/__SOCIAL_NET__/g,Gigya.getProviderName(_b.provider));}else{if(_d.status=="suspended"){_e=dojo.byId("accountSuspendedText").innerHTML;}else{_e=dojo.byId("invalidLoginText").innerHTML;}}dojo.byId("loginError").innerHTML=_e;}});return;}dojo.byId("socialNetPleaseLogIn").style.display="none";dojo.byId("gigyaLoginWidget").style.display="none";dojo.byId("socialNetOrBreak").style.display="none";dojo.byId("loginLinkAccountsPrompt").style.display="";dojo.byId("loginLinkAccountsExplanation").style.display="";var _f="<b>"+Gigya.getProviderName(_b.provider)+"</b>";setSocialNetName(_f);var _10=dojo.byId("mainLoginDialogContent");_10.innerHTML=_10.innerHTML.replace(/__SOCIAL_NET_NAME__/g,_f);dojo.byId("socialNetLoggedInNotLinked").style.display="";dojo.byId("registerAndLinkAccounts").style.display="";dojo.byId("registerUnlinkedAccount").style.display="none";dojo.byId("loginEmail").focus();if(_b.provider=="facebook"){showFacebookConfirmation();dojo.byId("facebookConfirmation").style.display="";}else{populateRegistrationFields();}dojo.byId("loginButton").style.display="none";dojo.byId("loginAndLinkButton").style.display="";dojo.byId("joinButton").style.display="none";dojo.byId("joinAndLinkButton").style.display="";};function populateRegistrationFields(_11){if(_11==true){dojo.byId("newUserNickname").value="";dojo.byId("newUserEmail").value="";dojo.byId("newUserBirthMonth").selectedIndex=0;dojo.byId("newUserBirthDay").selectedIndex=0;dojo.byId("newUserBirthYear").selectedIndex=0;dojo.byId("newUserGenderMale").checked=false;dojo.byId("newUserGenderFemale").checked=false;return;}dojo.byId("newUserNickname").value=gigyaUser.nickname.trim();if(gigyaUser.email.length>0){dojo.byId("newUserEmail").value=gigyaUser.email.trim();}dojo.byId("newUserBirthMonth").selectedIndex=gigyaUser.birthMonth;dojo.byId("newUserBirthDay").selectedIndex=gigyaUser.birthDay;dojo.byId("newUserBirthYear").value=gigyaUser.birthYear;switch(gigyaUser.gender){case "m":dojo.byId("newUserGenderMale").checked=true;break;case "f":dojo.byId("newUserGenderFemale").checked=true;break;}};function setNewPassword(){var _12="";var pw1=dojo.byId("resetPw").value.trim();var pw2=dojo.byId("resetPwConfirm").value.trim();if(pw1!==pw2){_12=dojo.byId("passwordsDontMatchText").innerHTML;}else{if((pw1.length<Lemon_Authorize.PASSWORD_MIN_LENGTH)||(pw1.length>Lemon_Authorize.PASSWORD_MAX_LENGTH)){_12=dojo.byId("passwordLengthText").innerHTML;}else{Lemon_Authorize.setNewPassword(resetPwToken,pw1,function(){if(Lemon_Authorize.status=="OK"){location.href="/setup/index/passwordchanged/1";}else{_12=dojo.byId("couldntSetPasswordText").innerHTML;}});}}if(_12.length>0){dojo.byId("pwResetErrorMsg").style.display="block";dojo.byId("pwResetErrorMsg").innerHTML=_12;}};function setSocialNetName(_13){dojo.query(".loginSocialNetNameSpan").forEach(function(_14){_14.innerHTML=_13;});};function showFacebookConfirmation(){var _15=function(id,_16){var _17=dojo.byId(id);var div=dojo.byId(id+"Div");if((_17==null)||(div==null)){devError("span '"+id+"' or div '"+id+"Div' not found.");return;}_17.innerHTML=_16;div.style.display="";};if(gigyaUser.nickname.trim().length>0){_15("fbNickname",gigyaUser.nickname);}if(gigyaUser.email.trim().length>0){_15("fbEmail",gigyaUser.email);}var _18="";if((gigyaUser.birthMonth>0)&&(gigyaUser.birthDay>0)){_18+=gigyaUser.birthMonth+"-"+gigyaUser.birthDay;if(gigyaUser.birthYear>0){_18+="-";}}if(gigyaUser.birthYear>0){_18+=gigyaUser.birthYear;}if(_18.length>0){_15("fbBirthdate",_18);}var _19=null;switch(gigyaUser.gender){case "m":_19="Male";break;case "f":_19="Female";break;}if(_19!=null){_15("fbGender",_19);}var _1a=dojo.byId("fbFillForm");if(_1a!=null){var _1b=false;dojo.connect(_1a,"onclick",function(){populateRegistrationFields(_1b);_1b=!_1b;});}};function showLoginDialog(){resetDialog();if(Gigya.isEnabled()){dojo.byId("socialNetLoginBar").style.display="";gigya.services.socialize.showLoginUI(Gigya.config,{containerID:"gigyaLoginWidget",border:0,width:550,height:50,showTermsLink:false,hideGigyaLink:true,onLoad:function(_1c){Gigya.logCallback(_1c);},onClose:Gigya.logCallback,onError:function(_1d){Gigya.logCallback(_1d);}});}dijit.byId("mainLoginDialog").show();};function showRegistrationPage(){dojo.byId("initialLoginPanel").style.display="none";dojo.byId("loginRegistrationPanel").style.display="";dojo.byId("newUserNickname").focus();};function unlinkAccounts(){if((devMode!=true)||!Gigya.isEnabled()){return;}Gigya.unlinkAccounts();};function updateTemplate(){var _1e=dojo.byId("mainLoginDialogContent");var _1f=_1e.innerHTML.replace(/__BRAND_NAME__/g,BRAND_NAME).replace(/__ARTICLE_AND_BRAND_NAME__/g,ARTICLE_AND_BRAND_NAME).replace(/__MINIMUM_AGE__/g,MINIMUM_AGE).replace(/__PASSWORD_MIN_LENGTH__/g,Lemon_Authorize.PASSWORD_MIN_LENGTH).replace(/__PASSWORD_MAX_LENGTH__/g,Lemon_Authorize.PASSWORD_MAX_LENGTH);_1e.innerHTML=_1f;};function validateNewUser(_20){var _21=new Array();var _22=dojo.byId("newUserNickname").value.trim();var _23=dojo.byId("newUserPassword").value.trim();var _24=dojo.byId("newUserConfirmPassword").value.trim();var _25=dojo.byId("newUserEmail").value.trim();var _26=Number(dojo.byId("newUserBirthYear").value);var _27=Number(dojo.byId("newUserBirthMonth").value);var day=Number(dojo.byId("newUserBirthDay").value);var _28=dojo.date.getDaysInMonth(new Date(_26,_27-1,1));if((_26==0)||(_27==0)||(day==0)){_21.push("nodate");}else{if(day>_28){_21.push("invaliddate");}else{var age=getAge(_27,day,_26);if(age<MINIMUM_AGE){_21.push("tooyoung");}}}if(!dojo.byId("newUserOperatorAgreement").checked){_21.push("operatorterms");}if(!dojo.byId("newUserPrivacyPolicy").checked){_21.push("privacyterms");}if(_22==""){_21.push("nickname");}if(_23!==_24){_21.push("passwordMismatch");}else{if(_23.length<Lemon_Authorize.PASSWORD_MIN_LENGTH||_23.length>Lemon_Authorize.PASSWORD_MAX_LENGTH){_21.push("passwordInvalid");}}if(_25==""){_21.push("emailempty");}else{if(isValidEmail(_25)==false){_21.push("emailInvalid");}}if(_21.length>0){displayRegErrors(_21);return false;}var _29=null;if(dojo.byId("newUserGenderMale").checked){_29="male";}else{if(dojo.byId("newUserGenderFemale").checked){_29="female";}}var _2a={dest:dojox.dtl.filter.strings.addslashes(currentDestination),nickname:_22,password:_23,email:_25,gender:_29,birthdate:_26+"-"+_27+"-"+day};if((_20===true)&&(gigyaUser!=undefined)){if(gigyaUser.isSiteUID==false){if(devMode==true){console.info("Will attempt to link gigya UID '"+gigyaUser.UID+"' to our new user object");}_2a.gigyaUID=gigyaUser.UID;}else{if(devMode==true){console.warn("Not linking accounts via Gigya, because accounts are already linked");}}}Lemon_Authorize.createUser(_2a,function(_2b){switch(_2b.status){case "OK":dojo.cookie("newuser",_2b.uid);var _2c=true;if(_2b.warning){switch(_2b.warning[0]){case "cannotlogin":_2c=false;showLoginDialog();dojo.byId("loginError").innerHTML=dojo.byId("newUserCannotLogInText").innerHTML;break;}}if(Gigya.isEnabled()&&(_2b.signature!=undefined)){var _2d={timestamp:_2b.timestamp,signature:_2b.signature,siteUID:_2b.uid,callback:Gigya.logCallback};gigya.services.socialize.notifyLogin(Gigya.config,_2d);}if(_2c){currentDestination="";dijit.byId("mainLoginDialog").hide();window.top.location=_2b.url;}break;case "email_in_use":dojo.byId("registrationError").innerHTML=dojo.byId("emailAlreadyUsedText").innerHTML;break;case "badvalues":var _2e=new Array();for(var _2f in _2b.errorFields){switch(_2f){case "birthdate":_2e.push("invaliddate");break;case "email":_2e.push("emailInvalid");break;case "nickname":_2e.push("nickname");break;case "password":_2e.push("passwordInvalid");break;}}displayRegErrors(_2e);break;default:dojo.byId("registrationError").innerHTML=dojo.byId("cannotCreateAccountText").innerHTML;break;}});};function validateUser(_30){var _31=dojo.byId("loginEmail").value.trim();var _32=dojo.byId("loginPassword").value.trim();var _33=new Array();if(_31.value==""){_33.push("emailempty");}else{if(isValidEmail(_31)==false){_33.push("email");}}if(_32==""){_33.push("pw");}if(_33.length>0){dojo.byId("loginError").innerHTML=dojo.byId("invalidLoginText").innerHTML;return false;}var _34=dojox.dtl.filter.strings.addslashes(currentDestination);var _35={email:_31,password:_32,dest:_34};if((_30===true)&&(gigyaUser!=undefined)){if(gigyaUser.isSiteUID==false){if(devMode==true){console.info("Will attempt to link gigya UID "+gigyaUser.UID+" to our user");}_35.gigyaUID=gigyaUser.UID;}else{if(devMode==true){console.info("Not linking accounts via Gigya, because accounts are already linked");}}}Lemon_Authorize.validateLogin(_35,function(_36){if(_36.status=="OK"){currentDestination="";dijit.byId("mainLoginDialog").hide();if(Gigya.isEnabled()&&(_36.signature!=undefined)){var _37={timestamp:_36.timestamp,signature:_36.signature,siteUID:_36.uid,callback:Gigya.logCallback};gigya.services.socialize.notifyLogin(Gigya.config,_37);}window.top.location=_36.url;}else{var _38="invalidLoginText";if(_36.status=="suspended"){_38="accountSuspendedText";}dojo.byId("loginError").innerHTML=dojo.byId(_38).innerHTML;}});};function validateResetPw(){var _39=dojo.byId("loginForgotEmail").value;if((_39=="")||(isValidEmail(_39)==false)){dojo.byId("forgotPassError").innerHTML=dojo.byId("invalidResetPasswordEmailText").innerHTML;return false;}dojo.byId("loginForgotEmail").value="";dijit.byId("mainLoginDialog").hide();Lemon_Authorize.forgotPassword(_39,function(){if(Lemon_Authorize.validated){showMessage("An email was sent to "+_39+".");}else{showMessage("Unable to reset password at this time.");}});};if(!dojo._hasResource["lemon.model.wall"]){dojo._hasResource["lemon.model.wall"]=true;dojo.provide("lemon.model.wall");function Lemon_Wall(_3a,_3b,_3c){this.enabled=false;this.messages=[];this.standid=null;if(!isNaN(_3a)){this.standid=_3a;}if(typeof (_3b)=="boolean"){this.enabled=_3b;}if(typeof (_3c)=="object"){this.messages=_3c;}};Lemon_Wall.prototype={setWall:function(_3d,_3e,_3f){if(typeof (_3d)=="number"){this.standid=_3d;}if(typeof (_3e)=="boolean"){this.enabled=_3e;}if(typeof (_3f)=="object"){this.messages=_3f;}},setEnabled:function(_40,_41){if(typeof (_40)!="boolean"){if(devMode){console.error("'enabled' must be a boolean");}return;}if(this.enabled!==_40){lemonAjax({url:"/stand/setwallstate",content:{wallstate:_40?"1":"0",standid:this.standid},load:function(_42){_41(_42);}});}this.enabled=_40;},getMessages:function(_43){if(!this.enabled){if(devMode){console.warn("Wall not enabled");}return;}var _44=new Object();lemonAjax({url:"/stand/getwallmessages/stand/"+this.standid,load:function(_45){_44.enabled=_45.wallstate;_44.messages=_45.messages;_43(_44);}});},getMessageCount:function(){return this.messages.length;},saveMessage:function(msg,_46){if(!this.enabled||typeof (msg)!="string"||msg.length<1){return null;}var me=this;lemonAjax({url:"/stand/postwallmessage",content:{message:msg,stand:this.standid},load:function(_47){if(_47.status=="OK"){me.messages.splice(0,0,_47.data.message);}_46(_47);}});},deleteMessage:function(_48,_49){if(!this.enabled||isNaN(_48)){return null;}var me=this;lemonAjax({url:"/stand/removewallmessage",content:{messagepid:_48,stand:this.standid},load:function(_4a){if(_4a.standwallmessageremove==true){for(var i in me.messages){var _4b=me.messages[i].id;if(_4b==_48){me.messages.splice(i,1);break;}}}_49(_4a);}});}};}if(!dojo._hasResource["lemon.model.user"]){dojo._hasResource["lemon.model.user"]=true;dojo.provide("lemon.model.user");function Lemon_User_Type(){};Lemon_User_Type.prototype={privateMessages:{"received":{},"sent":{}},dailyFanCounts:{},dailyFanCountDeltas:{},downloadItems:{},getAddresses:function(_4c){lemonAjax({url:"/myaccount/get-addresses",load:function(_4d){_4c(_4d);}});},queryDailyFanCounts:function(_4e,_4f,_50,_51){var _52="";var _52={"usercode":_4e,"start":_4f,"end":_50};var me=this;Library.Db.runQuery("user.GetDailyFanCounts",_52,function(_53){if(_53.status=="OK"){var _54;var _55={};_55["total"]=0;me.dailyFanCounts={};me.dailyFanCounts["total"]={};me.dailyFanCountDeltas={};me.dailyFanCountDeltas["total"]={};for(var i in _53.data){var row=_53.data[i];row.count=parseInt(row.count);var _56=row.datecollect.split("-");var _57=new Date(_56[0],(_56[1]-1),_56[2]);if(i==0){_54=row.datecollect;}if(row.datecollect==_54){_55[row.networkname]=row.count;_55["total"]=row.count;continue;}if(!(row.networkname in me.dailyFanCounts)){me.dailyFanCounts[row.networkname]={};}if(!(row.datecollect in me.dailyFanCounts[row.networkname])){me.dailyFanCounts[row.networkname][row.datecollect]=0;}me.dailyFanCounts[row.networkname][row.datecollect]=row.count;if(!(row.datecollect in me.dailyFanCounts["total"])){me.dailyFanCounts["total"][row.datecollect]=0;}me.dailyFanCounts["total"][row.datecollect]+=row.count;_57.setDate(_57.getDate()-1);var _58=_57.getFullYear()+"-"+(_57.getMonth()<9?"0":"")+(_57.getMonth()+1)+"-"+(_57.getDate()<10?"0":"")+_57.getDate();var _59=null;if(_58==_54){_59=_55[row.networkname];}else{if(null!=me.dailyFanCounts[row.networkname][_58]){_59=me.dailyFanCounts[row.networkname][_58];}}if(null!=_59){if(!(row.networkname in me.dailyFanCountDeltas)){me.dailyFanCountDeltas[row.networkname]={};}if(!(row.datecollect in me.dailyFanCountDeltas[row.networkname])){me.dailyFanCountDeltas[row.networkname][row.datecollect]=0;}if(!(row.datecollect in me.dailyFanCountDeltas["total"])){me.dailyFanCountDeltas["total"][row.datecollect]=0;}var _5a=row.count-_59;me.dailyFanCountDeltas[row.networkname][row.datecollect]=_5a;me.dailyFanCountDeltas["total"][row.datecollect]+=_5a;}}}_51(_53);});},getPrivateMessageById:function(_5b,_5c){if(typeof (_5c)=="undefined"){_5c="received";}var _5d=this.privateMessages[_5c];for(var i in _5d){if(_5d[i].msgid==_5b){return _5d[i];}}return null;},addAddress:function(_5e,_5f){lemonAjax({url:"/myaccount/add-address",content:_5e,load:function(_60){_5f(_60);}});},editAddress:function(_61,_62){lemonAjax({url:"/myaccount/add-address",content:_61,load:function(_63){_62(_63);}});},deleteAddress:function(_64,_65){lemonAjax({url:"/myaccount/add-address",content:{"addressid":_64},load:function(_66){_65(_66);}});},deletePrivateMessage:function(_67,_68){lemonAjax({url:"privatemessage/delete-private-message",content:{msgid:_67},load:function(_69){_68(_69);}});},getPrivateMessages:function(_6a,_6b,_6c,_6d){if(_6a.toLowerCase()!="sent"&&_6a.toLowerCase()!="received"&&_6a.toLowerCase()!="deleted"){devError("Lemon_User.getPrivateMessages() - Only valid values for parameter 1 are 'sent', 'received', and 'deleted'!");}var me=this;lemonAjax({url:"/privatemessage/get-private-messages",content:{msgtype:_6a,limit:_6b,offset:_6c},load:function(_6e){me.privateMessages[_6a]=_6e.data.messages;_6d(_6e);}});},getPrivateMessagesForUserId:function(id,_6f,_70,_71,_72){if(_6f.toLowerCase()!="sent"&&_6f.toLowerCase()!="received"&&_6f.toLowerCase()!="deleted"){devError("Lemon_User.getPrivateMessages() - Only valid values for parameter 1 are 'sent', 'received', and 'deleted'!");}var me=this;lemonAjax({url:"/privatemessage/get-private-messages-for-userid",content:{id:id,msgtype:_6f,limit:_70,offset:_71},load:function(_73){me.privateMessages[_6f]=_73.data.messages;_72(_73);}});},markMessageRead:function(_74,_75,_76){var me=this;lemonAjax({url:"/privatemessage/set-private-message-read",content:{msgid:_74,read:(_75===true?"true":"false")},load:function(_77){if(_77.status=="OK"&&_77.data.dateread){for(var i in me.privateMessages["received"]){var msg=me.privateMessages["received"][i];if(msg.msgid==_74){me.privateMessages["received"][i].dateread=_77.data.dateread;break;}}}_76(_77);}});},markMessageReadByUserId:function(_78,_79,_7a,_7b){var me=this;lemonAjax({url:"/privatemessage/set-private-message-read-by-userid",content:{userid:_78,msgid:_79,read:(_7a===true?"true":"false")},load:function(_7c){if(_7c.status=="OK"&&_7c.data.dateread){for(var i in me.privateMessages["received"]){var msg=me.privateMessages["received"][i];if(msg.msgid==_79){me.privateMessages["received"][i].dateread=_7c.data.dateread;break;}}}_7b(_7c);}});},saveBasic:function(_7d,_7e){lemonAjax({url:"/myaccount/savebasic",content:_7d,load:_7e,error:function(err){response.status="savefailed";}});},saveProfilePrefs:function(_7f,_80){lemonAjax({url:"/myaccount/saveprofileprefs",content:_7f,load:_80});},saveCommPrefs:function(_81,_82){lemonAjax({url:"/myaccount/savecommunicationprefs",content:_81,load:_82});},savePassword:function(_83,_84,_85){lemonAjax({url:"/myaccount/savepassword",content:{oldpassword:_83,password:_84},load:_85});},saveDescription:function(_86,_87){lemonAjax({url:"/myaccount/savedescription",content:{selfdescription:_86},load:_87});},savePaypal:function(_88,_89){lemonAjax({url:"/myaccount/save-paypal",content:{paypal:_88},load:function(_8a){_89(_8a);}});},savePointAwardsId:function(_8b,_8c){lemonAjax({url:"/myaccount/save-point-awards-id",content:{pointawardsid:_8b},load:_8c});},sendPrivateMessage:function(_8d,_8e){lemonAjax({url:"/privatemessage/send-private-message",content:{title:_8d.title,comment:_8d.comment,receiverid:_8d.receiverid,threadid:_8d.threadid,parentid:_8d.parentid,senderid:_8d.senderid},load:_8e});},setDefaultVideo:function(_8f,_90,url,_91){lemonAjax({url:"/account/set-default-video",content:{videoid:_8f,network:_90,url:url},load:_91});},stageUserImage:function(_92,_93){dojo.io.iframe.send({form:_92,contentType:"multipart/form-data",handleAs:"json",timeout:15000,load:_93});},getDashboardStands:function(_94){_94.getawards=_94.getawards||false;_94.offset=_94.offset||0;_94.userid=_94.userid||0;lemonAjax({url:"/myaccount/get-dashboard-stands",content:{userpid:_94.userid,limit:_94.limit,offset:_94.offset,getawards:_94.getawards},load:function(_95){var _96=new Object();_96.dashboardStands=[];if(_95.total){_96.totalDashboardStands=_95.total;}for(var s in _95){if(!isNaN(s)){_96.dashboardStands.push(_95[s]);}}_94.callback(_96);}});},getDownloads:function(_97){var me=this;lemonAjax({url:"/account/get-downloads",load:function(_98){if(_98.status=="OK"){me.downloadItems=_98.data.download_items;}_97(_98);}});},getStands:function(_99,_9a,_9b,_9c){if(isNaN(_9b)){_9b=0;}lemonAjax({url:"/user/get-stands",content:{id:_99,limit:_9a,offset:_9b},load:_9c});},getSales:function(_9d){lemonAjax({url:"/myaccount/get-sales",content:{},load:function(_9e){_9d(_9e);}});},getUsers:function(_9f,_a0,_a1,_a2){lemonAjax({url:"/administration/get-users",content:{role:_9f,limit:_a0,offset:_a1},load:_a2});},getUserDetail:function(id,_a3){lemonAjax({url:"/administration/get-user-details",content:{id:id},load:_a3});}};var Lemon_User=new Lemon_User_Type();}if(!dojo._hasResource["lemon.model.authorize"]){dojo._hasResource["lemon.model.authorize"]=true;dojo.provide("lemon.model.authorize");function Lemon_Authorize_Type(){};Lemon_Authorize_Type.prototype={PASSWORD_MIN_LENGTH:4,PASSWORD_MAX_LENGTH:32,status:null,validated:false,url:"",standpid:null,warning:null,errorFields:null,roles:null,requiredRegFields:["email","nickname","password"],ssoStatus:null,requireRegFields:function(_a4){for(var i in _a4){var _a5=_a4[i];if(dojo.indexOf(this.requiredRegFields,_a5)<0){this.requiredRegFields.push(_a5);}}},gigyaValidateLogin:function(_a6,_a7){if(!Lemon_Gigya.prototype.isEnabled()){if(devMode==true){console.warn("gigya API key undefined");}return;}var me=this;var _a8=_a6.eventObj;var _a9={dest:_a6.destination,provider:_a8.provider,signature:_a8.signature,timestamp:_a8.timestamp,uid:_a8.UID};lemonAjax({url:"/authorize/gigya-verify-user",content:_a9,load:function(_aa){if(devMode==true){console.log("gigyaValidateLogin response="+dumpArray(_aa,true));}if(_aa.status=="OK"){me.validated=true;me.url=_aa.url;me.standpid=_aa.standpid;}if(_a7){_a7(_aa);}}});},validateLogin:function(_ab,_ac){var me=this;this.validated=false;lemonAjax({url:"/authorize/verify-user",content:_ab,load:function(_ad){me.status=_ad.status;if(_ad.status=="OK"){me.validated=true;me.url=_ad.url;me.standpid=_ad.standpid;}_ac(_ad);}});},createUser:function(_ae,_af){this.validated=false;var me=this;lemonAjax({url:"/authorize/create-user",content:_ae,timeout:45000,load:function(_b0){ret=_b0;if(_b0.status=="OK"){me.validated=true;me.url=_b0.url;me.standpid=_b0.standpid;if(_b0.warning){me.warning=_b0.warning;}else{me.warning=null;}}if(_b0.errorFields){me.errorFields=_b0.errorFields;}else{me.errorFields=null;}me.status=_b0.status;_af(_b0);}});},forgotPassword:function(_b1,_b2){this.validated=false;lemonAjax({url:"/authorize/forgot-password",content:{email:_b1},load:_b2});},setNewPassword:function(_b3,_b4,_b5){var me=this;lemonAjax({url:"/authorize/set-new-password",content:{token:_b3,newPw:_b4},load:function(_b6){me.status=_b6.status;_b5();}});}};var Lemon_Authorize=new Lemon_Authorize_Type();}if(!dojo._hasResource["lemon.model.product"]){dojo._hasResource["lemon.model.product"]=true;dojo.provide("lemon.model.product");function Lemon_Product_Type(){};Lemon_Product_Type.prototype={getStands:function(_b7,_b8,_b9,_ba){lemonAjax({url:"/product/get-stands",content:{productid:_b7,limit:_b8,offset:_b9},load:_ba});}};var Lemon_Product=new Lemon_Product_Type();}if(!dojo._hasResource["lemon.model.facebook"]){dojo._hasResource["lemon.model.facebook"]=true;dojo.provide("lemon.model.facebook");function Lemon_Facebook_Type(){};Lemon_Facebook_Type.prototype={activateStand:function(_bb,_bc,_bd){lemonAjax({url:"/setup/activate-fb-stand",content:{standid:_bb,facebookuid:_bc},load:function(_be){_bd(_be);}});},getOwnerFriendStands:function(_bf,_c0,_c1){lemonAjax({url:"/facebook/get-owner-friend-stands",content:{limit:_bf,offset:_c0},load:_c1});},getPublicFriendStands:function(_c2){lemonAjax({url:"/facebook/get-public-friend-stands",content:{},load:_c2});},getProducts:function(_c3,_c4,_c5,_c6,_c7){var _c8=new Object();_c8.products=[];lemonAjax({url:"/facebook/get-stand-products",content:{standId:_c3,limit:_c4,offset:_c5,activeOnly:_c6},load:function(_c9){if(!isNaN(_c9.total)){_c8.totalProducts=_c9.total;}for(var key in _c9){if(!isNaN(key)&&typeof (_c9[key])=="object"){_c8.products.push(_c9[key]);}}_c7(_c8);}});},createOwnerPage:function(_ca){lemonAjax({url:"/facebook/create",content:{},load:function(_cb){_ca(_cb);}});},createPublicPage:function(_cc){lemonAjax({url:"/facebook/public-create",content:{},load:function(_cd){_cc(_cd);}});},shopAdded:function(_ce){lemonAjax({url:"/facebook/shopadded",content:{},load:function(_cf){_ce(_cf);}});},productAdded:function(_d0){lemonAjax({url:"/facebook/productadded",content:{},load:function(_d1){_d0(_d1);}});}};var Lemon_Facebook=new Lemon_Facebook_Type();}if(!dojo._hasResource["lemon.model.gigya"]){dojo._hasResource["lemon.model.gigya"]=true;dojo.provide("lemon.model.gigya");var Gigya;var gigyaEnabledProviders=gigyaEnabledProviders||null;dojo.addOnLoad(function(){Gigya=Gigya||new Lemon_Gigya();});function Lemon_Gigya(){this.config={signIDs:true,shortURLs:(BrandGlobals.devMode==true)?"never":"always",APIKey:gigyaAPIKey,enabledProviders:gigyaEnabledProviders};if(BrandGlobals.devMode==true){if(!this.isEnabled()){console.warn("gigya API key undefined");return;}gigya.services.socialize.addEventHandlers(this.config,{onConnect:this.logEvent,onDisconnect:this.logEvent,onLogin:this.logEvent,onLogout:this.logEvent});}};Lemon_Gigya.prototype={PRODUCT_SHARED:"product_shared",PRODUCT_SHARED_FROM_STAND:"stand_product_shared",STAND_SHARED:"stand_shared",SHOP_SHARED:"shop_shared",defaultProductTemplate:"{actor} wants you to check out this product!",defaultProductActionName:"",defaultProductUserMessage:"",defaultStandTemplate:"{actor} wants you to check out this stand!",defaultStandActionName:"",defaultStandUserMessage:"",defaultShopTemplate:"{actor} wants you to check out this shop!",defaultShopActionName:"",defaultShopUserMessage:"Check out these great tunes!",hostAddress:location.protocol+"//"+location.host,_fixupTemplate:function(_d2,_d3){if(!_d2){return "";}_d2=_d2.replace(/%SERVER%/g,this.hostAddress);for(var _d4 in _d3){var _d5=_d3[_d4];if(_d5!=undefined){var re=new RegExp("%"+_d4.toUpperCase()+"%","g");_d2=_d2.replace(re,_d5);}}if((BrandGlobals.devMode==true)&&(_d2.indexOf("%")!==-1)){console.warn("Possible unsubstituted sharing template string: "+_d2);}return _d2;},_recordShare:function(_d6,_d7){var _d8=_d7.context;if(_d8!=undefined){var _d9=_d7.providers.split(",");var _da=_d9.length;var _db={sharetype:_d6};for(var _dc in _d8){_db[_dc.toLowerCase()]=_d8[_dc];}if(_da>0){lemonAjax({url:"/stat/record-share",content:_db,load:function(_dd){if(_dd.status!="OK"){devError("Problem recording share; gigyaResponse="+dumpObject(_d7,true));}}});}}else{devError("_recordShare: context expected");}},_share:function(_de,_df){var _e0=_df.templateValues;_df.actionLink=this._fixupTemplate(_df.actionLink,_e0);_df.name=this._fixupTemplate(_df.name,_e0);_df.description=this._fixupTemplate(_df.description,_e0);_df.linkBackURL=this._fixupTemplate(_df.linkBackURL,_e0);_df.template=this._fixupTemplate(_df.template,_e0);_df.userMessage=this._fixupTemplate(_df.userMessage,_e0);var act=new gigya.services.socialize.UserAction();act.setTitle(_df.name);act.setDescription(_df.description);act.setLinkBack(_df.linkBackURL);act.setTemplate(_df.template);act.setUserMessage(_df.userMessage);if(_df.actionLinkTitle!=undefined){act.addActionLink(this._fixupTemplate(_df.actionLinkTitle,_e0),_df.actionLink);}if(_df.imageURL!=undefined){act.addMediaItem({type:"image",src:this._fixupTemplate(_df.imageURL,_e0),href:_df.linkBackURL});}if(_df.flashURL!=undefined){act.addMediaItem({type:"flash",src:this._fixupTemplate(_df.flashURL,_e0),width:_df.width||_df.flashWidth,height:_df.height||_df.flashHeight,previewImageURL:this._fixupTemplate(_df.previewImageURL,_e0),previewImageWidth:_df.previewImageWidth,previewImageHeight:_df.previewImageHeight});}var _e1=this;var _e2=new Object();if(_df.containerID){_e2.containerID=_df.containerID;}_e2.context=_df.context;_e2.onError=_df.onError||this.logEvent;_e2.onSend=_df.onSend||this.logCallback;_e2.onSendDone=function(_e3){_e1.logCallback(_e3);if(_e3.context!=undefined){_e1._recordShare(_de,_e3);}if(_df.onSendDone){_df.onSendDone(_e3);}};_e2.userAction=act;_e2.enabledProviders="facebook,twitter,yahoo,google,myspace,orkut";_e2.moreEnabledProviders="linkedin,messenger,delicious, digg, friendfeed, googlebuzz, googlebookmarks, myaol, stumbleupon, livebookmarks, technorati, plaxo, slashdot, reddit, Tumblr, faves, newsvine, fark, mixx, Bit.ly, misterwong, ask, amazon, gmail, baidu, box.net, netlog, evernote, aolmail, propeller, currenttv, simpy, yardbarker, blinklist, diigo, sphinn, backflip, dropjack, segnalo, linkagogo, kaboodle, skimbit, Hyves, facebookshare, twitter, yahoobookmarks";gigya.services.socialize.showShareUI(this.config,_e2);},getProviderName:function(_e4){return _e4.substring(0,1).toUpperCase()+_e4.substring(1);},isEnabled:function(){return (gigyaAPIKey!=undefined)&&(gigyaAPIKey.length>0);},logCallback:function(_e5){if(BrandGlobals.devMode==true){console.log("GIGYA callback: "+dumpObject(_e5,true)+(_e5.context?"; context: "+dumpObject(_e5.context,true):""));}},logEvent:function(_e6){if(BrandGlobals.devMode!=true){return;}console.log("GIGYA EVENT: \""+_e6.eventName+"\""+(_e6.context?", context: "+dumpObject(_e6.context,true):""));if(_e6.eventName){switch(_e6.eventName.toLowerCase()){case "error":if(_e6.status){console.error("  status: "+_e6.status+", msg: "+_e6.statusMessage);}if(_e6.errorCode){console.error("  errorCode: "+_e6.errorCode+", errorMsg: "+_e6.errorMessage);}break;}}var _e7=_e6.user;if(_e7!=undefined){console.info("user = {"+dumpObject(_e7,true)+"}");console.info("capabilities = {"+dumpObject(_e7.capabilities,true)+"}");var _e8="";for(var _e9 in _e7.identities){if(_e8.length>0){_e8+=", ";}_e8+="["+_e9+" -- "+dumpObject(_e7.identities[_e9],true)+"]";}console.info("identities = {"+_e8+"}");}},shareProduct:function(_ea){_ea.template=_ea.template||this.defaultProductTemplate;_ea.userMessage=_ea.userMessage||this.defaultProductUserMessage;_ea.actionLinkTitle=_ea.actionLinkTitle||this.defaultProductActionLinkTitle;_ea.actionLink=_ea.actionLink||this.defaultProductActionLink;var _eb=this.PRODUCT_SHARED;var _ec=_ea.context;if(_ec&&_ec.standid){_eb=this.PRODUCT_SHARED_FROM_STAND;}this._share(_eb,_ea);},shareStand:function(_ed){_ed.linkBackURL=_ed.linkBackURL||"%SERVER%/stand/index/id/"+_ed.standid;_ed.template=_ed.template||this.defaultStandTemplate;_ed.userMessage=_ed.userMessage||this.defaultStandUserMessage;_ed.actionLinkTitle=_ed.actionLinkTitle||this.defaultStandActionLinkTitle;_ed.actionLink=_ed.actionLink||this.defaultStandActionLink;this._share(this.STAND_SHARED,_ed);},shareShop:function(_ee){_ee.linkBackURL=_ee.linkBackURL||"%SERVER%/band/%SHOP_ADDR%";_ee.userMessage=_ee.userMessage||this.defaultShopUserMessage;_ee.actionLinkTitle=_ee.actionLinkTitle||this.defaultShopActionLinkTitle;_ee.actionLink=_ee.actionLink||this.defaultShopActionLink;this._share(this.SHOP_SHARED,_ee);},toString:function(){return "Lemon_Gigya";},unlinkAccounts:function(){gigya.services.socialize.unlinkAccounts(this.config,{callback:this.logCallback});}};}

