var ratio = 1024 / 768;
var pic = document.createElement("img");
var container = null;

function init(){
	container = document.getElementById("photo");

	pic.onload = function(){
		resizeHandler();
	}

	pic.src = "img/macrovision.jpg";
	resizeHandler();

	container.appendChild(pic);
	
	if (window.addEventListener){
		window.addEventListener("resize", resizeHandler, false);
	}
	else if (window.attachEvent){
		window.attachEvent("onresize", resizeHandler);
	}
}

function resizeHandler(){
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		var sw = (window.innerWidth > 1024) ? window.innerWidth : 1024;
		var sh = (window.innerHeight > 768) ? window.innerHeight : 768;
	}
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		var sw = (document.documentElement.clientWidth > 1024) ? document.documentElement.clientWidth : 1024;
		var sh = (document.documentElement.clientHeight > 768) ? document.documentElement.clientHeight : 768;
	}
	
	if(container != null){
		pic.width = sw;
		pic.height = sw / ratio;

		if(pic.height < sh){
			pic.height = sh;
			pic.width = sh * ratio;
		}
	}
}
