	//  Handle special cases where we need different code 
	//  for Internet Explorer vs. Netscape navigator 
	var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
	var W3CDOM = parseInt(navigator.appVersion.substring(0,1)) >= 5;
	
	var audioWindow;

	var fileLMS = getURLValue('filelms');
	if ( fileLMS != null)
	{
		//set cookie
		document.cookie = "fileLMS=" + fileLMS + "; path=;";
	}
	else
	{
		//check for it in cookie
		fileLMS = getCookieValue("fileLMS");
	}
	
	if (fileLMS == '1')
		fileLMS = true;
	else
		fileLMS = false;
	
	if (myDisablePrev != "true")
		var myDisablePrev = "false";
		
	if (myDisableNext != "true")
		var myDisableNext = "false";
	
	if (myMediaDone != "true")
		var myMediaDone = "false";
		
	var myEnableAudio = parseInt(getCookieValue("enableaudio","1"));
	var myShowAudio = parseInt(getCookieValue("showaudio","0"));
	
	if (myExtValue == null)
		var myExtValue = 0;
	
	if (myAudioFile == null)
		var myAudioFile = "";
		
	if (myAudioFile == '')
		myShowAudio = 0;
	
	var myEnableAudioStr = "false";
	if (myEnableAudio == 1)
		var myEnableAudioStr = "true";
	
	var myLoadDone = false;
	var origImg = new Image;
	
	function gotopage(myPage,myDirection)
	{
		if (myDisableNext == "true" && myDirection == "next")
			alert("You can not continue at this point. Please try a different option.");
		else
		{
			if (myPage == "start")
			{
				//hit previous on first page
				if (myShowAudio == 1)
					audioWindow.close();
				opener.ExitAU(window.document.location.toString(),"0");
				window.close();
			}
			else
			{
				if (myPage == "done")
				{
					if (myShowAudio == 1)
						audioWindow.close();
					//hit next on last page
					opener.ExitAU(window.document.location.toString(),"1");
					window.close();
				}
				else
				{
					opener.sendBookmark(myPage);
					//go to page within this lesson
					parent.location.href = myPage;
				}
			}
		}
	}
		
	function mouse_ov(objName)
	{
		myImgObj = eval("document." + objName);
		origImg.src = myImgObj.src;
		if (myLoadDone)
		{
			if (((objName == "next") && (myDisableNext == "true")) || ((objName == "previous") && (myDisablePrev == "true")))
			{
				//nothing
			}
			else
			{
				myOvObj = eval(objName + "_ov");
				myImgObj.src = myOvObj.src;
			}
		}
	}
	
	function mouse(objName)
	{
		if (myLoadDone)
		{
			myImgObj = eval("document." + objName);
			myImgObj.src = origImg.src;
		}
	}
	
	function openGlossary() 
		{
	msg=open("../glossary/default.htm","glossaryWin","scrollbars=yes,resizeable=yes,width=450,height=250,toolbar=no,directories=no,menubar=no,status=no,");
		}
	function openPrefs() 
		{
	msg=open("../prefsform.htm","prefWin","scrollbars=no,resizeable=no,width=400,height=250,toolbar=no,directories=no,menubar=no,status=no,");
		}
	function gotoMenu(myDone)
	{			
		if (myShowAudio == 1)
			audioWindow.close();
		opener.ExitAU(window.document.location.toString(),myDone);
		window.close();
	}
	/*
	function gotoNextPage()
	{
		if (myNextPage != "done")
			opener.sendBookmark(myNextPage);
		
		gotoPage(myNextPage,'next');
	}
	*/
	function gotoPrevPage()
	{
		gotoPage(myPrevPage,'previous');
	}
	function rePlay()
		{
			location.reload();
		}
		
	function setNext()
	{

		if (myDisableNext == "true")
			document.next.src = next_de.src;
		else
		{
			if (myMediaDone == "true")
				document.next.src = next_flash.src;
			else
				document.next.src = next_def.src;
		}
		
	}
	
	function runMovie()
	{
		if (myShowAudio == 1)
		{
			audioWindow = window.open(myAudioFile, "audioWindow", "toolbar=no, menubar=no, location=no, height=150, width=400, resizable=no, scrollbars=yes, top=1, left=1");
			audioWindow.focus();
		}
		if (InternetExplorer)
		{
			flashPlayer.style.display = '';
		}
	}
	
		//  Handle all the FSCommand messages in a Flash movie  
	function flashPlayer_DoFSCommand(command, args)
	{ 
		// IE and Navgiator have slightly different document object models 
		// IE treats objects as members of "window" while in Navigator, 
		// embedded objects are members of "window.document" 
		var myPlayer = InternetExplorer ? window.flashPlayer : window.document.flashPlayer;
		//alert(myPlayer.PercentLoaded());
		//alert(command);
		if (command == 'start')
		{
			if (InternetExplorer)
				Loading.style.display = 'none';
			else
				document.Loading.visibility = "hide";
		}

		if (command == 'stop')
		{
			myMediaDone = "true";
			setNext();
		}
		
		if (command == 'glossary')
		{
			if (args == '')
				myTarget = "../glossary/default.htm";
			else
				myTarget = "../glossary/terms/" + args + ".htm";
			
			msg=open(myTarget,"glossaryWin","scrollbars=yes,resizeable=yes, width=450,height=250,toolbar=no,directories=no,menubar=no,status=no,");
		}
		
		if (command == 'gotoPage')
		{
			gotoPage(args,"next");
		}
		if (command == 'gotoNextPage')
		{
			//check to see if this is a review page
			if (getURLValue("curpage",8) != null)
				gotoReviewPage('next');
			else
				gotoNextPage();
		}
		if (command == 'disablenext')
		{
			myDisableNext = "true";
			setNext();
		}
		if (command == 'enablenext')
		{
			myDisableNext = "false";
			setNext();
		}
		if (command == 'reviewpopup')
		{ 
		RevWin=open("review.htm?pages=" + args + "&curpage=1","ReviewWin","scrollbars=no,resizeable=no,width=790,height=525,toolbar=no,directories=no,menubar=no,status=yes,");
		}
		if (command == 'openDlgWin')
		{
			//openDlgWin, args="path,left,top,width,height,scroll,resize,menu"
			//path can be relative or absolute
			//left,top,width and height are numeric
			//width and height can be percentages of screen size (use % at end of each value)
			//scroll,resize and menu are yes/no
		
			//parseString function returns a item from a delimited list
			//parseString(string,delimiter,item number zero based,default return value)
			myPath = parseString(args,",",0);
			myL = parseString(args,",",1);
			myT = parseString(args,",",2);
			myX = parseString(args,",",3);
			myY = parseString(args,",",4);
			myS = parseString(args,",",5);
			myR = parseString(args,",",6);
			myM = parseString(args,",",7);
			
			if (myX.substring(myX.length-1,myX.length) == "%")
				myX = parseInt((myX.substring(0,myX.length-1) / 100) * screen.width);
			if (myY.substring(myY.length-1,myY.length) == "%")
				myY = parseInt((myY.substring(0,myY.length-1) / 100) * screen.height);
				
			openPopUp(myPath,myL,myT,myX,myY,myS,myR,myM);
		}
		
		if (command == 'flashreplay')
		{
			if (args == 'on')
				document.replay.src = replay_flash.src;
			else
				document.replay.src = replay_def.src;
		}
	}
	
