window.onload = function() {
    setMainImageSize();
}

window.onresize = function() {
    setMainImageSize();
}

var type = "";
if (navigator.userAgent.indexOf("Opera")!=-1 && document.getElementById) type="OP";
if (document.all) type="IE";
if (document.layers) type="NN";
if (!document.all && document.getElementById) type="MO";

function setMainImageSize() {
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
		 myWidth = window.innerWidth;
		 myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
	}
	
	if(myHeight < 530) {
		myHeight = 530;
		document.body.style.overflow = 'visible';
	}
	
	if(myWidth < 770) {
		myWidth = 770;
		document.body.style.overflow = 'visible';
	}
	
	var new_image_height = (myHeight - 40);
	var new_image_width = new_image_height;
	
	var left = ((myWidth / 2) - ((new_image_width + 270) / 2 )) ;
	var right = 0;

	if(new_image_width > (myWidth-270-20)) { 
			new_image_width = (myWidth-270-20);
			new_image_height = new_image_width;
			left = 20;
			top = ((myWidth / 2) - (new_image_width / 2));
	}
	
	var mainimage = document.getElementById('mainimage');
	
	mainimage.style.height = new_image_height + "px";
	mainimage.style.width = new_image_width + "px";
	mainimage.style.position = "absolute";
	mainimage.style.top = ((myHeight / 2) - (new_image_height / 2 )) + "px";
	mainimage.style.left = left + "px";
	
	var content = document.getElementById('content');
	
	content.style.position = "absolute";
	content.style.top = ((myHeight / 2) - (new_image_height / 2 )) + "px";
	content.style.left = (left+new_image_width) + "px";
	content.style.height = new_image_height + "px";
}
