/**********************************************************************************************************************************
** Browser
**********************************************************************************************************************************/
/**********************************************************************************************************************************
** Global Variables
**********************************************************************************************************************************/
var episode = new Episode()
var skin = new Skin()

/**********************************************************************************************************************************
** Episode                      
**********************************************************************************************************************************/
// Episode Data
function Episode () {
  this.filename = "";
  this.name = "";
  this.organizer = "";
  this.type = "";
  this.startTime = "";
  this.location = "";
  this.description  = "";
// Episode Media Data
  this.aMediaData = new Array();
// Episode TOC
  this.aTOC = new Array();
// Episode Resources
  this.aResources = new Array();
// Episode Events
  this.aEvents = new Array();
// Episode Languages
  this.aLanguages = new Array();
// Last Episode Events
  this.aLastEvents = new Array();
}

Episode.prototype.addMediaData = function (oEpisodeMediaData) {
  this.aMediaData.push(oEpisodeMediaData);
};

Episode.prototype.addTOC = function (oEpisodeTOC) {
  this.aTOC.push(oEpisodeTOC);
};

Episode.prototype.addResource = function (oEpisodeResource) {
  this.aResources.push(oEpisodeResource);
};

Episode.prototype.addEvent = function (oEpisodeEvent) {
  this.aEvents.push(oEpisodeEvent);
};

Episode.prototype.addLanguage = function (oEpisodeLanguage) {
  this.aLanguages.push(oEpisodeLanguage);
};

Episode.prototype.addLastEvent = function (oEpisodeEvent) {
  this.aLastEvents.push(oEpisodeEvent);
};



//
// Episode TOC Object
//
function oEpisodeMediaData(profile_id, language_code, language_name, format_code, bitrate, media_version, media_protocol, media_extension, uri_download) {
  this.profile_id       = profile_id;
  this.language_code    = language_code;
  this.language_name    = language_name;
  this.format_code      = format_code;   
  this.bitrate          = bitrate;   
  this.media_version    = media_version;  
  this.media_protocol   = media_protocol; 
  this.media_extension  = media_extension;
  this.uri_download     = uri_download;   
}

//
// Episode TOC Object
//
function oEpisodeTOC(timecode, text) {
  this.timecode = timecode;
  this.text = text;
}

//
// Episode Resource Object
//
function oEpisodeResource(MimeType, URL, name) {
  this.name = name;
  this.URL = URL;
  this.MimeType = MimeType;
}

//
// Episode Event Object
//
function oEpisodeEvent(timecode, type, parameters) {
  this.timecode = timecode;
  this.type = type;
  this.parameters = parameters;
}

//
// Episode TOC Object
//
function oEpisodeLanguage(language_code, language_name) {
  this.language_code    = language_code;
  this.language_name    = language_name;
}

/**********************************************************************************************************************************
** Skin                      
**********************************************************************************************************************************/

function Skin() {
  this.title = "";
  this.backgroundImage = "";
  this.backgroundColor = "";
  this.width = 1024;
  this.height = 738;
  this.styleTOC = "ComboBox"; // ComboBox, ListBox
  this.styleResources = "CommaSeparated"; // CommaSeparated, Table
  this.styleLanguages = "Buttons"; // Buttons, ComboBox
  this.mediaPlayerAutoStart = true;
  this.aContainers = new Array();
  this.aContents = new Array();
  this.emailFrom = "";
  this.emailTo = "";
  this.emailSubject = "";
}

Skin.prototype.addContainer = function (oSkinContainer) {
  this.aContainers.push(oSkinContainer);
};

Skin.prototype.addContent = function (oSkinContent) {
  this.aContents.push(oSkinContent);
};


//
// Skin Container Object
//
function oSkinContainer(id, type, ObjectHREF, ObjectSource) {
  this.id = id;
  this.type = type;
  this.ObjectHREF = ObjectHREF;
  this.ObjectSource = ObjectSource;
}
//
// Skin Content Object
//
function oSkinContent(type, title, ObjectSource, url, focused) {
  this.type = type;
  this.title = title;
  this.ObjectSource = ObjectSource;
  this.url = url;
  if (focused == null) {
    focused = false;
  }
  this.focused = focused;  
}

function findContentElement(contentElementType) {
  for (j=0; j < skin.aContents.length; j++) {
  	if (skin.aContents[j].type = contentElementType) return skin.aContents[j];
  }
  return null;
}

