﻿	// external script -- src="ans.js"

		function classChange(pElemRef, pClass) { // called by naviagtion cell mouseover/out handlers
			//alert("In classChange");// debug alert
			//alert("In classChange, pElemRef = " + pElemRef);// debug alert
			pElemRef.className=pClass;
		}		
		
		function goPage(pWhere) { // called by naviagtion bar selection, go to new html page
			//alert("In traceOption, pWhere = " + pWhere);// debug alert
			top.location.href=pWhere;
		}		

		function popPage(pWhich) { // called by naviagtion bar selection, go to new html page
			//alert("In popPage, pWhich = " + pWhich);// debug alert
			alert("Sorry, not yet implemented");
		}		


		function openPopUp(pPg) { // called by clicking a small image (thum image) in a page 
			//alert("In openPopUp"); // debug alert
			var page = "popUpPgs/" + pPg;
			imgWindowRef= window.open(page,"popWindow","scrollbars=yes,width=850,height=750,resizable,menubar=0,left=20");
		}		

	function openQuizPg(qPg) { // called by clicking a small image (thum image) in a page 
			//alert("In openPopUp"); // debug alert
			var page =  qPg;
			imgWindowRef= window.open(page,"quizWindow","scrollbars=yes,width=700,height=750,resizable,menubar=0,left=10");
		}		
		
function hideBut(pElemRef,pID) { // called by a "button" that hides a path content div, to reveal the content
			//alert("In hideBut, pElemRef.style.visibility = " + pElemRef.style.visibility);// debug alert
			elemRef = document.getElementById(pID); // get ref to the content div
			elemRef.style.visibility = "visible"; // show the content
			pElemRef.style.visibility = "hidden"; // hide the button shielding the content
			
		}		
		
		function optClassChange(pElemRef, pClass) { // called by Show/Trace Pathway option "button" mouseover/out handlers
			//alert("In optClassChange");// debug alert
			if (pElemRef.className == "targ") return; // leave existing target unchanged
			pElemRef.className=pClass;
		}		
		
		function traceOption(pWhich){ // called by clicking a Show/Trace Pathway option "button"
			//alert("In traceOption, pWhich = " + pWhich);// debug alert
			var imageDivRef = document.getElementById("imageDiv"); // get ref to the image div
			var imageDivButRef = document.getElementById("imageDivBut"); // get ref to the image reveal "buton"
			var shwPathRef = document.getElementById("shwPwy"); // get ref to the option "button" Show Pathway
			var trcPathRef = document.getElementById("trcPwy"); // get ref to the option "button" Trace Pathway
			var targOrgRef = document.getElementById("targOrg"); // get ref to Target Organs partion of the pathway
			var divRef = document.getElementById("pathwayDiv"); // get div container for the pathway box 
			var divArr = divRef.childNodes; // load container nodes (divs) into an array
			if (pWhich == "show") {
				if (shwPathRef.className == "targ") return; // Take no action if option is already a target
				shwPathRef.className = "targ";
				trcPathRef.className = "norm";
				for (var i = 0; i < divArr.length; i++) { // loop thru container div elements
					if (divArr[i].nodeType == 1) { // if child is an element node, i.e., a div node, then reverse visibility
						// below: Hide the div if its id string includes "But", else show the div
						 (divArr[i].id.indexOf("But") > 0)?divArr[i].style.visibility = "hidden":divArr[i].style.visibility = "visible";
					}
				}
				imageDivRef.style.visibility = "visible"; // show the image
				imageDivButRef.style.visibility = "hidden"; // hide the "button"
			}
			if (pWhich == "trace") {
				if (trcPathRef.className == "targ") return; // take no action if option is already a target
				shwPathRef.className = "norm";
				trcPathRef.className = "targ";
				for (var i = 0; i < divArr.length; i++) { // loop thru container div elements
					if (divArr[i].nodeType == 1) { // if child is an element node, i.e., a div node, then reverse visibility
						// below: Show the div if its id string includes "But", else hide the div
						 (divArr[i].id.indexOf("But") > 0)?divArr[i].style.visibility = "visible":divArr[i].style.visibility = "hidden";
					}
				}
				imageDivRef.style.visibility = "hidden"; // hide the image
				imageDivButRef.style.visibility = "visible"; // show the "button"
			}
			// cancel this: targOrgRef.style.visibility = "visible"; // always leave the Traget Organs visible
			}
			
			
		function navDsply(pID,pClass) {
			//alert(" In navOvr" ); // debug alert
			document.getElementById(pID).className = pClass;//rollover class
			if (pID == "section") { // if section, show/hide RETURN on mouse over/out
				document.getElementById("returnCell").className = pClass;
			}
		}
				
		function navClick(pID,pClass,pWhere) {
			//alert(" In navClick" ); // debug alert
			document.getElementById(pID).className = pClass;// default class
			window.location = pWhere; // load chosen page
		}		
			
 
		function xxxshowSummary(pPage) { // called by clicking to evoke an instructor summary
			//alert("In showSummary " ); // alert debug
			windowRef= window.open(pPage,"summaryWindow","scrollbars=yes,width=800,height=650,resizable,menubar=0,left=100"); // open instructor summary in a new popup window
		}			

		function xxxcloseWin(){ // called by CLOSE button
			alert("In closeWin");// debug alert
			window.close(); //close popup summary window
		}
