
// ****************************************************************************
// *
// * CONFIDENTIAL PROPERTY OF RAYTHEON TRAINING, LLC.
// *
// * (c) 2000 General Motors Corporation,   All Rights Reserved
// *
// *
// *
// *    Module:                    Openpage.js
// *    Coded by:
// *    Creation Date:             28 August 2000
// *    Current Version Number:    3.1
// *    Current Version Date:      9 Aug. 2001
// *
// *    Module Overview:
// *    Purpose: Contributes functionality to Logon, Return, Start,
// *    Glossary, Outline, Main Menu, Help, Survey, Conclusion, Course
// *    Content Pages. Used in all common course html files except
// *    Update.html. Used in StcNavhelp.html, all navigation, and all
// *    footer templates. List of function names in order of their presence
// *    in Openpage.js with description
// *
// *
// *    This module contains functions that apply to the Strategy Based
// *    Diagnostic (SBD) Exercises.
// *
// *    Function List:
// *        navmainmenu
// *        navoline
// *        navgloss
// *        navhelp
// *        navexit
// *        topnavbar
// *        topnavbarExitOnly
// *        backbutton
// *        backbuttonurl
// *        forwardbuttonurl
// *        replaybutton
// *        menuhiddeninput
// *        learnbuttonurl
// *        preload
// *        msover
// *        msout
// *        storepagename
// *        EmbedAudio
// *        playAudio
// *        stopMedia
// *        replayMedia
// *        stopMedia
// *        playFlash
// *        playMPG
// *        right
// *        MM_reloadPage
// *        MM_findObj
// *        MM_showHideLayers
// *        initAns
// *        writeCourseNumberAndDescription
// *        SetMenuFlag
// *        stripDEUrl
// *        stripEndAnchor
// *        CheckName
// *        TurnOnLink
// *        enablelink
// *        testformenablelink
// *        formenablelink
// *        determineMenuLinkStates
// *        isEnabled
// *        setMenuLinkStates
// *        getCookie
// *        putCookie
// *        getCookies
// *        initCookies
// *        getenabledmenulist
// *        putenabledmenulist
// *        startupFunctions
// *        StartUp
// *        playMenuAudio
// *        nobookmark
// *        testprev
// *
// *    Modification History:
// *     28Aug00  (TK)  Initial version coded.
// *     14Sep00  (PET) Added Initial Module Headers.
// *     21Sep00  (RDT) Added  Headers.
// *     11Jun01  (PZ)  change replaybutton and add menureplaybutton
// *     18Jun01  (PZ)  Change playFlash function
// *     18Jun01  (PZ)  Add writeSurveyTable
// *     09Aug01  (PZ)  Add nobookmark function
// *     10Aug01  (pZ)  add testprev function
// *     15Aug01  (PZ)  remove testprev. add it into stchelp.html
// *
// ****************************************************************************
// *****************************************************************************
// Revision - openpage.js 8/18/2000
// *****************************************************************************

//******************************************************************************
// CONSTANTS SECTION
//******************************************************************************


//******************************************************************************
//
// AUTHOR:  David E. Thomas / Samurai Systems, Inc.
// DATE  :  09/09/2000
// VARIABLES:
//  definedcookies : Contains an initialization string for the browsers
//                   cookie object.  Any cookies needed in the CBT application
//                   should be stored in here.  Initially there are only
//                   two defined names:
//                   1) 'enabledmenulist'  2) 'sbd'
var definedcookies = 'enabledmenulist=mainmenu.html;sbd=home!mainmenu.html~stepsDone!0';
var CourseNumber = "19047.06W-R2";
var CourseDesc = 'Security Systems ';
var CourseAbbr = 'SEC-';
var enabledmenus = getenabledmenulist();

// These are HTML image tags for the top navigation bar buttons.
// Any modifications here will change all the buttons throughout the
// course.
// AUTHOR:  David E. Thomas / Samurai Systems, Inc.
var xnavimgmain  = '<img src="images/stcmmenu.gif" align=top border="0">';
var xnavimgoline = '<img src="images/stcoline.gif" align=top border="0">';
var xnavimggloss = '<img src="images/stcgloss.gif" align=top border="0">';
var xnavimghelp  = '<img src="images/stchelp.gif" align=top border="0">';
var xnavimgexit  = '<img src="images/stcexit.gif" align=top border="0">';
var xnavspc      = '<img src="images/stcspc03.gif" align=top border="0">';
// The following variables must be global.  They are used by TurnOnLink(), enablelink()
// and playMenuAudio()
// AUTHOR:  David E. Thomas / Samurai Systems, Inc.
var xargs = new Array;
var xcp = 'Course Progress::';
var donotplayaudioagain = true;

//******************************************************************************
// This code will run when the javascript is first loaded.
//******************************************************************************

// xPrev is the URL located after the hash mark and is used to return
// to a previous page when the back button is clicked.  Normally you would
// use a history.go() but this does not work with our specialized browser
// because going back in the history does not run scripts.
var xPrev = location.hash.substr(1);

// the current page
var xCurr = window.location;

if (xPrev == "") xPrev = xCurr;

if (document.images)
        var stuff = new preload("images/stclogo1.gif","images/stcspc01.gif","images/stclogo2.gif","images/stcmmenu.gif","images/stcoline.gif","images/stcgloss.gif","images/stchelp.gif","images/stcexit.gif","images/stcspc03.gif","images/stcspc02.gif","images/stcnext.gif","images/stcback.gif","images/stcrplay.gif","images/stcgrid.gif","images/stccopy.gif","images/stcnxt_m.gif","images/stcbk_m.gif","images/stcrpl_m.gif","images/stclearn.gif","images/stclrn_m.gif");

document.onmousedown = right;

MM_reloadPage(true);


//******************************************************************************
//                                    FUNCTIONS
// ****************************************************************************
// ****************************************************************************
//                            writeSurveyTable()
//
// AUTHOR:  Peter Zheng IBS. inc.
//
// DESCRIPTION:
//  Creates Survuy table
//
// PARAMETERS:
//
//  arguments[] (string) - survuy title
//
// RETURN VALUE:
//  none
//
//  INPUTS:    ('','arguments[1]','arguments[2]','arguments[3]','arguments[4]','arguments[5]','arguments[6]')
//  OUTPUTS:    none
// ****************************************************************************
function writeSurveyTable() {

  var i=1;
  var j=1;
  var k=arguments[0];
  var length=arguments.length

  document.write('<table  border="0" width="98%" align="right"><tr>');
  document.write('<td width="40%">&nbsp;</td>');
  document.write('<td width="3%">&nbsp;</td>');
  document.write('<td width="11%" align="center">Strongly Disagree</td>');
  document.write('<td width="11%" align="center">Disagree</td>');
  document.write('<td width="11%"align="center">Somewhat Agree</td>');
  document.write('<td width="11%" align="center">Agree</td>');
  document.write('<td width="11%" align="center">Strongly Agree</td></tr>');

  if (k==12){
  length=5;
  }
  for (j=1;j<length;j++){
    document.write('<tr>');
    document.write('<td width="40%" height="17">'+arguments[j]+'</td>');
    document.write('<td width="3%" height="17">&nbsp;</td>');

    for (i=1;i<=5;i++){
      document.write('<td width="11%" align="center" height="17"><input type="radio" name="Feedback'+(j+k)+'" value="'+i+'" onClick="UpdateForm(this.name, this.value);"></td>');
    }

    document.write('</tr>');
    document.write('<tr><td colspan="7"><br></td></tr>')
  }

  document.write('</table>');

}

