
/* SLIDE BAR */

function SlideBar11(id, type, self, time, autostart) {
	this.obj = [];
	this.button = [];
	this.timer;
	this.time = time;
	this.now = 0;
	this.self = self;

	this.show = function(id) {
		if (typeof this.timer != 'undefined') clearTimeout(this.timer);
		if (this.button[this.now]) eval(this.self+'_off(this.button[this.now])');
		this.obj[this.now].style.display = "none";
		if (typeof id == 'undefined') {
			this.now++;
		}
		else {
			this.now = id;
		}
		if (this.now<0 || this.obj.length<=this.now) {
			this.now = 0;
		}
		if (this.button[this.now]) eval(this.self+'_on(this.button[this.now])');
		this.obj[this.now].style.display = "block";
		if (typeof id == "undefined") {
			this.timer = setTimeout(this.self+".show();", this.time);
		}
	}

	this.roll = function(i) {
		i += this.now;
		if (i<0) {
			i *= -1;
			i %= this.obj.length;
			i = this.obj.length - i;
		}
		else if (this.obj.length<=i) {
			i %= this.obj.length;
		}
		this.show(i);
	}

	this.slide = function() {
		this.timer = setTimeout(this.self+".show();", this.time);
	}

	this.init = function(id, type, self, time, autostart) {
		if (typeof autostart == 'undefined') {
			autostart = 1;
		}
		var parent = document.getElementById(id);
		var objs = parent.getElementsByTagName(type);
		var j = 0;
//		for (var i in objs) {
		for (var i=0; i<objs.length; i++) {
			if (objs[i].parentNode == parent) {
				this.obj[j] = objs[i];
				if (j > 0) objs[i].style.display = 'none';
				j++;
			}
		}
		if (autostart) this.slide();
	}
	this.init(id, type, self, time, autostart);

	this.addButtons = function(id, vertical) {
		if (typeof vertical == 'undefined') {
			vertical = 0;
		}
		var button;
		for (i=0; i<this.obj.length; i++) {
			button = document.createElement('img');
			if (i == 0) eval(this.self+'_on(button)');
			else eval(this.self+'_off(button)');
			button.style.padding = "0 2px";
			button.onmouseover = new Function(this.self+".show('"+i+"');");
			button.onmouseout = new Function(this.self+".slide();");
			button.setAttribute('onMouseOver', this.self+".show('"+i+"');");
			button.setAttribute('onMouseOut', this.self+".slide();");
			this.button[i] = document.getElementById(id).appendChild(button);
			if (vertical) {
				document.getElementById(id).appendChild(document.createElement('br'));
			}
		}
	}

	this.setButtons = function(id, type) {
		var parent = document.getElementById(id);
		var objs = parent.getElementsByTagName(type);
		var j = 0;
		for (var i in objs) {
			if (objs[i].parentNode == parent) {
				this.button[j] = objs[i];
				j++;
			}
		}
	}
}




