//Modified by Ramarao to be specific to boconline.co.uk and boconline.co.ie


/*###################################################################
# 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.*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


// ######  Making sure that whereever BOC is it is uppercase	  ######
// ######  i - ignores case and g is global throughout the string ######
//href=href.replace(/boc/ig,"BOC");

//alert(window.location.href + "\n  regexed = " + href);
pref = new Array();	// for "partial href"
s1=href.split("/");	// s: array that hold the folders' names
s=new Array();
fname=new Array();	// fname: "full name" that will be displayed
parts=new Array();	// hold fname's parts[1]_parts[2]
x=1;

number_of_levels=1;
difference=s1.length-number_of_levels;

if (difference<=2){
	number_of_levels=difference;
	}

for (i=1; i<s1.length; i++)
	{
		if (i>number_of_levels) {
			s[x]=s1[i];			
			x++;
	}
};


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 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]=""}
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]=""}	//hides any "domain.com"

//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.*/

for (i=2;i<(s.length-2);i++)
{
	
	displayname=fname[i];	       
	
	(fname[i] == "")?(path+=""):((fname[i].charAt(0)=="[")?(path+=fname[i]+" \&gt; "):(path+="<a href=\""+href.substring(0,href.indexOf(pref[i])+pref[i].length)+"index.asp\">"+ displayname +"</a> \&gt; "));
	
}
i=s.length-1;
fullname=s[i].substring(0,s[i].indexOf("."));

/* Capitalising letters in filename */
if (fullname!== "<")			// look at the first character. unless it's an '<'...e.g.<img>
	{
	pnoun = fullname.charAt(0).toUpperCase();	// first character to upper case
	for (j=1;j<(fullname.length);j++)
		{
		var k = j-1;					// k designates the character following the "_"
		if (fullname.charAt(j) == "_")		// if there is an "_"...
			{
			pnoun+= " ";			// ...replace it with a space.
			}
		else if (fullname.charAt(k) == "_")	// If  there is a "_" in front... 
			{
			pnoun+=fullname.charAt(j).toUpperCase(); // ...capitalize the following character
			}
		else 
		{
			pnoun+=fullname.charAt(j);	// Append each original character in fname onto pnoun
		}
	}
	fullname=pnoun;	// Replace fname with pnoun. (Optionally add ".toUpperCase()" if you want ALL upper case names.)
}

i=s.length-2;
fullname=fullname.replace(/~/ig,"/");

if (difference==3){
	
	if (fullname=="Index"){	
	(fname[i] == "")?(path+=""):((fname[i].charAt(0)=="[")?(path+=fname[i]+" \&gt; "):(path+=fname[i]+"\&gt;"));
	
	}
}
else {
	
	 displayname2=fname[i];
	 
	if (fullname=="Index"){
		(fname[i] == "")?(path+=""):((fname[i].charAt(0)=="[")?(path+=fname[i]):(path+=displayname2));
	}
	else{	
	
	 (fname[i] == "")?(path+=""):((fname[i].charAt(0)=="[")?(path+=fname[i]+" \&gt; "):(path+="<a href=\""+href.substring(0,href.indexOf(pref[i])+pref[i].length)+"index.asp\">"+ displayname2 +"</a>\&gt; "));
	}
}

/* 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
	{
	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
url=url.replace(/boc/ig,"BOC");
url=url.replace(/Mm/g,"mm");
url=url.replace(/Uvex/ig,"uvex");

document.write(url);
}