// BlackHillsEnergy.com
	/* Browser Detection for NS 4 */
	/* Browser Detection - if NS - don't show breadcrumbs due to nav .js url problem */
	var agt=navigator.userAgent.toLowerCase();
	var is_major = parseInt(navigator.appVersion);
	var is_minor = parseFloat(navigator.appVersion);
	var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
		&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
		&& (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
	var is_nav2 = (is_nav && (is_major == 2));
	var is_nav3 = (is_nav && (is_major == 3));
	var is_nav4 = (is_nav && (is_major == 4));
	var is_webtv = (agt.indexOf("webtv") != -1); 
	var is_TVNavigator = ((agt.indexOf("navio") != -1) || (agt.indexOf("navio_aoltv") != -1)); 
	var is_AOLTV = is_TVNavigator;
	var is_hotjava = (agt.indexOf("hotjava") != -1);
	var is_hotjava3 = (is_hotjava && (is_major == 3));
	var is_hotjava3up = (is_hotjava && (is_major >= 3));

	/* Global Variables */
	var $crumbs = "<div class='breadcrumbs'><strong>You are here:</strong> &nbsp;";
	//if (location.hostname == "aquiladev") { var $home_directory = "http://aquiladev"; }
	//else { var $home_directory = location.protocal + location.hostname; }
	var $home_directory = location.protocol +"//"+ location.hostname;
	var $divider = "&nbsp;&raquo;&nbsp;";
	var $cStyle = "breadcrumbs";

	/* Site Directory Masking Information */
	var dirList = new Array(
		{directory:"capacity", label:"Capacity Services"},
		{directory:"midstream", label:"Mid-Stream"},
		{directory:"openseason", label:"Open Season"},
		{directory:"econdev", label:"Economic Development"},
		{directory:"aer", label:"Energy Resources"}, 
		{directory:"aboutus", label:"About Us"}
	);

	// Array includes any folder/section index filename used in the site
	var toExclude = new Array("index.html", "index.shtml");

	// Looks for location.href extension match - if none is found
	// we assume we are at the folder root (ie. /folder/)
	var look4ext = new Array(".html", ".shtml", ".htm", ".jsp");

// --------------------------------------------------------------------------------------//
// Code below should remain matched to blackhillsenergy.com/js/breadcrumb.js & vice versa //
// --------------------------------------------------------------------------------------//

	/* Uppercase's 1st letter in directory names */
	function makeCaps($a) { 
		$sub_dir_name = $a;

		var testVar = false;
		/* Checks array above to see if it finds a match - if found it labels the dir correctly */
		for (d=0; d < dirList.length; d++) {
			if (dirList[d].directory == $sub_dir_name) { 
				$sub_dir_name = dirList[d].label; 
				testVar = true;
				return $sub_dir_name; }
		}

		/* No match found so we write the breadcrumb dynamically */
		if (!testVar) {
			$sub_dir_name = $a.split(" ");
			//loops thru directory names and changes 'name' to 'Name'
			for (l = 0; l <  $sub_dir_name.length; l++) { 
				$sub_dir_name[l] =  $sub_dir_name[l].toUpperCase().slice(0, 1) +  $sub_dir_name[l].slice(1); 
			}
			return  $sub_dir_name.join(" ");
		}
	}//EoFn makeCaps()
	
	// determins number of levels up required to reach root directory and prints the appropriate number of '../'
	function getLoc($num) {
		var $path = "";
		if ($num > 0) {
			for ($count = 0; $count < $num; $count++) { 
				$path = $path + "../"; /* for each level specified by $num add a '../' */ }
		}
		return $path;
	}//EoFn getLoc()
	

	/*************** Main Breadcrumbs Coding **********************/
	function breadCrumbs() {
		// kills breadcrumbs if any == true
		if (is_nav2 || is_nav3 || is_nav4 || is_webtv || is_TVNavigator || is_AOLTV || is_hotjava || is_hotjava3 || is_hotjava3up) return;

		// gets current URL and converts to text string
		// e.g. http://www.itrainweb.com/tests/javascript/test_elements.html
		// gets the substring of the URL after the home directory (http://itrainweb.com/)and splits it at the
		// e.g. tests,javascript,test_elements.html
		$location = window.location.toString();
			
		// prints the path to the home directory + the $divider e.g.'<a href="../../index">Home</a><span>>></span>'
		// uses the getLoc() function defined below with the subString.length to determine how many 
		// levels up from the current file the home directory is.
		$subString = $location.substr($location.indexOf($home_directory) + $home_directory.length + 1).split("/");
		
		// Prints out the path to the home directory, the home directory name ($home_file) and the $divider (and style classes if defined)
		// Remove +$home_file to return to default directory listing
		//$crumbs += "<a href=\"" + getLoc($subString.length - 1) + "\" class=\"" + $cStyle + "\">BlackHillsEnergy.com</a>"+$divider;
		$crumbs += "<a href=\"http://www.blackhillsenergy.com\" class=\"" + $cStyle + "\">BlackHillsEnergy.com</a>"+$divider;

		// prints remainder of path converting file names first letters to uppercase using getCaps()==
		$a = ($location.indexOf() == -1) ? 1 : 2;
		
		// Breaks loop if match is found
		$breakloop = false;

		// Loops thru sub-directories, adds uppercase letter from makeCaps() and prints as link
		// Remove +$home_file to return to default directory listing
		// Checks to see if we are at the root of the folder, if so, we don't need to list the 
		// link back to the root level of the folder so we don't
		for (j=0; j < toExclude.length; j++) {
		if ($breakloop) { break; }
			// search's string for excluded filename; 
			//NO match (== -1) / found match (!= -1)
			if (eval("$location.search(/"+toExclude[j]+"/)") != -1) {
				var $subStringLoop = $subString.length - 1; 
				$breakloop = true; }
			else { var $subStringLoop = $subString.length; }
		}

		// If we didn't find the page name (with extension) to exlcude above
		// we try to find page extension - if none is found we assume 
		// we are at the index level of the root folder (ie. /folder/)
		for (j=0; j < look4ext.length; j++) {
		if ($breakloop) { break; }
			if (eval("$location.search(/"+look4ext[j]+"/)") != -1) {
				var $subStringLoop = $subString.length;
				$breakloop = true; 
			}
			else { var $subStringLoop = $subString.length - 1; }
		}

		for (i = 0; i < $subStringLoop - $a; i++) {
			$subString[i] = makeCaps(unescape($subString[i]));
			$lnkLevel = getLoc($subString.length - i - 2);
			if ($lnkLevel == "") $lnkLevel = "."; // fixes NS issue
			//	$crumbs += "<span class=\"" + $cStyle + "\">"+$subString[i]+"</span>"+$divider; // no links
				$crumbs += "<a href=\"" + $lnkLevel + "\" class=\"" + $cStyle + "\">"+$subString[i]+"</a>"+$divider;
		}

		$crumbs += document.title + "</div>";
		document.write($crumbs); // writes breadcrumbs
	} // EoFn breadCrumbs()	