function toggle(id) {
    var element = document.getElementById(id);
    with (element.style) {
        if ( display == "none" ){
            display = ""
        } else{
            display = "none"
        }
    }
}


function Rotator(name) {
    this.id=name;
    this.banners=[];
    this.bannerIndex=0;
    this.duration=5; // 5 секунд на показ баннера по умолчанию
}

Rotator.prototype.add=function(id) {
    this.banners[this.banners.length]=id;
}

Rotator.prototype.setDuration=function(pause) {
    if (pause!=undefined && parseInt(pause)!=NaN) {
	this.duration=pause;
    }
}

Rotator.prototype.rotate=function(startPause) {
    var currentDuration;
    if (startPause!=undefined && parseInt(startPause)!=NaN) {
	currentDuration=startPause;
    } else {
	currentDuration=this.duration;
    }
    setTimeout(this.id+".change()",currentDuration*1000);
}

Rotator.prototype.change=function() {
    if (this.banners.length>1) {
	var oldindex=this.bannerIndex;
	this.bannerIndex=(this.bannerIndex+1) % this.banners.length;
	toggle(this.banners[oldindex]);
	toggle(this.banners[this.bannerIndex]);
    }
    this.rotate();
}