


function breadCrumbs(base, delStr, defp, cStyle, tStyle, dStyle, nl) {

	loc = window.location.toString();
    subs = loc.substr(loc.indexOf(base) + base.length + 1).split("index.html");

	document.write("<a href=\"" + getLoc(subs.length - 1) + defp + "\"><span class=\"" + cStyle + "\">Affinity Energy</span></a>  ");
    a = (loc.indexOf(defp) == -1) ? 1 : 2;
	firstRun	= true;
	b = 1;
		
//alert("loc  " + loc + "\n" + "subs  " + subs + "\n" + "defp  " + defp + "\n" + "a  " + a + "\n" + "subs.length  " + subs.length + "\n" + "subs.length - a  " + (subs.length - a))
    for (i = 0; i < (subs.length - b); i++) {
        subs[i] = makeCaps(unescape(subs[i]));
		subs[i] = replaceSubString(subs[i],"_"," ");
		separator = ((a == 2) ? "" : "<span class=\"" + dStyle + "\">" + delStr + "</span> ");
		
        document.write("<span class=\"" + dStyle + "\">" + delStr + "</span> " + "<a href=\"" + getLoc(subs.length - i - 2) + defp + "\"><span class=\"" + cStyle + "\">" + subs[i] + "</span></a>  " + separator);
		if (firstRun) {
			b = a;
			firstRun = false;
		}
    }
    if (nl == 1) {
        document.write("<br>");
    }
	if (a == 1) {
    	document.write("<span class=\"" + tStyle + "\">" + document.title + "</span>");
	}
}

function makeCaps(a) {
    g = a.split(" ");
    for (l = 0; l < g.length; l++) {
        g[l] = g[l].toUpperCase().slice(0, 1) + g[l].slice(1);
    }
    return g.join(" ");
}

function getLoc(c) {
    var d = "";
    if (c > 0) {
        for (k = 0; k < c; k++) {
            d = d + "../";
        }
    }
    return d;
}

function writePageTitle() {

	loc			= window.location.toString();
	folderName	= loc.substring(0,loc.lastIndexOf('index.html'));
	folderName	= folderName.substring(folderName.lastIndexOf('index.html')+1);
    pageName	= loc.substring(loc.lastIndexOf('index.html')+1,loc.lastIndexOf('.'));
    pageName	= ((pageName.indexOf("index") == -1) ? pageName : folderName);
	pageTitle	= replaceSubString(pageName,"_"," ");
	pageTitle	= makeCaps(pageTitle);
	document.title	= pageTitle;
}

function replaceSubString(string,oldVal,newVal) {
	while (string.indexOf(oldVal)>-1) {
		pos		= string.indexOf(oldVal);
		string	= string.substring(0, pos) + newVal + string.substring(pos + oldVal.length, string.length);
	}
	return string;
}

