// ver 5.2
// EJF 05/25/04

/******************************************************************************************
**
** THE FOLLOWING SET OF FUNCTIONS ARE USED TO CREATE THE MANDATORY SCORM CMI OBJECT COLLECTION
**
** The result is an CMI object that conforms to SCORM 1.2 RTE1 Mandatory level
**
******************************************************************************************/


/******************************************************************************************
** Create CMI object, and init values
******************************************************************************************/
var cmi 			= new collection('core,suspend_data');
cmi.suspend_data			= ''			/* read-write */

cmi.core 			= new collection('student_id,student_name,output_file,lesson_location,credit,lesson_mode,lesson_status,path,score,time');
cmi.core.student_id 		= ''			/* read-only  */
cmi.core.student_name 		= ''			/* read-only  */
cmi.core.lesson_location 	= ''			/* read-write */
cmi.core.credit 			= ''			/* read-only  */
cmi.core.lesson_status 		= ''			/* read-write */
cmi.core.entry				= ''			/* read-only  */

cmi.core.score		= new collection('raw','min','max');
cmi.core.score.raw			= ''			/* read-write */
cmi.core.score.min			= ''			/* read-write */
cmi.core.score.max			= ''			/* read-write */
cmi.core.total_time			= '00:00:00'	/* read-only  */
cmi.core.lesson_mode 		= ''			/* read-only  */
cmi.core.exit				= ''			/* write-only */
cmi.core.session_time		= '00:00:00'	/* write-only */

/******************************************************************************************
**
** Function: addItem()
** Inputs:	newItem
** Return:	None
**
** Description:
**  Called from the "collection" function, this function adds a new item to the collection
**
******************************************************************************************/
function addItem(newItem)
{
    this.length += 1;  					// Increment the length of the array.
    this[(this.length-1)] = newItem;  	// Add the new item, maintaining item numbering.
}

/******************************************************************************************
**
** Function: collection()
** Inputs:	string
** Return:	None
**
** Description:
**  Creates a collection of new elements as an object.
**  Each collection supports the "addItem" method and a length property.
**
**	  list - Comma delimited string
**
******************************************************************************************/
function collection(list) // Define a sibling object collection.
{
	this.length = 0;  		// Number of properties in the object, not including this one.
	this.addItem = addItem;   	// Include the addItem function as a method.
	var newarray=list.split(/,/i);
	for(var i=0; i < newarray.length; i++)
	{
		this.addItem(newarray[i])
	}
}

