
/* breadcrumbs script gratefully adapted from code at:
 * http://www.greggriffiths.org/webdev/clientside/javascript/breadcrumbs/index.html
 * The breadcrumbs will correspond to the folders and subfolders of the site. Multiword folder names can be used 
 * by putting an underscore between words; the underscore will be replaced by a space in the breadcrumbs.
 * Set the variable "siteName", below, to the name of the folder that you want to appear as the first breadcrmb. 
 * Use the case in which you wish it to appear: regardless of the case in the link or the address bar, it will 
 * appear in the  breadcrumbs as it appears here:
 */
var siteName=  "Forge_of_Innovation"
		/* This function is called by buildBreadCrumbTrail() as it builds the string of folder names and links.
		 * It adds the correct number of "../" pathname operators for the current page to link back to each level
		 *of parent directory.  
		 */
		function buildDepth(iterations)
		{
			var iterations=iterations-3;
			var depthStr="";
			for (i=0;i<iterations;i++)
			{
				depthStr=depthStr + "../";
			}
			return depthStr;
		}
		function buildBreadCrumbTrail()
		{
			var constituentFolders = new Array();
			var currentURL = document.location.toString();
			/* Construct a regular expression based on siteName which will be used to find the 
			 * first appearance of the name, regardless of case, and replace it with the correct case*/ 
			var searchExpression = new RegExp(siteName,"ig");
			currentURL=currentURL.replace(searchExpression, siteName);
			// Get rid of everything before the siteName folder
			currentURL=currentURL.substring(currentURL.indexOf("/" + siteName));
			// divide the URL into arrray elements, using the "/" as a delimiter
			constituentFolders=currentURL.split("/");
			/* build the breadcrumb string, which will consist of the names of each constituent folder name,
			 * linked to"index.html" inside that folder. Setting "count" to 1 instead of 0 starts the loop
			 * after the first "/". Iterating only to "constituentFolders.length-1" stops it from displaying the 
			 * "index.html" for the current folder.
			 */
			var outputStr="";
			for (count=1;count<(constituentFolders.length-1);count++)
			{ 
			outputStr=outputStr + " > <a href='" + buildDepth((constituentFolders.length-count)+1) + "index.html' >" + constituentFolders[count] + "</a>";
			}
			// lop off the first dividing character which was added in front of the first link.
			outputStr=outputStr.substring(2);
			// replace the underscores with spaces
			outputStr=outputStr.replace(/_/g," ");
			outputStr=outputStr.replace(/%27/g,"'");
			document.write(outputStr);
		}

