//-------------------------------------------------------------------
// File:     CandGWeb.js
// Purpose:  Contains commonly-used JavaScript code
// security: COPYRIGHT (c) Copyright 2003-2007 C&G Web Enterprises
// owner:    Gary Richtmeyer, gary@CandGweb.com
//-------------------------------------------------------------------
// Global functions provided:
//   DateStr            - Returns a formatted date string
//   delCookie          - Delete the specified cookie
//   getCookie          - Get the value of the specified cookie
//   MakeArray          - Make an array
//   PageBottom         - Generate standard end-of-page HTML
//   PageTop            - Generate standard top-of-page HTML
//   PopHelp            - Pop-up a "help"-type window
//   PopWindow          - Pop-up a generic window
//   PrevNextBase       - Base code for PrevNextSect() and PrevNextStep()
//   PrevNextPage       - Generate prev/next "page" navigation links
//   PrevNextSect       - Generate prev/next "section" navigation links
//   PrevNextStep       - Generate prev/next "step" navigation links
//   PrevPage           - Generate standard "return to previous page" HTML
//   setCookie          - Set the specified cookie to a certain value
//   ShowClose          - Generate standard "close this window" HTML
//-------------------------------------------------------------------
// 2003-08-01 GLR - Initial creation
// 2003-08-26 GLR - remove unused code
// 2004-07-29 GLR - update copyright
// 2005-12-21 GLR - rearrange navigation buttons; update copyright
// 2008-03-12 GLR - Add "Online Support" section to PC Support; update copyright
//-------------------------------------------------------------------

// ----- set variables
var author_name     = 'Gary Richtmeyer'
var author_email    = 'gary@CandGWeb.com'

// ----- Use a date of Dec 31, 2009 23:59:59 to set a "permanent" cookie -----
var permdate = new Date(2009,11,31,23,59,59)

// ----- Determine the environment -----
var browser_name    = navigator.appVersion
var browser_release = browser_name.substring(0,browser_name.indexOf(' '))
var browser_version = parseInt(navigator.appVersion)
var browser_type    = '?'
if (navigator.appName == "Netscape")            { browser_type = 'NS'    }
if (navigator.userAgent.indexOf("Opera") != -1) { browser_type = 'OPERA' }
if (navigator.appVersion.indexOf("MSIE") != -1) { browser_type = 'MSIE'  }
var screen_width    = window.screen.width
var screen_height   = window.screen.height
// ----- Simple version detection and shortcut variables -----
var isNS     = ( navigator.appName == "Netscape" && browser_version >= 4 )
var isNS4    = ( navigator.appName == "Netscape" && browser_version <= 4 )
var HIDDEN   = (isNS) ? 'hide' : 'hidden';
var VISIBLE  = (isNS) ? 'show' : 'visible';



//*******************************************************************
// Various functions
//*******************************************************************

//-------------------------------------------------------------------
// setGlobalVars: set global variables
//   Usage: setGlobalVars(x)   x = option number of how many dirs
//                                 "up" from here is the root dir.
//   Sets the following global variables (referred to as
//   "top.xxxx" within other files):
//      baseURL    - The URL of the "root" directory
//      ImagePath  - The URL where the images are stored
//-------------------------------------------------------------------
function setGlobalVars(updirs) {
  temp = document.location.pathname    // change "\" in path
  j = temp.indexOf('\\')               // (e.g. on a PC and using MSIE)
  while ( j >= 0 ) {                   // to "/"
    temp = temp.substr(0,j) + '/' + temp.substr(j+1)
    j = temp.indexOf('\\',j)
    }
  if ( arguments.length == 0 )
         { updirs = 0 }
    else { updirs = arguments[0] }
  if ( updirs == null ) updirs = 0
  while ( updirs > 0 ) {
    temp = temp.substring(0,temp.lastIndexOf('/'))
    updirs = updirs - 1
    }
  baseURL   = document.location.protocol + '//' +
              document.location.host     +
              temp.substring(0,temp.lastIndexOf('/'))
  ImagePath = baseURL + '/Images/'
  }


