// This function generates a breadcrumb trail based on the path to the
// document calling it.  The three optional parameters are:
//   sDelimiter - the separator to output between crumbs - def '|'
//   sHomedir   - the base directory for this tree branch - def '/'
//   sDoctitle  - the text of the rightmost crumb - def doc title

function breadcrumbs(sDelimiter,sHomedir,sDoctitle)
{
  if (!sDelimiter) sDelimiter = '>';
  if (!sDoctitle) sDoctitle = document.title;
  var sURL = (location.pathname.indexOf('?') != -1) ?
              location.pathname.substring(0, location.pathname.indexOf('?')) :
              location.pathname;
      sURL = (location.pathname.charAt(0) == '/') ?
              location.pathname.substring(1) : location.pathname;
  var aURL = sURL.split('/');

  var j = 0;
  if (sHomedir) {
    var sHom = (sHomedir.charAt(0) == '/') ? sHomedir.substring(1) : sHomedir;
        sHom = (sHom.charAt(sHom.length - 1) == '/') ?
                sHom.substring(0,sHom.length - 1) : sHom;
    var aHom = sHom.split('/');
    if (aHom && (aHom[0] != '')) {
      while ((j < aHom.length) && (aHom[j] == aURL[j])) j++;
      sHomedir = '/' + aHom.join('/') + '/'; }
    else sHomedir = '/'; }
  else sHomedir = '/';

  if(aURL && (j < aURL.length)) {
    var sOutput = '<a href="' + sHomedir + '">Home</a> ' + sDelimiter + ' ';
    var sPath = sHomedir;
    for(var i = j; i < aURL.length - 1; i++) {
      sPath += aURL[i] + '/';
      sOutput += '<a href="' + sPath + '">';
      sOutput += aURL[i].charAt(0).toUpperCase() + aURL[i].substring(1).replace("_"," ");
      sOutput += '</a> ' + sDelimiter + ' '; }
      document.write(sOutput); }
}

