var news, News = new Class({
	initialize: function() {
		// Set variables
		this.news = $(document.body).getElement('div.news');
		this.feed = this.news.getElement('ul');
		this.pos = 0;
		// Fade in
		this.news.setStyles({'opacity': 0, 'visibility': 'visible'});
		// Events
		if ($chk($(document.body).getElement('ul.pagination'))) {
			(function() { new Fx.Tween(this.news, {duration: 1000, property: 'opacity'}).start(1); }).delay(1500, this);
			this.events();
		}
	},
	events: function() {
		this.pages = $(document.body).getElement('ul.pagination');
		this.pages.getElement('a').addClass('focus');
		var tween = new Fx.Tween(this.feed, {duration: 500, link: 'cancel', property: 'margin-top'});
		this.pages.getElements('a').addEvents({
			'mouseenter': function() {
				news.pages.getElements('a')[news.pos].removeClass('focus');
				this.addClass('focus');
			},
			'mouseleave': function() {
				this.removeClass('focus');
				news.pages.getElements('a')[news.pos].addClass('focus');
			},
			'click': function() {
				// Keep position in mind
				var pos = this.get('href').substr(5).toInt()-1;
				// Show/hide news
				tween.start(pos*-246);
				// Focus/unfocus
				news.pos = pos;
				// Stop event
				return false;
			}
		});
	}
});

window.addEvent('domready', function(){ news = new News });
