//  navjs.js

// This file has the functions
//

var G_location_dir=location.pathname.substring(0,location.pathname.lastIndexOf("/")+1);
//
// alert("IN \"navjs.js\" ... G_location_dir=" + G_location_dir);

//-------------------------------------------------------------------------
// This is the window opened up for ``Get Started''
function OpenGetStarted() {
    // This opens the accept menu
    WindowAccept = window.open("./accept.htm","accept","STATUS=0,MENUBAR=0,DIRECTORY=0,TOOLBAR=0,SCROLLBARS,RESIZABLE,WIDTH=400,HEIGHT=450");
}

//-------------------------------------------------------------------------
// This opens the about window
//
function OpenAbout() {
    WindowAbout = window.open("./about.htm","about","STATUS=no,MENUBAR=no,DIRECTORY=no,TOOLBAR=no,SCROLLBARS=yes,RESIZABLE=yes,WIDTH=400,HEIGHT=450");
}

//-------------------------------------------------------------------------
// This opens the how-to-use window
//
function OpenHow() {
    WindowHow = window.open("./howtouse.htm","how","STATUS=yes,MENUBAR=no,DIRECTORY=no,TOOLBAR=no,SCROLLBARS=yes,RESIZABLE=yes,WIDTH=500,HEIGHT=450");
}

//-------------------------------------------------------------------------
// This opens the instructor window
//
function OpenReader() {
    WindowReader = window.open("./mathread.htm","reader","STATUS=yes,MENUBAR=0,DIRECTORY=0,TOOLBAR=no,SCROLLBARS,RESIZABLE,WIDTH=500,HEIGHT=450");
}

//-------------------------------------------------------------------------
// This opens up the program for usage
//
function OpenAll() {

	// put in the new menu
    top.LF2.location="./lf2menu.htm";

	// create the TOC heading
    top.RF1.location="./rf1toc.htm";

	// create the TOC
    top.RF2.location="./rf2toc.htm";

}

//-------------------------------------------------------------------------
// This function is very similar to CloseOutlyingWindowsGoodWay(), but this
// routine closes the windows by opening them and then closing them.
// This creates a small ``flash'' on the screen.  I am doing it this was
// since I know no other way to delete the two index windows (possible
// open) when the main page is resized or re-loaded.
// 
// If these windows are not deleted, then using one of those windows will
// cause a problem as it is no longer linked to the page that was
// re-sized.
//
//zz function CloseOutlyingWindowsBadWay() {
//zz 
//zz     WindowProject = window.open("./null.htm","project","STATUS=no,MENUBAR=no,DIRECTORY=no,TOOLBAR=no,SCROLLBARS=yes,RESIZABLE=yes,WIDTH=1,HEIGHT=1");
//zz     WindowProject.close();
//zz 
//zz }

//-------------------------------------------------------------------------
// CloseOutlyingWindowsGoodWay
//
//zz function CloseOutlyingWindowsGoodWay() {
//zz     //alert("ENTERING \"CloseOutlyingWindowsGoodWay\"");
//zz 
//zz     // if the window is null, do nothing
//zz     if ( null == window.WindowProject ) { }
//zz     else {
//zz         // now that we know the window has existed, 
//zz         // we can see if it has been closed
//zz         if ( false==window.SegmentWindow.closed ) {
//zz             window.WindowProject.close();   
//zz             window.WindowProject=null;
//zz         }
//zz     }
//zz 
//zz }

//-------------------------------------------------------------------------
// Returntotitlepage
//
// This function allows the system to be restarted.
//
function ReturnToTitlePage() {
    //alert("ENTERING \"Returntotitlepage\"");

    // close the outlying windows
    // CloseOutlyingWindowsGoodWay();

    // close the outlying windows
//zz    CloseOutlyingWindowsBadWay();

    // now go back to the title page
    top.location="./indexok.htm";

    //alert("EXITING \"ReturnToTitlePage\"");
	
	return true;
}

//-------------------------------------------------------------------------
// This function opens a chapter description
//
function OpenChapter(name) {

	// define local variables
	var loc;

	loc= G_location_dir + "chap/" + name + ".htm";

	//alert(loc);

    WindowChapter = window.open(loc,"chapter","STATUS=no,MENUBAR=yes,DIRECTORY=no,TOOLBAR=yes,SCROLLBARS=yes,RESIZABLE=yes,WIDTH=600,HEIGHT=450");
    WindowNotebook.focus();
}

//-------------------------------------------------------------------------
// This function opens a project
//
function OpenProject(MethNo,SecNo) {

	// define local variables
	var name;

	name= G_location_dir + "cd/" + MethNo + "/index.htm#"+ SecNo;

	//alert("IN \"OpenProject\"\n**MethNo="+MethNo+"\n** name="+name+"\n** G_location_dir="+G_location_dir);

    WindowProject = window.open(name,"project","STATUS=yes,MENUBAR=no,DIRECTORY=no,TOOLBAR=yes,SCROLLBARS=yes,RESIZABLE=yes,WIDTH=600,HEIGHT=450");
    WindowProject.focus();
}


