/*===============================================================
COPYRIGHT NOTICE
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Copyright (C) 2007 Donald Montgomery MacLean

This is free  software; you can redistribute it  and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This  sofware is  made  available in  the  hope that  it will  be
useful,  but  WITHOUT  ANY  WARRANTY; without  even  the  implied
warranty of MERCHANTABILITY or  FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.

A copy of  the GNU General Public License  should be available on
the site where  you obtained this software. It  is also available
at:  http://www.gnu.org/licenses/licenses.html or  by  writing to
the Free Software Foundation,  Inc., 51 Franklin St, Fifth Floor,
Boston, MA 02110-1301 USA.

This is merely a notice. The only legally binding document is the
GNU General Public License.
===============================================================*/


/*===============================================================
MANUAL
-----------------------------------------------------------------
NAME
@(#) course_utils.js - functions for Crash Course in Web browsing

SYNOPSIS
     This  is not  a stand-alone  program. It  contains functions
     designed to  be loaded (SRC-ed)  into the HTML files  of the
     Crash Course in Web Browsing.
     
DESCRIPTION
     The  functions  in  this  file  are based  on  functions  in
     'mrhs59utils.js', ver 1.7.2. This  file has been provided so
     that the files making up the  Crash Course can be used as an
     independent package. Each function in this file contains its
     own  documentation.  See  the  file 'crash_course.html'  for
     general information about the course.

AUTHOR
     Donald MacLean          IGdonaldNOatREmacCAleansPIdotTAnetLS
                                      (Do what the capitals say.)
VERSION
@(#)  course_utils.js    vers 1.0.0 - 2007 06 14
     
End MANUAL
===============================================================*/


/*=============================================================*/
function set_title(str)
/*---------------------------------------------------------------
NAME
     set_title() - put "(LOCAL)", etc in title of disk file

DESCRIPTION
     When we are viewing a  local (disk) version of an HTML file,
     this function will  prepend "(C:)", etc, to the  title if it
     can  figure out  the name  of  the disk.  Otherwise it  will
     default to  "(LOCAL)".  Nothing will be prepended  if we are
     viewing the file over the Web.

     This is so that if we have a remote and a local version open
     at  the same time,  we can  distinguish easily  between them
     especially when they are iconized (or "minimized").

     In addition,  the intrusive browser  name will be  pushed to
     the right on the Title Bar.
---------------------------------------------------------------*/
{
  var title = str;

  if ( /http:\/\/.*/.test(window.location.href) ) {
    /*-------------------
    Web file. Do nothing.
    -------------------*/
    ;
  } else if ( /file:\/\/\/.*/.test(window.location.href) ) {
    /* 
     *  Local file. Prepend disk name to Title
     */
    title = "("   + window.location.href.substring(8,10) 
          + ") "  + title;
  } else  {
    /*-------------------------
    Can't figure out disk name.
    -------------------------*/ 
    title = "(LOCAL) " + title;
  }
  /*---------------------------------------
  Push intrusive browser name to the right.
  ---------------------------------------*/
  title +=
    "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
  + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
  + "(&nbsp;-&nbsp;:&nbsp;)";

  document.write("<TITLE>" + title + "</TITLE>");
}
/* End function 'set_title()' */
/*=============================================================*/


/*=============================================================*/
function get_browsername()
/*---------------------------------------------------------------
NAME
     get_browsername() - get name of browser being used

DESCRIPTION
     This function illustrates how  it is possible to recognize a
     Firefox browser, even though its appName is 'Navigator'.  It
     also eliminates blatant Microsoft advertising.
---------------------------------------------------------------*/
{
  if (navigator.userAgent.indexOf("Firefox")!= -1) {
    return "Firefox";
  } else if (navigator.userAgent.indexOf("Opera")!= -1) {
    return "Opera";
  } else if (navigator.appName.indexOf("Microsoft")!= -1) {
    return "Internet Explorer";
  } else {
    return "Unknown";
  }
}
/* End of function 'get_browsername()' */ 
/*=============================================================*/


/*==================
Local Variables:
indent-tabs-mode:nil
fill-column:65
fill-prefix:"     "
End:
==================*/
