function updateHeaderText() {
	var url = document.location.href;
	var header = null;
	// Location header <div>.
	var divs = document.getElementsByTagName('div');
	for (var i = 0; i != divs.length; i++) {
		if (divs[i].className == 'bg-hdr-rightcontent') {
			header = divs[i];
			break;
		}
	}
	// Update header contents based on current document URI.
	if (url.indexOf('a-z-health-guide') > -1) {
		header.innerHTML = 'Health A to Z';
	}
	if (url.indexOf('care-guides') > -1) {
		header.innerHTML = 'Care Guides';
	}
	if (url.indexOf('surgery-procedures') > -1) {
		header.innerHTML = 'Surgery &amp; Procedures';
	}
	if (url.indexOf('pregnancy-center') > -1) {
		header.innerHTML = 'Pregnancy Center';
	}
	if (url.indexOf('wellness-calculators') > -1) {
		header.innerHTML = 'Wellness Calculators';
	}
	if (url.indexOf('symptom-navigator') > -1) {
		header.innerHTML = 'Symptom Navigator';
	}
	// Old URLs.
	if (url.indexOf('Health%20Illustrated%20Encyclopedia') > -1) {
		header.innerHTML = 'Health A to Z';
	}
	if (url.indexOf('Spanish%20Health%20Illustrated%20Encyclopedia') > -1) {
		header.innerHTML = 'A-Z Guia de Salud';
	}
	if (url.indexOf('Care%20Guides') > -1) {
		header.innerHTML = 'Care Guides';
	}
	if (url.indexOf('Surgery') > -1) {
		header.innerHTML = 'Surgery &amp; Procedures';
	}
	if (url.indexOf('Pregnancy%20Center') > -1) {
		header.innerHTML = 'Pregnancy Center';
	}
	if (url.indexOf('Wellness%20Tools') > -1) {
		header.innerHTML = 'Wellness Calculators';
	}
	if (url.indexOf('Symptom%20Checker') > -1) {
		header.innerHTML = 'Symptom Navigator';
	}
	// Spanish URLS
	if (url.indexOf('a-z-guia-de-salud') > -1) {
		header.innerHTML = 'A-Z Guia de Salud';
	}
	if (url.indexOf('cirugias-y-procesos') > -1) {
		header.innerHTML = 'Cirugias Y Procesos';
	}
	if (url.indexOf('centro-de-embarazo') > -1) {
		header.innerHTML = 'Centro de Embarazo';
	}
	return header;
}

// Opens the SymptomNavigator pop-up menu
function blitSymptomMenu(bodyPart){
	bodyPartsDiv = document.getElementById("bodyParts");
	showMenu(bodyPartsDiv, bodyPart);
}

// Here we actually do the opening after blitSymptomMenu got the document element.
function showMenu(menu, selection) {
	var flashObject = document.getElementById('swfFile');
	menu.style.display = "block";
	menu.style.position = "absolute";
	menu.style.left = "400px";
	menu.style.top = "407px";
	menu.className = "symptomNavPopup";

	var menuChildren = menu.getElementsByTagName('div');
	for (var i = 0; i != menuChildren.length; i++) {
		menuChildren[i].style.display = "none";
	}

	var selectionDiv = document.getElementById(selection);
	selectionDiv.style.display = "block";
}

// This resets the menu element's visibility
function hideMenu(menu) {
	menu.style.display = "none";
	var children = menu.getElementsByTagName('div');
	for (var i = 0; i != children.length; i++) {
		if (children[i].style.display != "none") {
			children[i].style.display = "none";
		}
	}
	menu.className = "";
}

// Updates the doctor speciality drop-down box on the overview pages
function getSpecialties() {
	new Ajax.Updater('', '/doctors/json/specialties', {
		  onSuccess: function(transport) {
			document.getElementById('medical-condition').options[0] = new Option("Doctor's Medical Specialty","");
			data = (transport.responseText).evalJSON();
			for (x = 0; x < data.length; x++) {
				document.getElementById('medical-condition').options[x + 1] = new Option(data[x],data[x]);
			}
		  }
	});
}

// This populates the baynote content guides.
function generateBaynoteLinks(lang) {
	//Create new AJAX request for record listing
	url = 'http://lomalindahealth.org/common/php/baynote-content.php';
	//url = "http://1.81.12.75/iw/cci/meta/no-injection/iw-mount/default/main/llumc/lomalindahealth.org/Medical_Center/LLUMC_Common/STAGING/common/php/baynote-content.php";
	if (lang == "es") {
		url += "?lang=es";
	}
	new Ajax.Request(url, {		
	  method: 'get',
	  onSuccess: function(transport) {
		$("contentGuide").innerHTML = transport.responseText;
		stateChanged();
	  }
	});
}

// Updates the left navigation based on the documents URL
function updateLeftNav() {
	var leftNav = document.getElementById("leftnavblock").getElementsByTagName("li");
	var address = window.location.href;
	
	var regex = new RegExp("health\\-library/([\\w\-]+)?", "i");
	var addressMatch = regex.exec(address);

	// Check for index pages
	if (addressMatch[0] == "health-library/index" || addressMatch[0] == "health-library/") {
		disableNavItem(leftNav[0]);
	}
	else if (addressMatch[0] == "health-library/spanish") {
		disableNavItem(leftNav[5]);
	}
	else {
		for (var i = 0; i != leftNav.length; ++i) {
			if (leftNav[i].firstChild.getAttribute("href").indexOf(addressMatch[1]) > -1) {
				disableNavItem(leftNav[i]);
				break;
			}
		}
	}
}

// Disabled a left navigation item
// See updateLeftNav()
function disableNavItem(item) {
	var anchor = item.firstChild;
	var itemText = anchor.innerHTML;
	// Remove <a>
	item.removeChild(anchor);
	// Add <span>
	var span = document.createElement("span");
	span.setAttribute("class", "bold");
	span.style.fontWeight = "bold";
	span.innerHTML = itemText;
	item.appendChild(span);
}