// Written by Harry Love
// Email: hlove@u.washington.edu
// Use at your own risk.
// Feel free to use, personalize, improve, and distribute.
// Last update: November 7, 2002

// Updated June 24, 2003
// William L. Graham, WL-Graham@csu.edu
// Added hooks for styles; simplified

// To place breadcrumbs in your page, save this
// file to a directory that makes sense to you.
// Link to it in the <head> portion of your web page.
// In the <body> portion of your page,
// /* paste the following line of code: */
// /* <script type="text/javascript">dropCrumbs();</script> */
// /* DO NOT COPY THIS LINE */

// BEGIN BASIC CUSTOMIZATION

// Starting Point: 1 = domain, 2 = 1st directory, 3 = 2nd directory, etc.
// Must be specified as an integer; no floating point numbers.
// ***Note***: If the starting number is greater than the number of 
// directories you have, the URL will be undefined.
var startPoint = 1; // idea from Hassan Schroeder

// Separator: set the character(s) that will be used to
// separate each of the breadcrumb links.
// Set the space in between each link by 
// specifying a number of non-breaking spaces (&nbsp;).
// The default separator is a "greater than(>)" symbol (&gt;).
var sep = "&nbsp;&gt; "

// Starting Name: setting startName to "domain" will 
// use the full domain name (www.yourdomain.com).
// Any other text will be used literally.
// E.g., specifying "Home" will use "Home" as the first
// link in the chain.
// ***Note***: if startPoint is greater than 1, it will start
// the chain at a point beyond the domain.  startName will
// be used for the name of the first link, regardless of where it
// starts.
var startName = "CSU Home Page";

// Uppercase or lowercase directory names?  If
// uppercase is set to yes, the first character
// in each of the directory names will be capitalized.
// If allUppercase is set to yes, the entire directory
// name will be capitalized for each directory.
var uppercase = "yes";
var allUppercase = "no";

// Endpoint: how do you want the script to handle a
// URL that ends in a directory name? E.g., if the URL
// is http://www.mydomain.com/start/, do you want the
// script to write the name of the directory or the
// title of the default document in this directory?
// You have 2 choices: directory or title.
var endPoint = "title";

var replaceSpecialCharacters = 'no';

// END BASIC CUSTOMIZATION
var d=document;
var url = d.location.href;
var endChar = url.substr(url.length-1);


url=url.replace("//","/");

// This next set of "if" clauses removes the cgi-bin++ portion of the URL for
// pages that include the cgi-bin directory.
if(url.search("cgi-bin") != -1)
{
	var badReg = /\/cgi-bin\/.+url=/i;
	url=url.replace(badReg,"");
	if(url.search("cgi-bin") != -1)
	{
		var badReg = /\/cgi-bin\//i;
		url=url.replace(badReg,"/hsl/");
		
		if(url.search("admin") != -1)
		{
			badReg = /\/admin/i;
			url=url.replace(badReg,"");
		}
	}
}

if(url.search("&url=") != -1)
{
	var badReg2 = /\/hsl\/.+url=/i;
	url=url.replace(badReg2,"");
}

// End cgi-bin removal clauses

var urlText = url;
	

var urlLinkArray=url.split('/');


if(startName=="domain")
{
	var y;
	startName="";
	for(x=0;x<startPoint;x++)
	{
		y=x+1;
		if(y>=1&&y<startPoint)
		{
			startName = startName + urlLinkArray[y] + "/";
		}

		else
		{
			startName = startName + urlLinkArray[y];
		}
	}
}

if(replaceSpecialCharacters == "yes")
{
	for(x=0;x<charactersToReplace.length;x++)
	{
		var myRegExp = new RegExp(charactersToReplace[x][0], "g");
		urlText = urlText.replace(myRegExp,charactersToReplace[x][1]);
	}
}


var urlTextArray=urlText.split('/');

var urlL = urlLinkArray.length;
var uppercaseText;
var lowercaseText;
var lcase;
var linkName=new Array();


