/////////////
// OBJECTS //
/////////////
  var lm;


  function learningMethod(lmGUID, styleSheetGUID, methodPicsGUID, stream, streamYear,
                          name, label, brand, licenseText, introText, methodLink) {
    this.lmGUID          = lmGUID;
    this.styleSheetGUID  = styleSheetGUID;
    this.methodPicsGUID  = methodPicsGUID;
    this.stream          = stream;
    this.streamYear      = streamYear;
    this.name            = name;
    this.label           = label;
    this.brand           = brand;
    this.licenseText     = licenseText;
    this.introText       = introText;
    this.methodLink      = methodLink;

    this.references      = [];
    this.teacherRef      = '';
    this.studentRef      = '';

    this.groups          = [];
    this.groupsByGUID    = [];
    return this;
  }


  learningMethod.prototype.addReference = function(altText, referenceGUID) {
    var ref = new reference(altText, referenceGUID);
    this.references[this.references.length] = ref;
  }


  function reference(altText, referenceGUID) {
    this.altText       = altText;
    this.referenceGUID = referenceGUID;
    return this;
  }


  learningMethod.prototype.addTeacherRef = function(altText, referenceGUID) {
    var ref         = new reference(altText, referenceGUID);
    this.teacherRef = ref;
  }


  learningMethod.prototype.addStudentRef = function(altText, referenceGUID) {
    var ref         = new reference(altText, referenceGUID);
    this.studentRef = ref;
  }


  learningMethod.prototype.addGroup = function(groupGUID, groupType, menuTitle, title,
                                               sequence, infoBox) {
    var gr = new group(groupGUID, groupType, menuTitle, title, sequence, infoBox);
    this.groups[this.groups.length] = gr;
    this.groupsByGUID[groupGUID]    = gr;
  }


  function group(groupGUID, groupType, menuTitle, title, sequence, infoBox) {
    this.groupGUID           = groupGUID;
    this.groupType           = groupType;
    this.menuTitle           = menuTitle;
    this.title               = title;
    this.dirName             = makeFScompatible(title) + '.' + groupGUID.replace(/\-/g,'');
    this.sequence            = sequence;
    this.infoBox             = infoBox;
    this.learningUnits       = [];
    this.learningUnitsByGUID = [];
    return this;
  }


  group.prototype.addLearningUnit = function(luGUID, subGroupTitle, subGroupParagraphTitle,
                                             subGroupSequence, sequence, title, code,
                                             testType, maxTime,
                                             finishBox, bgImageGUID, navigationMode, copyright, description,
                                             introText) {
    var lu = new learningUnit(luGUID, subGroupTitle, subGroupParagraphTitle,
                              subGroupSequence, sequence, title, code,
                              testType, maxTime, finishBox, bgImageGUID, navigationMode, copyright, description ,
                              introText);
    this.learningUnits[this.learningUnits.length] = lu;
    this.learningUnitsByGUID[luGUID]              = lu;
  }


  function learningUnit(luGUID, subGroupTitle, subGroupParagraphTitle, subGroupSequence,
                        sequence, title, code, testType, maxTime,
                        finishBox, bgImageGUID, navigationMode, copyright, description,
                        introText) {
    this.luGUID                 = luGUID;
    this.subGroupTitle          = subGroupTitle;
    this.subGroupParagraphTitle = subGroupParagraphTitle;
    this.subGroupSequence       = subGroupSequence;
    this.sequence               = sequence;
    this.title                  = title;
    this.dirName                = makeFScompatible(title) + '.' + luGUID.replace(/\-/g,'');
    this.code                   = code;
    this.testType               = testType;          // 0 = NO TEST, 1 = PREPARATION (TIMER UP), 2 = DIAGNOSTIC (TIMER DOWN), 3 = NO TEST WITH SCORE PAGE
    this.maxTime                = maxTime;
    this.finishBox              = finishBox;
    this.bgImageGUID            = bgImageGUID;

    this.navigationMode         = navigationMode;    // 0 = FREE, 1 = LINEAR, 2 = HEURISTIC
    this.screens                = [];
    this.screensByGUID          = [];

    this.copyright              = copyright;
    this.description            = description;
    this.introText              = introText;

    this.status                 = C_LU_NOT_RUNNING;
    this.timeSpent              = 0;                 // TIME SPENT IN SECONDS
    return this;
  }
