function LoadSubscriptions(e,c,d){for(var b=getElementsByClassName(c,"div",null),a=0;a<b.length;a++)$create(MotorShout.SubscribeMake,{UserId:e,ManufacturerId:d},null,null,b[a])}Type.registerNamespace("MotorShout");MotorShout.SubscribeMake=function(a){MotorShout.SubscribeMake.initializeBase(this,[a]);this.userId=null;this.manufacturerId=null;this.isSaving=false};MotorShout.SubscribeMake.prototype={initialize:function(){MotorShout.SubscribeMake.callBaseMethod(this,"initialize");$addHandlers(this.get_element(),{click:this._onClick},this);var a=this.get_element()},dispose:function(){$clearHandlers(this.get_element());MotorShout.SubscribeMake.callBaseMethod(this,"dispose")},_onClick:function(){!this.isSaving&&this.save()},save:function(){var a=this.get_element();a.innerHTML="Saving...";this.isSaving=true;if(this.manufacturerId==null)this.manufacturerId=a.id;MotorShout.Web.Services.WebService.ToggleSubscription(this.userId,this.manufacturerId,this._onSaveCompleted,this._onSaveFailed,this);this.close()},_onSaveCompleted:function(a,c){var b=c.get_element();b.className=a?"on":"off";b.title=a?"Unsubscribe":"Subscribe";b.innerHTML=a?"Unsubscribe":"Subscribe";c.isSaving=false},_onSaveFailed:function(c,b){var a=b.get_element();a.className="on";a.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_ManufacturerId:function(){return this.manufacturerId},set_ManufacturerId:function(a){this.manufacturerId=a}};MotorShout.SubscribeMake.registerClass("MotorShout.SubscribeMake",Sys.UI.Behavior);
