
function classPowerplay(){
	this.timerID = 0;
	this.tStart = null;
	
	this.delay = 1000;

	this.htmlArray = new Array();
	
	//this.count = rand(this.htmlArray.length);
	this.count=0;
	
	this.init = function(){
		document.getElementById(this.divName).appendChild(this.htmlArray[this.count]);
	}
	
	this.addHtml = function(htmlToAdd){
		this.htmlArray.push(htmlToAdd);
	}
	
	this.change = function(){
		// do nothing if we have only one banner
		if(this.htmlArray.length<2) {
			return;
		}
		if(this.timerID){
			clearTimeout(this.timerID);
			this.clockID = 0;
		}
		if(this.count<this.htmlArray.length-1){
			this.count++;
		}else{
			this.count = 0;
		}
		document.getElementById(this.divName).replaceChild(this.htmlArray[this.count], document.getElementById(this.divName).lastChild);
		//window.status="set Element " + this.count;
	}
	
	this.stop = function(){
		if(this.timerID){
			clearTimeout(this.timerID);
			this.timerID = 0;
		}
	}
}

function changePowerplay(powerplayObject, delay){
	setTimeout(powerplayObject + ".init()",1);
	setInterval(powerplayObject + ".change()", delay);
}