// ****************************************************************************
//                            navmainmenu()
//
// AUTHOR:  David E. Thomas / Samurai Systems, Inc.
//
// DESCRIPTION:
//  Creates anchor for main menu button on top navigation bar.
//
// PARAMETERS:
//
//  anchordata (string) - The anchor's value.  Will most likely be the
//                        the button image.
//
//  urldata             - URL to return to if back button is clicked
// RETURN VALUE:
//  string    - the HTML anchor for the main menu button
//  Function that
//
//  INPUTS:    (anchordata, urldata)
//  OUTPUTS:    return vs
//
// ****************************************************************************
 function navmainmenu(anchordata, urldata) {
  var vs = '<a href="mainmenu.html#' + urldata + '" onClick="stopMedia();return true">' + anchordata + '</a>';
  return vs;
}


// ****************************************************************************
//                           navoline()
//  Function that
//
// AUTHOR:  David E. Thomas / Samurai Systems, Inc.
// DESCRIPTION:
//  Creates anchor for course outline button on top navigation bar.
// PARAMETERS:
//  anchordata (string) - The anchor's value.  Will most likely be the
//                        the button image.
//  urldata             - URL to return to if back button is clicked
// RETURN VALUE:
//  string    - the HTML anchor for the course outline
//  INPUTS:    (anchordata, urldata)
//  OUTPUTS:    return vs
//
// ****************************************************************************
function navoline(anchordata, urldata) {
  var vs = '<a href="stcoline.html#' + urldata + '" onClick="stopMedia();return true">' + anchordata + '</a>';
  return vs;
}


// ****************************************************************************
//                             navgloss()
//
//  Function that
// AUTHOR:  David E. Thomas / Samurai Systems, Inc.
// DESCRIPTION:
//  Creates anchor for glossary button on top navigation bar.
// PARAMETERS:
//  anchordata (string) - The anchor's value.  Will most likely be the
//                        the button image.
//  urldata             - URL to return to if back button is clicked
// RETURN VALUE:
//  string    - the HTML anchor for the glossary
//  INPUTS:   (anchordata, urldata)
//  OUTPUTS:    return vs
//
// ****************************************************************************
function navgloss(anchordata, urldata) {
  var vs = '<a href="stcgloss.html#' + urldata + '" onClick="stopMedia();return true">' + anchordata + '</a>';
  return vs;
}


// ****************************************************************************
//                             navhelp()
//
//  Function that
// AUTHOR:  David E. Thomas / Samurai Systems, Inc.
//
// DESCRIPTION:
//  Creates anchor for help button on top navigation bar.
//
// PARAMETERS:
//
//  anchordata (string) - The anchor's value.  Will most likely be the
//                        the button image.
//  urldata             - URL to return to if back button is clicked
// RETURN VALUE:
//  string    - the HTML anchor for the help screens
//  INPUTS:   (anchordata, urldata)
//  OUTPUTS:    return vs
//
// ****************************************************************************
function navhelp(anchordata, urldata) {
  var vs = '<a href="stchelp.html#' + urldata + '" onClick="stopMedia();return true">' + anchordata + '</a>';
  return vs;
}


// ****************************************************************************
//                               navexit()
//
//  Function that
// AUTHOR:  David E. Thomas / Samurai Systems, Inc.
//
// DESCRIPTION:
//  Creates anchor for exit button on top navigation bar.
//
// PARAMETERS:
//
//  anchordata (string) - The anchor's value.  Will most likely be the
//                        the button image.
//
//  urldata             - URL to return to if back button is clicked
//
// RETURN VALUE:
//
//  string    - the HTML anchor for the exit button
//  INPUTS:    (anchordata)
//  OUTPUTS:    return vs
//
// ****************************************************************************
function navexit(anchordata) {
  var vs = '<a href="dummy.html" onClick="window.close(self); return false">' + anchordata + '</a>';
  return vs;
}


// ****************************************************************************
//                                topnavbar()
//
//  Function that
//
// AUTHOR:  David E. Thomas / Samurai Systems, Inc.
//
// DESCRIPTION:
//  Generate top navigation bar.  xCurr is the current page's URL.  This
//  will be embedded in the href after the hash mark for each button.  This
//  URL information will be used so that when the user goes to a page via
//  one of the top nav bar buttons, he will be able to come back to
//  the current page using the back button.
//  INPUTS:    None.
//  OUTPUTS:   None.
//
// ****************************************************************************
function topnavbar() {
 document.write('<tr><td>' + navmainmenu(xnavimgmain, xCurr));
 document.write(navoline(xnavimgoline, xCurr));
 document.write(navgloss(xnavimggloss, xCurr));
 document.write(navhelp(xnavimghelp, xCurr));
 document.write(navexit(xnavimgexit));
 document.write(xnavspc + '</td></tr>');
}

// ****************************************************************************
//                              topnavbarPrevMM()
//
//  Function that
//
// AUTHOR:  Jason Key
// DESCRIPTION:
//  Generate top navigation bar with MainMenu disabled. This is for Mainmenu.html only
//  xPrev is the previous page's URL if there
//  was a hash in the document.URL, otherwise it is the current page.  This
//  will be embedded in the href after the hash mark for each button.  This
//  URL information will be used so the back buttons can return to the
//  previous page.
//
//  INPUTS:    None.
//  OUTPUTS:   None.
//
// ****************************************************************************
function topnavbarPrevMM() {
 document.write('<tr><td>' + xnavimgmain);
 document.write(navoline(xnavimgoline, xPrev));
 document.write(navgloss(xnavimggloss, xPrev));
 document.write(navhelp(xnavimghelp, xPrev));
 document.write(navexit(xnavimgexit));
 document.write(xnavspc + '</td></tr>');
}




// ****************************************************************************
//                              topnavbarPrev()
//
//  Function that
//
// AUTHOR:  David E. Thomas / Samurai Systems, Inc.
//
// DESCRIPTION:
//  Generate top navigation bar.  xPrev is the previous page's URL if there
//  was a hash in the document.URL, otherwise it is the current page.  This
//  will be embedded in the href after the hash mark for each button.  This
//  URL information will be used so the back buttons can return to the
//  previous page.
//
//  INPUTS:    None.
//  OUTPUTS:   None.
//
// ****************************************************************************
function topnavbarPrev() {
 document.write('<tr><td>' + navmainmenu(xnavimgmain, xPrev));
 document.write(navoline(xnavimgoline, xPrev));
 document.write(navgloss(xnavimggloss, xPrev));
 document.write(navhelp(xnavimghelp, xPrev));
 document.write(navexit(xnavimgexit));
 document.write(xnavspc + '</td></tr>');
}
// ****************************************************************************
//                             topnavbarExitOnly()
//
//  Function that
// DESCRIPTION:
//
//  This generates the top nav bar with all buttons disabled except
//  exit button.
//
//  INPUTS:    None.
//  OUTPUTS:   None.
//
// ****************************************************************************
function topnavbarExitOnly() {
  document.write('<tr><td>' + xnavimgmain);
  document.write(xnavimgoline);
  document.write(xnavimggloss);
  document.write(xnavimghelp);
  document.write(navexit(xnavimgexit));
  document.write(xnavspc + '</td></tr>');
}

