function DisplayType(contentUserInterface,pageArray)  {
  var lang = "en"; //defaults to en
  var is508 = false;
  var numPages = pageArray.length;
  var userInterfaces = new Array();
  var description = "";
  var pThis = this;
  userInterfaces[0] = contentUserInterface;
  this.userInterface = contentUserInterface;
  this.glossary = new Glossary();
  this.assessment = new Assessment();
  this.branches = new Array();
  this.branchMenuPage = null;
  this.currentBranch = "main";

  if (pageArray != null)  {
    setBranches();
  }

  this.getPages = function()  {
    return pageArray;
  }
  this.getBranchPages = function()  {
    return this.branches[this.currentBranch];
  }
  this.setPages = function(pa)  {
    pageArray = pa;
    setBranches();
  }
  this.getBranchPages = function(branchName) {
    if (this.branches[branchName] != null)  {
      if (this.branches[branchName].length > 0) {
        return this.branches[branchName];
      }
    }
    return null;
  }
  /*
  //not used
  this.setPage = function(p,index) {
    var oldPage = pageArray[index];
    pageArray[index] = p;
    replacePageInBranch(oldPage,p);
  }
  */
  this.addUserInterface = function(userInterface)  {
    userInterfaces[userInterfaces.length] = userInterface;
  }
  this.addUserInterfaces = function(uiArray)  {
    for (i=0;i<uiArray.length;i++)  {
      userInterfaces[userInterfaces.length] = uiArray[i];
    }
  }
  this.getUserInterface = function(name) {
    var uis = userInterfaces;
    for (i=0;i<uis.length;i++)  {
      if (uis[i].name == name)  {
        return uis[i];
      }
    }
    return null;
  }
  this.getUserInterfacePath = function(name) {
    var ui = this.getUserInterface(name);
    if (ui != null) {
      return ui.getPath(lang);
    }
    return null;
  }
  this.setUserInterface = function(userInterface) {
    this.userInterface = userInterface;
  }
  this.loadUserInterfaces = function()  {
    for (u=0;u<userInterfaces.length;u++) {
      this.loadUserInterface(userInterfaces[u]);
    }
  }
  this.loadUserInterface = function(userInterface) {
    var imageFolder = cwsObj.imagePath + lang + "/";
    for (i=0;i<userInterface.images.length;i++) {
      var image = userInterface.images[i];
      var fileName = image.getFileName();
      if (fileName != "") {
        var extension = image.getExtension();
        if (image.hasOn) {
          image.setOnSrc(imageFolder + fileName + "_on." + extension);
          image.setOnOverSrc(imageFolder + fileName + "_on_ov." + extension);
          fileName += "_off";
        }
        image.setDefaultSrc(imageFolder + fileName + "." + extension);
        if (image.hasOver) {
          image.setOverSrc(imageFolder + fileName + "_ov." + extension);
        }
        if (image.hasDisabled) {
          image.setDisabledSrc(imageFolder + fileName + "_de." + extension);
        }
        if (image.hasFlash) {
          image.setFlashSrc(imageFolder + fileName + "_flash." + extension);
        }
      }
    }
  }
  this.setDescription = function(pDescription) {
    description = pDescription;
  }
  this.getDescription = function()  {
    return description;
  }
  /*
  this.getTopHtml = function()  {
    return this.userInterface.topHtml;
  }
  this.getBottomHtml = function()  {
    return this.userInterface.bottomHtml;
  }
  */
  this.setLang = function(l)  {
    lang = l;
    this.loadUserInterfaces();
  }
  this.getLang = function() {
    return lang;
  }
  this.set508 = function(bool)  {
    is508 = bool;
  }
  this.get508 = function()  {
    return is508;
  }
  /*
  this.getPageArray = function() {
    return this.branches[this.currentBranch];
    //return pageArray;
  }
  */
  this.getPage = function(pageNumber)  {
    pArray = pageArray;
    if ((pArray.length > 0) && (pageNumber <= pArray.length)) {
      return pArray[pageNumber-1];
    }
    return null;
  }
  this.getNumPages = function() {
    return pageArray.length;
  }
  this.getBranchPage = function(branchPageNumber) {
    pArray = this.branches[this.currentBranch];
    if ((pArray.length > 0) && (branchPageNumber <= pArray.length)) {
      return pArray[branchPageNumber-1];
    }
    return null;
  }
  this.getBranchNumPages = function() {
    return this.branches[this.currentBranch].length;
  }
  this.generateSelectDisplayTypeHtml = function() {

  }
  function setBranches()  {
    var b = new Array();
    for (var pIndex in pageArray)  {
      var p = pageArray[pIndex];
      var branchName = p.branchName;
      if (b[branchName] == null) {
        b[branchName] = new Array();
      }
      var index = b[branchName].length;
      p.branchPageNumber = index + 1;
      b[branchName][index] = p;
      if (p.branchMenu) {
        pThis.branchMenuPage = p;
      }
    }
    pThis.branches = b;
  }
  this.loadUserInterfaces();
  //this.loadUserInterface(this.userInterface);
}

