//adjusted by Simon Mann to be specific to the boc.com Site


/*###################################################################
# js_paths.js						Version1.5
# Copyright (c) 2001-2003 by Henning Poerschke          WebMediaConception.com
#
# This script's idea is based on code by Kevin Lynn Brown found at:
# The JavaScript Source!! http://javascript.internet.com
#
# js_paths.js may be used and modified free of charge by anyone AS LONG
# AS this copyright notice and the comments above remain intact, and any
# significantly modified code is made publically available at evolt.org.
#
# This script is PROVIDED 'AS IS' and comes with NO WARRANTY whatsoever!!
# BY USING THIS CODE YOUR AGREE TO INDEMNIFY HENNING POERSCHKE & 
# WebMediaConception FROM ANY LIABILITY THAT MIGHT ARISE FROM ITS USE.
# 
# This script is released under the GPL.
# Selling the code for this program or any derivative work, however, is 
# expressly forbidden. A full copy of the GPL can be found in the Code section of
# http://evolt.org. In all cases copyright and this header must remain intact.
# 
#####################################################################*/

/*
# ABOUT THIS SCRIPT
#
# js_paths.js takes the current document's location.href and splits it up into its
# various elements: protocol, folder hierarchy, and file name.
# It then offers choices if and how to display these elements.
#
# There's a built in naming convention that can be overridden at will for specific
# folders and/or files.
#
# Finally it puts everything back together and spits out the breadcrumb.
#
# HANDLING OF FOLDER HIERARCHY
#
# Since js_paths.js was created to work offline
# unwanted results are to be expected, like a breadcrumb that is so long that it fills half the page
# because of a gazillion folders in its path.
*/

