window.addEvent('domready', function() {
	
	// MAIN PAGE NEWS LIST LOADER
	var getNews = new Request({
		url: curLang == 'rus' ? "/" : "/" + curLang + "/",
		onSuccess: function(txt){
			$('news_block').set('html', txt);
		},
		onFailure: function(){
			$('news_block').set('html', 'No news');
		}

	});
	$('news_block').set('html', "<div style='text-align:center;padding:150px 0'><img src='/images/spinner.gif'></div>");
	getNews.send("height=" + $('top_block').getStyle('height') + "&resolution=" + this.size().width);
	
	// TOP NEWS
	$('top_news').getElement('li').addClass('current');
	// top news titles handler
	$('top_news').getElements('li').addEvent('mouseover:pause', function(e){
		e.stop();
		if ($('topPhotoContainer').getElement('img').get('src') == topNews[this.id]['src']) return;
		this.getSiblings('li').each(function(el){
			el.removeClass('current');
		});
		$('topPhotoContainer').getElement('img').set('src', topNews[this.id].src);
		$('topPhotoContainer').getElement('img').set('alt', this.get('text'));
		var a = $('topPhotoContainer').getElement('img').getParent('a');
		a.set('title', this.get('text'));
		a.set('href', this.getElement('a').getProperty('href'));
		this.addClass('current');
	});
	$('top_news').getElements('li:first-child').addEvent('mouseover', function(){
		if ($('topPhotoContainer').getElement('img').get('src') == topNews['first']['src']) return;
		$('topPhotoContainer').getElement('img').set('src', topNews['first'].src);
		this.getSiblings('li').each(function(el){
			el.removeClass('current');
		});
		this.addClass('current');
	});
});