//quiz stuff
function showPrompt(answerObj)
{
	myAnsList = getCookieValue("ansList");
	mySearchStr = "," + mypageNum + ",";
	if ((myAnsList == null) || (myAnsList.indexOf(mySearchStr,0) == -1))
	{
		myAnsList = myAnsList + mypageNum + ",";
		
		correctAns = "";
		correctAnsNum = Math.floor(((1 / (myExtValue / 1000000)) / 3) / mypageNum);
		switch (correctAnsNum)
		{
			case 1:
				correctAns = "A";
				break;
			case 2:
				correctAns = "B";
				break;
			case 3:
				correctAns = "C";
				break;
			case 4:
				correctAns = "D";
				break;
		}
		if (correctAns != "")
		{
			correctAnsObj = eval("document.form1." + correctAns);
			correctFeedback = "Correct!";
			inCorrectFeedback = "Incorrect. The correct answer is: '" + correctAnsObj.value + "'";
			if (answerObj.name == correctAns)
			{
				myNumCorrect = parseInt(getCookieValue("correct"));
				myNumCorrect = myNumCorrect + 1;
				//save new correct to cookie
				document.cookie = "correct=" + myNumCorrect + "; path=/;";
				alert(correctFeedback);
			}
			else
				alert (inCorrectFeedback);
	
			//save ansList cookie
			document.cookie = "ansList=" + myAnsList + "; path=/;";
		}
		else
			alert ("Fatal Error! Unable to calculate correct answer.  Please contact your training administrator.");
	}
	else
		alert ("You've already answered this question!");
		
	//navigate to next question
	if (myDoneNum == mypageNum)
	{
		//grade quiz
		myNextPage = "results.htm";
	}
	else
	{
		myNextPage = "page" + convertSCONum(mypageNum+1) + ".htm";
	}
	parent.location.href = myNextPage;
}
	
	function openPopUp(myPage,myL,myT,myX,myY,myS,myR,myM)
	{
		if ((myPage == null) || (myPage == ""))
			alert("Popup URL can not be empty.");
		else
		{
			var myLeft = "0";
			if ((myL != null) && (myL != ""))
				myLeft = myL;
			var myTop = "0";
			if ((myT != null) && (myT != ""))
				myTop = myT;
			var myWidth = "400";
			if ((myX != null) && (myX != ""))
				myWidth = myX;
			var myHeight = "300";
			if ((myY != null) && (myY != ""))
				myHeight = myY;
			var myScroll = "no";
			if ((myS != null) && (myS != ""))
				myScroll = myS;
			var myResize = "yes";
			if ((myR != null) && (myR != ""))
				myResize = myR;
			var myMenu = "no";
			if ((myM != null) && (myM != ""))
				myMenu = myM;
		}
			
		PopUpWin=open(myPage,"PopUpWin","left=" + myLeft + ",top=" + myTop + ",scrollbars=" + myScroll + ",resizable=" + myResize + ",width=" + myWidth + ",height=" + myHeight + ",toolbar=no,directories=no,menubar=" + myMenu + ",status=no,");
	
	}
	
	function parseString(myString,myDelimiter,myItemNum)
	{
		var myPos = -1;
		var myItem;
		for (i = 0; i <= myItemNum; i++)
		{
			myItem = myString;
			myPos = myString.indexOf(myDelimiter);
			if (myPos > -1)
			{
				myItem = myString.substring(0,myPos);
				myString = myString.substring(myPos+1,myString.length);
			}
		}	
		return myItem;
	}
	
	function getCookieValue(myMasterKey,myDefault)
	{
		myCookie = document.cookie;
		while (myCookie.indexOf("=",0) > -1)
		{
			i = myCookie.indexOf(";",0);
			if (i == -1)
				i = myCookie.length;
			myPair = myCookie.substring(0,i);
			j = myPair.indexOf("=",0);
			myKey = myPair.substring(0,j);
			if (myKey.substring(0,1) == " ")
				myKey = myKey.substring(1,(myKey.length));
			myValue = myPair.substring(j+1,(myPair.length));
			myCookie = myCookie.substring(i+1,(myCookie.length));
			if (myKey == myMasterKey)
			{
				return myValue;
			}
		}
		return myDefault;
	}
	
	function getSubCookieValue(myMasterKey,myCookie,myDefault)
	{
		while (myCookie.indexOf("|",0) > -1)
		{
			i = myCookie.indexOf("&",0);
			if (i == -1)
				i = myCookie.length;
			myPair = myCookie.substring(0,i);
			j = myPair.indexOf("|",0);
			myKey = myPair.substring(0,j);
			if (myKey.substring(0,1) == " ")
				myKey = myKey.substring(1,(myKey.length));
			myValue = myPair.substring(j+1,(myPair.length));
			myCookie = myCookie.substring(i+1,(myCookie.length));
			if (myKey == myMasterKey)
			{
				return myValue;
			}
		}
		return myDefault;
	}
	
	function getURLValue(myKey)
	{
		var myURLPos = -1;
		var myStr = null;
		var myTemp = window.document.location;
		var myURL = myTemp.toString();
		var myOffset = myKey.length + 1;
	
		if (myURL.indexOf('?') > -1)
		{
			//get page
			myURLPos = myURL.indexOf(myKey);
			if (myURLPos > -1)
			{
				myStr = myURL.substring(myURLPos+myOffset,myURL.length);
				if (myStr.indexOf('&') > 0)
					myStr=myStr.substring(0,myStr.indexOf('&'));
			}	
		}
		return myStr
	}
	
	function runError(myError, myArg)
	{
		if (myError == "login")
		{
			alert("Login Invalid! Please try again.");
			document.f.password.value='';
		}
		if (myError == "access")
		{
			alert("You have not logged into the training.  Please do so.");
			if (myArg == "close")
				window.close();
			else
				location.href = myArg + "login.htm";
		}
		if (myError == "empty")
		{
			alert("You must supply " + myArg + ".");
		}
		if (myError == "passwords")
		{
			alert("Your passwords do not match, try again.");
		}
		if (myError == "dupUser")
		{
			alert("There is already an user with this username.  Please select another username.");
			document.f.username.value = '';
		}
		if (myError == "lms")
		{
			alert("There has been an error with the LMS system.  Student Tracking is not working correctly.");
		}
			
	}

	//var cHi = 90;  //  ASCII 'z';
	//var cLow = 65;  // ASCII ' ';
	
	function generateKey()
	{
	    var i 
	    var pszK = "";
	    for (i = 0; i <= 80; i++) 
		{
			pszK = pszK + String.fromCharCode(48 + i);
			pszK = pszK + String.fromCharCode(122 - i);
			i = i + 5;
		}
	    return pszK
	}
	
	

	function encrypt(sStrIn,sKey,cHi,cLow)
	{    
	    var iLen 
		var i
	    var iChar 
	    var iLastChar 
	    var iLocation 
	    var sEncryptedStr = "";
		var cDelta = cHi - cLow + 1;
		
	    iLen = sStrIn.length;
	    //sKey = GenerateKey();
		//sKey = myUsername + "KARTAUSER" + myProgID;
	    iLastChar = sKey.charCodeAt(0);
	    iLocation = 0;
	    
	    for (i = 0; i < iLen; i++)
		{
	        iChar = sStrIn.charCodeAt(i);
	        iChar = iLastChar + iChar + sKey.charCodeAt((i % 40) + 1);
	        while (iChar > cHi)
			{
	            iChar = iChar - cDelta;
			}

	        
	        iLastChar = sStrIn.charCodeAt(iLocation);
	        iLocation = iLocation + 1;
	        sEncryptedStr = sEncryptedStr + String.fromCharCode(iChar);
	    }

	    
	    return sEncryptedStr
		
	}
	
	
	function decrypt(sEncryptedStr,sKey,cHi,cLow)
	{
	    var iLen 
		var i 
	    var iChar
	    var iLastChar
	    var sStrIn 
	    var sStrOut
	    var iLocation 
	    var sStr = "";
	    var cDelta = cHi - cLow + 1;
		
		//sKey = GenerateKey();
		//sKey = myUsername + "KARTAUSER" + myProgID;
	    iLen = sEncryptedStr.length;
	    sStrIn = sEncryptedStr;
	    iLastChar = sKey.charCodeAt(0);
	    iLocation = 0;
	    
	    for (i = 0; i < iLen; i++)
		{
	        iChar = sStrIn.charCodeAt(i);
	        iChar = iChar - iLastChar - sKey.charCodeAt((i % 40) + 1);
	        while (iChar < cLow)
			{
	            iChar = iChar + cDelta;
	        }
	        iLastChar = iChar;
	        iLocation = iLocation + 1;
	        sStr = sStr + String.fromCharCode(iChar);
	   	}
	    
	    return sStr
	}
	
	function convertSCONum(myNum)
	{
		var myNumStr = myNum.toString();
		if (myNumStr.length == 1)
			myNumStr = "00" + myNumStr;
		if (myNumStr.length == 2)
			myNumStr = "0" + myNumStr;
		return myNumStr;
	}
	

