$(function(){
	var baseSize = {width: parseInt($('#background-elements ul li').css('min-width')), height: parseInt($('#background-elements ul li').css('min-height'))};
	var aspectRatio = (baseSize.width > baseSize.height) ? baseSize.width / baseSize.height : baseSize.height / baseSize.width;
	var backgroundElements = $('#background-elements ul li');
	setBackgroundElement();
	$(window).bind('resize',setBackgroundElement);
	function setBackgroundElement(){
		if($(this).width() > baseSize.width){
		
			backgroundElements.width($(this).width());
			backgroundElements.height($(this).width()/aspectRatio);
			
			if($(this).height() > backgroundElements.height()){
				backgroundElements.height($(this).height());
				backgroundElements.width($(this).height()*aspectRatio);
			}
		}else{
			if($(this).height() > baseSize.height){
				backgroundElements.height($(this).height());
				backgroundElements.width($(this).height()*aspectRatio);
			}
		}
	}
});
