/////////////////////////////////////////////////////////////////
//////
//////	GLOBAL SCRIPTS
//////
/////////////////////////////////////////////////////////////////



//------------LMS SCRIPTS ------\\

	var IngConn;
	if (window.parent.aiccConnect != null)
		IngConn = window.parent.aiccConnect();
			 
	function SendAICCComplete(quiz_score){
		if (IngConn) {
			//alert("Begin Send Data");
			IngConn.status = "c"
			IngConn.score = quiz_score;
			IngConn.sendData(1);
			//alert("Data Sent");
		}
	}

	function SendAICCNotComplete(quiz_score){
		if (IngConn) {
			//alert("Begin Send Data");
			IngConn.status = "f"
			IngConn.score = quiz_score;
			IngConn.sendData(1);
			//alert("Data Sent");
		}
	} 
	         
	function SendAICCLessonData(){
		if (IngConn) {
			//alert("Begin Send Data");
			IngConn.sendData(2);
			//alert("Data Sent");
		}
	}
	
	//---------- INIT ----------\\
	function init() {
		//alert("initialize");
		if (IngConn) {
		 //alert("object exists");
			//IngConn.getData();
			if (IngConn.status != "c") {
				//alert("Begin Send Data");
				IngConn.status = "i";
				IngConn.sendData(1);
				//alert("Data Sent");
			}
		}
	}

	//---------- lesson duration ----------\\
	function setLessonDuration(lessonDuration) {
		//alert("setLessonDuration");
		IngConn.duration = lessonDuration;
	}
		
	//---------- corelesson data ----------\\
	function setCoreLessonData(questionsData) {
		//alert("setCoreLessonData");
		rExp  = /\"\"/gi;
		questionsData = questionsData.replace(rExp, "\"");
		
		IngConn.coreLesson = '   \"date\", \"time\", \"interaction_id\", \"objective_id\", \"type_interaction\", \"correct_response\", \"student_response\", \"result\", \"weighting\", \"latency\"';
		IngConn.coreLesson = IngConn.coreLesson + questionsData;
	}
	
//---------- EXIT ----------\\
function exit()
{
	if (confirm("Are you sure you want to exit the course?")) {
		if (window.parent.aiccConnect != null) {
			if (confirm("If you have completed this course click OK to register your completion.  If you plan to complete the course at a later date click Cancel.")) {
	
				var IngConn;
					IngConn = window.parent.aiccConnect();
					IngConn.status = "c";
					IngConn.score = "100";
					IngConn.sendData();
					alert("Your learning experience is being updated. \n Please wait until your browser closes automatically");
					setTimeout("window.parent.close()",5000);
			} else {
				window.parent.close();
			}
		} else {
			window.parent.close();
		}
	}
}

