var storedA = new Array();
var storedB = new Array();
var storedC = new Array();
var storedD = new Array();
var projectHeight;
var archiveHeights;
var photoHeight;
var screenHeight;

function getHeights() {
	screenHeight = document.getElementById("fullscreenCover").getBoundingClientRect().height;
	screenWidth = document.getElementById("fullscreenCover").getBoundingClientRect().width;

	//document.getElementById("mainBody").style.left = ((screenWidth/2)-261) + 'px';

	document.getElementById("fullscreenCover").style.height = '0px';

	for(i=0;i<entryCount;i++) {
		storedA[i] = document.getElementById("entry[" + i + "]").getBoundingClientRect().height;
	}
	for(i=0;i<projectCount;i++) {
		storedB[i] = document.getElementById("project[" + i + "]").getBoundingClientRect().height;
	}
	for(i=0;i<archiveCount;i++) {
		storedC[i] = document.getElementById("archive[" + i + "]").getBoundingClientRect().height;
	}
	for(i=0;i<albumCount;i++) {
		storedD[i] = document.getElementById("album[" + i + "]").getBoundingClientRect().height;
	}

	//albumListHeight = document.getElementById("albumList").getBoundingClientRect().height;
	//document.getElementById("albumList").style.height = "0px";

	projectListHeight = document.getElementById("projectList").getBoundingClientRect().height;
	document.getElementById("projectList").style.height = "0px";
	archiveListHeight = document.getElementById("archiveList").getBoundingClientRect().height;
	document.getElementById("archiveList").style.height = "0px";

	blogHeight = document.getElementById("blog").getBoundingClientRect().height;
	document.getElementById("blog").style.height = "0px";
	projectsHeight = document.getElementById("projects").getBoundingClientRect().height;
	document.getElementById("projects").style.height = "0px";
	archiveHeight = document.getElementById("archive").getBoundingClientRect().height;
	document.getElementById("archive").style.height = "0px";
	galleryHeight = document.getElementById("gallery").getBoundingClientRect().height;
	document.getElementById("gallery").style.height = "0px";
	artistHeight = document.getElementById("artist").getBoundingClientRect().height;
	document.getElementById("artist").style.height = "0px";

	for(j=0;j<entryCount;j++) {
		document.getElementById("entry["+j+"]").className = 'blogentry slideup';
		document.getElementById("entry["+j+"]").style.height = '0px';
	}
	for(j=0;j<projectCount;j++) {
		toggleProject();
		document.getElementById("project["+j+"]").className = 'projectsentry slideup';
		document.getElementById("project["+j+"]").style.height = '0px';
	}
	for(j=0;j<archiveCount;j++) {
		toggleArchive();
		document.getElementById("archive["+j+"]").className = 'archiveentry slideup';
		document.getElementById("archive["+j+"]").style.height = '0px';
	}
	for(j=0;j<albumCount;j++) {
		document.getElementById("album["+j+"]").className = 'albumentry slideupalbum';
		document.getElementById("album["+j+"]").style.height = '0px';
	}
	if(startPanel!="projects") { 
		document.getElementById("projectList").className = 'slideup';
		document.getElementById("projectList").style.height = '0px';
	}
	if(startPanel!="archive") {
		document.getElementById("archiveList").className = 'slideup';
		document.getElementById("archiveList").style.height = '0px';
	}
	if(startPanel=="blog") {
		show("blog");
		if(startId>=entryCount) startId = entryCount - 1;
		if(startId>=0) { toggle(startId); }
		if(startId==-1) { toggle(entryCount-1); }
	}
	if(startPanel=="projects") { 
		if(startId>=projectCount) startId = projectCount - 1;
		if(startId>=0) { 
			turnOffAll();
			document.getElementById("projectList").className = 'slidedown';
			document.getElementById("projectList").style.height = projectListHeight + 'px';
			showProject(startId);
		} else { 
			turnOffAll();
			document.getElementById("projectList").className = 'slidedown';
			document.getElementById("projectList").style.height = projectListHeight + 'px';
		}
	}
	if(startPanel=="archive") { 
		if(startId>=archiveCount) startId = archiveCount - 1;
		if(startId>=0) { 
			showArchive(startId);
		} else { 
			turnOffAll();
			document.getElementById("archiveList").className = 'slidedown';
			document.getElementById("archiveList").style.height = archiveListHeight + 'px';
		}
	}
	if(startPanel=="gallery") {
		show("gallery");
		if(startId>=albumCount) startId = albumCount - 1;
		if(startId>=0) { 
			showAlbum(startId);
		}
	}
	if(startPanel=="artist") { show("artist"); }
	document.getElementById("loadingScreen").style.display = 'none';
}

function turnOffAll() {
	document.getElementById("projectList").className = 'slideup';
	document.getElementById("projectList").style.height = '0px';
	document.getElementById("archiveList").className = 'slideup';
	document.getElementById("archiveList").style.height = '0px';
}