//-------------------------------------------------------------------
// StartScreen: Setup initial screen layout, header section and navigation.
// Use: StartScreen('sectionId','nodeId',dirlevel)
//   sectionId - ID of the active major section
//   nodeId    - ID of the active minor section
//   dirlevel  - Directory level (0=root, 1=one "down", 2=two "down"...)
//-------------------------------------------------------------------
function StartScreen(sectionId,nodeId,dirlevel) {
  setGlobalVars(dirlevel)

  tempstr = '<body background="' + top.ImagePath + 'sitebgleft.gif" ' +
                  'rightmargin=0 bottommargin=0 ' +
                  'marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>'
  document.write(tempstr)
//----- Define the navigation icons
if (document.images) {
  var button_prefix = "main_"
  var ip = top.ImagePath + button_prefix
  aboutusdown      = new Image(140,30); aboutusdown.src      = ip + "aboutus_down.gif";
  aboutushere      = new Image(140,30); aboutushere.src      = ip + "aboutus.gif";
  aboutusover      = new Image(140,30); aboutusover.src      = ip + "aboutus_over.gif";
  aboutusup        = new Image(140,30); aboutusup.src        = ip + "aboutus_up.gif";
  homedown         = new Image(140,30); homedown.src         = ip + "home_down.gif";
  homehere         = new Image(140,30); homehere.src         = ip + "home.gif";
  homeover         = new Image(140,30); homeover.src         = ip + "home_over.gif";
  homeup           = new Image(140,30); homeup.src           = ip + "home_up.gif";
  consultingdown   = new Image(140,30); consultingdown.src   = ip + "consulting_down.gif";
  consultinghere   = new Image(140,30); consultinghere.src   = ip + "consulting.gif";
  consultingover   = new Image(140,30); consultingover.src   = ip + "consulting_over.gif";
  consultingup     = new Image(140,30); consultingup.src     = ip + "consulting_up.gif";
  contactusdown    = new Image(140,30); contactusdown.src    = ip + "contactus_down.gif";
  contactushere    = new Image(140,30); contactushere.src    = ip + "contactus.gif";
  contactusover    = new Image(140,30); contactusover.src    = ip + "contactus_over.gif";
  contactusup      = new Image(140,30); contactusup.src      = ip + "contactus_up.gif";
  pcnetworkdown    = new Image(140,30); pcnetworkdown.src    = ip + "pcnetworking_down.gif";
  pcnetworkhere    = new Image(140,30); pcnetworkhere.src    = ip + "pcnetworking.gif";
  pcnetworkover    = new Image(140,30); pcnetworkover.src    = ip + "pcnetworking_over.gif";
  pcnetworkup      = new Image(140,30); pcnetworkup.src      = ip + "pcnetworking_up.gif";
  pcsupportdown    = new Image(140,30); pcsupportdown.src    = ip + "pcsupport_down.gif";
  pcsupporthere    = new Image(140,30); pcsupporthere.src    = ip + "pcsupport.gif";
  pcsupportover    = new Image(140,30); pcsupportover.src    = ip + "pcsupport_over.gif";
  pcsupportup      = new Image(140,30); pcsupportup.src      = ip + "pcsupport_up.gif";
  websitesdown    = new Image(140,30); websitesdown.src    = ip + "websites_down.gif";
  websiteshere    = new Image(140,30); websiteshere.src    = ip + "websites.gif";
  websitesover    = new Image(140,30); websitesover.src    = ip + "websites_over.gif";
  websitesup      = new Image(140,30); websitesup.src      = ip + "websites_up.gif";
  }


//----- start top-of-page header block
if ( isNS4 )     // Netscape 4.x ?   if so, circumvent it's problems
       { tempstr = '<table height=108 width="100%" '                           +
                          'cellspacing="0" cellpadding="0">'                   +
                   '<tr><td width="100%" height="100%" valign=top '            +
                          'background="' + top.ImagePath + 'sitebgtop.gif">'   +
                   '<table height=108 width="100%" '                           +
                          'cellspacing="0" cellpadding="0" '                   +
                          'background="' + top.ImagePath + 'spacer.gif">'
         }
  else { tempstr = '<table height=108 width="100%" '                           +
                          'cellspacing="0" cellpadding="0" '                   +
                          'background="' + top.ImagePath + 'sitebgtop.gif">'
         }
tempstr +=    '<tr><td width=15></td>'                                         +
              '<td valign=top align=left>'                                     +
                 '<a href="' + baseURL + '">'                                  +
                 '<img src="' + top.ImagePath + 'CandGwebLogo1.gif" '          +
                     'width=105 height=100 border=0></a></td>'
tempstr +=    '<td align=center valign=top>' +
                  '<img src="' + top.ImagePath + 'spacer.gif" '                +
                       'width="5" height="12"><br>'                            +
                  '<span class=masthead>C &amp; G Web Enterprises</span>'      +
                  '<br><span class=tagline>'                                   +
                  '"Internet and PC Solutions for Home and Small-Business"'    +
                  '</span></td>'
tempstr +=    '<td align=right valign=top>'                                    +
                  '<img src="' + top.ImagePath + 'spacer.gif" '                +
                       'width="5" height="13"><br>'                            +
                  '<span class=navdate>' + DateStr('','SHORT') + '</span><br>' +
                  '<a href="Javascript:window.print()">'                       +
                  '<img src="' + top.ImagePath + 'printer.gif" '               +
                       'width=32 height=42 border=0 '                          +
                       'alt="Print this page"></a></td>'                       +
              '</tr></table>'
if ( isNS4 ) tempstr += '</td></tr></table>'
document.write(tempstr)
//----- end top-of-page header block

//----- define overall layout of screen
  document.write('<table width="100%" cellspacing="0" cellpadding="1">' +
                 '<tr valign=top align=left><td width="150">'           +
                 '<img src="' + top.ImagePath + 'spacer.gif" '          +
                      'width="5" height="6"><br>')

//----- start navigation portion (down left side of screen)
  sectionId = sectionId.toUpperCase()
  nodeId    = nodeId.toUpperCase()
  //----- HOME ------
  document.write(SectionLink(sectionId, 'HOME', 'index.html', 'Home',140,30))
  if ( sectionId == 'HOME' ) {
      }
  //----- PC SUPPORT -----
  document.write(SectionLink(sectionId, 'PCSUPPORT', 'PCSupport/index.html', 'PC Support',140,30))
  if ( sectionId == 'PCSUPPORT' ) {
    tempstr = '<table cellspacing=1 cellpadding=1>' +
      NodeLink(nodeId, 'PCTECHASSIST',      'PCSupport/PCTechAssist.html',       'PC Technical Assistance')  +
      NodeLink(nodeId, 'NEWPCINSTALL',      'PCSupport/NewPCInstall.html',       'New PC Installation')      +
      NodeLink(nodeId, 'TUNEUP',            'PCSupport/TuneUp.html',             'PC "Tune-Up"')             +
      NodeLink(nodeId, 'ONLINESUPPORT',     'PCSupport/OnlineSupport.html',      'Online Support')           +
      '</table><br>'
    document.write(tempstr)
    }
  //----- PC NETWORK -----
  document.write(SectionLink(sectionId, 'PCNETWORK', 'PCNetwork/index.html', 'PC Networking',140,30))
  if ( sectionId == 'PCNETWORK' ) {
    tempstr = '<table cellspacing=1 cellpadding=1>' +
      NodeLink(nodeId, 'INDEX',             'PCNetwork/index.html',              'Introduction')             +
      NodeLink(nodeId, 'WHATTYPEOFNETWORK', 'PCNetwork/WhatTypeOfNetwork.html',  'What Type Of Network?')    +
      NodeLink(nodeId, 'PRICES',            'PCNetwork/Prices.html',             'Pricing')                  +
      '</table><br>'
    document.write(tempstr)
    }
  //----- CONSULTING SERVICES ------
  document.write(SectionLink(sectionId, 'CONSULTING', 'Consulting/index.html', 'Consulting',140,30))
  if ( sectionId == 'PCCONSULTING' ) {
    tempstr = '<table cellspacing=1 cellpadding=1>' +
      NodeLink(nodeId, 'HIRINGCONSULTANTS', 'Consulting/HiringConsultants.html',  'Hiring Consultants')       +
      '</table><br>'
    document.write(tempstr)
    }
  //----- Web Design ------
  document.write(SectionLink(sectionId, 'WEBSITES', 'WebSites/index.html', 'Web Design',140,30))
  if ( sectionId == 'WEBSITES' ) {
    tempstr = '<table cellspacing=1 cellpadding=1>' +
      NodeLink(nodeId, 'WEBSITEDESIGN',     'WebSites/WebSiteDesign.html',      'Web Site Design')          +
      NodeLink(nodeId, 'WEBSITEHOSTING',    'WebSites/WebSiteHosting.html',     'Web Site Hosting')         +
      NodeLink(nodeId, 'WEBSITESUPPORT',    'WebSites/WebSiteSupport.html',     'Web Site Support & Maintenance') +
      NodeLink(nodeId, 'WHYYOUNEED',        'WebSites/WhyYouNeed.html',         'Why You Need a Web Site')  +
      NodeLink(nodeId, 'WHYCHOOSEUS',       'WebSites/WhyChooseUs.html',        'Why Choose Us?')           +
      NodeLink(nodeId, 'SEARCHENGINE',      'WebSites/SearchEngine.html',       'Search Engine Submission') +
      NodeLink(nodeId, 'FAQS',              'WebSites/FAQs.html',               'FAQs')                     +
      NodeLink(nodeId, 'EXAMPLES',          'WebSites/Examples.html',           'Examples')                 +
      NodeLink(nodeId, 'GETTINGSTARTED',    'WebSites/GettingStarted.html',     'Getting Started')          +
      '</table><br>'
    document.write(tempstr)
    }
  //----- ABOUT US -----
  document.write(SectionLink(sectionId, 'ABOUTUS', 'AboutUs/OurCompany.html', 'About Us',140,30))
  if ( sectionId == 'ABOUTUS' ) {
    tempstr = '<table cellspacing=1 cellpadding=1>' +
      NodeLink(nodeId, 'OURCOMPANY',        'AboutUs/OurCompany.html',         'Our Company')              +
      NodeLink(nodeId, 'OURVALUES',         'AboutUs/OurValues.html',          'Our Values')               +
      '</table><br>'
    document.write(tempstr)
      }
  //----- CONTACT US ------
  document.write(SectionLink(sectionId, 'CONTACTUS', 'ContactUs.html', 'ContactUs',140,30))
  if ( sectionId == 'CONTACTUS' ) {
    }

//----- end of navigation portion, begin cell which is major portion of the page
  document.write('</td><td width=10>' +
                 '<img src="' + top.ImagePath + 'spacer.gif" ' +
                      'width="10" height="3"></td>' +
                 '<td>')
  return
  }

