function slides() {

	this.getSlides = function() {
		elArray = new Array();
		var els = document.getElementsByTagName("div");
		var elsLen = els.length;
		var pattern = new RegExp("slides");
		for (i = 0, j = 0; i < elsLen; i++) {
			if ( pattern.test(els[i].className) ) {
				elArray[j] = els[i];
				j++;
			}
		}

		return elArray;
	}

	this.numberSlides = function() {
		var els = document.getElementsByTagName("div");
		var elsLen = els.length;
		var pattern = new RegExp("slides");
		for (k = 0, l = 0; k < elsLen; k++) {
			if ( pattern.test(els[k].className) ) {
				l++;
				var itn = els[k].getElementsByTagName("span");
				var itnLen = itn.length;
				var itnPatt = new RegExp("itemno");
				for (m=0;m<itnLen;m++) {
					if ( itnPatt.test(itn[m].className) ) {
						itn[m].innerHTML=l+" of "+this.amount;
					}
				}
			}
		}
	}

	this._prev = function() {
		this.getSlides()[this.position-1].style.display = "none";
		if (this.position <= 1) {
			this.position = this.amount;
		} else {
			this.position--;
		}
		this.getSlides()[this.position-1].style.display = "block";
	}

	this._next = function() {
		this.getSlides()[this.position-1].style.display = "none";
		if (this.position >= this.amount) {
			this.position = 1;
		} else {
			this.position++;
		}
		this.getSlides()[this.position-1].style.display = "block";
	}

	this.next = function() {
		this.autoplay = 0;
		this._next();
	}

	this.prev = function() {
		this.autoplay = 0;
		this._prev();
	}

	/* constructor */
	this.amount = this.getSlides().length;
	this.numberSlides;
	this.autoplay = 1;

	if (this.amount > 0) {
		this.position = 1;
		this.getSlides()[this.position-1].style.display = "block";
		this.numberSlides();
	} else {
		this.position = 0;
	}

}

function init() {
	mySlide = new slides();
	if (mySlide.position > 0) {
		timer = window.setInterval("doTimer()", 5500);
		return true;
	} else {
		return false;
	}
}

function destroy() {
	clearInterval(timer);
}

function doTimer() {
	if (mySlide.autoplay == 1)
		mySlide._next();
}