var SlidingNews = new Class({
	stop: false,
	initialize: function(element) {
		this.element = element;
		if (this.element.getSize().y>this.element.getParent().getSize().y) {
			this.children = this.element.getChildren();
			this.last = this.children[this.children.length-1];
			this.height = this.last.getStyle('height').toInt()+this.last.getStyle('padding-top').toInt()+this.last.getStyle('padding-bottom').toInt()+this.last.getStyle('margin-top').toInt()+this.last.getStyle('margin-bottom').toInt();
			this.slidingHeight = this.element.getSize().y.toInt()-this.height;
			
			this.element.addEvent('mouseenter',this.stopRotate.bind(this));
			this.element.addEvent('mouseleave',this.replay.bind(this));
			this.init.delay(3000,this);
		}
	},

	init: function(){
		(function(){
			if (!this.stop)
				this.start.bind(this)();
		}.bind(this)).periodical(60,this);
	},

	replay: function(){
		this.stop = false;
	},

	stopRotate: function(){
		this.stop = true;
	},

	start: function() {
		if (this.slidingHeight<=Math.abs(this.element.getStyle('top').toInt())) {
			this.stopRotate();
			(function(){
				this.element.setStyle('top',0);
				this.replay();
			}).delay(5000,this);
		}
		this.element.setStyle('top',this.element.getStyle('top').toInt()-1);
		//this.element.tween('top',this.element.getStyle('top').toInt()-5);
	}
});

window.addEvent('domready', function(){
	var sliders = $$('.content_news .slider');
	if (sliders.length>0)
		new SlidingNews(sliders[0]);
});
