/***************
 * zintNavigation.js    v3.1
 *
 * c 1997-2000 integral
 * www.integral.com.tr
 *
 * included in zintNavigation.htm
 ***************/


// to show which page is our current page

ZINT_CHAPTER_SEPERATOR = "zintChapterSeparator";	// should be the same with zintLoadBook.js
ZINT_CHAPTER_END = "zintEndChapter";			// should be the same with zintLoadBook.js
ZINT_TEST_END = "zintEndTest";				// should be the same with zintLoadBook.js

// top.DEBUG_MODE is defined in conXXX/index.htm


/**************************************
 * All page navigation through gotoPage
 **************************************/
function gotoPage(numPage, up){
	var pagesPath;
	var noteFileNameCurrent;
	var noteFileNameNext;
	var s;
	
	top.pageCurrent = numPage;

	if (up) {
		pagesPath = "../";
	}
	else {
		pagesPath = "";
	}

	// Update bookmark on TOC, if necessary
	if (top.arrPage[top.pageCurrent].headingNum != top.headingCurrent) {
		top.headingCurrent = top.arrPage[top.pageCurrent].headingNum;
		top.frames["contents"].location.replace(top.frames["contents"].location.href);
	}
	
	// Update main page
	top.frames["main"].location.href = pagesPath + top.arrPage[top.pageCurrent].fileName;
	
	// Update note frame, if present
	if (top.hasNoteFrame) {
		if (top.arrPage[top.pageCurrent].noteFileName != "") {
			noteFileNameNext = top.arrPage[top.pageCurrent].noteFileName;
		} else {
			noteFileNameNext = "zintEmpty.htm";
		}
		
		s = top.frames["notes"].location.href;
		noteFileNameCurrent = s.substring(s.lastIndexOf("/")+1,s.length);
		if (noteFileNameNext != noteFileNameCurrent) {
			top.frames["notes"].location.href = pagesPath + noteFileNameNext;
		} 
	}
	
	if (top.DEBUG_MODE) {
		top.frames["navbar"].document.formPageName.pageName.value = top.arrPage[top.pageCurrent].fileName;
	}
	
}



/**************************************
 * next page
 **************************************/
function nextPage(){
	if ((top.arrPage[top.pageCurrent + 1].fileName == ZINT_TEST_END + ".htm" )
	  ||(top.arrPage[top.pageCurrent + 1].fileName == ZINT_CHAPTER_END + ".htm" )) {
		// nop
	}else{		
		gotoPage(top.pageCurrent + 1);
	}
}



/**************************************
 * previous page
 **************************************/
function previousPage(){
	if (top.arrPage[top.pageCurrent - 1].fileName == ZINT_CHAPTER_SEPERATOR + ".htm" ) {
		//nop
	}else{
		gotoPage(top.pageCurrent - 1);
	}
}

function gotoChapter(numChapter){
	top.CONTENT_CHAPTER = top.arrChapter[numChapter].title;
	top.chapterCurrent = numChapter;
	gotoPage(top.arrChapter[numChapter].firstPageNum, "../");
	top.frames["contents"].location.href = "../zintTOC.htm";
	top.frames["navbar"].location.href = "../zintNavbar.htm";
}


function gotoTest(numChapter){
	top.chapterCurrent = numChapter;
	gotoPage(top.arrChapter[top.chapterCurrent].firstPageNum);
	top.frames["contents"].location.href = "zintAnswerSheet.htm";
	top.frames["navbar"].location.href = "zintAnswerButtons.htm";
}


/*
 * CONTENT_HTLM_HOME should be set in index.htm
 */
function gotoHomePage(){
	top.location.href = top.CONTENT_HTLM_HOME;
}


function returntoText(){
	gotoText(top.chapterCurrent - 1);
}


function whichPage() {
	document.all.pageName.style.visibility = "visible";
	document.all.pageName.value = top.arrPage[top.pageCurrent].fileName;
}
