/*****
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 = "<span class=\"crumb\"> > </span>";
var precrumb = "";
var postcrumb = "";
var sectionsep = "/";
//var rootpath = "/"; // Use "/" for root of domain.
var rootpath = "/dom"; // Use "/" for root of domain.
var rootname = "Department of Medicine Home";

var ucfirst = 1; // if set to 1, makes "directory" default to "Directory"

var objurl = new Object;
objurl['facdir'] = 'Faculty Directory';
objurl['giving'] = 'Ways of Giving';
objurl['maps'] = 'Maps & Directions';

objurl['faculty'] = 'Prospective Faculty';
objurl['opportunity'] = 'Career Opportunities';
objurl['hospitals'] = 'Affiliated Hospitals';

objurl['physicians'] = 'Referring Physicians';
objurl['find'] = 'Find a Physician';
objurl['refer'] = 'Refer a Patient';

objurl['about'] = 'About the Department';
objurl['directory'] = 'Department Directory';
objurl['future'] = 'Future of the Department';
objurl['history'] = 'History of the Department';
objurl['values'] = 'Core Values';
objurl['awards'] = 'Faculty Awards';

objurl['education'] = 'Medical Education';
objurl['fellowship'] = 'Fellowship Training Programs';

objurl['positions'] = 'Positions and Opportunities';

objurl['patients'] = 'For Patients';
objurl['physician'] = 'Find a Physician';
objurl['services'] = 'Patient Services';
objurl['visitor'] = 'Visitor Information';
objurl['springmill'] = 'Spring Mill Medical Center';
objurl['diseases'] = 'Common Diseases or Conditions';


// Grab the page's url and break it up into directory pieces
var pageurl = (new String(document.location).toLowerCase());
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 from pageurl
if (pageurl.charAt(0) == '/') // remove beginning slash
{
  pageurl = pageurl.substring(1, pageurl.length);
}

var page_ar = pageurl.split(sectionsep);
var currenturl = protocol + rooturl;

// Start of special code for this breadcrumb file only! - dls, 5/2008
// These sections are TWO folders deep from the root (/DoM/about) - we need to strip the /DoM from the home folder URL
var substituteURL
if (currenturl.substring(currenturl.length - 4, currenturl.length) == "/DoM")
	substituteURL = "/";
else
	substituteURL = currenturl;

//var allbread = precrumb + "<a class=\"breadcrumb\" href=\"" + currenturl + "\">" + rootname + "</a>" + postcrumb; // start with root
var allbread = precrumb + "<a class=\"breadcrumb\" href=\"" + substituteURL + "\">" + rootname + "</a>" + postcrumb; // start with root
// End of special code for this breadcrumb file only! - dls, 5/2008

for (i=0; i < page_ar.length-1; i++)
{
  var displayname = "";
  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() + page_ar[i].substring(1);
    }
    else
    {
      displayname = page_ar[i];
    }
  }
  allbread += crumbsep + precrumb + "<a class=\"breadcrumb\" href=\"" + currenturl + "\">" + displayname + "</a>" + postcrumb;
}
//alert(allbread);
document.write(allbread);