// JavaScript Document

school = 0;
sv_main = 0;
sv_about = 1;
sv_book = 2;

school_about = 1;
sv_about_prepare = 0;
sv_about_need = 1;

awards = 2;
awards_main = 0;
awards_book = 1;
awards_chrono = 2;

biblio = 3;
biblio_main = 0;
biblio_alpha = 1;
biblio_chrono_both = 2;
biblio_chrono_single = 3;

visHeight = '354';
hidHeight = '372';
biblioHeight = '336';
visTop = '142px';
hidTop = '124px';
biblioTop = '160px';

names = new Array();
names[school] = new Array('sv_main','sv_about','sv_book');
names[school_about] = new Array('sv_about_prepare','sv_about_need');
names[awards] = new Array('awards_main','awards_book','awards_chrono');
names[biblio] = new Array('biblio_main','biblio_alpha','biblio_chrono_both','biblio_chrono_single');

mainNames = new Array();
mainNames[school] = 'school';
mainNames[awards] = 'awards';
mainNames[biblio] = 'biblio';
locBotName = 'lBarBot';
mainName = 'viewPort';
bibBarName = 'biblioBar';

basePathString = 'index.htm';

empty = -1;

function switchState(section, button) {
	for (i=0; i<names[section].length; i++) {
		newState = (names[section][i] == names[section][button]) ? 'active' : 'inactive';
		document.getElementById(names[section][i]).className = newState;
		
	}

}

function activateSub(state, section, button, showBib) {
	with (parent.document) {
		curHeight = getElementById(mainName).height;
		curVis = getElementById(locBotName).style.visibility;
		curBibVis = getElementById(bibBarName).style.visibility;
		newHeight = state ? (showBib?biblioHeight:visHeight) : hidHeight;
		newVis = state ? 'visible' : 'hidden';
		newBibVis = showBib ? 'visible' : 'hidden';
		curTop = getElementById(mainName).style.top;
		newTop = state ? (showBib?biblioTop:visTop) : hidTop;
		curLocBotTop = getElementById(locBotName).style.top;
		newLocBotTop = showBib ? '142px' : '124px';
		if (curLocBotTop != newLocBotTop) {
			getElementById(locBotName).style.top = newLocBotTop;
		}
		if (curHeight != newHeight) {
			getElementById(mainName).height = newHeight;
		}
		if (curVis != newVis) {
			getElementById(locBotName).style.visibility = newVis;
		}
		if (curBibVis != newBibVis) {
			getElementById(bibBarName).style.visibility = newBibVis;
		}
		if (curTop != newTop) {
			getElementById(mainName).style.top = newTop;
		}
	}
	
	topPath = top.location.href;
	basePath = (topPath.substring(topPath.length-basePathString.length,topPath.length) == basePathString) ? topPath.substring(0,topPath.length-basePathString.length) : topPath;
	newPath = state ? basePath+'main/location/'+mainNames[section]+'/'+names[section][button]+'/'+names[section][button]+'_loc.htm' : basePath+'main/blank.htm';
	curPath = parent[locBotName].location.href;
	if (newPath != curPath) {
		parent.document.getElementById(locBotName).src = newPath; 
	}
}

function setScroll(state) {
	
	parent.document.getElementById(mainName).scrolling = state;

}

bookName = 'bookPort';
navName = 'bookNav';
artName = 'bookArt';
bookBasePath = '../books/';
navExt = '_nav.htm';
artExt = '_art.htm';
mainExt = '_main.htm';

function activateBook(state, book) {
	topPath = top.location.href;
	blankPage = (topPath.substring(topPath.length-basePathString.length,topPath.length) == basePathString) ? topPath.substring(0,topPath.length-basePathString.length) : topPath;
	blankPage += 'main/blank.htm';
	navPath = state ? book+navExt : blankPage;
	artPath = state ? book+artExt : blankPage;
	mainPath = state ? book+mainExt : blankPage;
	with (parent.document) {
		curVis = getElementById(artName).style.visibility;
		newVis = state ? 'visible' : 'hidden';
		if (curVis != newVis) {
			getElementById(navName).style.visibility = newVis;
			getElementById(artName).style.visibility = newVis;
			getElementById(bookName).style.visibility = newVis;
		}
		curVis = getElementById(mainName).style.visibility;
		newVis = state ? 'hidden' : 'visible';
		if (curVis != newVis) { getElementById(mainName).style.visibility = newVis; }
	}
	curHref = parent[artName].location.href;
	if (curHref != artPath) {
		parent[artName].location.href = artPath;
		parent[navName].location.href = navPath;
		parent[bookName].location.href = mainPath;
	}
}