// ****************************************************************************
//                             backbutton()
//
//  Function that
// AUTHOR:  David E. Thomas / Samurai Systems, Inc.
//
// DESCRIPTION:
//  Dynamically write out back button to be active or inactive depending
//  on whether their was a previous page.  The first time in there is no
//  no previous page.
//  INPUTS:    None.
//  OUTPUTS:   None.
//
// ****************************************************************************
function backbutton() {
  if((xPrev == "") || (xPrev == xCurr)) document.write('<img src="images/stcback.gif" align=top border="0"  name="image12">');
  else document.write('<a href="' + xPrev + '" OnMouseOver="msover(\'image12\',\'images/stcbk_m.gif\'); window.status=\'Previous\'; return true" OnMouseOut="msout(\'image12\',\'images/stcback.gif\'); window.status=\'\'; return true" onClick="stopMedia();determineMenuLinkStates(); return true"><img src="images/stcback.gif" align=top border="0"  name="image12"></a>');
}

// ****************************************************************************
//                                backbuttonurl()
//
//  Function that
// AUTHOR:  David E. Thomas / Samurai Systems, Inc.
//
// DESCRIPTION:
//  If an href is empty or pound sign then the back button is nothing more than
//  than an image (nonclickable).  Otherwise, a back button is created that
//  will go to the href given when clicked.  The active back button
//  includes mouse events that change the look of the button when the mouse
//  moves over it.
//
//  INPUTS:    (url)  URL to go to when back button is clicked.
//  OUTPUTS:   None.
//
// ****************************************************************************
function backbuttonurl(url) {
  url = stripDEUrl(url);
  if ((url.length == 0) || (url == '#'))  document.write('<img src="images/stcback.gif" align=top border="0"  name="image12">');
  else document.write('<a href="' + url + '" OnMouseOver="msover(\'image12\',\'images/stcbk_m.gif\'); window.status=\'Previous\'; return true" OnMouseOut="msout(\'image12\',\'images/stcback.gif\'); window.status=\'\'; return true" onClick="stopMedia(); determineMenuLinkStates(); return true"><img src="images/stcback.gif" align=top border="0"  name="image12"></a>');
}

function backbuttonurl_noimage(url) {
  url = stripDEUrl(url);
  if ((url.length == 0) || (url == '#'))  document.write('');
  else document.write('<a href="' + url + '" OnMouseOver="msover(\'image12\',\'images/stcbk_m.gif\'); window.status=\'Previous\'; return true" OnMouseOut="msout(\'image12\',\'images/stcback.gif\'); window.status=\'\'; return true" onClick="stopMedia(); determineMenuLinkStates(); return true"><img src="images/stcback.gif" align=top border="0"  name="image12"></a>');
}

// ****************************************************************************
//                       forwardbuttonurl()
//
//  Function that
//
// AUTHOR:  David E. Thomas / Samurai Systems, Inc.
// DATE:  08/28/00
// DESCRIPTION:
//  If an href is empty or pound sign then the forward button is nothing more
//  than
//  than an image (nonclickable).  Otherwise, a forward button is created that
//  will go to the href given when clicked.  The active forward button
//  includes mouse events that change the look of the button when the mouse
//  moves over it.
//
//
// PARAMETERS:
//
//  href  - URL to go to when forward button is clicked.
//  INPUTS:    (url)
//  OUTPUTS:   None.
//
// ****************************************************************************
function forwardbuttonurl(url) {
  url = stripDEUrl(url);
  if ((url.length == 0) || (url == '#')) document.write('<img src="images/stcnext.gif" align=top border="0"  name="image11">');
  else document.write('<a href="' + url + '" OnMouseOver=msover(\'image11\',\'images/stcnxt_m.gif\'); window.status=\'Next\'; return true" OnMouseOut="msout(\'image11\',\'images/stcnext.gif\'); window.status=\'\'; return true" OnClick="stopMedia();determineMenuLinkStates();return true"><img src="images/stcnext.gif" align=top border="0"  name="image11"></a>');
}


// ****************************************************************************
//                           replaybutton()
//
//  Function that
//
// AUTHOR:  Peter Zheng / IBS, Inc.
//
// DESCRIPTION:
//  Creates an active replay button . Developer can hard code the flash file name as first paramenter.
//  Also Develper and pass"nonarration" as first paramenter to just draw a grid graphic.
//
// PARAMETERS:
//
//  INPUTS:    none
//  OUTPUTS:   None.
//
// ****************************************************************************
function replaybutton() {

  var lngAt
  var prefix
    lngAt = document.URL.search('#');
    lngAt == -1 ? (prefix=document.URL.length-14) :(prefix=lngAt-14);

    if (arguments[0]=='nonarration'){
    var flashName='<tr><td width="114"><img src="images/stcgrid25.gif" border="0" width="114" name="image14"></td></tr>';
    }
    else{
    var flashName=(arguments.length == 1 ?'<embed src="media/'+arguments[0]+'" width="114" height="25"></embed>' : '<embed src="media/'+document.URL.substr(prefix,9)+'.swf" width="114" height="25"></embed>' );
    }
    //var flashName='<embed src="media/test00001.swf" play="false"></embed>'
    document.write(flashName);

  //if (arguments.length > 0) document.write('<img src="images/stcrplay.gif" align=top border="0"  name="image13">');
  //else document.write('<a OnMouseOver=msover(\'image13\',\'images/stcrpl_m.gif\'); window.status=\'Replay\'; return true" OnMouseOut="msout(\'image13\',\'images/stcrplay.gif\'); window.status=\'\'; return true" OnClick="replayMedia();return true"><img src="images/stcrplay.gif" align=top border="0" name="image13"></a>');
}
// ****************************************************************************
//                           menureplaybutton()
//
//  Function that
//
// AUTHOR:  David E. Thomas / Samurai Systems, Inc.
//
// DESCRIPTION:
//  Creates an active replay button or not depending on the dontdoit
//  argument.
//
// PARAMETERS:
//
//  dontdoit  - whether or not to have the replay button enabled
//  INPUTS:    (dontdoit)
//  OUTPUTS:   None.
//
// ****************************************************************************
function menureplaybutton() {
    var lngAt
    var prefix
      lngAt = document.URL.search('#');
      lngAt == -1 ? (prefix=document.URL.length-14) :(prefix=lngAt-14);

    //var flashName=(arguments.length != 1 ?'<embed src="media/'+document.URL.substr((document.URL.length-14),9)+'.swf" play="'+startPlay+'" width="114" height="25"></embed>' : '<embed src="media/'+document.URL.substr((document.URL.length-14),9)+'.swf" play="'+startPlay+'" width="'+arguments[0]+'" height="'+arguments[0]+'"></embed>');
    //var flashName='<embed src="media/test00001.swf" play="false"></embed>'
    if (arguments[0]=='nonarration'){
      var flashName='<tr><td width="114"><img src="images/stcgrid25.gif" border="0" width="114" name="image14"></td></tr>';
    }
    else{
      var flashName=(arguments.length == 1 ?'<embed id="memusound" src="media/'+arguments[0]+'" play="false" width="114" height="25"></embed>' : '<embed id="memusound" src="media/'+document.URL.substr(prefix,9)+'.swf" play="false" width="114" height="25"></embed>');
    }
    document.write(flashName);

  //if (arguments.length > 0) document.write('<img src="images/stcrplay.gif" align=top border="0"  name="image13">');
  //else document.write('<a OnMouseOver=msover(\'image13\',\'images/stcrpl_m.gif\'); window.status=\'Replay\'; return true" OnMouseOut="msout(\'image13\',\'images/stcrplay.gif\'); window.status=\'\'; return true" OnClick="replayMedia();return true"><img src="images/stcrplay.gif" align=top border="0" name="image13"></a>');
}

