var glossary = {
"Antepartum" : "Before birth",
"CCS" : "California Children's Services",
"CPT" : "Describes medical or psychiatric procedures performed by physicians and other health providers. The codes were developed by the Health Care Financing Administration (HCFA) to assist in the assignment of reimbursement amounts to providers by Medicare carriers.",
"CPQCC" : "The California Perinatal Quality Care Collaborative (CPQCC) is an outgrowth of an initiative proposed by the California Association of Neonatologists and supported by the David and Lucile Packard Foundation and the State of California Department of Health Services, Maternal and Child Health Branch. PQCC has partnered with the Vermont Oxford Network (VON) and Stanford University's Center for Health Policy and Research (HRP) to collect and analyze perinatal health data used for developing and monitoring perinatal quality health improvement projects initiated by CPQCC.",
"DRG" : "Diagnosis Related Groups. A hospital payment methodology based on the patient's diagnosis, procedures, age, sex, discharge status, and complications. Used for hospital billing purposes.",
"Gynecology" : "The study of the diseases of the female reproductive organs and the breasts",
"HL7" : "Health Level Seven is one of several ANSI-accredited Standards Developing Organizations (SDOs) operating in the healthcare arena. Their mission is: \"to provide standards for the exchange, management and integration of data that support clinical patient care and the management, delivery and evaluation of healthcare services. Specifically, to create flexible, cost effective approaches, standards, guidelines, methodologies, and related services for interoperability between healthcare information systems.\"",
"ICD-9" : "International Classification of Disease, 9th revision",
"ICD9" : "International Classification of Disease, 9th revision",
"ICN" :  "Intensive Care Nursery (same as SCN or NICU) ",
"Interface" : "A system which allows the exchange, management and integration of data from multiple standalone data-management systems in the hospital setting, which increase accuracy, save time and effort in data entry, and help improve the workflow.",
"JCAHO" : "The Joint Council on Accreditation of Healthcare Organizations evaluates and accredits nearly 19,000 health care organizations and programs in the United States. An independent, non-profit organization, the Joint Commission is the nation's predominant standards-setting and accrediting body in health care. Their mission is: \"to continuously improve the safety and quality of care provided to the public through the provision of health care accreditation and related services that support performance improvement in health care organizations.\"",
"Level 2" : "An intermediate-care nursery ",
"Level 3" : "A nursery (NICU) capable of taking the sickest infants (long-term ventilators, surgeries, etc.)",
"Neonatal" : "Concerning the first 28 days after birth.",
"M & M" : "Morbidity & Mortality conferences are traditional, recurring conferences held by medical services at academic medical centers and by most large private medical and surgical practices.",
"Obstetrics" : "The branch of medicine that concerns management of women during pregnancy, childbirth and the 42 day-period following childbirth and expulsion of the placenta and membrances.",
"Pediatrics" : "The medical science relating to the care of children and treatment of their diseases.",
"Perinatal" : "Concerning the period beginning after the 28th week of pregnancy and ending 28 days after birth.",
"Provider" : "A doctor, hospital, health care professional, or health care facility.",
"TCN" : "Transitional Care Nursery (a step-down from the NICU, aka intermediate care nursery)",
"VON" : "Vermont Oxford Network is a non-profit voluntary collaboration of health care professionals dedicated to increasing the effectiveness and efficiency of medical care for newborn infants and their families through an integrated program of outcomes research, randomized clinical trials, quality improvement projects and education."
};

function setup_acronym_tags()
{
	add_acronym_tags(document.documentElement);
	Behaviour.apply();
}
function add_acronym_tags(parent)
{
	for(var child = parent.firstChild; child != null; child = child.nextSibling)
	{
		if (child.nodeType == 3) //is text
		{
			text = child.nodeValue;
			for(var word in glossary)
			{
				loc = text.indexOf(word);
				if (loc != -1 && glossary[word] != "") {
					// Create a load of replacement nodes
					before = document.createTextNode(text.substr(0,loc));
					after = document.createTextNode(text.substr(loc+word.length));
					hiwordtext = document.createTextNode(word);
					hiword = document.createElement("acronym");
					hiword.title = glossary[word];
					glossary[word] = "";
					hiword.appendChild(hiwordtext);
					parent.insertBefore(before,child);
					parent.insertBefore(hiword,child);
					parent.insertBefore(after,child);
					parent.removeChild(child);
					add_acronym_tags(parent);
				}
			}
		}
		else if(child.nodeType == 1        //is an element
					&& child.nodeName != 'HEAD'//but not the head   
					&& child.nodeName != 'ACRONYM'//and not an acroynm
					&& child.nodeName != 'A'  //and not a link
					&& child.nodeName != 'H1'  //and not a header
					&& child.nodeName != 'H2'
					&& child.nodeName != 'H3'
			        )
		{
			add_acronym_tags(child);
		}
	}
}


var popups = {
		'acronym' : function(element){
			element.onclick = function(){
				alert(this.innerHTML + ": " + this.title);
			}
		}
	};
Behaviour.register(popups);
Behaviour.addLoadEvent(setup_acronym_tags);