//-------------------------------------------------------------------
// EndScreen: Closes table begun by "StartScreen()"
// Use: EndScreen()
//-------------------------------------------------------------------
function EndScreen() {
  document.write('</td></tr></table>')
  return
  }


// ImgUp: Turn the specified navigation button to the "up" position
function ImgUp(imgName) {
  if ( document.images )
         { document[imgName].src = eval(imgName + "up.src") }
    else { imgName = null; }
  return true
  }

// ImgDown: Turn the specified navigation button to the "Down" position
function ImgDown(imgName) {
  if ( document.images )
         { document[imgName].src = eval(imgName + "down.src") }
    else { imgName = null; }
  return true
  }

// ImgOver: Turn the specified navigation button to the "Over" position
function ImgOver(imgName) {
  if ( document.images )
         { document[imgName].src = eval(imgName + "over.src") }
    else { imgName = null; }
  return true
  }


//-------------------------------------------------------------------
// SectionLink: Generate HTML for a major section in the nav bar
// Use: SectionLink(callerid,thisitem,thisurl,navtitle,width,height)
//   callerid  - Section ID of requester
//   thisitem  - Section ID associated with the following items
//   thisurl   - URL of target file
//   navtitle  - description for the "bubble" text
//   width     - width  of the graphic (in pixels)
//   height    - height of the graphic (in pixels)
//-------------------------------------------------------------------
function SectionLink(callerid,thisitem,thisurl,navtitle,width,height) {
  if (thisurl == undefined) thisurl = ''
  if (thisurl.substr(0,1) == '!')
         thisurl = thisurl.substr(1)
    else thisurl = top.baseURL + '/' + thisurl
  imgprefix = thisitem.toLowerCase()
  if (callerid == thisitem)
         { result = '<a href="' + thisurl + '">' +
                    '<img src="' + eval(imgprefix + 'here.src') + '" ' +
                    'border=0 width=' + width + ' height=' + height +
                    ' name="' + imgprefix + '" alt="' + navtitle + '"></a>' }
    else { result = '<a href="' + thisurl + '" ' +
                    'onMousedown=ImgDown("' + imgprefix + '") ' +
                    'onMouseOver=ImgOver("' + imgprefix + '") ' +
                    'onMouseOut=ImgUp("'    + imgprefix + '")>' +
                    '<img src="' + eval(imgprefix + 'up.src') + '" ' +
                    'border=0 width=' + width + ' height=' + height +
                    ' name="' + imgprefix + '" alt="' + navtitle + '"></a>' }
  return result + '<br><img src="' + top.ImagePath + 'spacer.gif" width=5 height=5><br>'
  }