// ****************************************************************************
//                                 menuhiddeninput()
//
//  Function that
//
// AUTHOR:  David E. Thomas / Samurai Systems, Inc.
//
// DESCRIPTION:
//  Writes out input pairs for the form that will be on menu pages.
//  The first input box will be used to retrieve whether or not a menu item
//  should be enabled (the browser will populate it).  The second input
//  box will be used to store the URL and description for the menu item.
//
//  The menu item will be generated dynamically after the page is written
//  by using the DOM to read the information from the second input box.
//
// PARAMETERS:
//
//  url           - the url to go to when the user clicks on the menu item
//  description   - the text for the menu item
//  OUTPUTS:   None.
//
// ****************************************************************************
function menuhiddeninput(url, description) {
  url = stripDEUrl(url);
  description = stripEndAnchor(description);
  if ((url.length > 0) && (url != '#')) {
    document.write('<input type="hidden" name="Course Progress::' + url + '">');
    document.write('<input type="hidden" name="CP_' + url + '" value="' + description + '">');
  }
}

// ****************************************************************************
//                                   learnbuttonurl()
//
//  Function that
//
// DESCRIPTION:
//
//  Generates a learn more button that navigates to the URL passed in.
//  If the URL is # or empty then only the learn more button image will be
//  displayed.
//
// PARAMETERS:
//
//  url   - the url to go to when the learn button is clicked
//  NONE
//  INPUTS:    (url)
//  OUTPUTS:   None.
//
// ****************************************************************************
function learnbuttonurl(url) {
  url = stripDEUrl(url);
  if ((url.length == 0) || (url == '#')) document.write('<img src="images/stclearn.gif" align=top border="0" name="image14">');
  else {
    document.write('<a href="' + url + '" OnMouseOver="msover(\'image19\',\'images/stclrn_m.gif\'); window.status=\'Replay\'; return true" OnMouseOut="msout(\'image19\',\'images/stclearn.gif\'); window.status=\'\'; return true" OnClick="stopMedia();determineMenuLinkStates(); return true"><img src="images/stclearn.gif" align=top border="0" name="image19"></a>');
  }
}

// ****************************************************************************
//                                   preload()
//
//  Function that preloads.
//
// DESCRIPTION:
//
//  Preload images
//  INPUTS:    None.
//  OUTPUTS:   None.
//
// ****************************************************************************
function preload() {
        this.length = preload.arguments.length;
        for (var i = 0; i < this.length; i++) {
            this[i+1] = new Image();
            this[i+1].src = preload.arguments[i];
        }
}

// ****************************************************************************
//                             msover()
//  Function that
//
// DESCRIPTION:
//
//  Replace image in image list with another image.  This is used to change
//  button images on the mouse over event.
//
// PARAMETERS:
//
//  img   - image name to replace
//  ref   - path to image
//  INPUTS:    (img,ref)
//  OUTPUTS:   None.
//
// ****************************************************************************
function msover(img,ref) {
  document.images[img].src = ref;
}


// ****************************************************************************
//                                msout()
//
//  Function that
//
// DESCRIPTION:
//
//  Replace image in image list with another image.  This is used to change
//  button images on the mouse out event.
//
// PARAMETERS:
//
//  img   - image name to replace
//  ref   - path to image
//  NONE
//  INPUTS:   (img,ref)
//  OUTPUTS:   None.
//
// ****************************************************************************
function msout(img,ref) {
  document.images[img].src = ref;
}

// ****************************************************************************
//                              storepagename()
//
//  Function that
//
// DESCRIPTION:
//
//  Writes a course abbreviation with a page name.  The page name
//  will be the last six letters of the the current HTML page name.
//  string    - course abbreviation followed by page name
//  INPUTS:    None.
//  OUTPUTS:    return page;
//
// ****************************************************************************
function storepagename() {
  var lngAt;

  longpage=document.URL;

  //Certain URL's will have an additional file specification on the end for
  //the back button to work preperly. The end of the current page URL
  //in that case will be at the # token.
  lngAt = longpage.search('#');
  if( lngAt == -1)
  {
    prefix=longpage.length-14;
  }
  else
  {
    prefix=lngAt-14;
  }

  page=longpage.substr(prefix,9);
  return page;
}

// ****************************************************************************
//                                EmbedAudio()
//
//  Function that
//
// DESCRIPTION:
//  NONe
//  INPUTS:    None.
//  OUTPUTS:   None.
//
// ****************************************************************************
function EmbedAudio() {
  //var lngAt;
//
  //longpage=document.URL;
//
  //Certain URL's will have an additional file specification on the end for
  //the back button to work preperly. The end of the current page URL
  //in that case will be at the # token.
  //lngAt = longpage.search('#');
  //if( lngAt == -1)
  //{
  //  prefix=longpage.length-14;
  //}
  //else
  //{
  //  prefix=lngAt-14;
  //}
//alert('this page calls palyaudio function. that function should not been called. tell peter remove it!');
  //audioname=longpage.substr(prefix,9);
  //document.write('<DIV id="jslayer" style="position:absolute;  z-index:2; left: 0px; top: 0px; ">');
  //document.write('<embed id="mysound" src="media/'+audioname+'.mp3" autostart=FALSE volume=75 hidden=true>');
  //document.write('</embed>');
  //document.write('</DIV>')
}
// ****************************************************************************
//                                    playAudio()
//
//  Function that
// DESCRIPTION:
//
//  Calculate 6 character audio name and automatically play it.
//  INPUTS:    None.
//  OUTPUTS:   None.
//
// ****************************************************************************
function playAudio() {
  //var lngAt;
//
  //longpage=document.URL;

  //Certain URL's will have an additional file specification on the end for
  //the back button to work preperly. The end of the current page URL
  //in that case will be at the # token.
  //lngAt = longpage.search('#');
  //if( lngAt == -1)
  //{
  //  prefix=longpage.length-14;
  //}
  //else
  //{
  //  prefix=lngAt-14;
  //}
//alert('this page calls palyaudio function. that function should not been called. tell peter remove it!');
  //audioname=longpage.substr(prefix,9);
//
  //document.write('<embed src="media/'+audioname+'.mp3" autostart=TRUE volume=75 hidden=true>');
  //document.write('</embed>');
}

