rb.registerNamespace("rb.widget");
rb.widget.slideshow = rb.widget.base.extend({
	get_slides: function () {
		return this._slides
	},
	set_slides: function (a) {
		this._slides = a
	},
	get_slideDuration: function () {
		return this._slideDuration
	},
	set_slideDuration: function (a) {
		this._slideDuration = a
	},
	get_slideTransition: function () {
		return this._slideTransition
	},
	set_slideTransition: function (a) {
		this._slideTransition = a
	},
	init: function () {
		this._super();
		this._slides = null;
		this._widget = null;
		this._playerDialog = null;
		this._slideDuration = null;
		this._slideshow = null;
		this._container = null;
		this._slideTransition = null;
		this._delegates = {
		}
	},
	_onLoad: function (c, d) {
		this._super(c, d);
		this._widget = this.getControl("Widget");
		this._container = this.getControl("Container");
		this._buttonSetWidget = rb.component.findFirstByType("buttonset");
		if (this._buttonSetWidget) {
			var b = this._widget.find("[buttonset]");
			this._buttonSetWidget.register(b.attr("buttonset"), b, true, rb.createDelegate(this, this._onButtonUpdate))
		}
		this._slideshow = this._widget.find(".slideshow");
		this._slideshow.cycle({
			fx: "fade",
			speed: this._slideTransition,
			timeout: this._slideDuration,
			pager: ".navlist",
			next: ".next",
			prev: ".prev",
			pause: 1,
			before: this._onSlideChange,
			pauseOnPagerHover: 1,
			pagerAnchorBuilder: function (f, e) {
				return ".navlist li:eq(" + (f) + ") a"
			}
		});
		this._container.show()
	},
	_onButtonUpdate: function (a) {
		if (a.state == "pending") {
			this.lock()
		}
		if (a.state == "completed") {
			this.unlock()
		}
	},
	_onSlideChange: function (e, c, g) {
		var a = $(e).attr("slideID");
		var d = $(c).attr("slideID");
		var f = $(this).parent().parent().find(".highlight");
		var b = f.attr("slideID");
		$(f).each(function () {
			if ($(this).attr("slideID") == a) {
				$(this).hide()
			}
			if ($(this).attr("slideID") == d) {
				$(this).show()
			}
		})
	},
	_resetPage: function (c, b) {
		if (c == null) {
			c = []
		}
		for (index = 0; index < this._slides.length; index++) {
			var a = this._inStock(c, this._slides[index]);
			this._setButtonState(this._slides[index]["ReferenceNumber"], a, b)
		}
	},
	_getCurrentSlide: function (b) {
		var c = null;
		var d = $(b.target).parents("div[key]:first");
		var a = d.attr("key");
		$.each(this._slides, function (e) {
			if (this["ReferenceNumber"] == a) {
				c = this
			}
		});
		return c
	}
});