//-------------------------------------------------------------------
// NodeLink: Generate HTML for a node "under" a major section
// Use: NodeLink(callerid,thisitem,thisurl,thisdesc)
//   callerid  - Node ID of requester
//   thisitem  - Node ID associated with the following items
//   thisurl   - URL of target file
//   thisdesc  - text for the link description
//-------------------------------------------------------------------
function NodeLink(callerid,thisitem,thisurl,thisdesc) {
  if ( callerid == thisitem )
         linkclass = 'nodehere'
    else linkclass = 'nodenothere'
  if ( thisurl.substr(thisurl,11) == "javascript:")
         { temp = thisurl }
    else { temp = top.baseURL + '/' + thisurl }
  return '<tr valign=top><td><img src="' + top.ImagePath        +
         'rightred2.gif" align=bottom width=7 height=14></td>'  +
         '<td><a href="' + temp + '">'                          +
         '<span class=' + linkclass + '>' + thisdesc + '</span></a></td></tr>'
  }


//-------------------------------------------------------------------
// ScriptFN: Returns only the filename of a URL
// Use: ScriptFN([url])
//   If not URL is provided, the current URL is used.
//-------------------------------------------------------------------
function ScriptFN(surl) {
  if ( surl == undefined ) surl = document.location.pathname
  pathend = surl.lastIndexOf('/') + 1
  fnext   = surl.substr(pathend)
  return fnext.substr(0,fnext.indexOf('.'))
  }


//-------------------------------------------------------------------
// PopWindow: "Pop-up" a window
//-------------------------------------------------------------------
function PopWindow(popfile,popid,popx,popy,popwidth,popheight) {
  if ( popid     == null ) popid     = ''
  if ( popwidth  == null ) popwidth  = 400
  if ( popx      == null ) popx      = window.screen.width  - popwidth - 50
  if ( popheight == null ) popheight = window.screen.height - 140
  if ( popy      == null ) popy      = 40
  screenopts = 'location=no,menubar=no,resizable=yes,' +
               'scrollbars=yes,toolbar=no,' +
               'height=' + popheight + ',width=' + popwidth
  if (isNS)
         { screenopts += ',screenX=' + popx + ',screenY=' + popy }
    else { screenopts += ',left='    + popx + ',top='     + popy }
  popwin = window.open(popfile,popid, screenopts)
  window.popwin.focus()
  }

//-------------------------------------------------------------------
// PopHelp: "Pop-up" a help-type window
//     PopHelp(url,[label],[windowid],[options])
//            "url" is either a two-digit suffix for "spshlpxx.html"
//            or the actual URL
//-------------------------------------------------------------------
function PopHelp(hlpfile,hlplabel,hlpid,hlpopts) {
  defopts = 'location=no,menubar=no,resizable=yes,' +
            'scrollbars=yes,toolbar=no,' +
            'height=500,width=500,alwaysRaised=yes'
  if ( hlpfile        == null ) hlpfile   = ''
  if ( hlplabel       == null ) hlplabel  = ''
  if ( hlpid          == null ) hlpid     = ''
  if ( hlpopts        == null ) hlpopts   = ''
  if ( hlpfile.length == 2    ) hlpfile   = 'spshlp' + hlpfile + '.html'
  if ( hlpfile        == ''   ) hlpfile   = applic_help
  if ( hlplabel       != ''   ) hlpfile  += '#' + hlplabel
  if ( hlpid          == ''   ) hlpid     = 'spshelpp'
  if ( hlpopts        == ''   )
         { winopts = defopts }
    else { winopts = defopts + ',' + hlpopts }
  if (isNS)
         { winopts += ',screenX=150,screenY=150' }
    else { winopts += ',left=150,top=150' }
  helpwin = window.open(hlpfile,hlpid,winopts)
  window.helpwin.focus()
  }

//-------------------------------------------------------------------
// More(url): Show "More" to associated page
//-------------------------------------------------------------------
function More(closeurl) {
  closeurl = '<nobr><a href="' + closeurl + '">' +
             'More...' +
             '<img src="' + ImagePath + 'morearrow.gif" ' +
             'width=8 height=11 border=0></a></nobr>'
  document.writeln(closeurl)
  return
  }

