// JavaScript Document

function playNews() {
		this.el = $('newscontainer');
    	this.items = this.el.getElements('div');
		this.current = 0;
		w = 160;
		this.h = 115;
}

function next() {
		this.fx = new Fx.Tween(this.items[this.current],{duration: 2000, onComplete:function() {
				var i = (this.current==0)?this.items.length:this.current;
				this.items[i-1].injectInside(this.el);
				this.fx.item.setStyles({'margin-top': 0});
		}.bind(this)});
		this.fx.item = this.items[this.current];
		this.fx.start('margin-top', 0, -this.h);
		this.current++;
		if (this.current >= this.items.length) this.current = 0;
}

(function(){
	window.addEvent('domready', function(){
	    playNews();
		if(this.items.length > 1)
			this.aktiveThisNews =  function(){ this.next();}.periodical(5000);
     });
})();
