/*****
Dynamic Javascript Breadcrumb Navigation by Adam DuVander
http://duvinci.com/projects/javascript/crumbs/

Released under Creative Commons License:
http://creativecommons.org/licenses/by/2.5/
*****/
var crumbsep = "&nbsp;» &nbsp;";
var precrumb = "<span class=\"breadcrumbs\">";
var postcrumb = "</span>";
var sectionsep = "/";
var rootpath = "www.macsim.com.au/"; // Use "/" for root of domain.

/**
 ** Uncomment the line below when the site goes live (and remove this comment if you wish)
 **/

// var rootpath = "www.macsim.com.au/"; // Use "/" for root of domain.


var rootname = "Home";

var ucfirst = 1; // if set to 1, makes "directory" default to "Directory"
var showpage = document.title; // this contains what to show as the current page in the crumb. Set to "" to show nothing

var objurl = new Object;
objurl['index'] = 'www.macsim.com.au/';
objurl['About%20Macsim'] = 'About Macsim';
objurl['Products'] = 'Products';
objurl['News%20and%20Promotions'] = 'News & Promotions';
objurl['Contact%20Us'] = 'Contact Us';
objurl['Terms%20and%20Conditions'] = 'Terms & Conditions';
objurl['Privacy%20Policy'] = 'Privacy Policy';
objurl['Site%20Map'] = 'Site Map';
objurl['Customer%20Login'] = 'Customer Login';
objurl['Shopping%20Cart'] = 'Shopping Cart';
objurl['Company%20Profile'] = 'Company Profile';
objurl['Distribution%20Centers'] = 'Distribution Centers';

// URLs for stuff under Products.
// We need to perform this conversion in the breadcrumb trail because
// the actual URLs are not based on /Products/Folder Name/ but rather /Products/folder_name.php
var prodUrl = new Object;
prodUrl['Anchoring'] = 'anchoring.php';
prodUrl['Rivets'] = 'rivets.php';
prodUrl['Screws'] = 'screws.php';
prodUrl['Nuts%20and%20Bolts'] = 'nuts_bolts.php';
prodUrl['Silicone%20and%20Adhesives'] = 'silicone_adhesives.php';
prodUrl['Tools'] = 'tools.php';
prodUrl['Nails'] = 'nails.php';
prodUrl['Miscellaneous'] = 'miscellaneous.php';
prodUrl['Framing%20Nails'] = 'framing_nails.php';

// Grab the page's url and break it up into directory pieces
var pageurl = (new String(document.location));
var protocol = pageurl.substring(0, pageurl.indexOf("//") + 2);
pageurl = pageurl.replace(protocol, ""); // remove protocol from pageurl
var rooturl = pageurl.substring(0, pageurl.indexOf(rootpath) + rootpath.length); // find rooturl
if (rooturl.charAt(rooturl.length - 1) == "/") //remove trailing slash
{
  rooturl = rooturl.substring(0, rooturl.length - 1);
}
pageurl = pageurl.replace(rooturl, ""); // remove rooturl fro pageurl
if (pageurl.charAt(0) == '/') // remove beginning slash
{
  pageurl = pageurl.substring(1, pageurl.length);
}

var page_ar = pageurl.split(sectionsep);
var currenturl = protocol + rooturl;
var allbread = precrumb + "<a href=\"" + currenturl + "\">" + rootname + "</a>" + postcrumb; // start with root

for (i=0; i < page_ar.length-1; i++)
{
  var displayname = "";
  if (prodUrl[page_ar[i]]) {
    currenturl += "/" + prodUrl[page_ar[i]];
  }
  else {
    currenturl += "/" + page_ar[i];
  }
  if (objurl[page_ar[i]])
  {
    displayname = objurl[page_ar[i]];
  }
  else
  {
    if (ucfirst == 1)
    { 
      displayname = page_ar[i].charAt(0).toUpperCase() + decodeURI(page_ar[i].substring(1));
    }
    else
    {
      displayname = decodeURI(page_ar[i]);
    }
  }
  allbread += crumbsep + precrumb + "<a href=\"" + currenturl + "\">" + displayname + "</a>" + postcrumb;
}

if (showpage != "")
{
  allbread += crumbsep + showpage;
}
document.write(allbread);