//-------------------------------------------------------------------
// ShowClose: Display the text to close a pop-up window
//-------------------------------------------------------------------
function ShowClose() {
  document.writeln(ShowClose2())
  return null
  }
//----- ShowClose2: Returns text to close a pop-up window
function ShowClose2() {
  return '<table width="100%"><tr>' +
         '<td align=right valign=baseline class="closetext">' +
         '<a href="javascript:window.close();">' +
         '<img src="' + ImagePath + 'close_cross.gif" ' +
         'border=0 width=10 height=10></a> ' +
         '<a href="javascript:window.close();">Close window</td>' +
         '</tr></table>'
  }

//-------------------------------------------------------------------
// getCookie: Retrieve a cookie's value by name; returns "null" if not set
//            str = getCookie(cookiename)
//-------------------------------------------------------------------
function getCookie(name){
  var cname = name + "=";
  var dc = document.cookie;
  if (dc.length > 0) {
    begin = dc.indexOf(cname);
    if (begin != -1) {
      begin += cname.length;
      end = dc.indexOf(";", begin);
      if (end == -1) end = dc.length;
      return unescape(dc.substring(begin, end));
      }
    }
  return null;
  }

//-------------------------------------------------------------------
// setCookie: Sets a cookie's value
//            setCookie(cookiename, value, [expires])
//-------------------------------------------------------------------
function setCookie(name, value, expires) {
  document.cookie = name + "=" + escape(value) +
           ((expires == null) ? "" : "; expires=" + expires.toGMTString());
  }

//-------------------------------------------------------------------
// delCookie: Delete a cookie
//            delCookie(cookiename)
//-------------------------------------------------------------------
function delCookie(name) {
  document.cookie = name + "=; expires=Thu, 01-Jan-70 00:00:01 GMT" +  "; path=/";
  }

//-------------------------------------------------------------------
// MakeArray: create an array of the designated size
//            MakeArray(number-of-items)
//-------------------------------------------------------------------
function MakeArray(n) {
  this.length = n
  for (var i = 0; i <= n; i++) { this[i] = 0 }
  return this
  }

//-------------------------------------------------------------------
// DateStr: Return a date string formatted from the passed date value.
// Use: DateStr([date], { FULL | SHORT } )
//        date   - The date to format; if omitted, the current
//                 date/time is used
//        FULL   - Returns a fully-qualified date (this is the default)
//                 e.g. "Sunday, August 29, 1999 at 3:00:00 p.m."
//        SHORT  - Returns an abbreviated date string
//                 e.g. "Sunday, 29 August 1999"
//-------------------------------------------------------------------
function DateStr(dsparm,dstype) {
  if ( dsparm==null ) dsparm=''
  if ( dstype==null ) dstype='FULL'; else { dstype='SHORT' }
  dow=new MakeArray(6); moy=new MakeArray(11)
  dow[0]='Sunday';    dow[1]='Monday';   dow[2]='Tuesday';   dow[3]='Wednesday'
  dow[4]='Thursday';  dow[5]='Friday';   dow[6]='Saturday'
  moy[0]='January';   moy[1]='February'; moy[2]='March';     moy[3]='April'
  moy[4]='May';       moy[5]='June';     moy[6]='July';      moy[7]='August'
  moy[8]='September'; moy[9]='October';  moy[10]='November'; moy[11]='December'
  if ( dsparm=='' )                     // any passed value?
         { dsdate  = new Date() }       //   no, get today's date
    else { dsdate  = new Date(dsparm) } //   yes, get the date
  year  = dsdate.getYear()  ; hour    = dsdate.getHours()
  month = dsdate.getMonth() ; minutes = dsdate.getMinutes()
  dom   = dsdate.getDate()  ; seconds = dsdate.getSeconds()
  day   = dsdate.getDay()
  if        ( year < 100  ) { yyyy = year + 2000 }
    else if ( year < 1000 ) { yyyy = year + 1900 }
    else                    { yyyy = year }
  if        ( hour <= 11 ) { ampm='a.m.' }
    else if ( hour == 12 ) { ampm='p.m.' }
    else                   { ampm='p.m.'; hour=hour-12 }
  if ( hour == 0 ) showhour="00"; else showhour=hour
  if ( minutes < 10 ) minutes = "0" + minutes
  if ( seconds < 10 ) seconds = "0" + seconds
  if ( dstype == 'FULL' )
         { retstr = dow[day] + ", " + moy[month] + " " + dom + ", " + yyyy +
                    " at " + showhour + ":" + minutes + ":" + seconds + " " + ampm }
    else { retstr = dow[day] + ", <nobr>" + dom + " " + moy[month] + " " + yyyy + "</nobr>"}
  return retstr
  }


//-------------------------------------------------------------------
// PrevPage: Show a "return to previous page" link
//    PrevPage()
//-------------------------------------------------------------------
function PrevPage() {
  document.writeln('<a href="javascript:history.back();">' +
                   '<img src="' + top.ImagePath +
                   'ReturnToPrevPage.gif" ' +
                   'border=0 align=middle>Return to calling page</a>')
  }

