Type.registerNamespace("MotorShout");MotorShout.AddFavorite=function(a){MotorShout.AddFavorite.initializeBase(this,[a]);this.userId=null;this.modelId=null;this.isSaving=false;this.imageFormat="fave{0}"};MotorShout.AddFavorite.prototype={initialize:function(){MotorShout.AddFavorite.callBaseMethod(this,"initialize");$addHandlers(this.get_element(),{click:this._onClick},this);var a=this.get_element()},dispose:function(){$clearHandlers(this.get_element());MotorShout.AddFavorite.callBaseMethod(this,"dispose")},_onClick:function(){!this.isSaving&&this.save()},save:function(){var a=this.get_element();a.innerHTML="Saving...";this.isSaving=true;if(this.modelId==null)this.modelId=a.id;MotorShout.Web.Services.WebService.ToggleFavorite(this.userId,this.modelId,this._onSaveCompleted,this._onSaveFailed,this);this.close()},_onSaveCompleted:function(b,a){var c=a.get_element();c.className=String.format(a.imageFormat,b);c.title=b?"Remove from Garage":"Add to Garage";c.innerHTML=b?"Remove from Garage":"Add to Garage";a.isSaving=false},_onSaveFailed:function(c,a){var b=a.get_element();b.className=String.format(a.imageFormat,"true");b.innerHTML=c.get_message()},close:function(){var a=this.get_element();a.style.display=""},get_UserId:function(){return this.userId},set_UserId:function(a){this.userId=a},get_ModelId:function(){return this.modelId},set_ModelId:function(a){this.modelId=a}};MotorShout.AddFavorite.registerClass("MotorShout.AddFavorite",Sys.UI.Behavior);