function Rotator(name, width, height, time) {
	this.addImage = _addImage
	this.write = _write
	this.rotNext = _rotNext
	this.newRot = _newRot
	this._rotImages = new Array()
	this._rotSize = 0
	this._current = 1
	
	this._name = name;
	this._width = width;
	this._height = height;
	this._time = time;
}

function _addImage(source) {
	var tmp = new Image()
	tmp.src = source
	this._rotImages[this._rotSize] = new Object()
	this._rotImages[this._rotSize].src = source
	this._rotSize++;
}

function _rotNext(){
	document.images[this._name+ 'Rotator'].src = this._rotImages[this._current].src;
	//alert(document.images[this._name+ 'Rotator'].src);
	setTimeout(this._name+'.newRot()',this._time)
}

function _newRot(){
	this._current++;
	if (this._current >= this._rotSize)
		this._current = 0;
	this.rotNext();
}

function _write(){
	tempCode = '<!a href="javascript:'+this._name+'"';
	tempCode += '>';
	tempCode += '<img src="' + this._rotImages[this._current].src + '" width="' + this._width;
	tempCode += '" height="' + this._height + '" name="' + this._name + 'Rotator"></a>';
	document.write(tempCode);
	this.rotNext();
	/*tempCode = "";
	if (this.mySize > 1){
		if (this.currentAd == null) this.randomAd();
		if (this.currentAd >= this.mySize) this.currentAd = this.mySize - 1;
		tempCode = '<!a href="javascript:'+this.objName+'.link()"';
		tempCode += ' onMouseOver="' + this.objName + '.showStatus(); return true"';
		tempCode += ' onMouseOut="status=\'\';return true">';
		tempCode += '<img src="' + this.ads[this.currentAd].src + '" width="' + this.width;
		tempCode += '" name="' + this.objName + 'Img" height="' + this.height + '" ';
		if (this.altText) tempCode += 'alt="'+this.altText + '" ';
		tempCode += 'border="0" ></a>';
		document.write(tempCode);
		this.nextAd();
	} else document.write("Virhe: Vähintään kaksi banneria jotta homma toimii.");*/
}