//-------------------------------------------------------------------
// PrevNextSect: Show Previous/Next "section" links
//    PrevNextSect([prevURL],[nextURL],[TOP] [BOTTOM])
//       See "PrevNextBase()" for a description of the parameters
//-------------------------------------------------------------------
function PrevNextSect(prevURL,nextURL,opts) {
  PrevNextBase('SECTION',prevURL,nextURL,opts)
  return
  }

//-------------------------------------------------------------------
// PrevNextStep: Show Previous/Next "step" links
//    PrevNextStep([prevURL],[nextURL],[TOP] [BOTTOM])
//       See "PrevNextBase()" for a description of the parameters
//-------------------------------------------------------------------
function PrevNextStep(prevURL,nextURL,opts) {
  PrevNextBase('STEP',prevURL,nextURL,opts)
  return
  }

//-------------------------------------------------------------------
// PrevNextBase: Show Previous/Next section/step links
//    PrevNextBase({SECTION|STEP},[prevURL],[nextURL],[TOP] [BOTTOM])
//       SECTION  - If specified, prev/next "section" links are created
//       STEP     - If specified, prev/next "step" links are created
//       prevURL  - Anchor name (without the "#") of previous item;
//                  if null, no "prevsect" link shown
//       nextURL  - Anchor name (without the "#") of next item;
//                  if null, no "nextsect" link shown
//       TOP      - If specified, a TopOfPage link is generated
//                  (uses the anchor created by "PageTop()"
//       BOTTOM   - If specified, a BottomOfPage link is generated
//                  (uses the anchor created by "PageBottom()"
//-------------------------------------------------------------------
function PrevNextBase(baseType,prevURL,nextURL,sectOpts) {
  var baseType  = (baseType=='STEP') ? 'step' : 'section'
  if ( prevURL  == null ) prevURL  = ''
  if ( nextURL  == null ) nextURL  = ''
  if ( sectOpts == null ) sectOpts = ''
  var wantTop  = ( sectOpts.indexOf("TOP")    != -1 )
  var wantBot  = ( sectOpts.indexOf("BOTTOM") != -1 )
  if ( prevURL=='' && nextURL=='' && !wantTop && !wantBot) return
  // generate the HTML
  temp = ''
  if ( prevURL != '' ) {     // create previous link if provided
    temp += '<a href="#' + prevURL +
            '"><img src="' + top.ImagePath +
            'prev' + baseType + '.gif" ' +
            'align=middle border=0 alt="Previous section"></a>'
    }
  if ( nextURL != '' ) {     // create next link if provided
    if ( temp.length > 0 ) temp += '&nbsp;&#124;&nbsp;'
    temp += '<a href="#' + nextURL +
            '"><img src="' + top.ImagePath +
            'next' + baseType + '.gif" ' +
            'align=middle border=0 alt="Next section"></a>'
    }
  if ( wantTop ) {           // create top-of-page if requested
    if ( temp.length > 0 ) temp += '&nbsp;&#124;&nbsp;'
    temp += '<a href="#PageTop">' +
            '<img src="' + top.ImagePath + 'topofpage.gif" ' +
            'align=middle border=0 alt="Top of Page"></a>'
    }
  if ( wantBot ) {           // create bottom-of-page if requested
    if ( temp.length > 0 ) temp += '&nbsp;&#124;&nbsp;'
    temp += '<a href="#PageBottom">' +
            '<img src="' + top.ImagePath + 'bottomofpage.gif" ' +
            'align=middle border=0 alt="Bottom of Page"></a>'
    }
  document.writeln('&#91; ' + temp + ' &#93;<br>&nbsp;')
  return
  }

//-------------------------------------------------------------------
// PrevNextPage: Show Previous/Next page links
//    PrevNextPage([prevURL],[prevFrame],[prevText],
//                 [nextURL],[nextFrame],[nextText], [RETURN])
//       prevURL   - URL of previous page; if null, no "prevpage" link shown
//       prevFrame - target frame (if any)
//       prevText  - Optional text for "previous page" link
//       nextURL   - URL of next page; if null, no "nextpage" link shown
//       nextFrame - target frame (if any)
//       nextText  - Optional text for "next page" link
//       RETURN    - If specified, generate a "return to caller" link
//-------------------------------------------------------------------
function PrevNextPage(prevURL,prevFrame,prevText,nextURL,nextFrame,nextText,wantRet) {
  if ( prevURL   == null ) prevURL   = ''
  if ( prevFrame == null ) prevFrame = ''
  if ( nextURL   == null ) nextURL   = ''
  if ( nextFrame == null ) nextFrame = ''
  if ( wantRet   == null ) wantRet   = ''
  if ( prevURL == '' && nextURL == '' && wantRet == '' ) return
  if ( prevURL  == '' )          // do previous-page handling
         { prevURL   = '<br>'
           prevclass = ''
           }
    else { if ( prevText  == null ) prevText  = ''
           if ( prevText  != ''   ) prevText  = ' (' + prevText + ')'
           if ( prevFrame != ''   ) prevFrame = ' target="' + prevFrame + '"'
           prevURL   = '<a href="' + prevURL + '"' + prevFrame + '>' +
                       '<img src="' + top.ImagePath + 'prevpage.gif" ' +
                       'align=middle border=0 alt="Previous page">' +
                       'Prev Page' + prevText + '</a>&nbsp;'
           prevclass = ' class="prevnextpage"'
           }
  if ( nextURL  == '' )          // do next-page handling
         { nextURL   = '<br>'
           nextclass = ''
           }
    else { if ( nextText  == null ) nextText  = ''
           if ( nextText  != ''   ) nextText  = ' (' + nextText + ')'
           if ( nextFrame != ''   ) nextFrame = ' target="' + nextFrame + '"'
           nextURL   = '&nbsp;<a href="' + nextURL + '"' + nextFrame + '>' +
                       'Next Page' + nextText +
                       '<img src="' + top.ImagePath + 'nextpage.gif" ' +
                       'align=middle border=0 alt="Next page"></a>'
           nextclass = ' class="prevnextpage"'
           }
  if ( wantRet  == '' )          // do return-to-caller handling
         { RetURL    = '<br>'
           Retclass  = ''
           }
    else { RetURL    = '<a href="javascript:history.back();">' +
                       '<img src="' + top.ImagePath + 'callpage.gif" ' +
                       'align=middle border=0 alt="Previously displayed page">' +
                       'Previously displayed page</a>'
           Retclass  = ' class="prevnextpage"'
           }
  // generate HTML
  temp1 = '<table width="100%" border=0><tr>'
  temp2 = '<td align=left width="45%"><table cellspacing=0 cellpadding=0><tr>' +
             '<td height=16'  + prevclass + '>' + prevURL + '</td>' +
             '</tr></table></td>'
  temp3 = '<td align=left width="10%"><table cellspacing=0 cellpadding=0><tr>' +
             '<td height=16'  + Retclass + ' nowrap>' + RetURL + '</td>' +
             '</tr></table></td>'
  temp4 = '<td align=right width="45%"><table cellspacing=0 cellpadding=0><tr>' +
             '<td height=16'  + nextclass + '>' + nextURL + '</td>' +
             '</tr></table></td>'
  temp5 = '</tr></table>'
//alert(temp1 + temp2 + temp3 + temp4 + temp5)
  document.writeln(temp1 + temp2 + temp3 + temp4 + temp5)
  return
  }


