				//declare variable to point to window opened by open Figure
				var figWindow;
				
				
				/* from text to reference */
				function linkBack(reference,caller,position,link) {
							
						refDiv = document.getElementById(reference);
						refDivLink = document.getElementById('ref_'+reference);
						
						/* turn off all highlighted references */
						turnOffAll();
						
						/* round corner container divs */					
						blRefDivLink = document.getElementById('bl_'+reference);
						brRefDivLink = document.getElementById('br_'+reference);
						tlRefDivLink = document.getElementById('tl_'+reference);
						trRefDivLink = document.getElementById('tr_'+reference);
						
						/* change round div styles */
						blRefDivLink.className = "ref-bl";
						brRefDivLink.className = "ref-br";
						tlRefDivLink.className = "ref-tl";
						trRefDivLink.className = "ref-tr";
						
						/* change href of reference anchor to screen offset of caller*/
						refDivLink.href = '#'+caller;

						
						refDiv.className = "reference";
						document.location.hash = reference;
						link.href = "#"+reference;
						
				}
				
				/* from reference to text */
				function linkFront(link) {
					
						reference = link.id.substr(4,link.id.length);
						
						/* turn off all highlighted references */
						turnOffAll();
						
						/* round corner container divs */					
						blRefDivLink = document.getElementById('bl_'+reference);
						brRefDivLink = document.getElementById('br_'+reference);
						tlRefDivLink = document.getElementById('tl_'+reference);
						trRefDivLink = document.getElementById('tr_'+reference);
						
						/* change round div styles to nothing */
						blRefDivLink.className = "";
						brRefDivLink.className = "";
						tlRefDivLink.className = "";
						trRefDivLink.className = "ref-padding";

						
				}
				
				/* un-highlight all references */
				function turnOffAll () {
					
					/*loop through all div elements and see if the class is "ref-*" */
					/* replace with blank or ref-padding as necessary */
					var divEls = document.getElementsByTagName("div");
					
					for(i=0;i < divEls.length; i++) {
						divEls.item(i).className = divEls.item(i).className.replace('ref-bl','');
						divEls.item(i).className = divEls.item(i).className.replace('ref-br','');
						divEls.item(i).className = divEls.item(i).className.replace('ref-tl','');
						divEls.item(i).className = divEls.item(i).className.replace('ref-tr','ref-padding');
					}
					
				}
				
/* functions for mouse events associated with the article navigation */
/* two timeouts - one short, one long. the short one keeps down the appearance of lag */

function showNav (el) {
	//document.getElementById("navShow").innerHTML += "<br>Show" + el.id;
	showStyle(el);
	clearTimeout(el.timeOut);
	clearTimeouts();
	}
	
function hideNav (el) {
		//document.getElementById("navShow").innerHTML += "<br>Hide " + el.id;
		el.timeOut = setTimeout(function() {waitAgain(el);},5);
		el.longTimeOut = setTimeout(function() {hideStyle(el);},750);
		el.clearedLong = 0;
}

function waitAgain (el) {	
	//document.getElementById("navShow").innerHTML += "<br>Wait Again"+el.longTimeOut + " " + el.id;
	if (el.clearedLong) {
		hideStyle(el);
	}
}

function hideStyle (el) {
	el.className = "";
	
}

function showStyle (el) {
		el.className+=" sfhover";
}

function clearTimeouts() {
	var sfTopEls = document.getElementsByTagName("UL");

	for (var j=0; j<sfTopEls.length; j++) {

		if (sfTopEls[j].className.indexOf("nav") >= 0) {
			
		var sfEls = sfTopEls[j].getElementsByTagName("LI");
			for (var i=0; i<sfEls.length; i++) {
					//document.getElementById("navShow").innerHTML += "<br>before " + sfEls[i].id + " " + sfEls[i].longTimeOut;
					clearTimeout(sfEls[i].longTimeOut);
					sfEls[i].clearedLong = 1;
					//document.getElementById("navShow").innerHTML += "<br>After " + sfEls[i].id + " " + sfEls[i].longTimeOut;
			}
		}
	}	
}

/* function to close all menus when a link from a menu has been clicked */
function clearMenus() {
	var sfTopEls = document.getElementsByTagName("UL");

	for (var j=0; j<sfTopEls.length; j++) {

		if (sfTopEls[j].className.indexOf("nav") >= 0) {
			
		var sfEls = sfTopEls[j].getElementsByTagName("LI");
			for (var i=0; i<sfEls.length; i++) {
					hideStyle(sfEls[i]);
			}
		}
	}	
}

/*function called when menu link is clicked */
function menuLink (articleLink) {
	clearMenus();
	window.location.hash = articleLink;
}

/* function for figure popup window */

function figureOpen(figureIndex,figureDOI,imageType) {
    //ADDED DEFAULT IMAGETYPE OF 'TABLE'
    //THIS IS BECAUSE THE XML STRUCTURE CHANGED FROM THE ORIGINAL VERSION
    //UPON WHICH THIS FUNCTION IS BASED
    //AND THIS IS A QUICKER FIX THAN RE-TRANSFORMING AFFECTED ARTICLES
    
    if (!imageType.length) imageType = "table";
    
	if (figWindow == undefined) {
	window.open('imagebrowse.cfm?imageIndex='+figureIndex+'&doi='+figureDOI+"&imageType="+imageType, 'figWinName', 'height=695,width=780,directories=0,menus=0,resizable=1');
		}
	else	{
		figWindow.location.search = '?imageIndex='+figureIndex;
	}
}

/* function to open PubMed links from references */

function goPubMed(pmid) {
	window.open('http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&dopt=Citation&list_uids='+pmid);
	}