function toggle(a) {
	if(document.getElementById("entry[" + a + "]").className == 'blogentry slidedown') {
		for(j=0;j<entryCount;j++) {
			document.getElementById("entry["+j+"]").className = 'blogentry slideup';
			document.getElementById("entry["+j+"]").style.height = '0px';
		}
	} else {
		for(j=0;j<entryCount;j++) {
			document.getElementById("entry["+j+"]").className = 'blogentry slideup';
			document.getElementById("entry["+j+"]").style.height = '0px';
		}
		document.getElementById("entry[" + a + "]").className = 'blogentry slidedown';
		document.getElementById("entry[" + a + "]").style.height = storedA[a] + 'px';
	}
}

function toggleProject() {
	if(document.getElementById("projectList").className == 'slidedown') {
		document.getElementById("projectList").className = 'slideup';
		document.getElementById("projectList").style.height = '0px';
	} else {
		turnOffAll();
		document.getElementById("projectList").className = 'slidedown';
		document.getElementById("projectList").style.height = projectListHeight + 'px';
	}
}

function toggleArchive() {
	if(document.getElementById("archiveList").className == 'slidedown') {
		document.getElementById("archiveList").className = 'slideup';
		document.getElementById("archiveList").style.height = '0px';
	} else {
		turnOffAll();
		document.getElementById("archiveList").className = 'slidedown';
		document.getElementById("archiveList").style.height = archiveListHeight + 'px';
	}
}

function showProject(i) {
	for(j=0;j<projectCount;j++) {
		document.getElementById("project["+j+"]").className = 'projectsentry slideup';
		document.getElementById("project["+j+"]").style.height = '0px';
	}
	document.getElementById("project["+i+"]").className = 'projectsentry slidedown';
	document.getElementById("project["+i+"]").style.height = storedB[i];
	show("projects");
}

function showArchive(i) {
	for(j=0;j<archiveCount;j++) {
		document.getElementById("archive["+j+"]").className = 'archiveentry slideup';
		document.getElementById("archive["+j+"]").style.height = '0px';
	}
	document.getElementById("archive["+i+"]").className = 'archiveentry slidedown';
	document.getElementById("archive["+i+"]").style.height = storedC[i];
	show("archive");
}

function showAlbum(i) {
	if(document.getElementById("album[" + i + "]").className == 'albumentry slideupalbum') {
		for(j=0;j<albumCount;j++) {
			document.getElementById("album["+j+"]").className = 'albumentry slideupalbum';
			document.getElementById("album["+j+"]").style.height = '0px';
			document.getElementById("album["+j+"]").style.clear = 'none';
		}
		document.getElementById("album["+i+"]").className = 'albumentry slidedown';
		document.getElementById("album["+i+"]").style.height = 'auto';//storedD[i];
		document.getElementById("album["+i+"]").style.clear = 'both';
		for(j=0;j<imageSource[i].length;j++) {
			document.getElementById("albumImage["+i+"]["+j+"]").src = imageSource[i][j];
		}
	} else {
		document.getElementById("album["+i+"]").className = 'albumentry slideupalbum';
		document.getElementById("album["+i+"]").style.height = '0px';
		document.getElementById("album["+i+"]").style.clear = 'none';
	}
}

function showImage(i,j) {
	document.getElementById("fullscreenImage").src = imageSource[i][j];
	document.getElementById("fullscreen").style.display = 'table';
	document.getElementById("fullscreenImage").className = 'visible';
	document.getElementById("fullscreenCover").className = 'faint';
	document.getElementById("fullscreenCover").style.height = screenHeight + 'px';
	//document.body.style.overflowY = 'hidden';
}

function hideImage() {
	document.getElementById('fullscreen').style.display='none';
	document.getElementById("fullscreenImage").className = 'fadeout';
	document.getElementById("fullscreenCover").className = 'fadeout';
	document.getElementById("fullscreenCover").style.height = '0px';
	//document.body.style.overflowY = 'scroll';
}

function show(a) {
	document.getElementById("blog").className = 'transparent';
	if(a=="blog") {
		document.getElementById("blog").style.height = blogHeight + 'px';
	} else {
		document.getElementById("blog").style.height = '0px';
	}

	document.getElementById("projects").className = 'transparent';
	if(a=="projects") {
		document.getElementById("projects").style.height = projectsHeight + 'px';
	} else {
		document.getElementById("projects").style.height = '0px';
	}

	document.getElementById("archive").className = 'transparent';
	if(a=="archive") {
		document.getElementById("archive").style.height = archiveHeight + 'px';
	} else {
		document.getElementById("archive").style.height = '0px';
	}

	for(j=0;j<albumCount;j++) {
		document.getElementById("album["+j+"]").className = 'albumentry slideupalbum';
		document.getElementById("album["+j+"]").style.height = '0px';
	}
	document.getElementById("gallery").className = 'transparent';
	if(a=="gallery") {
		document.getElementById("gallery").style.height = galleryHeight + 'px';
		//document.getElementById("albumList").style.height = albumListHeight + 'px';
		//document.getElementById("albumList").className = "slidedown";
	} else {
		document.getElementById("gallery").style.height = '0px';
	}

	document.getElementById("artist").className = 'transparent';
	if(a=="artist") {
		document.getElementById("artist").style.height = artistHeight + 'px';
	} else {
		document.getElementById("artist").style.height = '0px';
	}
	document.getElementById(a).className = 'visible';
}

