

function informer_rotator ( informers, captions, options ) {
	
	this.options = { timeout : 5000, caption : null, img : null };
	
	if ( options && typeof options == 'object' ) {
		
		var t;
		if ( options['timeout'] && 
			( t = parseInt(options['timeout']) ) >= 100 ) 
		{ this.options['timeout'] = t; }
		
		if ( options['caption'] && 
			typeof options['caption'] == 'object' ) 
		{ this.options['caption'] = options['caption']; }
		
		if ( options['img'] ) 
		{ this.options['img'] = options['img']; }
		
		if ( options['url'] ) {
			this.options['url'] = options['url'];
		}
	}
	
	if ( !this.options['img'] ) { throw new Error("informer_rotator: " + 
		"img object is not defined" ); }
		
	if ( informers && captions && 
		 captions.length > 0 && 
		 captions.length == informers.length ) 
	{
		this.informers = informers;
		this.captions  = captions;
	}
	this.current_id = 0;
}

informer_rotator.prototype.get_id = function () {
	
	if ( this.current_id >= this.informers.length - 1 ) {
		this.current_id = 0;
	} else {
		this.current_id++;
	}
	return this.current_id;
}

informer_rotator.prototype.rotate = function () {
	
	var id = this.get_id();
	try {
	this.options['img'].Update_URL( this.informers[id], true, 30, 2, "reset" );
	} catch (e) {}
	this.options['caption'].innerHTML = "<a href='" + this.options['url'] + "'>" + this.captions[id] + "</a>";
}

informer_rotator.prototype.go = function () {
	
	var THIS = this;
	var loop = function () {
		THIS.rotate();
		setTimeout( loop, THIS.options['timeout'] );
	}
	setTimeout( loop, this.options['timeout'] );
}


