/**********************************************\
 * COPYRIGHT 1999-2003 David J. Aronson       *
 * This applies to the contents of this file, *
 * collectively and individually!             *
\**********************************************/


function ColorsBar (colors, ht)
{
 var  bar = '<p><table align="center" border="1" cellpadding="0" cellspacing="0" width="100%"><tr>';
 var  colorNum;
 var  numColors = colors.length;
 var  pct = Math.floor (100 / numColors);

 function MkColorBar (clr, ht, pct)
 {
  return '<td bgcolor="' + clr + '" width="' + pct + '%"><img height="' +
         ht + '" src="pixel.gif"></td>';
 }

 for (colorNum = 0; colorNum < numColors; colorNum++)
 {
  bar += MkColorBar (colors[colorNum], ht, pct);
 }
 bar += '</tr></table>';
 document.write (bar);
}


function showlinklist (a, sep, start)
{
 for (i = 0; i < a.length; i += 2)
 {
  if (a[i].indexOf ("http://") == 0) tmpStart = "";
  else tmpStart = start;
  if (i > 0) document.write (sep);
  document.write ('[<a href="' + tmpStart + a[i] + '">' + a[i+1] + '</a>]');
 }
}


function sepr8r()
{
 ColorsBar (new Array ('red', 'white', 'blue'), 2);
}


function EndsWith (haystack, needle)
{
 if (haystack == undefined) return false;
 if (needle == undefined) return true;
 var hlen = haystack.length;
 return (haystack.substring (hlen - needle.length, hlen) == needle);
}


function stdend (homePath)
{
 sepr8r();
 if (EndsWith (document.location.href, 'index.html')) start = '';
 else start = '../';
 document.write ('<p align="center"><small>');
 // NavBar();
 // document.write ('Path: <a href="http://www.davearonson.net/">Home</a> -> ');
 // showlinklist (homePath, ' ->  ', start);
 // document.write ('<br>');
 document.write ('Extras: ');
 a = new Array (
  'http://htmlgear.tripod.com/feed/control.feed?a=render&i=1&u=davearonson', 'Email',
  'thissite/whatsnew.html', 'News',
  'thissite/links.html', 'Links',
  'thissite/sitemap.html" target="_new', 'Map',
  // 'http://pub8.bravenet.com/vote/vote.asp?usernum=620252985" target="_new', 'Polls',
  'index.html" target="_top', 'NoFrames'
 );
 showlinklist (a, ' | ', start);
 document.write ('</small>');
}


function NavNode (dir, fname, name, subs)
{
 this.dir = dir;
 this.fname = fname;
 this.name = name;
 this.subs = subs;

 function HomePath()
 {
  var s = '/';
  if (dir != null) s += dir + '/';
  return s + fname;
 }

 function Link (dest)
 {
  var s = '[';
  if (dest) s += '<a href="' + PathTo() + '">';
  s += name;
  if (dest) s += '</a>';
  return s + ']';
 }

 function PathTo()
 {
  var s;
  if (curDir == '')
  {
   if (dir == null) s = '';
   else s = dir + '/';
  }
  else if (dir == null) s = '../';
  else if (EndsWith (curDir, dir)) s = '';
  else s = '../' + dir + '/';
  return s + fname;
 }

 function SubBar (url)
 {
  var  i;
  if (EndsWith (url, HomePath()))
  {
    var bar = Link (false);
    if (subs != null)
    {
     bar += '<br>Subpages: ';
     for (i = 0; i < subs.length; i++)
     {
      if (i > 0) bar += ' | ';
      bar += subs[i].Link (true);
     }
    }
    return bar;
  }
  else if (subs != null)
  {
   for (i = 0; i < subs.length; i++)
   {
    var bar = subs[i].SubBar (url);
    if (bar != null) return Link (true) + ' => ' + bar;
   }
   return null;
  }
  else return null;
 }

 this.HomePath = HomePath;
 this.Link = Link;
 this.PathTo = PathTo;
 this.SubBar = SubBar;
}


function NavBar()
{
 document.write ('<p align="center">Page: ' + homeNode.SubBar (window.location.href) + '<br>');
}