// ****************************************************************************
//                               stopMedia()
//
//  Function that
//
// DESCRIPTION:
//
//  Stop any media elements on the page (flash, mp3).
//  INPUTS:    None.
//  OUTPUTS:   None.
//
// ****************************************************************************
function stopMedia() {
//  var x;
//
//  for (x=0; x < document.embeds.length; x++)
//    document.embeds[x].stop();
//alert(x < document.embeds.length);

//  return true;
}

// ****************************************************************************
//                              replayMedia()
//
//  Function that
// DESCRIPTION:
//
//  Replay all the media on the page (flash, mp3)
//  INPUTS:    None.
//  OUTPUTS:   return true
//
// ****************************************************************************
function replayMedia() {
  var x;

  for (x=0; x < document.embeds.length; x++) {
    document.embeds[x].stop();
    document.embeds[x].CurrentPosition= 0;
    document.embeds[x].play();
  }
  return true;
}

// ****************************************************************************
//                                stopMedia()
//
//  Function that
//
// DESCRIPTION:
//
//  Stop all the media on the page (flash, mp3)
//  INPUTS:    None.
//  OUTPUTS:   return true
//
// ****************************************************************************
function stopMedia() {
//  var x;

//  for (x=0; x < document.embeds.length; x++) {
//    document.embeds[x].stop();
//    document.embeds[x].CurrentPosition= 0;
//  }
//  return true;
//  alert(x < document.embeds.length+'2 second');


}

// ****************************************************************************
//                             playFlash()
//
//  Function that
//
// DESCRIPTION:
//
//  Embed a flash object in page and play it.
//  NONE
//  INPUTS:    None or 2 or 3. If parameter number is 2, the first is width and the second is height.
//                             If parameter number is 3, the first one is swf file name, the second one is width, teh third one is height.
//  OUTPUTS:   None.
//  Sample code:
//    <table width="650" align="center" border="0" cellspacing="0" cellpadding="0" id="contentTable">
//    <tr>
//        <!-- Copy theChange "start.swf"(first parameter) into the flash file name you want to play. -->
//        <!-- Change "start.swf"(first parameter) into the flash file name you want to play. -->
//        <!-- Change width(second parameter) and height(third parameter) to resize the flash. -->
//      <td valign="top" align="center"><script language="javascript">playFlash('start.swf','320','480');</script></td>
//    </tr>
//    </table>
// ****************************************************************************
function playFlash() {
  longpage=document.URL;
  prefix=longpage.length-14;
  flashname=longpage.substr(prefix,9);
  var x = (arguments.length == 2 ? '<embed src="media/'+flashname+'.swf" WIDTH="'+arguments[0]+'" HEIGHT="'+arguments[1]+'">' : '<embed src="media/'+flashname+'.swf">');

  if (arguments.length==3){
    x='<embed src="media/'+arguments[0]+'" WIDTH="'+arguments[1]+'" HEIGHT="'+arguments[2]+'">'
  }
  document.write(x);
  document.write('</embed>');
}

// ****************************************************************************
//                             playMPG()
//
//  Function that
//
// DESCRIPTION:
//
//  embeds an MPG in the page and plays it
//  NONE
//  INPUTS:    None.
//  OUTPUTS:   None.
//
// ****************************************************************************
function playMPG() {
  longpage=document.URL;
  prefix=longpage.length-14;
  MPGname=longpage.substr(prefix,9);
  document.write('<embed src="media/'+MPGname+'.mpg" autostart=TRUE volume=75 hidden=false>');
  document.write('</embed>');
}

// ****************************************************************************
//                           right()
//
//  Function that
// DESCRIPTION:
//
//  disable right click view source option
//
// PARAMETERS:
//  INPUTS:    None.
//  OUTPUTS:   None.
//
// ****************************************************************************
function right()
{
  var msg = "Sorry, view source is not\n available with this program.";
  if (navigator.appName == 'Netscape' && e.which == 3)
  {//alert(e.which);
    alert(msg);
  }
  else
  if (navigator.appName == 'Microsoft Internet Explorer' && event.button==2)
  {
    alert(msg);
    return false;
  }
  return true;

}

// ****************************************************************************
//                               MM_reloadPage()
//  Function that
// DESCRIPTION:
//
//  DreamWeaver generated function.
//  Reloads the window if Nav4 resized.
//  NONE
//  INPUTS:    (init)
//  OUTPUTS:   None.
//
// ****************************************************************************
function MM_reloadPage(init) {
  if (init==true)
    with (navigator)
    {
      if ((appName=="Netscape")&&(parseInt(appVersion)==4))
      {
        document.MM_pgW=innerWidth;
        document.MM_pgH=innerHeight;
        onresize=MM_reloadPage;
      }
    }
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH)
    location.reload();
}

// ****************************************************************************
//                             MM_findObj()
//
//  Function that
//
// DESCRIPTION:
//
//  DreamWeaver generated function.
//  Locate layers
//
//  INPUTS:    (n, d)
//  OUTPUTS:   None.
//
// ****************************************************************************
function MM_findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}


