/*
	ICUS_SCORM_API_SA_plugin.js

	For ICUS SCORM to StandAlone wrapper 
	10/12/2004 - Created by DineshS Based on Timothee's AICC Wrapper
	(c) 2004 - ICUS Pte Ltd
	
	Overrides LMSInitialize action to get the serialized data from cookie and deSerialize it.
	Overrides LMSFinish and LMSCommit action to get the serialised data and pass it to the wrapper to store it in cookie.

	Requires ICUS_SCORM_API.js
*/


o = SCORMAPI.prototype;

/* =============================================
	Store reference to existing function
============================================= */
o.$_SA_LMSInitialize = o.LMSInitialize;
o.$_SA_LMSCommit = o.LMSCommit;

/* =============================================
	Overwrite API method
============================================= */
o.LMSInitialize = function(arg) {
	var result = this.$_SA_LMSInitialize(arg);
	if (result == "false") return result;
	this.deserialize(this.$container.readLMSCookie());
	/*
	//
	*/
	var str = "";
	if (launch_data != null)
	{
		for(var i in launch_data)
		{
			str += "\n" + i + "=" + launch_data[i];
		}
		this.LMSSetValue("cmi.launch_data",str,true)
	}
	return result;
}

o.LMSCommit = function(arg) {
	var result = this.$_SA_LMSCommit(arg);
	if (result == "false") return result;
	this.$container.writeLMSCookie(this.serialize());
	return result;
}



/* =============================================
	Clean up used variables
============================================= */

delete o;

