$(document).ready(function(){
	if ($("#home-news ul.news > li").size() > 2) {
		$("#home-news ul.news li:even").each(function () {
			$(this).add($(this).next()).wrapAll('<span class="news-pair"></span>');
		});
		$("#home-news ul.news").cycle({
			fx: 'fade',
			speed: 'slow',
			timeout: 10000,
			next: '#home-next',
			prev: '#home-prev',
			slideExpr: 'span.news-pair',
			fastOnEvent: 1,
			cleartype: true,
			cleartypeNoBg: true
		});
	} else { 
		$(".nav-news").hide();
	}
	
	$(function() {   

	var theWindow        = $(window),
		$bg              = $("#bg"),
		aspectRatio      = 1.6;
		
	function resizeBg() {
		if ( (theWindow.width() / theWindow.height()) < aspectRatio ) {
			$bg
				.removeClass()
				.addClass('bgheight')
				//.attr({height: (theWindow.height()-131)});
		} else {
			$bg
				.removeClass()
				.addClass('bgwidth')
				//.attr({height: (theWindow.height()-131)});
		}
	}
								
	theWindow.resize(function() {
		resizeBg();
	}).trigger("resize");
	});
	
	jQuery.event.add(window, "load", resizeFrame);
	jQuery.event.add(window, "resize", resizeFrame);					
	function resizeFrame() 
	{
		var h = $(window).height();
		$("#centered").css('height',(h-220));
		$(".keepcentered").css('visibility','visible');
	}
	
});
