function el(s) {
	return document.getElementById(s);
}

function popup(url) {
	window.open(url,'popupwindow');
}

function navNext() {
	if (currentPage < totalPages) {
		exitFlag = false;
		if (scormEnabled) doLMSCommit();
		eval("document.location.href = 'page" + (currentPage + 1) + ".html';");
	}
	else {
		finishSCO();
	}
}


function navBack() {
	exitFlag = false;

	if (currentPage > 1) {
		if (scormEnabled) doLMSCommit();
		eval("document.location.href = 'page" + (currentPage - 1) + ".html';");
	}
}


function navJump() {
	exitFlag = false;

	var answer = parseInt(window.prompt("To which page would you like to jump?", ""));

	if (answer > 0 && answer <= totalPages) {
		if (scormEnabled) doLMSCommit();
		eval("document.location.href = 'page" + answer + ".html';");
	}
}


function doJumpPage(page) {
	if (page != null) {
		page = parseInt(page);

		if (page <= totalPages && page > 0) {
			if (scormEnabled) doLMSCommit();
			eval("document.location.href = 'page" + page + ".html';");
			return true;
		}
	}

	return false;
}


function navSound() {
	audioSetting = audioSetting == "1" ? "0" : "1";

	scoToggleSound(audioSetting);

	exitFlag = false;
	if (scormEnabled) doLMSCommit();
	eval("document.location.href = 'page" + currentPage + ".html';");
}


function navExit() {
	if (confirm("Are you sure you want to exit?")) {
		finishSCO();
	}
}


function navHelp() {
	openWindow('../../assets/ug/start.html', 'ug', 571, 790, 'no');
}


function showGlossary(term) {
	openWindow('glossary.html?#' + term, 'gl', 450, 350, 'yes');
}


function openWindow(loc, winId, winHt, winWd, winScr, winSize) {
	var winLeft = (screen.width  - winWd) / 2;
	var winTop  = (screen.height - winHt) / 2;

	winSize = (winSize) ? "yes" : "no";

	var popWin = window.open(loc, winId, 'toolbar=no,location=no,status=no,resizable=' + winSize + ',scrollbars=' + winScr +',width=' + winWd + ',height=' + winHt + ',left=' + winLeft + ',top=' + winTop);
	popWin.focus();
}


function showerror() {
	if (!showCallout && !animating) {
		if (intType < 6|| intType == 12) {
			for (var i=1; i <= hsLeft.length; i++) {
				showobject("ca" + i);
				setTimeout("hideerror('ca" + i + "');", 2000);
			}
		}
		else if (intType == 10) {
			showobject("ca1");
			showobject("ca1txt");
			setTimeout("showobject('ca2');showobject('ca2txt');", 2000);
			setTimeout("hideerror('ca1');hideerror('ca2');hideerror('ca1');hideerror('ca1txt');hideerror('ca2txt');", 4000);
		}
		else {
			showobject("correctarea");
			setTimeout("hideerror('correctarea');", 2000);
			if (intType == 6) resetText();
		}

		showCallout = true;
	}
}


function hideerror(object) {
	hideobject(object);
	showCallout = false;
}


function showobject(o) {
	if (el(o)) el(o).style.visibility = "visible";
}


function hideobject(o) {
	if (el(o)) el(o).style.visibility = "hidden";
}


function toggleTip() {
	hideobject("tipbox");
	if (tipOpen_m) { toggleTip_m(); }
	if (!tipOpen)  { showobject("tipbox"); }
	if (tipOpen && (validText != "")) { resetText(); }
	tipOpen = !tipOpen;
}


function toggleTip_m() {
	hideobject("tipbox_m");
	if (tipOpen) { toggleTip(); }
	if (!tipOpen_m) { showobject("tipbox_m"); }
	if (tipOpen_m && (validText != "")) { resetText(); }
	tipOpen_m = !tipOpen_m;
}


function cancelKey(evt) {
	if (evt.preventDefault) {
		evt.preventDefault();
		return false;
	}
	else {
		evt.keyCode = 0;
		evt.returnValue = false;
	}
}


function zp(s) {
	return (s < 10) ? "0" + s : s;
}


function showchecks() {
	var e = document.getElementsByTagName("td");

	for (var i=0; i < e.length; i++) {
		if (e[i].className == "check") {
			var img = document.createElement("img");
			img.src = "../../assets/images/check.gif";
			img.alt = "";
			e[i].appendChild(img);
		}
	}
}