/*                                                                          nh_nav.js
-------------------------------------------------------------------------------------

Purpose:
~~~~~~~
Provide navigation functions for all sections of the Numeracy modules

N.B. For these to work,
the approriate definitions of pages & page[i] must be loaded for the section
e.g. scripts/ncss.js for the Community Service & Safety section


Designed: 5 January 2000
~~~~~~~~  Dr Tim Brook for Solutions onLine
          copyright Canberra Institute of Technology 2000

Snail mail contact:
	Solutions onLine
	CIT Solutions
	Canberra Institute of Technology,
	GPO Box 826, Canberra, ACT 2601.

Modified: 6/1/00 13.50
~~~~~~~~~ Tim

-----------------------------------------------------------------------------------*/
// Initialisation
// ~~~~~~~~~~~~~~

// Constants (Declare at the top so they becomes global)
// ~~~~~~~~~
var prefix = '../'   // prefix for URLs (mustn't put .. in page[i] list)
var exitUri = prefix + 'home/nh_0005.htm'    // URL to exit to


// Variables (Declare at the top so they becomes global)
// ~~~~~~~~~
var backUri = exitUri    // URL of previous content
var nextUri = exitUri    // URL of next content

//---------------------------------------------------------
// Subroutines
// ~~~~~~~~~~~

//---------------------------------
//---------------------------------------------------------
// Main functions
// ~~~~~~~~~~~~~~

// Depending on the current content, return backUri
function setBack() {

    backUri = exitUri  // default
    for (var i = 1; i < pages; i++) {
     // if this i is the current page
    if (top.Content.document.URL.toLowerCase().indexOf(page[i]) != -1) {
         // back should go to the previous page
            if (page[i-1].toLowerCase().indexOf(".pdf") == -1) {
                backUri = prefix + 'programs/' + page[i-1]
            } else {
                backUri = prefix + 'pdfs/' + page[i-1]
            }
        }
//        alert(top.Content.document.URL + " ? " + page[i] + " : " + backUri)
    }

    return backUri
}
// --------------------------------

// Depending on the current content, return nextUri
function setNext() {

    nextUri = exitUri  // default
    for (var i = 1; i < pages; i++) {
     // if the page before this i is the current page
        if (top.Content.document.URL.toLowerCase().indexOf(page[i-1]) != -1) {
        // next should go to this i page
            if (page[i].toLowerCase().indexOf(".pdf") == -1) {
                nextUri = prefix + 'programs/' + page[i]
            } else {
                nextUri = prefix + 'pdfs/' + page[i]
            }
        }
//        alert(top.Content.document.URL + " ? " + page[i-1] + " : " + nextUri)
    }
    return nextUri
}
// --------------------------------

// Set Back and Next links to point to specified uri
// This is heavy handed but allows for some HTML edits on the BottomBackNext page
function setLinks(uri) {

    with (top.BottomBackNext.document) {
        for (var i = 0; i < links.length; i++) {

	    links[i].href = uri

            if (uri == exitUri) {
                links[i].target = '_top'
            } else {
                links[i].target = 'Content'
            }
        }
    }
    return document.title
}
//---------------------------------
//-----------------------------------------------------------------------------
