rb.registerNamespace("rb.widget");
rb.widget.buttonset = rb.widget.base.extend({
	get_runView: function () {
		return this._runView
	},
	set_runView: function (a) {
		this._runView = a
	},
	init: function () {
		this._super();
		this._runView = null;
		this._registeredSets = {};
	},
	updateButton: function (a, h) {
		var e = a.attr("buttonkey");
		var c = a.attr("comingsoon");
		var b = a.siblings(".rb-ribbon");
		if (h === undefined) {
			h = this.resolveButtonSet(a)
		}
		var g = "";
		var f = "";
		var d = "";
		d = this.get_find();
		g = "rb-red rb-btn-find";
		f = "rb-ribbon-red"
		if (a.find(".ui-button-text").size() > 0) {
			a.find(".ui-button-text").html("<span>" + d + "</span>");
			a.removeClass("rb-red rb-blue rb-orange rb-btn-remind rb-btn-reminded rb-btn-cart rb-btn-rent rb-btn-find rb-btn-oos").addClass(g)
		} else {
			a.html(d);
			a.addClass(g)
		}
		if (b.size() > 0) {
			b.removeClass("rb-ribbon-red rb-ribbon-blue rb-ribbon-orange").addClass(f)
		}
	},
	createButton: function (c) {
		var b = rb.component.findFirstByType("buttonset");
		var a = c.find("[buttonkey]:first");
		b.updateButton(a, b.resolveButtonSet(a));
		if (a.attr("latebind") != "true") {
			b.registerSingle(a)
		}
	},
	onClick: function (a) {
		this._onButtonClicked(a)
	},
	refresh: function (a) {
		this._onRegistered(this._registeredSets[a].find(".rb-btn-unreg"))
	},
	register: function (d, c, a, b) {
		if (this._registeredSets[d] != undefined && this._registeredSets[d].autoUpdate == true) {
			return
		}
		this._registeredSets[d] = c;
		if (a == true) {
			this._registeredSets[d].autoUpdate = true;
			this._registeredSets[d].auCallback = b
		} else {
			this._registeredSets[d].autoUpdate = false;
			this._registeredSets[d].auCallback = null
		}
		this.refresh(d)
	},
	registerSingle: function (a) {
		this._onRegistered(a)
	},
	resolveButtonSet: function (a) {
		return a.parents("[buttonset]:first").attr("buttonset")
	},
	_onLoad: function (a, b) {
		if ($("[buttonset]").size() > 0) {
			var c = this;
			$("[buttonset]").each(function () {
				var e = $(this);
				c.register(e.attr("buttonset"), e)
			});
		}
	},
	_onButtonClicked: function (e) {
		var b = $(e.currentTarget);
		var f = b.attr("buttonkey");
		var h = this._getProduct(f);
		var c = this;
	},
	_onRegistered: function (a) {
		a.button().removeClass("rb-btn-unreg").addClass("rb-btn-reg").unbind("click").click(rb.createDelegate(this, this._onButtonClicked))
	},
	_refreshButtons: function (a) {
	},
	_recordClick: function (d, b, e, c) {
	}
});
