// Dynamic Breadcrumbs
// Written by Harry Love
// Email: hlove@u.washington.edu
// Use at your own risk.
// Feel free to use, personalize, improve, and distribute.
// Last update: November 7, 2002

// To place breadcrumbs in your page, save this
// file to a directory that makes sense to you.
// Link to it in the <head> portion of your web page.
// In the <body> portion of your page,
/* paste the following line of code:
<script type="text/javascript">createBreadcrumbs();</script>
DO NOT COPY THIS LINE */

// BEGIN BASIC CUSTOMIZATION

// Starting Point: 1 = domain, 2 = 1st directory, 3 = 2nd directory, etc.
// Must be specified as an integer; no floating point numbers.
// ***Note***: If the starting number is greater than the number of 
// directories you have, the URL will be undefined.
var startPoint = 2; // idea from Hassan Schroeder

// Separator: set the character(s) that will be used to
// separate each of the breadcrumb links.
// Set the space in between each link by 
// specifying a number of non-breaking spaces (&nbsp;).
// The default separator is a "greater than(>)" symbol (&gt;).
//var sep = "&nbsp;&gt;&nbsp;"
var sep = "&nbsp;»&nbsp;"

// Starting Name: setting startName to "domain" will 
// use the full domain name (www.yourdomain.com).
// Any other text will be used literally.
// E.g., specifying "Home" will use "Home" as the first
// link in the chain.
// ***Note***: if startPoint is greater than 1, it will start
// the chain at a point beyond the domain.  startName will
// be used for the name of the first link, regardless of where it
// starts.
var startName = "Digital Images Home";

// Uppercase or lowercase directory names?  If
// uppercase is set to yes, the first character
// in each of the directory names will be capitalized.
// If allUppercase is set to yes, the entire directory
// name will be capitalized for each directory.
var uppercase = "yes";
var allUppercase = "no";

// Endpoint: how do you want the script to handle a
// URL that ends in a directory name? E.g., if the URL
// is http://www.mydomain.com/start/, do you want the
// script to write the name of the directory or the
// title of the default document in this directory?
// You have 2 choices: directory or title.
var endPoint = "title";

// END BASIC CUSTOMIZATION

var d=document;
var url = d.location.href;
var endChar = url.substr(url.length-1);

// Replace the "//" in "http://www.mydomain.com" with "/" and store that in the url variable. 
url=url.replace("//","/");
	
// Split the URL into segments and store them in an array using "/" as a delimiter.
// According to the variables, specify upper- or lowercase directory names.
var urlArray=url.split('/');
var urlL = urlArray.length;
var linkName=new Array();
if(uppercase=="yes"&&allUppercase=="no")
{
	var lowercase;
	for(x=2;x<urlL;x++)
	{
		uppercase=urlArray[x].substr(0,1).toUpperCase();
		lowercase=urlArray[x].substr(1, urlArray[x].length);
		linkName[x]=uppercase+lowercase;
	}
}
else if(allUppercase=="yes"||uppercase=="yes"&&allUppercase=="yes")
{
	for(x=2;x<urlL;x++)
	{
		linkName[x]=urlArray[x].toUpperCase();
	}
}
else{linkName=urlArray;}

// Begin the start output variable; get the first segment (the protocol)
// of the urlArray and store that in the start variable.
var start=urlArray[0]+"//";

// If the startPoint is less than 1, reset to 1.
if(startPoint<1){startPoint=1;}

// Loop through all of the segments up to the
// starting point and create the opening link.
for(y=1;y<=startPoint;y++)
{
	start=start+urlArray[y]+"/";
}

function createBreadcrumbs()
{
	// Write the first crumb.  Use startName for the text.
	d.write('<a href="'+start+'">'+startName+'</a>');
	
	// If there are more directories, use this code.
	// Otherwise, exit.
	if(urlL>2)
	{	
		// Loop through the remaining segments of the array.
		for(x=startPoint+1;x<urlL;x++)
		{			
			// If this segment is not the last segment...
			if(x<urlL-1)
			{
				// If this is the penultimate segment, and the
				// last segment is blank...
				if(x==urlL-2&&linkName[urlL-1]=="")
				{
					// If we are using the directory name
					// for the last segment...
					if(endPoint=="directory")
					{
						// This is the last segment.
						// Write it to the page, then exit.
						d.write(sep+'<strong>'+linkName[x]+'</strong>');
						break;
					}
					else
					{
						// This is the last segment.
						// Write it to the page, then exit.
						d.write(sep+'<strong>'+d.title+'</strong>');
						break;
					}
				}
				// Otherwise, use this code...
				else
				{
					// Add the current start segment to the previous start segment
					// and add a backslash to the end.
					start=start+urlArray[x]+"/";
					
					// Write the link to the page with sep as a separator.
					d.write(sep+'<a href="'+start+'">'+linkName[x]+'</a>');
				}
			}
			// Otherwise, this is the last segment...
			else
			{
				// Add the current segment to the previous segment
				// but do not add a backslash.
				start=start+urlArray[x];
				
				// If this segment is a directory...
				if(endChar=="/")
				{
					// Write the last segment to the page with sep as a separator.
					d.write(sep+'<strong>'+linkName[x]+'</strong>');
				}
				// Otherwise this segment is a filename...
				else
				{
					// Write the link to the page with sep as a separator.
					// Use the document title for the segment name.
					d.write(sep+'<strong>'+d.title+'</strong>');
				}
			}
		}
	}
}