function resize(){
	var windowHeight = null;
	if (document.documentElement && document.documentElement.clientHeight) {
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body && document.body.clientHeight) {
		windowHeight = document.body.clientHeight;
	} else if (window.innerHeight) {
		windowHeight = window.innerHeight;
	}
	if (windowHeight) {
		if (windowHeight < _photoHeight + _remainingHeight) {
			var photoHeight = windowHeight - _remainingHeight;
			if (photoHeight < _minPhotoHeight) photoHeight = _minPhotoHeight;
			var photoWidth = Math.round(_photoSizeRatio * photoHeight);
		} else {
			var photoWidth = _photoWidth;
			var photoHeight = _photoHeight;
		}
		_photo.width = photoWidth;
		_photo.height = photoHeight;
	}
}
function init(){
	_minPhotoHeight = 400;
	_photo = document.getElementById('photo');
	if (_photo) {
		_photoWidth = _photo.width ? _photo.width : null;
		_photoHeight = _photo.height ? _photo.height : null;
		if (_photoWidth && _photoHeight) {
			_photoSizeRatio = _photoWidth / _photoHeight;
			var bodyHeight = document.getElementsByTagName('body')[0].offsetHeight;
			if (bodyHeight) {
				_remainingHeight = (bodyHeight + 10) - _photoHeight;
				resize();
				window.onresize = function(){
					resize();
				};
			}
		}
	}
}
if (document.addEventListener) {
	document.addEventListener('DOMContentLoaded', init, false);
} else if (document.all && ! window.opera) {
	document.write('<scr' + 'ipt id="DOMReady" defer="true" ' + 'src=//:><\/scr' + 'ipt>');  
	document.getElementById('DOMReady').onreadystatechange = function(){
		if (this.readyState == 'complete') {
			init();
		}
	};
}