if (window.location){	//just in case. haven't checked this out. are there any browser quirks with location.href?
	var path="";		// to hold the complete breadcrumb path
	var href=window.location.href; //orignal code
	//reg = /iw.*WORKAREA\/.*\//;  //sets up a regex to match the addtional folders in teamsite removes workarea name
	//reg = /iw-mount.*WORKAREA\//;  //sets up a regex to match the addtional folders in teamsite
	//var href=window.location.href.replace(reg,""); //uses regex to remove additional folder so breadcrumbs 'look' correct
	//alert(window.location.href + "\n  regexed = " + href);
	var ignoreStr = window.location.href;
	var myIndex = ignoreStr.indexOf("WORKAREA");
	ignoreStr = ignoreStr.substring(0, myIndex);
	ignoreStr = ignoreStr  + "WORKAREA\/";
	reg = /http.*iw-mount/;
	ignoreStr = ignoreStr.replace(reg,"iw-mount");
	ignoreArr=ignoreStr.split("/");

	pref = new Array();	// for "partial href"
	s=href.split("/");	// s: array that hold the folders' names
	fname=new Array();	// fname: "full name" that will be displayed
	parts=new Array();	// hold fname's parts[1]_parts[2]

	for (i=2;i<(s.length-1);i++){
		pref[2]=s[2]+"\/";
		pref[i+1]=pref[i]+s[i+1]+"/";
	};

	i=s.length-2;
	pref[i+1]=pref[i]+s[i+1]; //removes extra final slash from pref array


	
	for (i=2;i<(s.length-1);i++){
		fname[i]=s[i];

		/* Here you can suppress display of folders' names
		by assigning an empty fname string,
		or change names to be displayed.*/

		if 	(s[i]==""){fname[i]=""}	//This is where you may rename or suppress directories
		//else if (s[i]=="localhost"){fname[i]=""}
		//the folder names have been extracted, if this is viewed within teamsite, we want to reset href to contain the full iw-mount path
		
		else if (s[i]=="default"){fname[i]=""}  //added to change workarea name
		//else if (s[i]=="yourdomain.com"){fname[i]=""}		//This makes "yourdomain.com" invisible
		else if (s[i]==window.location.host){fname[i]="Home"}	//hides any "domain.com"
		else if (s[i]=="forms"){fname[i]=""}

		if (href.indexOf("iw-mount") != -1){ // we are in TeamSite, and need to ignore all folders from iw-mount and WA 
			for (y=0;y<(ignoreArr.length-1);y++){
				//alert("ignoreArr[" + y + "]: " + ignoreArr[y]);
				if (s[i]==ignoreArr[y]){fname[i]=""}
			};
		
		}
		
		//else if (s[i]=="C\:"){fname[i]=""}			//When developing your site locally, suppress local directories
		//else if (s[i]=="C|"){fname[i]=""}			//this is for Communicator 4.77win
		//else if (s[i]=="MY%20SITES"){fname[i]=""}
		//else if (s[i]=="MY SITES"){fname[i]=""}			//this is for Communicator 4.77win

		//else if (s[i]=="consulting"){fname[i]="[Consulting]"}	//If you have a folder/directory you want to show but not have 
		//else if (s[i]=="design"){fname[i]="web_design"}		//a link to it, put it in [square brackets]
									//Note: this will disable auto capitalization

		/* Parse fname string and put it back togather as pnoun ('propper noun')
		You can actually give a name to a folder here, consisting of more than one word.
		To do so, separate the words with an underline "_". */

		if (fname[i].charAt(0) !== "<") {	// look at the first character. unless it's an '<'...e.g.<img>
			pnoun = fname[i].charAt(0).toUpperCase();	// first character to upper case
			for (j=1;j<(fname[i].length);j++){
				var k = j-1;					// k designates the character following the "_"
				if (fname[i].charAt(j) == "_"){		// if there is an "_"...
					pnoun+= " ";			// ...replace it with a space.
				}
				else if (fname[i].charAt(k) == "_"){	// If  there is a "_" in front... 
					pnoun+=fname[i].charAt(j).toUpperCase(); // ...capitalize the following character
				}
				else { 
					pnoun+=fname[i].charAt(j);	// Append each original character in fname onto pnoun
				}
			}
			fname[i]=pnoun;	// Replace fname with pnoun. (Optionally add ".toUpperCase()" if you want ALL upper case names.)
		}
	};	//ops! Just a reminder to myself--was afraid this might get lost :-)

	/* This writes the breadcrumb links.
	Notice: I'm appending "index.asp" to the link here. Change this to your file type extension.*/


	var ifindexstr=top.window.location.href;
	var ifindex = ifindexstr.indexOf("index.asp");

	for (i=2;i<(s.length-2);i++){
		(fname[i] == "")?(path+=""):((fname[i].charAt(0)=="[")?(path+=fname[i]+" \&raquo; "):(path+="<a href=\""+href.substring(0,href.indexOf(pref[i])+pref[i].length)+"index.asp\">"+fname[i]+"</a> \&raquo; "));
	}

	i=s.length-2;
	
	if (ifindex != -1){
		(fname[i] == "")?(path+=""):((fname[i].charAt(0)=="[")?(path+=fname[i]+" \&raquo; "):(path+=fname[i]));
	}
	else{
		(fname[i] == "")?(path+=""):((fname[i].charAt(0)=="[")?(path+=fname[i]+" \&raquo; "):(path+="<a href=\""+href.substring(0,href.indexOf(pref[i])+pref[i].length)+"index.asp\">"+fname[i]+"</a> \&raquo; "));
	}
	
	
	i=s.length-1;
	fullname=s[i].substring(0,s[i].indexOf("."));

	/* For any files not adhering to the naming scheme, you may specify a custom display name here: 
	You can give a name to a page here, consisting of more than one word.
	To do so, separate the words with an underline "_".*/

	//if (fullname==""){fullname="overview"}
	if (fullname=="index"){fullname=""}  //changes breadcrumb current page name if 'index'
	//else if (fullname=="crptcnme"){fullname="some_name"}
	//else {};

	pnoun = fullname.charAt(0).toUpperCase();		// first character to upper case
	for (i=1;i<(fullname.length);i++){
		var k = i-1;								// k designates the character following the "_"
		if (fullname.charAt(i) == "_"){					// if there is an "_"...
			pnoun+= " ";						// ...replace it with a space.
		}
		else if (fullname.charAt(k) == "_"){				// If  there is a "_" in front...
			pnoun+=fullname.charAt(i).toUpperCase();	// ...capitalize the following character
		}
		else{
			pnoun+=fullname.charAt(i);				// Append each original character in fullname onto pnoun
		}
	}
	;path+=pnoun;
	//url=window.location.protocol+"//"+path;	                    //use only to display protocol type (ftp://; http://)
	url=path;								//If you do, comment out this line instead
	document.write(url);
}
//done