function displayTypeUserInterface(name,userInterface,width,height)  {
  this.userInterface = userInterface;
  this.name = name;
  this.width = width;
  this.height = height;
  this.bkcolor = "#FFFFFF";
  this.path = "";

  this.getPath = function(lang) {
    if (path != "") {
      return eval(path);
    }
    else  {
      return path;
    }
  }
}

function Page(pageId) {
  this.pageId = pageId;
  this.pageNumber = 0;
  this.branchPageNumber = 0;
  this.description = "";
  this.pageType = HTML_PAGE_TYPE;
  this.hasAudio = false;
  this.flashNext = true;
  this.singleContentSwf = null;
  this.inAssessment = false;
  this.question = null;
  this.branchName = "main";
  this.branchMenu = false;
  this.enableNext = true;
  this.enablePrevious = true;
  this.enablePlayPause = true;
  this.flashNext = false;
  this.stopFlashMovieOnLoad = true;

  var defaultAudioType = FLASH_AUDIO_TYPE;
  var pageAudioClip = null;

  var audioClips = new Array();

  this.setFlashNext = function(b) {
    this.flashNext = b;
  }
  this.hasAudioClips = function() {
    if (audioClips.length > 0) {
      return true;
    }
    else  {
      return false;
    }
  }
  this.setPageType = function(pageType) {
    this.pageType = pageType;
  }
  this.getPageType = function() {
    return this.pageType;
  }
  this.setAudioType = function(type) {
    if (type.value > -1)  {
      if (pageAudioClip == null) {
        pageAudioClip = new AudioClip(this.pageId,type);
      }
      else  {
        pageAudioClip.audioType = type;
      }
    }
    else  {
      pageAudioClip.audioType = type;
    }
  }
  this.getAudioType = function() {
    if (pageAudioClip != null) {
      return pageAudioClip.audioType;
    }
    return null;
  }
  this.addAudioClip = function(clipName,audioType)  {
    audioClips[audioClips.length] = new AudioClip(clipName,audioType);
  }
  this.addAudioClips = function(clipArray)  {
    for (i=0;i<clipArray.length;i++)  {
      audioClips[audioClips.length] = clipArray[i];
    }
  }
  this.setAudioClip = function(index,clipName,audioType)  {
    audioClips[index] = new AudioClip(clipName,audioType);
  }
  this.getAudioClip = function(index) {
    if (index < audioClips.length)  {
      return audioClips[index];
    }
    return null;
  }
  this.getAudioClips = function() {
    return audioClips;
  }
  this.getPageAudioClip = function()  {
    return pageAudioClip;
  }
  this.setPageAudioClip = function(clipName,audioType)  {
    pageAudioClip = new AudioClip(clipName,audioType);
    this.hasAudio = true;
  }
  this.getPageUrl = function() {
    if (this.pageType == FLASH_PAGE_TYPE)  {
      return FLASH_CONTENT_URL;
    }
    if (this.pageType == HTML_PAGE_TYPE) {
      return this.pageId + ".htm";
    }
    return null;
  }
}

Page.createPages = function(numPages,pagePrefix,defaultPageType,defaultAudioType) {
  var pageArray = new Array();
  for (i=0;i<numPages;i++)  {
    var pageId = pagePrefix + CwsUtil.padZeros(i+1,3);
    var page = new Page(pageId);
    page.pageNumber = i+1;
    if (defaultPageType > -1) {
      page.setPageType(defaultPageType);
    }
    page.setAudioType(FLASH_AUDIO_TYPE);
    if (typeof defaultAudioType != "undefined") {
      if (defaultAudioType.value > -1)  {
        page.setAudioType(defaultAudioType);
        page.hasAudio = true;
      }
    }
    pageArray[i] = page;
  }
  return pageArray;
}

Page.setPageType = function(pageArray,pageIndex,pageType,audioType) {
  pageArray[pageIndex].setPageType(pageType);
  if (audioType > -1)  {
    pageArray[pageIndex].setAudioType(audioType);
  }
  return pageArray;
}

Page.createPage = function(pageId,pageType,audioType)  {
  var page = new Page(pageId);
  if (pageType > -1) {
    page.setPageType(pageType);
  }
  page.setAudioType(FLASH_AUDIO_TYPE);
  if (typeof audioType != "undefined") {
    if (audioType.value > -1)  {
      page.setAudioType(audioType);
      page.hasAudio = true;
    }
  }
  return page;
}

function AudioClip(fileName,audioType) {
  this.audioType = audioType;
  this.fileName = fileName;
}


