/*

glossary v3  !! Modified by Jon Raasch (http://jonraasch.com) to fix IE6 bug !!

glossarys arbitrary terms.

<http://johannburkard.de/blog/programming/javascript/glossary-javascript-text-higlighting-jquery-plugin.html>

MIT license.

Johann Burkard
<http://johannburkard.de>
<mailto:jb@eaio.com>

*/

jQuery.fn.glossary = function(pat) {
 function innerglossary(node, pat) {
  var skip = 0;
  if (node.nodeType == 3) {
   var pos = node.data.toUpperCase().indexOf(pat);
   if (pos >= 0) {
	var anode = document.createElement('a');
	anode.className = 'tooltip';
	anode.href = '#';
	anode.rel = pat.toLowerCase();
	var middlebit = node.splitText(pos);
	var endbit = middlebit.splitText(pat.length);
	var middleclone = middlebit.cloneNode(true);
	anode.appendChild(middleclone);
	middlebit.parentNode.replaceChild(anode, middlebit);
	skip = 1;
   }
  }
  else if (node.nodeType == 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) {
   for (var i = 0; i < node.childNodes.length; ++i) {
	i += innerglossary(node.childNodes[i], pat);
   }
  }
  return skip;
 }
 return this.each(function() {
  innerglossary(this, pat.toUpperCase());
 });
};

jQuery.fn.removeglossary = function() {
 function newNormalize(node) {
	for (var i = 0, children = node.childNodes, nodeCount = children.length; i < nodeCount; i++) {
		var child = children[i];
		if (child.nodeType == 1) {
			newNormalize(child);
			continue;
		}
		if (child.nodeType != 3) { continue; }
		var next = child.nextSibling;
		if (next == null || next.nodeType != 3) { continue; }
		var combined_text = child.nodeValue + next.nodeValue;
		new_node = node.ownerDocument.createTextNode(combined_text);
		node.insertBefore(new_node, child);
		node.removeChild(child);
		node.removeChild(next);
		i--;
		nodeCount--;
	}
 }

 return this.find("a.tooltip").each(function() {
	var thisParent = this.parentNode;
	thisParent.replaceChild(this.firstChild, this);
	newNormalize(thisParent);
 }).end();
};


var glossary_terms = Array(
	'anemia',
	'A low level of red blood cells or hemoglobin; may be characterized by paleness, weakness, or shortness of breath with activity',
	'angiogenesis',
	'The growth of new blood vessels',
	'antibody',
	'Proteins (known as immunoglobulins) that circulate in the blood to protect against infections by recognizing and binding to foreign substances such as germs. This signals to other parts of the immune system to destroy germs or other targets',
	'apoptosis',
	'Programmed cell death',
	'bone marrow',
	'Soft, sponge-like area in the center of large bones that contains hematopoietic stem cells for production of white blood cells, red blood cells, and platelets',
	'cytokines',
	'A substance made a cell that acts as a signal for other cells',
	'femur',
	'Long bone of the leg (thigh bone)',
	'humerus',
	'Upper arm bone',
	'indolent',
	'Slow to develop',
	'M-protein',
	'An antibody found in unusually large amounts in the blood or urine of people with multiple myeloma and other types of plasma cell tumors. Also called monoclonal protein.',
	'Monoclonal gammopathy of undetermined significance (MGUS)',
	'A benign condition in which the levels of M-proteins are higher than normal. Also called MGUS. ',
	'osteolytic lesions',
	'Areas of breakdown on the bone',
	'plasma cells',
	'A type of white blood cell that produces antibodies',
	'platelet',
	'A type of blood cell that helps prevent bleeding by causing blood clots to form. Also called a thrombocyte.',
	'red blood cells',
	'A cell that carries oxygen throughout the body. Also called erythrocyte. ',
	'smoldering myeloma',
	'A slow-developing myeloma that often causes no symptoms. ',
	'sternum',
	'The long flat bone at the center front of the chest. Also called the breastbone. ',
	'white blood cells',
	'Infection-fighting blood cells made in the bone marrow. There are two main types of white blood cells: lymphocytes and myeloid cells. As some myeloid cells and some lymphocytes only live for a few days, the bone marrow is constantly making new cells to replace the old ones in the blood. The bone marrow normally makes millions of blood cells every day. When they are mature enough to leave the bone marrow, the white blood cells are released into the bloodstream to circulate around the body. Lymphocytes, unlike the myeloid cells, also circulate in the lymphatic system.'
);

function getGlossaryTermTitle(term){
	for(i=0; i < glossary_terms.length; i = i+2){
		if(term.toUpperCase() == glossary_terms[i].toUpperCase()){
			return glossary_terms[i];
		}
	}
}

function getGlossaryTermDefinition(term){
	for(i=0; i < glossary_terms.length; i = i+2){
		if(term.toUpperCase() == glossary_terms[i].toUpperCase()){
			return glossary_terms[i+1];
		}
	}
}