if(uppercase=="yes"&&allUppercase=="no")
{
	if(replaceSpecialCharacters=="yes"&&specialCharactersUpper=="yes")
	{
		for(x=0;x<charactersToReplace.length;x++)
		{
			var myRegExp = new RegExp(charactersToReplace[x][1]+"[a-z]", "g");
			for(y=2;y<urlL;y++)
			{
				if(urlTextArray[y].search(myRegExp)!=-1)
				{
					var regExpArray = new Array();
					regExpArray = urlTextArray[y].match(myRegExp);
					for(z=0;z<regExpArray.length;z++)
					{
						
						if(urlTextArray[y].search(myRegExp)!=-1)
						{
							
							var lastLetter = regExpArray[z].substr(regExpArray[z].length-1,regExpArray.length).toUpperCase();
							
							var newText = charactersToReplace[x][1]+lastLetter;
							urlTextArray[y] = urlTextArray[y].replace(regExpArray[z],newText);
						}
					}
				}
			}
		}
	}

	for(x=2;x<urlL;x++)
	{
		uppercaseText=urlTextArray[x].substr(0,1).toUpperCase();
		lowercaseText=urlTextArray[x].substr(1, urlTextArray[x].length);
		linkName[x]=uppercaseText+lowercaseText;
	}
}

else if(allUppercase=="yes"||uppercase=="yes"&&allUppercase=="yes")
{
	for(x=2;x<urlL;x++)
	{
		linkName[x]=urlTextArray[x].toUpperCase();
	}
}

else{linkName=urlTextArray;lcase="yes";}

var start=urlLinkArray[0]+"//";

if(startPoint<1){startPoint=1;}

for(y=1;y<=startPoint;y++)
{
	start=start+urlLinkArray[y]+"/";
}

/* global utilities */

function w (theMsg) {document.writeln (theMsg);}

/* Runs the footer, both variable and constant portions */
function contactUs (who,where) {
		
	// Set up the paragraph so a style can be applied
	// Write office-contact info if the HTML file says to
	if (who !== "") {
		w ('<BR clear="all"><P id="contactUs">');
		w ("Questions? Comments? Contact&nbsp;Us: ");
		w ("<A HREF='mailto:" + where + "'>" + who + "</A></P>");
	}
	return;
}

function stdFoot () {
	// get beyond all object characteristics
	w ('<br clear="all">');
	// Set up the paragraph so a style can be applied
	w ('<p id="admissionsAd">');

	// Add the link to the Admissions Page and all thereafter
	w ("For information click our ");
	w ("<A href='http://www.csu.edu/xgrad/AdmissionsInqFormGrad.htm' target='_blank'>graduate</A>");
	w (" or ");
	w ("<A href='http://www.csu.edu/Admissions/AdmissionRequest.htm' target='_blank'>undergraduate</A>");
	w (" form, and we will send you admissions material. ");
	w ("</p>");

w ('<P id="stdfooter">');
	// Then the university contact data ...
	w ("Chicago State University&nbsp;&copy;&nbsp;2003<BR>");
	w ("9501 South King Drive, Chicago, Illinois 60628<BR>");
	w ("773/995-2000<BR>All Rights Reserved<BR>");
	w ("Send suggestions for the website to the <A href='mailto:bamaster@csu.edu'>Webmaster</A>.<BR></P>");
	return;
}

function doFooters (who,where) {
	contactUs (who,where);
	stdFoot ();
	return;
}


function dropCrumbs (properties) {
	w('<div id="breadcrumbs">');
	
	if(lcase!="yes")
	{
		w('<a style="'+properties+'" class="breadcrumb" href="'+start+'">'+startName+'</a>');
	}

	else
	{
		startName = startName.toLowerCase();
		w('<a style="'+properties+'" class="breadcrumb" href="'+start+'">'+startName+'</a>');
	}
	
	
	if(urlL>2)
	{	
		for(x=startPoint+1;x<urlL;x++)
		{			
			if(x<urlL-1)
			{
				if(x==urlL-2&&linkName[urlL-1]=="")
				{
					if(endPoint=="directory")
					{
						w(sep+linkName[x]);
						break;
					}
					
					else
					{
						if(lcase!="yes")
						{
							w(sep+d.title);
							break;
						}

						else
						{
							var ttl = d.title.toLowerCase();
							w(sep+ttl);
							break;
						}						
					}
				}
				
				else
				{
					start=start+urlLinkArray[x]+"/";
					w(sep+'<a style="'+properties+'"  class="breadcrumb" href="'+start+'">'+linkName[x]+'</a>');
				}
			}
			
			else
			{
				start=start+urlLinkArray[x];
				if(endChar=="/")
				{
					w(sep+linkName[x]);
				}
				
				else
				{
					w(sep+d.title);
				}
			}
		}
	}
		d.writeln('</div>');
}