/************************************************
*
* JavaScript Breadcrumb Trail Generator 1.1
*
* Purpose:
*   This script produces a breadcrumb trail
*   based upon the url of the page with option
*   to mask/alter/tweak sub-sections.
*
* Author: AJ Hill
* Date: 2004-06-12
*
************************************************/

function breadcrumbs() {

	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;
	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];
	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.*/

	// Do Suppression / ReMapping of folder names
	

	/*
	*
	* set fname[i] = "" where s[i] == ""
	*
	* "name" = rename it
	* "" - hide it
	* "[name]" - no link (disables auto-capitals)
	* 
	*/
	
	switch (s[i]) {
		case 'C:':
			fname[i]='';
		break;
		case 'phpdev':
			fname[i]='';
		break;
		case 'www':
			fname[i]='';
		break;
		case 'houwebs300.corp.kbr.com':
			fname[i]='';
		break;		
		case 'houwebs300.corp.kbr.com:8080':
			fname[i]='';
		break;
		case 'mwkl.co.uk':
			fname[i]='Home';
		break;
		case 'www.mwkl.co.uk':
			fname[i]='Home';
		break;
		case 'cmd':
			fname[i]='Home';
		break;
		case 'js':
			fname[i]='JavaScript Directory';
		break;
		case '1.AboutUs':
			fname[i]='About Us';
		break;
		case '2.ProductLines':
			fname[i]='Product Lines';
		break;
		case '3.Services':
			fname[i]='Services';
		break;
		case '4.Procurement':
			fname[i]='Procurement';
		break;
		case '5.Portfolio':
			fname[i]='Portfolio';
		break;
		case '6.Careers':
			fname[i]='Careers';
		break;
		case '7.NewsCentre':
			fname[i]='News Centre';
		break;
		case '8.Contacts':
			fname[i]='Contacts';
		break;
		case '9.Login':
			fname[i]='Login';
		break;
		case '10.Subcontracts':
			fname[i]='Subcontracts';
		break;
		case '11.Construction':
			fname[i]='Construction';
		break;
	}

	/* 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.php" to the link here. Change this to your file type extension.*/

	for (i=2;i<(s.length-2);i++)
	{
	(fname[i] == "")?(path+=""):((fname[i].charAt(0)=="[")?(path+=fname[i]+" \&raquo; "):(path+="<a class=\"menu\" href=\""+href.substring(0,href.indexOf(pref[i])+pref[i].length)+"\">"+fname[i]+"</a> \&raquo; "));
	}

	i=s.length-2;
	(fname[i] == "")?(path+=""):((fname[i].charAt(0)=="[")?(path+=fname[i]+" \&raquo; "):(path+="<a class=\"menu\" href=\""+href.substring(0,href.indexOf(pref[i])+pref[i].length)+"\">"+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 "_".*/

	switch (fullname) {
		case 'houwebs300.corp.kbr.com':
			fullname = 'MWKL';
		break;
		case '':
			fullname = 'Overview';
		break;
		case 'index':
			fullname = 'Overview';
		break;
		case 'policies_standards':
			fullname = "Policies \& Standards";
		break;
		case 'epc':
			fullname = 'EPC';
		break;
		case 'sub_contractors':
			fullname = 'Subcontractors';
		break;
		case 'graduates_home':
			fullname = 'Graduates &raquo; Home';
		break;
		case 'graduates_job_profiles':
			fullname = 'Graduates &raquo; Job Profiles';
		break;
		case 'graduates_about':
			fullname = 'Graduates &raquo; About Programme';
		break;
		case 'graduates_about_us':
			fullname = 'Graduates &raquo; About Us';
		break;
		case 'graduates_training_scheme':
			fullname = 'Graduates &raquo; Training Scheme';
		break;
		case 'graduates_people_profiles':
			fullname = 'Graduates &raquo; People Profiles';
		break;
		case 'graduates_road_show':
			fullname = 'Graduates &raquo; Road Show';
		break;
		case 'graduates_why_work_at_MWKL':
			fullname = 'Graduates &raquo; Why Work At MWKL';
		break;
		case 'graduates_chartership':
			fullname = 'Graduates &raquo; Chartership';
		break;
		case 'graduates_graduate_profile':
			fullname = 'Graduates &raquo; Graduate Profiles';
		break;
		case 'graduates_application':
			fullname = 'Graduates &raquo; Application Form';
		break;
		case 'brochures_publications':
			fullname = 'Brochures \& Publications';
		break;
		case 'press_releases_article1':
		case 'press_releases_article2':
		case 'press_releases_article3':
		case 'press_releases_article4':
		case 'press_releases_article5':
		case 'press_releases_article6':
		case 'press_releases_article7':
		case 'press_releases_article8':
		case 'press_releases_article9':
		case 'press_releases_article10':
		case 'press_releases_article11':
		case 'press_releases_article12':
			fullname = '<a href="javascript:history.go(-1);" class="menu">Press Releases</a> &raquo; Article';
		break;
		case 'login':
			fullname = 'MWKL Login';
		break;
	}

	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
	return url;
}