//-------------------------------------------------------------------
// PageTop: Create top-of-page HTML text
//    PageTop(title [, parm1, parm2, ..., parmx ] )
//      title - The title of this page to be displayed to the user
//      parm  - any one of the following parameters:
//         { PRINT | NOPRINT }
//              Should the print-this-page icon be shown?
//              If omitted, NOPRINT is assumed.
//         CLASS=class
//              The CSS class to be used for the title.  If omitted,
//              the class "titlepage" is used.
//              e.g.  'CLASS=h2'
//         PREV=url | [ description ] | [ frame ]
//              A "previous-page" link to the specified url should be
//              generated.  If a description is provided, it is shown.
//              If a frame name is specified, a target is generated.
//              e.g.  'PREV=overview.html'
//              e.g.  'PREV=overview.html|Overview description'
//              e.g.  'PREV=overview.html|Overview description|dataframe'
//         NEXT=url | [ description ] | [ frame ]
//              A "next-page" link to the specified url should be
//              generated.  If a description is provided, it is shown.
//              If a frame name is specified, a target is generated.
//              e.g.  'NEXT=detail.html'
//              e.g.  'NEXT=detail.html|Detail Information'
//              e.g.  'NEXT=detail.html|Detail Information|dataframe'
//         { RETURN | NORETURN ]
//              Should a "return-to-calling-page" link be generated?
//              If omitted, NORETURN is assumed.
//
//-------------------------------------------------------------------
function PageTop(pagetitle) {
  var tclass='titlepage', _print=false, _return=false
  var pu='', pt='', pf='', nu='', nt='', nf=''
  if ( pagetitle == null ) pagetitle = ''
  //----- scan & evaluate the passed parameters
  for ( var ix=1; ix < arguments.length; ix++ ) {
    thisParm = arguments[ix]
    if ( thisParm == '' ) continue      // ignore null parms
    tempray = thisParm.split('=',2)
    keyword = tempray[0].toUpperCase()
    data    = tempray[1]; if ( data == undefined ) data = ''
    switch (keyword) {
      case 'PRINT'   : _print  = true;  break;
      case 'NOPRINT' : _print  = false; break;
      case 'RETURN'  : _return = true;  break;
      case 'NORETURN': _return = false; break;
      case 'CLASS'   : tclass  = data;  break;
      case 'NEXT'    :
        tempray = data.split('|',3);
        nu = tempray[0];
        nt = tempray[1]; if ( nt == undefined ) nt = '';
        nf = tempray[2]; if ( nf == undefined ) nf = '';
        break;
      case 'PREV'    :
        tempray = data.split('|',3);
        pu = tempray[0];
        pt = tempray[1]; if ( pt == undefined ) pt = '';
        pf = tempray[2]; if ( pf == undefined ) pf = '';
        break;
      default: alert(keyword + ' is an unknown keyword to PageTop() in ' +
                     document.URL)
      }
    }
  //----- generate the appropriate HTML
  document.writeln('<a name="PageTop"></a>')
  if ( pu != '' || nu != '' || _return ) {    // show links if any given
    PrevNextPage(pu,pf,pt,nu,nf,nt,_return ? 'RETURN' : '')
    document.writeln('<br>')
    }
  if ( _print && browser_version>=4 ) {  // show print icon if requested
       prticon = '<a href="Javascript:window.print()" class=ptprint>' +
                 '<img src="' + top.ImagePath +
                 'printer.gif" align=right ' +
                 'width=32 height=42 border=0 alt="Print this page"></a>'
       document.writeln(prticon);
       }
  if ( pagetitle != '') {  // show page title if a title provided

    if ( ( browser_type == 'NS' ) && ( browser_version <= 4 ) )
           { document.writeln('<h1><i>' + pagetitle + '</i></h1>')
             }
      else { document.writeln('<span class="' + tclass + '">' +
                              pagetitle + '</span>')
             }
    }
  return
  }

