// Specific display nomenclature 
var nomenclature = Array()
nomenclature["generic"] = "Neurosurgery";
nomenclature["brain_tumors"] = "Divison of Brain Tumors";
nomenclature["cerebrovascular"] = "Division of Cerebrovascular Surgery";
nomenclature["epilepsy"] = "Division of Epilepsy";
nomenclature["facial_pain"] = "Division of Facial Pain";
nomenclature["functional"] = "Division of Functional Neurosurgery";
nomenclature["neurocritical"] = "Division of Neurocritical Care";
nomenclature["pediatric"] = "Division of Pediatric Neurosurgery";
nomenclature["pns"] = "Division of Peripheral Nerve Surgery (PNS)";
nomenclature["tests"] = "Tests & Terms";
nomenclature["test"] = "Tests";
nomenclature["patient"] = "Patient Care";
nomenclature["about"] = "About Us";


function breadCrumbs(separator, cStyle, tStyle, dStyle) {
	// Ignore the filename in the URL
	var path = location.pathname.replace(/(^\/.*\/)(.*$)/, '$1');

	// Remove leading/trailing slashes from the path for proper splitting
	path = path.replace(/^\/(.*?)\/$/, '$1');

	var subdirArray = path.split('/');

	for (i = 1; i < subdirArray.length; i++) {
		var dirname = subdirArray[i];

		
		
		if(typeof(nomenclature[unescape(dirname)]) != "undefined") {
		dirname = nomenclature[unescape(dirname)];
		} else {
			dirname = titleCase(unescape(dirname));
		}
		
		
		var fullpath = '/';
		for (j = 0; j <= i; j++) {
			fullpath += subdirArray[j] + '/';
		}

		document.write('<a href="' + fullpath + '" class="' + cStyle + '">' + dirname +
			'</a>  ' + '<span class="' + dStyle + '">' + separator + '</span> ');
    }
	
	//split title on | pipes
	var tmp_title = document.title.toString().split("|");
	var title_portion = document.title;
	if (tmp_title.constructor.toString().indexOf("Array") > -1) {
		title_portion = tmp_title[0];
	} 
	
	
	//do not need breadcrumbs if we're in the top level already
	if (subdirArray.length > 1) {
	document.write('<span class="' + tStyle + '">' + title_portion + '</span>');
	}
}

function titleCase(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(' ');
}

// Call code to display breadcrumbs
breadCrumbs('>','breadcrumbslink','breadcrumbs','breadcrumbs');

