var ratio = 1,
	minheight = 680,
	maxheight = 830;
var flashOffset;

$(window).resize( onResize );
function onResize() {
	if($(window).height() > minheight && $(window).height() < maxheight) {
		$('#wrap .flashHolder').css({
			'height' : '100%'
		});
	}else if($(window).height() <= minheight) {
		$('#wrap .flashHolder').css({
			'height' : minheight+'px'
		});
	}else if($(window).height() >= maxheight) {
		$('#wrap .flashHolder').css({
			'height' : maxheight+'px'
		});
	}
	
	//flashOffset = (window.innerWidth - 1136)/2;
	flashOffset = ($(window).width() - 1136)/2;
	
	if(flashOffset >= 0){
		$('#wrap').css({
			'left': flashOffset + 'px'
		});
	} else {
		$('#wrap').css({
			'left': 0 + 'px'
		});
	}
}
onResize();

function onFlashLoaded( w ) {
	//console.log('onFlashLoaded ___ w:'+w);
	var pct = 1136/w;
	var wrapwidth = Math.floor(1136*pct);
	//console.log('pct = '+pct+', wrapwidth = '+wrapwidth);
	
	ratio = pct;
	minheight = Math.round(minheight*pct);
	maxheight = Math.round(maxheight*pct);
	
	$('div#flash').css({
		'width' : wrapwidth+'px'
	});
	$('#wrap .flashHolder').css({
		'width' : wrapwidth+'px'
	});
	$('#wrap').css({
		'width' : wrapwidth+'px',
		'left' : '-'+Math.round( wrapwidth/2 )+'px'
	});
	
	if(w!=1136) {
		$('html, body').css({
			'background' : '#c9c9c9'
		});
	}
	
	onResize();
}