// ****************************************************************************
//                                  MM_showHideLayers()
//
//  Function that
//
// DESCRIPTION:
//
//  DreamWeaver generated function.
//  Hide and show layers code.
//  NONE
//  INPUTS:    None.
//  OUTPUTS:   None.
//
// ****************************************************************************
function MM_showHideLayers() {
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

// ****************************************************************************
//                                 initAns()
//
//  Function that
//
// AUTHOR:  David E. Thomas / Samurai Systems, Inc.
//
// DESCRIPTION:
//  Insert an action for a form and submit it
//
//  NONE
//  INPUTS:    None.
//  OUTPUTS:   None.
//
// ****************************************************************************
function initAns(action) {
   document.forms[0].action = action;
   document.forms[0].submit();
}

// ****************************************************************************
//                       writeCourseNumberAndDescription()
//
//  Function that
// DESCRIPTION:
//  INPUTS:    (CourseNumber, CourseDesc)
//  OUTPUTS:   None.
//
// ****************************************************************************
function writeCourseNumberAndDescription(CourseNumber, CourseDesc) {
    document.write('<input type="hidden" name="CourseNumber" value="' + CourseNumber + '">');
    document.write('<input type="hidden" name="CourseDesc" value="' + CourseDesc + '">');
 }

// ****************************************************************************
//                             writeValidCourseNumber()
// DESCRIPTION:
//  INPUTS:    None.
//  OUTPUTS:   None.
//
// ****************************************************************************
function writeValidCourseNumber() {
    document.write('<input type="hidden" name="ValidCourseNumber" value="' + CourseNumber + '">');
}

// ****************************************************************************
//                              SetMenuFlag()
//  Function that
//
// DESCRIPTION:
//
//  Sets a menu flag to enable a menu item.
//
// PARAMETERS:
//
//  pstraction  - url to go to next after browser saves menu flag
//  pstrmenu    - menu number to enable
//
// RETURN VALUE:
//  FALSE     - cancels event in HTML *
//  INPUTS:    (pstraction, pstrmenu)
//  OUTPUTS:   return false
//
// ****************************************************************************
function SetMenuFlag(pstraction, pstrmenu)
{
  stopMedia();
  document.form1.elements[pstrmenu].value = "y";
  document.form1.action = pstraction;
  document.form1.submit();
  return false;
}

// ****************************************************************************
//                                  stripDEUrl()
//
//  Function that
//
// DESCRIPTION:
//
//  Retrieve URL from designer's edge string.  Pull URL out from inside quotes.
//            # if could not find URL in quotes
//  INPUTS:    (deurl)  ]string containing URL in quotes
//  OUTPUTS:    return  newUrl,'#'  [string  - URL ]
//
// ****************************************************************************
function stripDEUrl(deurl) {

  startpos = deurl.indexOf('"') + 1;
  if (startpos != 0) {
    endpos = deurl.lastIndexOf('"');
    newUrl = deurl.slice(startpos, endpos);
    return newUrl;
  }
  else {
    return '#';
  }

}


// ****************************************************************************
//                             stripEndAnchor()
//
//  Function that
//
// DESCRIPTION:
//
//  Take the end anchor off of the text.
//  INPUTS:    (endanchortext)   anchor text with an end anchor on the end
//  OUTPUTS:   return newtext, endanchortext
//
// ****************************************************************************
function stripEndAnchor(endanchortext) {
  var x = endanchortext.indexOf('</a>');
  if (x == -1) x = endanchortext.indexOf('</A>');
  if (x > 0) {
    var newtext = endanchortext.slice(0, x );
    return newtext;
  }
  else return endanchortext;
}

// ****************************************************************************
//                               CheckName()
//
//  Function that
// DESCRIPTION:
//
//  Make sure there are no numeric characters in the name fields.
//
// PARAMETERS:
//
//  NameToCheck   - string to check for numeric characters
//  INPUTS:    (NameToCheck)
//  OUTPUTS:   None.
//
// ****************************************************************************
function CheckName(NameToCheck) {

  charsToCheck = "0123456789";

  for (x=0; x<charsToCheck.length;x++) {
    found = NameToCheck.value.indexOf(charsToCheck.charAt(x))
    if (found != -1) {
      alert('The name field must not include any of the following characters:\n' + charsToCheck);
      NameToCheck.select();
      NameToCheck.focus();
      return false;
    }
  }

}

// ****************************************************************************
//                          TurnOnLink()
//
//  Function that
//
// AUTHOR:  David E. Thomas / Samurai Systems, Inc.
// DATE  :  08/18/2000
// DESCRIPTION:
//  Used internally by 'openpage.js' to place the value of 'y' into an html
//  form element. Retrieve URL from designer's edge string.  Pull URL out
//  from inside quotes.
//
// USAGE:
//  Not intended to be used externally
//  INPUTS:    None.
//  OUTPUTS:   None.
//
// ****************************************************************************
function TurnOnLink() {
  var xn;
  if (xargs.length > 0) {
    for (var x = 0; x < xargs.length; x++) {
      xn = xcp + xargs[x];
      document.form1.elements[xn].value = 'y';
    }
    determineMenuLinkStates();
  }
}


// ****************************************************************************
//                                  enablelink()
//
//  Function that
//
// AUTHOR:  David E. Thomas / Samurai Systems, Inc.
// DATE  :  08/18/2000
// DESCRIPTION:
//  Writes HTML for a hidden input field containing a menu link with an initial
//  value of 'y'.  The value can be changed by the Browser application
//
// USAGE:
//  Not intended to be used externally
//  INPUTS:    None.
//  OUTPUTS:   None.
//
// ****************************************************************************
function enablelink() {
  var xn = '<input type="hidden" name="' + xcp;
  if (xargs.length > 0) {
    for (var x = 0; x < xargs.length; x++) {
      document.write('  ' + xn + xargs[x] + '">');
    }
    setTimeout('TurnOnLink()',500);
    //TurnOnLink();
  }
}

// ****************************************************************************
//                                 testformenablelink()
//
//  Function that
//
// AUTHOR:  David E. Thomas / Samurai Systems, Inc.
// DATE  :  08/18/2000
// DESCRIPTION:
//  Writes HTML for a form called form1.  Uses optional arguments, where
//  the first argument is the name of the module test, and the remaining
//  arguments are menu links to be enabled.  The module test name and the
//  menu links are written as input hidden fields in the form.
//  Use this function to insert a form, called 'form1', with hidden
//  input field(s) for menu linking and for the value to a 'y'
//  INPUTS:    None.
//  OUTPUTS:   None.
//
// ****************************************************************************
function testformenablelink() {
  if (arguments.length > 0) {
    if (arguments.length > 1) {
      for (var x = 1; x < arguments.length; x++) {
        xargs[x-1] = arguments[x];
      }
    }
    document.write('<DIV id="jslayer" style="position:absolute;  z-index:2; left: 0px; top: 0px; visibility: hidden">');
    document.write('<form name="form1" method="post">');
    document.write('  <input type="hidden" name="' + arguments[0] + '::' + storepagename() + '" value="!">');
    document.write('  <input type="hidden" name="bookmark" value="n">');
    if (xargs.length > 0) {
        enablelink();
        }
    document.write('</form>');
    document.write('  </DIV>');
  }
}

// ****************************************************************************
//                           formenablelink()
//
//  Function that
//
// AUTHOR:  David E. Thomas / Samurai Systems, Inc.
// DATE  :  08/18/2000
// DESCRIPTION:
//  Writes HTML for a form with input fields enabling menu links.
//  Use this function to create a form and enable one or more menu links
//  in a form.
//
// PARAMETERS:
//
// RETURN VALUE:
//  INPUTS:    None.
//  OUTPUTS:   None.
//
// ****************************************************************************
function formenablelink() {
  if (arguments.length > 0) {
    document.write('<DIV id="jslayer" style="position:absolute;  z-index:2; left: 0px; top: 0px; visibility: hidden">');
    document.write('<form name="form1" method="post">');
    //document.write('<input type="hidden" name="bookmark" value="n">');
    document.write('<input type="hidden" name="label" value="Course Progress">');
    for (var x = 0; x < arguments.length; x++) {
      document.write('<input type="hidden" name="' + arguments[x] + '" value="y">');
    }
    document.write('</form>');
    document.write('  </DIV>');
  }
}

// ****************************************************************************
//                             determineMenuLinkStates()
//
//  Function that
//
// AUTHOR:  David E. Thomas / Samurai Systems, Inc.
// DATE  :  08/18/2000
// DESCRIPTION:
//  Enables and disables menu links based upon the value of any hidden menu
//  link fields on a page. Function to retrieve any form values for menu
//  links that are turned on, and saves them into a cookie variable.
//  INPUTS:    None.
//  OUTPUTS:   None.
//
// ****************************************************************************
function determineMenuLinkStates() {
  var namecheck;
  var tempname;
  var valuecheck;
  var inlabel;
  var arr_current = enabledmenus;
  var arr_enabled = new Array();
  var arr_disabled = new Array();
  var enabled_count = -1;
  var disabled_count = -1;
  var x;
  var y;
  var z;
  var cp_count=0;

  if (document.forms.length > 0) {
    for (x = 0; x < document.forms.length ; x++) {
      inlabel = false;
      if (document.forms[x].elements.length > 0) {
        for (y = 0; y < document.forms[x].elements.length; y++) {
          namecheck = document.forms[x].elements[y].name;
          valuecheck = document.forms[x].elements[y].value;
          if((namecheck == 'label') && (valuecheck == 'Course Progress')) {
            inlabel = true;
          }
          z = namecheck.indexOf('.html')
          if (z > 1) {
            if ((namecheck.length == 14) && (inlabel)) {
              if (valuecheck == 'y') {
                enabled_count++;
                arr_enabled[enabled_count] = namecheck;
              }
              else if (valuecheck == 'n') {
                disabled_count++;
                arr_disabled[disabled_count] = namecheck;
              }
            }
            else if (namecheck.indexOf('Course Progress::') == 0) {
              tempname = namecheck.split('::')[1];
              if (isEnabled(tempname)) cp_count++;
              if (valuecheck == 'y') {
                enabled_count++;
                arr_enabled[enabled_count] = tempname;
              }
              else if (valuecheck == 'n') {
                disabled_count++;
                arr_disabled[disabled_count] = tempname;
              }
            }
          }
        }
      }
    }
  }
  // Remove any disabled menus from the current array
  if ((arr_current.length > 0) && (disabled_count > -1)) {
    for (x = 0; x < (disabled_count + 1); x++) {
      for (y = 0; y < arr_current.length; y++) {
        if (arr_disabled[x] == arr_current[y]) arr_current[y] = "";
      }
    }
  }
  // Add enabled menus to the current array (if not already there).
  if (enabled_count > -1) {
    for (x = 0; x < (enabled_count + 1); x++) {
      if (arr_current.length == 0) {
        arr_current[arr_current.length] = arr_enabled[x];
      }
      else {
        var foundlink = false;
        for (y = 0; y < arr_current.length; y++) {
          if (arr_current[y] == arr_enabled[x]) foundlink = true;
        }
        if (!foundlink) arr_current[arr_current.length] = arr_enabled[x];
      }
    }
  }
  // Create the cookie variable and save the enabled menus.
  putenabledmenulist(arr_current);
  // Play audio if 'mysound' exists and only one menu link is enabled on page.
  if(document.embeds.length>0){
    if ((document.embeds[0].id =='memusound') && (cp_count == 1)) {
      document.embeds[0].forward();
    }
  }
}

// ****************************************************************************
//                            isEnabled()
//
//  Function that
//
// AUTHOR:  David E. Thomas / Samurai Systems, Inc.
// DATE  :  08/18/2000
// DESCRIPTION:
//  Returns TRUE if the menu link, specified in the parameter 'menulink', is
//  enabled. Otherwise it returns FALSE.
//  This function determines if a menu link is enabled
//
// PARAMETERS:
//  An html page name in the form of a string ('nnnnnn.html')
//
// RETURN VALUE:
//  A boolean value of TRUE or FALSE
//  INPUTS:   return xf
//  OUTPUTS:   None.
//
// ****************************************************************************
function isEnabled(menulink) {
  var x;
  var xf = false;
  for (x = 0; x < enabledmenus.length; x++) {
    if (menulink == enabledmenus[x]) xf = true;
  }
  return xf;
}


// ****************************************************************************
//                              setMenuLinkStates()
//
//  Function that
//
// AUTHOR:  David E. Thomas / Samurai Systems, Inc.
// DATE  :  08/18/2000
// DESCRIPTION:
//  Works only with the page 'return2.html'.  It retrieves the value of all
//  the enabled menu links from the student.ini file and stores them into
//   the memory
//  of the browser, using the cookie object.
//  This function is used by set the initial menu states.  The value for
//      this comes from the student.ini file via :
//  'return2.html <input type="hidden" name="*INI::Course Progress">'
//  INPUTS:    None.
//  OUTPUTS:   None.
//
// ****************************************************************************
function setMenuLinkStates() {
  var cpdata = "";
  var cparray;
  var xarr;
  var x;
  var y = 0;
  var initialmenus = new Array();
  // Initialize the cookies.
  //document.cookie = escape('enabledmenulist=mainmenu.html;sbd=nothing');
  if (document.location.href.indexOf('return2.html') > -1) {
    cpdata = document.forms[0].elements['*INI::Course Progress'].value.toLowerCase();
    cparray = cpdata.split('~');
    for (x = 0; x < cparray.length; x++) {
      if (cparray[x].indexOf('=') > 0) {
        xarr = cparray[x].split('=');
        if ((xarr[0].indexOf('.html') > 0) && (xarr[1].indexOf('y') > -1)) {
          initialmenus[y++] = xarr[0];
        }
      }
    }
    putenabledmenulist(initialmenus);
  }
  else {
    alert('You cannot use openpage.js::setMenuLinkStates() on this page!');
  }
}

// ****************************************************************************
//                         getCookie()
//
//  Function that
//
// AUTHOR:  David E. Thomas / Samurai Systems, Inc.
// DATE  :  09/09/2000
// DESCRIPTION:
//  Retrieves a value from the browsers cookie object. The value retrieved
//  depends upon the name passed as an argument to the
//
// PARAMETERS:
//  A name from the defined cookies variable list.
//  INPUTS:    None.
//  OUTPUTS:   None.
//
// ****************************************************************************
function getCookie() {
  var vname = '';
  var vcookies = getCookies();
  var vx;
  var vcomp;
  if (arguments.length > 0) {
    vname = arguments[0];
    if (vname.length > 0) {
      if (definedcookies.indexOf(vname) != -1) {
        for (vx = 0; vx < vcookies.length; vx++) {
          vcomp = vcookies[vx].split('=');
          if (vcomp[0] == vname) {
          //alert('vcomp[1]'+vcomp[1]);
            return vcomp[1];
          }
        }
      }
      else alert('Your page is attempting to get a cookie not in the defined cookies list.');
    }
    else alert('Your page is attempting to retrieve a cookie with an empty name.');
  }
  else alert('Your page is attempting to retrieve a cookie without a name.');
}

// ****************************************************************************
//                           putCookie()
//
//  Function that
//
// AUTHOR:  David E. Thomas / Samurai Systems, Inc.
// DATE  :  09/09/2000
// DESCRIPTION:
//  Stores a string expression into the memory of the browsers cookie object,
//  using a string expression in the format of ('name=values').  The
//  argument 'vexp' contains the string expression.
//  Function to store a named variable into the cookie object without
//  overwriting existing information.
//
// PARAMETERS:
//  A string variable expression in the form of 'name=value'
//  INPUTS:    None.
//  OUTPUTS:   None.
//
// ****************************************************************************
function putCookie() {
  var vexp;
  var vcookies;
  var va;
  var vcomp;
  var vchanged;
  var vs;
  var vx;
  if (arguments.length > 0) {
    vexp = arguments[0];
    if (vexp.length > 0) {
      if (vexp.indexOf('=') != -1) {
        va = vexp.split('=');
        if (definedcookies.indexOf(va[0]) != -1) {
          if (va.length <= 2) {
            vcookies = getCookies();
            vchanged = false;
            for (vx = 0; vx < vcookies.length; vx++) {
              vcomp = vcookies[vx].split('=');
              if (vcomp[0] == va[0]) {
                vcookies[vx] = va[0] + '=' + va[1];
                vchanged = true;
              }
            }
            if (vchanged) {
              vs = '';
              for (vx = 0; vx < vcookies.length; vx++) {
                if (vs == '') vs = vcookies[vx];
                else vs = vs + ';' + vcookies[vx];
              }
              document.cookie = 'cbtcookies=' + escape(vs);
            }
          }
          else alert('Your page is attempting to store a cookie with too many equal signs.');
        }
        else alert('Your page is attempting to store a cookie not in the defined cookies list.');
      }
      else alert('Your page is attempting to store a cookie without an equal sign.');
    }
    else alert('Your page is attempting to store a cookie with an empty expression.');
  }
  else alert('Your page is attempting to store a cookie without defining one.');
}

// ****************************************************************************
//                              getCookies()
//
//  Function that
//
// AUTHOR:  David E. Thomas / Samurai Systems, Inc.
// DATE  :  09/09/2000
// DESCRIPTION:
//  Retrieves the value in the cookie object and extracts the CBT cookie data
//  INPUTS:    None.
//  OUTPUTS:   return vcbtdta   [An array of cookie value expressions, in the
//    form of 'name=values'].
//
// ****************************************************************************
function getCookies() {
  var vdta;
  var vcbtdta = new Array();
  var vs = '';
  var cookiedata = document.cookie;
  if (cookiedata.length == 0 || cookiedata.substring(0,11) != 'cbtcookies=' ) {
    initCookies();
    cookiedata = document.cookie;
  }
  vdta = cookiedata.split('=');
  vs = unescape(vdta[1]);
  vcbtdta = vs.split(';');
  return vcbtdta;
}

// ****************************************************************************
//                                  initCookies()
//
//  Function that
//
// AUTHOR:  David E. Thomas / Samurai Systems, Inc.
// DATE  :  09/09/2000
// DESCRIPTION:
//  Initializes the cookie object with the defined cookie value list.
//  INPUTS:    None.
//  OUTPUTS:   None.
//
// ****************************************************************************
function initCookies() {
  document.cookie = 'cbtcookies=' + escape(definedcookies);
}


// ****************************************************************************
//                             getenabledmenulist()
//
//  Function that
//
// AUTHOR:  David E. Thomas / Samurai Systems, Inc.
// DATE  :  08/18/2000
// DESCRIPTION:
//  Retrieves an array of currently enabled menu links.
//  This function gets the cookie variable "enabledmenulist" and returns
//  an array of the menu names
//  INPUTS:    None.
//  OUTPUTS:   return menuarray  An array of strings containing the html page
//                  names that are enabled.
//
// ****************************************************************************
function getenabledmenulist() {
  var menucookie = getCookie('enabledmenulist');
  var menuarray;
  var x;
  if (menucookie.length > 0) {
    menuarray = menucookie.split('.html');
    for (x = 0; x < menuarray.length; x++) {
      if (menuarray[x] != "") menuarray[x] = menuarray[x] + '.html';
      //alert('menuarray['+x+']  '+menuarray[x]);
    }
  }
  else menuarray = new Array();
  return menuarray;
}


// ****************************************************************************
//                           putenabledmenulist()
//
//  Function that
//
// AUTHOR:  David E. Thomas / Samurai Systems, Inc.
// DATE  :  08/18/2000
// DESCRIPTION:
//  Takes an array of enabled menu link names, and stores them into memory
//      using the browser cookie object. This function puts the cookie
//      variable "enabledmenulist" into the cookie object, using an array
//      of menu links (html page names).  MUST HAVE '.html' at the end
//      of each page name (NOT .htm, .HTM OR .HTML)
//
// PARAMETERS:
//  An array of strings containing html page names whose links are
//  enabled.
//  INPUTS:    (menuarray)
//  OUTPUTS:   None.
//
// ****************************************************************************
function putenabledmenulist(menuarray) {
  var s = "enabledmenulist=";
  var x;
  for (x = 0; x < menuarray.length; x++) {
    if (menuarray[x] != "") s = s + menuarray[x];
  }
  putCookie(s);
}

// ****************************************************************************
//                             startupFunctions()
//
//  Function that
//
// AUTHOR:  David E. Thomas / Samurai Systems, Inc.
// DATE  :  08/29/2000
// DESCRIPTION:
//  If the page is 'return2.html' (which should not be the case), it executes
//  the function 'setMenuLinkStates()', otherwise it executes the function
//  'determineMenuLinkStates().
//  Function to call other functions as a group when this script file
//  is references
//
// USAGE:
//  Not intended to be used externally
//  INPUTS:    None.
//  OUTPUTS:   None.
//
// ****************************************************************************
function startupFunctions() {
  if (document.location.href.indexOf('return2.html') == -1) {
    determineMenuLinkStates();
}
}

// ****************************************************************************
//                          StartUp()
//
//  Function that
//
// AUTHOR:  David E. Thomas / Samurai Systems, Inc.
// DATE  :  08/29/2000
// DESCRIPTION:
//  Function called when a page is opened.  If the page is not 'return2.html'
//  it executes the function 'startupFunctions()' after one (1) second.
//  Otherwise, it does nothing.
//
// USAGE:
//  Not intended to be used externally
//
//  INPUTS:    None.
//  OUTPUTS:   None.
//
// ****************************************************************************
function StartUp() {
  if (document.location.href.indexOf('return2.html') == -1) {
    window.onUnload = determineMenuLinkStates();
    startupFunctions();
  }
}
var oPinion = '';
//******************************************************************************
//
// AUTHOR:  David E. Thomas / Samurai Systems, Inc.
// DATE  :  08/18/2000
// DESCRIPTION:
//  Plays the audio object 'mysound', if the variable 'dontplayaudioagain' is FALSE.
//
// PARAMETERS:
//
// RETURN VALUE:
//
//******************************************************************************

function playMenuAudio() {
    for (var x = 0; x < document.embeds.length; x++)
      if (document.embeds[x].id == 'mysound') mysound.play();
}

//******************************************************************************
//
// AUTHOR:  Peter Zheng
// DATE  :  08/10/2001
// DESCRIPTION:
//  Submit form, which is nobookmark. In the form, there is a hidden input:
//  Bookmark=no
//
// PARAMETERS:
//
// RETURN VALUE:
//
//******************************************************************************

function nobookmark() {
  if (arguments.length > 0) {
  alert('Here should not be any parameter.')
  }
  else{
    document.write('<DIV id="jslayer" style="position:absolute;  z-index:2; left: 0px; top: 0px; visibility: hidden">');
    document.write('<form name="nobookmark" method="post">');
    document.write('<input type="hidden" name="bookmark" value="n">');
    document.write('</form>');
    document.write('  </DIV>');
  }
}
