// JavaScript Document

//Rivertown Communications custom functions and variables

//Define functions

function setbookmark() {
	//var currpage = document.location.href;
	var currpage = location.href;
	parent.LMSSetValue("cmi.core.lesson_location", currpage);
	if (parent.API!=null) {
		alert("Bookmark was set.");
	} else {
		alert("Bookmark was NOT set.");
	}
}

function gotobkmark() {
	var bmark = parent.LMSGetValue("cmi.core.lesson_location");
	//alert(bmark);
	if (parent.LMSGetValue("cmi.core.lesson_status")=="incomplete") {
		if (bmark!=null && bmark!="") { 
			//document.location.href = bmark;
			location.href = bmark;
		}
	}
}
  
function nextPage(theURL) {
	//document.location.href = theURL;
	location.href = theURL;
}

function OpenSubWin(theFile, theWidth, theHeight, theTop, theLeft) {
	if (theTop<0 || theLeft<0) {
		theTop = 0;
		theLeft = (screen.width/2) - (theWidth/2);
	}
	theWidth = Math.round(theWidth);
	theHeight = Math.round(theHeight);
	theTop = Math.round(theTop);
	theLeft = Math.round(theLeft);
	var winFeatures = "top="+theTop+",left="+theLeft+",width="+theWidth+",height="+theHeight+",scrollbars=yes,resizable=yes";
	var newWin = window.open(theFile, "", winFeatures);
	if (newWin!=null) {
		newWin.focus();
		return 0;
	} else {
		alert("Failed to open " + theFile + ". Please turn off any pop up blockers you might have.");
		return -1;
	}
}

function GoTranscript() {
	var thePath = location.href;
	var thePathArray = thePath.split("/");
	thePath = "";
	for (i=0; i<thePathArray.length-1; i++) {
		thePath = thePath + thePathArray[i] + "/";
	}
	var theFile = thePathArray[i];
	var theFileArray = theFile.split(".");
	theFile = theFileArray[0];
	theFileArray = theFile.split("_");
	theFile = theFileArray[0] + "-AudioTranscript.htm";
	var theWidth = 400;
	var theHeight = 400;
	var theLeft = Math.round((screen.width/2) - (theWidth/2));
	MM_openBrWindow(thePath+theFile,"","scrollbars=yes,resizable=yes,width=400,height=400,left="+theLeft);
}

function LoadAudio(fileName) {
	//alert("LoadAudio("+fileName+")");
	document.getElementById("FlashContent2").style.visibility = "hidden";
	var so2 = new SWFObject(fileName, "myMovie2", "25", "29", "8.0.0");
	so2.addParam("quality", "high");
	so2.addParam("allowScriptAccess", "always");
	so2.write("FlashContent2");
	document.getElementById("FlashContent2").style.visibility = "";
}

function PlayAudio() {
	var thePath = location.href;
	var thePathArray = thePath.split("/");
	thePath = "";
	for (i=0; i<thePathArray.length-1; i++) {
		thePath = thePath + thePathArray[i] + "/";
	}
	var theFile = thePathArray[i];
	var theFileArray = theFile.split(".");
	theFile = theFileArray[0];
	theFileArray = theFile.split("_");
	theFile = theFileArray[0] + ".swf";
	if (theFile == "index.swf") {
		theFile = "01-01.swf";
	}
	var so2 = new SWFObject("Audio/"+theFile, "myMovie2", "25", "29", "8.0.0");
	so2.addParam("quality", "high");
	so2.addParam("allowScriptAccess", "always");
	so2.write("FlashContent2");
}

function RTExit() {
	if (API != null) {
		parent.EndTimer();
		parent.LMSFinish();
		parent.window.close();
	} else {
		window.close();
	}
}


