
//
var bgimgminwidth = 600;
var bgimgproportion = 0.75;

var wwidth;
var wheight;

function GetWindowWidth() {
	var x = 0;
	if (self.innerHeight) {
		x = self.innerWidth;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		x = document.documentElement.clientWidth;
	} else if (document.body) {
		x = document.body.clientWidth;
	}
	return x;
}

function GetWindowHeight() {
	var y = 0;
	if (self.innerHeight)	{
		y = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		y = document.documentElement.clientHeight;
	} else if (document.body) {
		y = document.body.clientHeight;
	}
	return y;
}

function resizeBgimg () {
	wwidth = GetWindowWidth();
	wheight = GetWindowHeight();
	if (wheight/wwidth > bgimgproportion) {
		if (wheight < 600*bgimgproportion) {
			document.getElementById('bgimg').style.width = "600px";
			document.getElementById('bgimg').style.height = 600*bgimgproportion + "px";
		} else {
			document.getElementById('bgimg').style.width = wheight/bgimgproportion;
			document.getElementById('bgimg').style.height = wheight;
		}
	} else {
		if (wwidth < 600) {
			document.getElementById('bgimg').style.width = "600px";
			document.getElementById('bgimg').style.height = 600*bgimgproportion + "px";
		} else {
			document.getElementById('bgimg').style.width = wwidth;
			document.getElementById('bgimg').style.height = wwidth * bgimgproportion;
		}
	}
}

function showCloseButton () {
	document.getElementById('closebuttonimg').className = "visible";
}

function CloseContent () {
	document.getElementById('content').className = "hidden";
	document.getElementById('hiddencontainer').className = "visible";
}

function OpenContent () {
	document.getElementById('content').className = "visible";
	document.getElementById('hiddencontainer').className = "hidden";
}

function loadPage () {
	resizeBgimg();
	showCloseButton();
}

window.onresize = function(event) {
   resizeBgimg();
}