/* Created by Paul Battersby Jan 20 2004 */

/* This script provides a simple table based navigation menu */
/* that changes the text and background colour as the        */
/* mouse is moved over each item in the menu                 */

/* Example:                                                  */
/*
 <HEAD>
 <META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
 <SCRIPT LANGUAGE="JavaScript" src=navmenu.js></SCRIPT>
 </HEAD>

 <BODY>
 <SCRIPT LANGUAGE="JavaScript">
  <!-- // Activate cloak
  NAVMENU_start("CELLSPACING=1 BORDER=2","8pt trebuchet ms, comic sans ms","white","#003300","white","#009900");
  NAVMENU_addItem("hello","http://www.yahoo.ca");
  NAVMENU_addItem("here","http://www.yahoo.ca");
  NAVMENU_addItem("there","http://www.yahoo.ca");
  NAVMENU_addItem("nowhere","http://www.yahoo.ca");
  NAVMENU_end();
  // Deactivate cloak -->
</SCRIPT>
</BODY>
*/

var navmenu_textColourSelect;   /* the colour of the menu text when the */
                                /*  mouse hovers over a menu item       */

var navmenu_textColourDeselect; /* the colour of the menu text when the */
                                /*  mouse is not over a menu item       */
var navmenu_font;               /* the font to use for the menu text    */

var navmenu_bgSelect;           /* the background colour of a menu item */
                                /*  when the mouse hovers above it      */

var navmenu_bgDeselect;         /* the background colour of a meny item */
                                /*  when the mouse is not hovering      */
                                /*  above it                            */

/*----------------------------------------------------------------------*/
/* NAVMENU_start                                                        */
/*                                                                      */
/*  This is to be called when a navigation menu is to be created        */
/*  This MUST be called before any other functions in this module       */
/*                                                                      */
/*  tableParams = any parameters that should be applied to the table    */
/*                from which the navigation menu is to be created. This */
/*                could include things like border size, cell spacing   */
/*                                                                      */
/*  font               = see documentation for navmenu_font above               */
/*  textColourDeselect = see documentation for navmenu_textColourDeselect above */
/*  bgDeselect         = see documentation for navmenu_bgDeselect above         */
/*  textColourSelect   = see documentation for navmenu_textColourSelect above   */
/*  bgSelect           = see documentation for navmenu_bgSelect above           */
/*----------------------------------------------------------------------*/
function NAVMENU_start(tableParams,font,textColourDeselect,bgDeselect,textColourSelect,bgSelect) {
    document.writeln("<table " + tableParams + ">");
    navmenu_textColourSelect   = textColourSelect;
    navmenu_textColourDeselect = textColourDeselect;
    navmenu_font               = font;
    navmenu_bgSelect           = bgSelect;
    navmenu_bgDeselect         = bgDeselect;

}  /* end of NAVMENU_init */

/*----------------------------------------------------------------------*/
/* navmenu_aMouseOver                                                   */
/*                                                                      */
/*  changes the background and text colour of the menu item             */
/*  to navmenu_bgSelect and navmenu_textColourSelect                    */
/*  respectively when the mouse enters the menu item                    */
/*                                                                      */
/*  id = the id of the menu item currently under the curser             */
/*----------------------------------------------------------------------*/
function navmenu_aMouseOver(id) {
    id.parentNode.style.backgroundColor=navmenu_bgSelect;
    id.style.color=navmenu_textColourSelect
}

/*----------------------------------------------------------------------*/
/* navmenu_aMouseOut                                                    */
/*                                                                      */
/*  changes the background and text colour of the menu item             */
/*  to navmenu_bgDeselect and navmenu_textColourDeselect                */
/*  respectively when the mouse leaves the menu item                    */
/*                                                                      */
/*  id = the id of the menu item that was recently vacated              */
/*       by the mouse                                                   */
/*----------------------------------------------------------------------*/
function navmenu_aMouseOut(id) {
    id.parentNode.style.backgroundColor=navmenu_bgDeselect;
    id.style.color=navmenu_textColourDeselect
}


/*----------------------------------------------------------------------*/
/* NAVMENU_addItem                                                      */
/*                                                                      */
/*   adds an item to the navigation menu                                */
/*                                                                      */
/*   text = the text to place in the menu                               */
/*   link = where to go when user clicks on menu item                   */
/*----------------------------------------------------------------------*/
function NAVMENU_addItem(text,link) {
    document.writeln("<tr>",
          "<TD BGCOLOR=",navmenu_bgDeselect,">",
          "<A STYLE='text-decoration:none;",
          " color:",navmenu_textColourDeselect,";",
          " font:",navmenu_font,
          "';",
          " ONMOUSEOVER = 'navmenu_aMouseOver(this)'; ONMOUSEOUT = 'navmenu_aMouseOut(this)';",
          " HREF='",link,"'>",text,"</A>",
          "</TD>",
          "</TR>");

}  /* end of NAVMENU_addItem */

/*----------------------------------------------------------------------*/
/* NAVMENU_end                                                          */
/*                                                                      */
/*   indicates the end of the navigation menu                           */
/*----------------------------------------------------------------------*/
function NAVMENU_end() {
    document.writeln("</table>");
}  /* end of NAVMENU_init */

