// Vertical Centering Content
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;
}
function setContent() {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {
			var contentElement = document.getElementById("nav-content");
			var contentHeight = contentElement.offsetHeight;
			if (windowHeight - contentHeight > 0) {
				contentElement.style.position = "relative";
				contentElement.style.top = ((windowHeight / 2) - (contentHeight / 2)) + "px";
			}
			else {
				contentElement.style.position = "static";
			}
		}
	}
}
window.onload = function() {
	setContent();
}
window.onresize = function() {
	setContent();
}

// Set navigation "on" classes when scrolling content (thanks to kristaganelon.com)
$(function (){
	$("#n-about").addClass("on");
	$(window).scroll(function () {
		var offset = $(window).scrollTop();
		if(offset >= 0 && offset <= 255) {
			$("#n-about").addClass("on");
			$("#n-work").removeClass("on");
			$("#n-contact").removeClass("on");
		}
		if(offset >=255 && offset <= 8600) {
			$("#n-about").removeClass("on");
			$("#n-work").addClass("on");
			$("#n-contact").removeClass("on");
		}
		if(offset >= 8600) {
			$("#n-about").removeClass("on");
			$("#n-work").removeClass("on");
			$("#n-contact").addClass("on");
		}
	});
});
