// site specific JavaScript functions 

function getWindowWidth() {
	var windowWidth = 0;
	if (typeof(window.innerWidth) == 'number') {
		windowWidth = window.innerWidth;
	}
	else {
		if (document.documentElement && document.documentElement.clientWidth) {
			windowWidth = document.documentElement.clientWidth;
		}
		else {
			if (document.body && document.body.clientWidth) {
				windowWidth = document.body.clientWidth;
			}
		}
	}
	return windowWidth;
}

function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}

var contentWidth = 700;
var contentHeight = 440;

function centerContent() {
	var windowWidth = getWindowWidth();
	var windowHeight = getWindowHeight();

	if (document.getElementById && document.getElementById('pageContent')) {
		var backgroundElement = document.getElementById('pageContent');
		if (windowWidth < contentWidth) {
			backgroundElement.style.margin = '0px 0px 0px 0px';
			backgroundElement.style.left = '0px';
		} else {
			backgroundElement.style.marginLeft = (contentWidth * -0.5 ) + 'px';
			backgroundElement.style.left = '50%';
		}

		if (windowHeight < contentHeight) {
			backgroundElement.style.top = (windowHeight * -0.5) + 'px';
		} else {
			backgroundElement.style.top = (contentHeight * -0.5) + 'px';
		}

	}
}

function setBackground() {
	var windowWidth = getWindowWidth();
	
	if (document.getElementById && document.getElementById('bg1')) {
		var backgroundElement = document.getElementById('bg1');
		var width;
		
		if (windowWidth < contentWidth) {
			width = 170;
		} else {
			width = windowWidth/2 - 180;
		}
		backgroundElement.style.width = width;
	}

	if (document.getElementById && document.getElementById('bg2')) {
		var backgroundElement = document.getElementById('bg2');
		var left;
		
		if (windowWidth < contentWidth) {
			left = 580;
		} else {
			left = windowWidth/2 + 230;
		}
		backgroundElement.style.left = left;
	}
	
	if (document.getElementById && document.getElementById('bg4')) {
		var backgroundElement = document.getElementById('bg4');
		var left;
			
		if (windowWidth < contentWidth) {
			left = 580;
		} else {
			left = windowWidth/2 + 230;
		}
		backgroundElement.style.left = left;
	}
}

window.onload = function() {
	setBackground();
	centerContent();
	insertEMail();
}

window.onresize = function() {
	setBackground();
	centerContent();
}
