window.onload = init;
window.onresize = resize;

var IconLimit = 61;

var pane = null;
var content = null;

var initMargin;
var expCol;

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function fixHeaderPositions() {	
	var pad = document.getElementById("pad");

	var home = document.getElementById("home");
	home.style.left = pad.offsetWidth="px";
	
	var photos = document.getElementById("photos");
	photos.style.left = home.offsetWidth="px";
	
	var blog = document.getElementById("blog");
	blog.style.left = photos.offsetWidth="px";
	
	var research = document.getElementById("research");
	research.style.left = blog.offsetWidth="px";

}


function resizeRightShadow() {
	var rightShadow = document.getElementById("right-shadow");
	pos = findPos(rightShadow);
	
	var pageWidth = 0;
	if(window.innerWidth) {
		pageWidth = window.innerWidth;
	} else if(document.documentElement && document.documentElement.clientWidth) {
		pageWidth = document.documentElement.clientWidth;
	} else if(document.body) {
		pageWidth = document.body.clientWidth;
	}
	rightShadow.style.width = (pageWidth - pos[0])+"px";
}

function setupShadow() {

	var activepage = document.getElementById(activePageId);
	activePagePos = findPos(activepage);

	var leftShadow = document.getElementById("left-shadow");
	leftShadow.style.width = (activePagePos[0] - 9)+"px";

	var leftActiveShadow = document.getElementById("left-active-shadow");
	leftActiveShadow.style.left = (activePagePos[0] - 9)+"px";

	var activeShadow = document.getElementById("active-shadow");
	activeShadow.style.left = (activePagePos[0] + 11)+"px";
	activeShadow.style.width = (activepage.offsetWidth - 22)+"px";

	var rightActiveShadow = document.getElementById("right-active-shadow");
	rightActiveShadow.style.left = (activePagePos[0] + activepage.offsetWidth - 11)+"px";
	
	var rightShadow = document.getElementById("right-shadow");
	rightShadow.style.left = (activePagePos[0] + activepage.offsetWidth + 9)+"px";
	
	var pageWidth = 0;
	if(window.innerWidth) {
		pageWidth = window.innerWidth;
	} else if(document.documentElement && document.documentElement.clientWidth) {
		pageWidth = document.documentElement.clientWidth;
	} else if(document.body) {
		pageWidth = document.body.clientWidth;
	}
	rightShadow.style.width = (pageWidth - activePagePos[0] - activepage.offsetWidth - 10)+"px";

/*
	var footer = document.getElementById("footer");
	var pageHeight = 0;
	if(window.innerHeight) {
		pageHeight = window.innerHeight;
	} else if(document.documentElement && document.documentElement.clientHeight) {
		pageHeight = document.documentElement.clientHeight;
	} else if(document.body) {
		pageHeight = document.body.clientHeight;
	}
	footer.style.top = (pageHeight - 50)+"px";
*/
	leftShadow.style.visibility = "visible";
	leftActiveShadow.style.visibility = "visible";
	activeShadow.style.visibility = "visible";
	rightActiveShadow.style.visibility = "visible";
	rightShadow.style.visibility = "visible";

//	footer.style.visibility = "visible";
}


function scrollToTop() {
	scroll(0,0);
}




function init(e) {

	pane = document.getElementById("pane");
	content = document.getElementById("content");

	initMargin = 250;
	expCol = 0;

	setupShadow();
	
	if(activePageId == "photos") {
		displayContent();
//		setUpPaneDrag();
	} else if(activePageId == "blog") {
		setUpDateSelections();
	}


}

function resize(e) {
//	resizeRightShadow();
}



