// requires prototype.js, swfobject.js

var Banner_swf = Class.create({
	initialize: function(container, folder, w, h) {
		this.container = container;
		this.folder = folder;
		this.w = w;
		this.h = h;
		this.n = 0;
		this.banners = [];
		$(this.container).select(".item").each(function(element) {
			this.banners.push(element.id);
		}.bind(this));
		this.timeout = window.setTimeout(this.rotate.bind(this), 0);
	},

	rotate: function() {
		var id_array = this.banners[this.n].split("|");
		var name = id_array[0];
		var duration = parseFloat(id_array[1]);
		if (name.indexOf(".swf") > -1 && $(this.banners[this.n] + "_swf")) {
			swfobject.embedSWF("/" + sf + this.folder + name, this.banners[this.n] + "_swf", this.w, this.h, "9.0.0");
		}
		$(this.container).select('.item').each(function(element) {
			element.hide();
		});					 
		$(this.banners[this.n]).show();

		this.n++;
		if (this.n >= this.banners.size()) this.n = 0;
		this.timeout = window.setTimeout(this.rotate.bind(this), duration + 500);
	}

});
