/* execute the following on first page load */
window.onload = function() {
	centerVertical();
}

/* exectute the following on re-positioning of browser window */
window.onresize = function() {
	centerVertical();
}






function centerVertical() {
	var wrapper = document.getElementById("wrapper");
	var background = document.getElementById("background");
	var wrapper_height = wrapper.offsetHeight;
	var center = getWindowHeight()/2;
	var top_position = center-(wrapper_height/2);
	if(top_position > 0) {
		wrapper.style.top = top_position + 'px';
		background.style.top = top_position + 'px';
	} else {
		wrapper.style.top = 0 + 'px';
		background.style.top = top_position + 'px';
	}
}

function getWindowHeight() {
	var windowHeight = 0;
	if (window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight) {
		windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
	}
	return windowHeight;
}
