var GS_FlashNews = new Class({
	Implements: Options,

	options: {
		myInterval: 7000,
		myDuration: 1000,
		myHeight: 200
	},
	
	initialize: function(containerId, options){
		var gotMore = true;
		var i=1;
		var tmpObj;
		while (gotMore)    {
			tmpObj = document.getElementById(containerId + i);
			if (tmpObj != null)       {
				tmpObj.style.height='0';
				i++;
			} else {
				gotMore = false;
			}
		}
		this.options=options;
		if (i <= 1) return; // no more than one element, then stop
		this.currentId = 0;
		var self = this; 
		setInterval(function(){self.nextNews(containerId,i-1);}, this.options.myInterval);
	},
	nextNews: function(containerId,noMore){
		// calculate next id
		var nextId = this.currentId+1;
		if (nextId>noMore){nextId=0;}
		// no this in setTimeout
		var myHeight = this.options.myHeight; 
		var myDuration = this.options.myDuration; 
		// hide old
		var oldEl = document.getElementById(containerId + this.currentId);
		new Fx.Style(oldEl,'height',{duration:myDuration}).start(myHeight,0);
		// expand next when shrink is finished
		var newEl = document.getElementById(containerId + nextId);
		setTimeout(function(){new Fx.Style(newEl,'height',{duration:myDuration}).start(0,myHeight);},myDuration);
		this.currentId=nextId;
	}
});	
