$('document').ready(function(){

if(jQuery.browser.msie && jQuery.browser.version < 9){
		DD_roundies.addRule('#page-content h1','10px 10px 0 0');
		DD_roundies.addRule('.widget h2','10px 10px 0 0');
		DD_roundies.addRule('.widget','10px 10px 10px 10px');
}

$('#bodyBG').css('display','block');
fullBG();
loImageFade();
})

$(window).resize(function(){
fullBG();
});

function fullBG(){
var ratio = F_width / F_height;

windowW = $('body').width();
windowH = $('body').height();

if(windowW/windowH > ratio){
	//alert('testW');
	$('#bodyBG').css('height','auto');
	$('#bodyBG').css('width',windowW+'px');
	$('#bodyBG').css('marginLeft',-(windowW/2)+'px');
	$('#bodyBG').css('marginTop',-(windowW/ratio/2)+'px');
}
else{
	//alert('testH');
	$('#bodyBG').css('width','auto');
	$('#bodyBG').css('height',windowH+'px');
	$('#bodyBG').css('marginLeft',-(windowH*ratio/2)+'px');
	$('#bodyBG').css('marginTop',-(windowH/2)+'px');
}
}

function loImageFade(){
	fadeToNext = function(){
		theActive = $('.fadeImages').find('.active');
		theActive.fadeTo(400,0);
		theActive.removeClass('active');
		if(theActive.next().length > 0){
			theActive.next().fadeTo(400,1);
			theActive.next().addClass('active');
			$('.fadeIndicator').find('.active').removeClass('active').next().addClass('active');
		}
		else{
			$('.fadeImages').children('li:first').fadeTo(400,1);
			$('.fadeImages').children('li:first').addClass('active');
			$('.fadeIndicator').find('li:last').removeClass('active');
			$('.fadeIndicator').find('li:first').addClass('active');
		}
	}
	
	fadeTo = function(offset){
		if($('.fadeIndicator').find('.active')[0] != $('.fadeIndicator').find('li')[offset]){
		theActive = $('.fadeImages').find('.active');
		theActive.fadeTo(400,0);
		theActive.removeClass('active');		
		
		$($('.fadeImages').children('li')[offset]).fadeTo(400,1);
		$($('.fadeImages').children('li')[offset]).addClass('active');
		
		
		$('.fadeIndicator').find('li').removeClass('active');
		$($('.fadeIndicator').find('li')[offset]).addClass('active');
		}
	}
	
	$('.fadeIndicator').find('li').each(function(){
		$(this).mouseover(function(){
			fadeTo($(this).index());
		})
	})
	
	//window.setInterval('fadeToNext()',3000);
}
