String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g, '');
}

function setLayout() {
	var clientHeight = (document.body.clientHeight || document.documentElement.clientHeight);
	var scrollTop = (document.documentElement.scrollTop || document.body.scrollTop);
	var menuBottom = 10 + document.getElementById('slogan').offsetHeight + 12 + 243 + document.getElementById('menu').offsetHeight - document.getElementById('contact').offsetHeight - 20;
	var contactTop = clientHeight + scrollTop;
	if (contactTop > document.getElementById('footer').offsetTop) contactTop = document.getElementById('footer').offsetTop;
	contactTop = contactTop - document.getElementById('contact').offsetHeight - 20;
	var newTop = 0;
	if (contactTop - menuBottom > 0) newTop = contactTop - menuBottom;
	document.getElementById('contact').style.top = newTop + 'px';
}

function disableSelection(target) {
	if (typeof target.onselectstart != 'undefined') {
		target.onselectstart = function() {
			return false;
		};
	} else if (typeof target.style.MozUserSelect != 'undefined') {
		target.style.MozUserSelect = 'none';
	} else {
		target.onmousedown = function() {
			return false;
		};
	}
	target.style.cursor = 'default';
}

if (window.addEventListener) {
	window.addEventListener('load', setLayout, false);
} else if (window.attachEvent) {
	window.attachEvent('onload', setLayout);
} else {
	window.onload = function() {
		setLayout();
	};
}