//-------------------------------------------------------------------
// PageBottom: Create bottom-of-page HTML text
//    PageBottom( [ parm1 [, parm2, parm3, ... , parmx ] ] )
//      parm - any one of the following parameters:
//         { DATE | NODATE }
//              Should the date of the calling HTML file be shown?
//              If omitted, DATE is assumed.
//         { FEED | NOFEED }
//              Should a Feedback-type link be included?
//              If omitted, FEED is assumed.
//         PREV=url | [ description ] | [ frame ]
//              A "previous-page" link to the specified url should be
//              generated.  If a description is provided, it is shown.
//              If a frame name is specified, a target is generated.
//              e.g.  'PREV=overview.html'
//              e.g.  'PREV=overview.html|Overview description'
//              e.g.  'PREV=overview.html|Overview description|dataframe'
//         { PROP | NOPROP }
//              Should the "Copyright ..." text be shown?
//              If omitted, PROP is assumed.
//         NEXT=url | [ description ] | [ frame ]
//              A "next-page" link to the specified url should be
//              generated.  If a description is provided, it is shown.
//              If a frame name is specified, a target is generated.
//              e.g.  'NEXT=detail.html'
//              e.g.  'NEXT=detail.html|Detail Information'
//              e.g.  'NEXT=detail.html|Detail Information|dataframe'
//         { RETURN | NORETURN ]
//              Should a "return-to-calling-page" link be generated?
//              If omitted, NORETURN is assumed.
//         { HITBOX | NOHITBOX ]
//              Should the "hitbox" be generated for tracking hits?
//              If omitted, HITBOX is assumed.
//-------------------------------------------------------------------
function PageBottom() {
  var _date=true, _feed=true, _prop=true, _return=false, _hitbox=false
  var pu='', pt='', pf='', nu='', nt='', nf=''
  //----- scan & evaluate the passed parameters
  for ( var ix=0; ix < arguments.length; ix++ ) {
    thisParm = arguments[ix]
    if ( thisParm == null ) continue      // ignore null parms
    if ( thisParm == ''   ) continue
    tempray = thisParm.split('=',2)
    keyword = tempray[0].toUpperCase()
    data    = tempray[1]; if ( data == undefined ) data = ''
    switch (keyword) {
      case 'DATE'    : _date   = true;  break;
      case 'NODATE'  : _date   = false; break;
      case 'FEED'    : _feed   = true;  break;
      case 'NOFEED'  : _feed   = false; break;
      case 'PROP'    : _prop   = true;  break;
      case 'NOPROP'  : _prop   = false; break;
      case 'RETURN'  : _return = true;  break;
      case 'NORETURN': _return = false; break;
      case 'HITBOX'  : _hitbox = true;  break;
      case 'NOHITBOX': _hitbox = false; break;
      case 'NEXT'    :
        tempray = data.split('|',3);
        nu = tempray[0];
        nt = tempray[1]; if ( nt == undefined ) nt = '';
        nf = tempray[2]; if ( nf == undefined ) nf = '';
        break;
      case 'PREV'    :
        tempray = data.split('|',3);
        pu = tempray[0];
        pt = tempray[1]; if ( pt == undefined ) pt = '';
        pf = tempray[2]; if ( pf == undefined ) pf = '';
        break;
      default: alert(keyword + ' is an unknown keyword to PageBottom() in ' +
                     document.URL)
      }
    }
  //----- generate the appropriate HTML
  document.writeln('<center><a name="PageBottom"><p></a>')
  if ( pu != '' || nu != '' || _return ) {    // show links if any given
    document.writeln('<p>')
    PrevNextPage(pu,pf,pt,nu,nf,nt,_return ? 'RETURN' : '')
    }
  if ( _prop || _date || _feed || _hitbox ) {  // generate footer if needed
    document.write('<hr noshade><table><tr>')
    if ( _prop )
           { temp = '<span class=footpromo><nobr>Copyright &copy; 2003-2008 ' +
                    '<a href="http://www.CandGWeb.com">C&G Web Enterprises</a>' +
                    '</nobr></span>' +
                    '<img src="' + top.ImagePath +
                    'sotf.gif" align=middle width=50 height=22>'
             }
      else { temp = '&nbsp;' }
    document.writeln('<td align=center valign=top>' + temp + '</td>')
    if ( _hitbox )
           { temp = '<img src="http://comm1.digits.com/wc/candgweb">' }
      else { temp = '&nbsp;' }
    document.write('<td width="30%" valign=top align=center>' + temp + '</td>')
    temp = '<td align=center valign=top><p>'
    if ( _date ) {
      temp += '<span class=footdate><nobr>Page last updated: ' +
              DateStr(document.lastModified) + '</nobr></span><br>'
      }
    if ( _feed ) {
      temp += '<span class=footfeed><nobr>' +
              'Questions about this web site or this page? ' +
              '<a href="mailto:' + author_email +
              '?subject=CandG%20Web%20Website%20Feedback%20(' +
              document.location.href + ')">' +
              'Tell us about it!</a></nobr></span>'
      }
    document.writeln(temp + '</td></tr></table></center>')
    }
  }
