var contentFrame = false;

//Get query params from the main frameset to set into the footer swf
var myQuery = "";
var query = parent.location.search.substring(1);
var pairs = new Array();
if(query.indexOf("&") != -1){
	pairs = query.split("&");
} else {
	pairs[0] = query;
}
for(var i = 0; i < pairs.length; i++){
	myQuery += "&" + pairs[i];
}

if (navigator.appName.indexOf('Netscape') != -1) {
	browser = "ns";
	myQuery += "&browser=ns";
} else {
	browser = "ie";
	myQuery += "&browser=ie";
}
 
//Construct the footer's object/embed tag
var tag = "";
tag += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="$protocol//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="792" height="56" id="footer">';
tag += '<param name="movie" value="../flash/Footer.swf?configservice=${config}' + myQuery + '">';
tag += '<param name="quality" value="high">';
tag += '<embed src="../flash/Footer.swf?configservice=${config}' + myQuery + '" quality="high" pluginspage="$protocol//www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="792" height="56" name="footer"></embed>'
tag += '</object>';
// Replace the protocol to stop browser from warning about non-secure items when loading flash in HTTPS/HTTP
tag = replaceProtocol(tag);

var coursemapWindow;
var optionsWindow;
var glossaryWindow;
var labWindow;
var confirmWindow;
var assArgs;

function doNumberSetting(){
	parent.content.setQuestionNumberValue(assArgs);
}

//Open the confirm window
function openConfirm(message, confirmType){
	confirmWindow = window.open("../templates/confirm.html?message=" + message + "&confirmType=" + confirmType, "confirmWindow", "width=350,height=150");
}
//Close the confirm window
function closeConfirm(){
	if(confirmWindow != null){
		confirmWindow.close();
		confirmWindow = null;
	}
}

//Calls the content pause
function pauseContent(){
	parent.content.pauseContent();
}

//Open the course map
function openCourseMap(){
	coursemapWindow = window.open("coursemap.html", "coursemapWindow", "width=580,height=400,resizable");
}

//Close the course map
function closeCourseMap(){
	if(coursemapWindow != null){
		coursemapWindow.close();
		coursemapWindow = null;
	}
	
}

//Open the course map
function openGlossary(){
	coursemapWindow = window.open("glossary.html", "glossaryWindow", "width=580,height=400,resizable");
}

//Close the course map
function closeGlossary(){
	if(glossaryWindow != null){
		glossaryWindow.close();
		glossaryWindow = null;
	}
	
}

//Show warning for Flash Player 6.0.29
function showFlashPlayerWarning(msg){
	//alert(msg);
}

//Open the options
function openOptions(){
	optionsWindow = window.open("options.html", "optionsWindow", "width=410,height=310");
}
//Close the options
function closeOptions(){
	if(optionsWindow != null){
		optionsWindow.close();
		optionsWindow = null;
	}
}

function closeLab(){
	if(labWindow != null){
		labWindow.close();
		labWindow = null;
	}
}

function logout(){
	parent.window.close();
}




var AICC_TIME = "00:00:00";
var AICC_LOCATION = "";
var AICC_COMPLETION = "";
var AICC_SCORE = "";

function submitAICCStats(location, time, status, score, coreLessonInfo){
	if(document.aiccstats.session_id.value != ""){
	
		if(top.window.opener != null){
			top.window.opener.AICC_TIME = time;
			top.window.opener.AICC_COMPLETION = status;
			top.window.opener.AICC_LOCATION = location;
			top.window.opener.AICC_SCORE = score;
			top.window.opener.AICC_CORE_LESSON_INFO = coreLessonInfo;
		}
	
		var paramString = "[core]\r\ntime=" + time;
		paramString += "\r\nlesson_status=" + status;
		paramString += "\r\nlesson_location=" + location;
		paramString += "\r\nscore=" + score;
		paramString += "\r\n[core_lesson]";
		paramString += coreLessonInfo;
		
		document.aiccstats.AICC_data.value = paramString;
		document.aiccstats.submit();
	}

}

function setAICC_URL(urlStr){
	document.aiccstats.action = urlStr;
	if(top.window.opener != null){
		top.window.opener.AICC_URL = urlStr;
	}
}

function setAICCSessionID(id){
	document.aiccstats.session_id.value = id;
	if(top.window.opener != null){
		top.window.opener.AICC_SESSION_ID = id;
	}
}

function setAICCTime(time){
	AICC_TIME = time;
}

function setAICCLocation(location){
	AICC_LOCATION = location;
}

function setAICCCompletion(completion){
	AICC_COMPLETION = completion;
}

function setAICCScore(score){
	AICC_SCORE = score;
}

function showErrorMessage(errorMsg){
	alert(errorMsg);
}


