/*
Program:
Husky Mounted Detection System (HMDS)

Source:
EOIR Technologies
PO Box 1240
Spotsylvania, VA  22553

HMDS Development Team
USA CECOM Night Vision and Electronic Sensors Directorate (NVESD)
10221 Burbeck Rd., STE 430
Fort Belvoir, VA 22060

Conditions for Use:
This software is Copyright(C) EOIR Technologies, Inc.

EOIR Technologies has all commercial interest and rights.
NVESD has full rights, title, and interest.

This software is provided "as is", without warranty by 
EOIR Technologies, Inc and NVESD. In no event shall EOIR 
Technologies, Inc. or NVESD be liable for any loss or for
any indirect, special, punitive, exemplary, incidental, or 
consequential damages arising from the use, possession, or
performance of this software.
*/

// Relies on Sarissa


var EOIR = EOIR ? EOIR : function ()
{
	var obj =
	{
	};

	return obj;

}();

EOIR.SCORM = function ()
{
	var loaded = false;
	var startTime;

	var obj =
	{
		initialize: function()
		{
			var result = doInitialize();
			if(result == "true")
			{
				loaded = true;
				startTime = new Date();
				if(!EOIR.SCORM.isBrowsing())
				{
					var strCompletionStatus = EOIR.SCORM.getValue("cmi.completion_status");
					if(strCompletionStatus == "not attempted" || strCompletionStatus == "unknown")
					{
						err = EOIR.SCORM.setValue("cmi.completion_status", "incomplete")
					}
				}
			}
			return result;
		},

		terminate: function()
		{
			if(loaded)
			{
				EOIR.SCORM.setValue("cmi.exit", "suspend");
				EOIR.SCORM.setValue("adl.nav.request", "suspendAll");
				EOIR.SCORM.commit();
				if(!doTerminate())
				{
					// Handle error.
				}
				loaded = false;
			}
		},

		commit: function()
		{
			return doCommit();
		},

		isBrowsing: function()
		{
			var strMode = EOIR.SCORM.getValue("cmi.mode");
			return (strMode == "browse") || (strMode == "review");
		},

		getValue: function(name)
		{
			return doGetValue(name);
		},

		setValue: function(name, val)
		{
			return doSetValue(name, val);
		},

		markCompleted: function()
		{
			return EOIR.SCORM.setValue("cmi.completion_status", "completed");
		}
	};

	return obj;
}();

