var currentPage, currentNav, currentArticle, doHashChange, doScroll, nav, navTop, sectionMain, errorPage;

setCurrentPage = function() {
	currentPage = window.location.hash.slice(1);
	return currentPage;
}

doHashChange = function() {
	if (setCurrentPage() != '') {
		if (currentPage.indexOf(':') != -1)
			currentPage = currentPage.split(':')[0];
		
		if (currentArticle && currentNav) {
			currentNav.className = '';
			currentArticle.className = '';
			currentArticle.style.zIndex = '1';
		}
		
		currentNav = document.getElementById('nav-' + currentPage);
		currentArticle = document.getElementById(currentPage);
		
		if (currentNav) currentNav.className = 'active';
		currentArticle.className = 'active';
		currentArticle.style.zIndex = '8';
		
		sectionMain.style.height = (currentArticle.offsetHeight + 100) + 'px';
	}
	/*
	while (window.scrollY != navTop) {
		window.setTimeout(function() {
			window.scrollBy(0, 10);
		}, Math.floor(Math.abs(window.scrollY - navTop) / 20));
	}
	window.clearTimeout();*/
	return false;
}

/*function createBoxes() {
	var w;
	w = window.innerWidth;
	document.write(w);
}
window.addEventListener('resize', createBoxes, false);*/

window.addEventListener('load', function() {
	nav = document.getElementById('nav');
	navTop = nav.offsetTop;
	sectionMain = document.getElementById('main');
	errorPage = document.getElementById('error');
	
	doHashChange();
},false);

window.addEventListener('hashchange', doHashChange, false);
