// photoGRAFIUS studios
// cookieCrumb Generator V 1.0
//
// Copyright 2009 photoGRAFIUS studios
// guy at photografius.com
//
// To Add a Word to Proper word in the Array scroll down to function "String.prototype.wordScrub"
//

// Convert To Title Case
String.noLC = new Object
  ({the:1, a:1, an:1, and:1, or:1, but:1, aboard:1,
    about:1, above:1, across:1, after:1, against:1,
    along:1, amid:1, among:1, around:1, as:1, at:1,
    before:1, behind:1, below:1, beneath:1, beside:1,
    besides:1, between:1, beyond:1, but:1, by:1, 'for':1,
    from:1, 'in':1, inside:1, into:1, like:1, minus:1,
    near:1, of:1, off:1, on:1, onto:1, opposite:1,
    outside:1, over:1, past:1, per:1, plus:1,
    regarding:1, since:1, than:1, through:1, to:1,
    toward:1, towards:1, under:1, underneath:1, unlike:1,
    until:1, up:1, upon:1, versus:1, via:1, 'with':1,
    within:1, without:1});


String.prototype.titleCase = function () {
  var parts = this.split(' ');
  if ( parts.length == 0 ) return '';

  var fixed = new Array();
  for ( var i in parts ) {
    var fix = '';
    if ( String.noLC[parts[i]] )
    {
      fix = parts[i].toLowerCase();
    }
    else if ( parts[i].match(/^([A-Z]\.)+$/i) )
    { // will mess up "i.e." and like
      fix = parts[i].toUpperCase();
    }
    else if ( parts[i].match(/^[^aeiouy]+$/i) )
    { // voweless words are almost always acronyms
      fix = parts[i].toUpperCase();
    }
    else
    {
      fix = parts[i].substr(0,1).toUpperCase() +
                 parts[i].substr(1,parts[i].length);
    }
    fixed.push(fix);
  }
  fixed[0] = fixed[0].substr(0,1).toUpperCase() +
                 fixed[0].substr(1,fixed[0].length);
  return fixed.join(' ');
}


// Cross-Browser Split
// avoid running twice, which would break the reference to the native `split`
if (!window.cbSplit) {

	var cbSplit = function (str, separator, limit) {
		// if `separator` is not a regex, use the native `split`
		if (Object.prototype.toString.call(separator) !== "[object RegExp]")
			return cbSplit._nativeSplit.call(str, separator, limit);

		var	output = [],
			lastLastIndex = 0,
			flags = (separator.ignoreCase ? "i" : "") +
				(separator.multiline  ? "m" : "") +
				(separator.sticky     ? "y" : ""),
			separator = RegExp(separator.source, flags + "g"), // make `global` and avoid `lastIndex` issues
			separator2, match, lastIndex, lastLength;

		str = str + ""; // type conversion
		if (!cbSplit._compliantExecNpcg)
			separator2 = RegExp("^" + separator.source + "$(?!\\s)", flags); // doesn't need /g or /y, but they don't hurt

		// behavior for `limit`: if it's...
		// - `undefined`: no limit.
		// - `NaN` or zero: return an empty array.
		// - a positive number: use `Math.floor(limit)`.
		// - a negative number: no limit.
		// - other: type-convert, then use the above rules.
		if (limit === undefined || +limit < 0) {
			limit = Infinity;
		} else {
			limit = Math.floor(+limit);
			if (!limit)
				return [];
		}

		while (match = separator.exec(str)) {
			lastIndex = match.index + match[0].length; // `separator.lastIndex` is not reliable cross-browser

			if (lastIndex > lastLastIndex) {
				output.push(str.slice(lastLastIndex, match.index));

				// fix browsers whose `exec` methods don't consistently return `undefined` for nonparticipating capturing groups
				if (!cbSplit._compliantExecNpcg && match.length > 1) {
					match[0].replace(separator2, function () {
						for (var i = 1; i < arguments.length - 2; i++) {
							if (arguments[i] === undefined)
								match[i] = undefined;
						}
					});
				}

				if (match.length > 1 && match.index < str.length)
					Array.prototype.push.apply(output, match.slice(1));

				lastLength = match[0].length;
				lastLastIndex = lastIndex;

				if (output.length >= limit)
					break;
			}

			if (separator.lastIndex === match.index)
				separator.lastIndex++; // avoid an infinite loop
		}

		if (lastLastIndex === str.length) {
			if (!separator.test("") || lastLength)
				output.push("");
		} else {
			output.push(str.slice(lastLastIndex));
		}

		return output.length > limit ? output.slice(0, limit) : output;
	};

	cbSplit._compliantExecNpcg = /()??/.exec("")[1] === undefined; // "NPCG": nonparticipating capturing group
	cbSplit._nativeSplit = String.prototype.split;

}

// Look For a word and scrub proper!
String.prototype.wordScrub = function () {
var i;

var myPwords = new Array();
//
// word in casesensitve search replace with! first word ALWAYS LOWERCASE next word Proper Case!
//
myPwords[0] = "commtech,CommTech";
myPwords[1] = "enhanced 911,Enhanced 911";

  	properWord=srubedURL;
	for (i in myPwords)
	{
		var myParts = myPwords[i].split(',')
		if(myParts[0]==properWord.toLowerCase()){
			properWord=myParts[1];
		}
	}



  return properWord;
}


myURL=cbSplit(location.pathname, '/', 99);

var myCrumb='<a href="/">Home</a>';
var growingURL="/";

for ( i = 0; i < myURL.length-1; i++) {
	if(myURL[i] != '' && myURL[i] != null){

		// If Gated Web Form Do This!
		if(myURL[i]=="gwf"){
			var myGWFtemplates = myFormTemplate.split(',')
			myCrumb += ' &gt; <a href="/Resources/">Resources</a> &gt;  ' + '<a href="/Resources/' + myGWFtemplates[0] + '/">' + myGWFtemplates[1] + '</a>';
		}else{
			growingURL += myURL[i] + '/';
		
			// UpperCase First Letter;
			srubedURL=myURL[i];
			// Create Spaces
			var srubedURL = srubedURL.replace(/_/g, " ");
			var srubedURL = srubedURL.replace(/%5F/g, " ");
			//Make TitleCase
			srubedURL=srubedURL.titleCase();
			// Look for certain words and convert to proper!
			srubedURL=srubedURL.wordScrub();
			myCrumb += ' &gt;  ' + '<a href="' + growingURL + '">' + srubedURL + '</a>';
		}
	
	}

}


document.write(myCrumb);