function breadcrumbs(){
  sURL = new String;
  var bits = new Array();
  var x = 0;
  var stop = 0;
  var output = "<a href=\"/\">Home</a> &gt; ";
  var myUrl = window.location.protocol + "//" + window.location.host + window.location.pathname;
  sURL = myUrl;

  // alert( myUrl );

  sURL = sURL.slice(8,sURL.length);
  chunkStart = sURL.indexOf("/");
  sURL = sURL.slice(chunkStart+1,sURL.length)

  var bIndex = isIndex(myUrl);

  while(!stop){
    chunkStart = sURL.indexOf("/");
    if (chunkStart != -1){
      bits[x] = sURL.slice(0,chunkStart)
      sURL = sURL.slice(chunkStart+1,sURL.length);
    }else{
      stop = 1;
    }
    x++;
  }

  for(var i in bits){
    if( (i == ( bits.length - 1 )) && bIndex == true ) {
      // we don't need a link
      var name = bits[i];
      name = capitalize( name );
      output += name;
    } else {

      // hack to avoid highlighting month for bnsf-news and news-releases
      var name = bits[i];
      var months = "januaryfebruarymarchaprilmayjunejulyaugustseptemberoctobernovemberdecember";
      var tempUrl = myUrl;
      if( months.indexOf(name) > -1 &&
          ( tempUrl.indexOf("news-releases") > -1 ||
            tempUrl.indexOf("bnsf-news") > -1 ) ) {
          // we don't need a link
        name = capitalize( name );
        output += name + " &gt; ";
      } else {
        output += "<a href=\"";
        for(y=1;y<x-i;y++){
          output += "../";
        }
        var name = bits[i];
        name = capitalize( name );
        output += bits[i] + "/\">" + name + "</a> &gt; ";
      }
    }
  }

  // get the last word(s) after the last " - "
  var aTitle = document.title.split(" - ");
  var title = aTitle.pop();

  if( bIndex == false ) {
    document.write(output);
    title = capitalize( title );
    document.write(title);
  } else {
    var m = output.match(/(.*) &gt; $/);
    if( m ) {
      output = m[1];
    }
    document.write(output);
  }
}

function capitalize(val) {
  newVal = '';
  val = val.replace( /-/g, ' ' );
  val = val.split(' ');
  for(var c=0; c < val.length; c++) {
    newVal += val[c].substring(0,1).toUpperCase() +
      val[c].substring(1,val[c].length) + ' ';
  }
  newVal = newVal.replace( /bnsf/i, 'BNSF' );
  newVal = newVal.replace( /\bsec\b/i, 'SEC' );
  newVal = newVal.replace( /\bfaq\b/i, 'FAQ' );
  newVal = newVal.replace( /\bfaqs\b/i, 'FAQs' );
  newVal = newVal.replace( /\bcots\b/i, 'COTS' );
  newVal = newVal.replace( /\blogs\b/i, 'LOGs' );
  newVal = newVal.replace( /\btranscaer\b/i, 'TRANSCAER' );

  return newVal;
}

function isIndex(data) {
  var m = data.match(/(.*)[\/\\]([^\/\\]+\.\w+)$/);
  if( m ) {
    if( m[2] == "index.html" ) {
      return true;
    }
    if( m[2] == "index.htm" ) {
      return true;
    }
  } else {
    return true;
  }
  return false;
}

