function UserInterface(name,width,height)  {
  //setup interface values
  var pnDisObj = null;
  var pageNumberFormat = "";
  var htmlObjs = new Array();
  var ui = this;
  this.images = new Array();
  this.topHtml = "";
  this.bottomHtml = "";
  this.bkcolor = "#FFFFFF";
  this.path = "";
  this.name = name;
  this.width = width;
  this.height = height;
  this.contentTop = 0;
  this.contentLeft = 0;
  this.contentWidth = 0;
  this.contentHeight = 0;
  this.persistentWindow = false;

  this.getTopHtml = function()  {
    var html = eval(this.topHtml);
    return html;
  }
  this.getBottomHtml = function() {
    var html = eval(this.bottomHtml);
    if (htmlObjs.length > 0)  {
      for (h=0;h<htmlObjs.length;h++) {
        html += htmlObjs[h].getHtml();
      }
    }
    return html;
  }
  this.addImage = function(image)  {
    this.images[this.images.length] = image;
  }
  this.getImage = function(name)  {
    for (q=0;q<this.images.length;q++) {
      if (this.images[q].getName() == name)  {
        return this.images[q];
      }
    }
    return null;
  }
  this.addHtmlObj = function(htmlObj) {
    htmlObjs[htmlObjs.length] = htmlObj;
  }
  this.getHtmlObj = function(id)  {
    for (j=0;j<htmlObjs.length;j++) {
      if (id == htmlObjs[j].id) {
        return htmlObjs[j];
      }
    }
    return null;
  }
  this.getHtmlObjs = function() {
    return htmlObjs;
  }
  this.getHtmlObjHtml = function(id,text) {
    for (j=0;j<htmlObjs.length;j++) {
      if (id == htmlObjs[j].id) {
        if ((text != "") && (text != null))  {
          htmlObjs[j].text = text;
        }
        return htmlObjs[j].getHtml();
      }
    }
    return "";
  }
  this.setPageNumberDisplay = function(pageNumberDisplayObj,displayFormat)  {
    pnDisObj = pageNumberDisplayObj;
    pageNumberFormat = displayFormat;
  }
  this.getPageNumberDisplayHtml = function(pageNumber,numPages)  {
    if (pnDisObj != null) {
      pnDisObj.text = eval(pageNumberFormat);
      return pnDisObj.getHtml();
    }
    else  {
      return "";
    }
  }
  this.getPath = function(lang) {
    if (this.path != "") {
      return eval(this.path);
    }
    else  {
      return this.path;
    }
  }
}

function HtmlObj(objType)  {
  this.text = "";
  this.id = "";
  this.name = "";
  this.position = "relative";
  this.top = "";
  this.left = "";
  this.width = "";
  this.height = "";
  this.paddingTop = "0px";
  this.paddingLeft = "0px";
  this.color = "#000000"
  this.fontFamily = "arial";
  this.fontSize = "16px";
  this.fontWeight = "normal";
  this.textAlign = "center";
  this.visibility = "";
  this.cursor = "";
  this.onMouseOver = "";
  this.onMouseOut = "";
  this.useEval = false;
  this.backgroundColor = "";
  this.zIndex = "";
  this.fontStyle = "";

  this.getHtml = function() {
    var html = "<" +  objType;
    if (this.id != "") {
      html += " id=\"" + this.id + "\"";
    }
    if (this.name != "")  {
      html += " name=\"" + this.name + "\"";
    }
    if (this.position != "")  {
      html += " style=\"position:" + this.position + ";";
      if (this.visibility != "")  {
        html += "visibility:" + this.visibility + ";";
      }
      if (this.top != "") {
        html += "top:" + this.top + ";";
      }
      if (this.left != "")  {
        html += "left:" + this.left + ";";
      }
      if (this.width != "") {
        html += "width:" + this.width + ";";
      }
      if (this.height != "") {
        html += "height:" + this.height + ";";
      }
      if (this.paddingTop != "") {
        html += "padding-top:" + this.paddingTop + ";";
      }
      if (this.paddingLeft != "") {
        html += "padding-left:" + this.paddingLeft + ";";
      }
      if (this.color != "") {
        html += "color:" + this.color + ";";
      }
      if (this.backgroundColor != "") {
        html += "background-color:" + this.backgroundColor + ";";
      }
      if (this.fontFamily != "") {
        html += "font-family:" + this.fontFamily + ";";
      }
      if (this.fontSize != "") {
        html += "font-size:" + this.fontSize + ";";
      }
      if (this.fontWeight != "") {
        html += "font-weight:" + this.fontWeight + ";";
      }
      if (this.fontStyle != "") {
        html += "font-style:" + this.fontStyle + ";";
      }
      if (this.textAlign != "") {
        html += "text-align:" + this.textAlign + ";";
      }
      if (this.cursor != "")  {
        html += "cursor:" + this.cursor + ";";
      }
      if (this.zIndex != "")  {
        html += "z-index:" + this.zIndex + ";";
      }
      html += "\"";
    }
    if (this.onMouseOver != "") {
      html += " onmouseover=\"" + this.onMouseOver + "\"";
    }
    if (this.onMouseOut != "") {
      html += " onmouseout=\"" + this.onMouseOut + "\"";
    }
    var text = this.text;
    if (this.useEval) {
      text = eval(text);
    }
    html += ">" + text + "</" + objType + ">";
    return html;
  }
}

function FlashMovie(file) {
  this.file = file;
  this.urlPrefix = "http://";
  this.id = "";
  this.bgColor = "#FFFFFF";
  this.width = 640;
  this.height = 480;
  this.params = "";
  this.version = "6,0,0,0";
  this.totalFramesIndex = 5;
  this.currentFramesIndex = 4;
  this.obj = null;
  this.type = "flash";
  this.menu = false;
  this.autoStart = true;
  this.align = "";
  this.sAlign = "";
  this.scale = "";
  
  this.playUrl = function(url)  {
    this.stop();
    this.file = url;
    this.loadMovie(url);
    this.play();
  }
  this.loadMovie = function(url)  {
    this.obj.LoadMovie(0,url);
  }
  this.stop = function()  {
    if ((this.obj != null) && (this.file != "") && (this.file != null))  {
      this.obj.StopPlay();
    }
  }
  this.play = function()  {
    if ((this.obj != null) && (this.file != "") && (this.file != null))  {
      this.obj.Play();
    }
  }
  this.getCurrentFrame = function() {
    if (this.obj != null) {
      if (typeof(this.obj.CurrentFrame) == "number") {
        return this.obj.CurrentFrame;
      }
      else {
        try {
          return this.obj.CurrentFrame();
        }
        catch (e) {
          return -1;
        }
      }
    }
    return -1
  }
  this.getHtml = function()  {
    var html = "";
    

    if (window.ActiveXObject &&
        (navigator.userAgent.indexOf("MSIE")!= -1) &&
        (navigator.userAgent.indexOf("Windows") != -1)) {
      html += "<OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"" + this.urlPrefix + "download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=" + this.version + "\" ";
    }
    else  {
      html += "<OBJECT data=" + this.file + " type=\"application/x-shockwave-flash\" PLUGINSPAGE=\"" + this.urlPrefix + "www.macromedia.com/go/getflashplayer\" ";
    }
    html += "id=\"" + this.id + "\" name=\"" + this.id + "\" WIDTH=\"" + this.width + "\" HEIGHT=\"" + this.height + "\" ALIGN=\"" + this.align + "\">";
    if ((this.file != "") && (this.file != null)) {
      html += "<PARAM NAME=movie VALUE=\"" + this.file + "\">";
    }
    if (!this.autoStart)  {
      html += "<PARAM NAME=play VALUE=" + this.autoStart + ">";
    }
    if (this.sAlign != "") {
      html += "<PARAM NAME=salign VALUE=\"" + this.sAlign + "\">";
    }
    if (this.scale != "") {
      html += "<PARAM NAME=scale VALUE=\"" + this.scale + "\">";
    }
    html += "<PARAM NAME=menu VALUE=" + this.menu + ">";
    html += "<PARAM NAME=loop VALUE=false>";
    html += "<PARAM NAME=quality VALUE=high>";
    html += "<PARAM NAME=bgcolor VALUE=\"" + this.bgColor + "\">";
    html += "<PARAM NAME=FlashVars VALUE=\"" + this.params + "\">";
    html += "<PARAM NAME=\"swliveconnect\" VALUE=\"true\">";
    html += "</OBJECT>";

    /*
    if (window.ActiveXObject &&
        (navigator.userAgent.indexOf("MSIE")!= -1) &&
        (navigator.userAgent.indexOf("Windows") != -1)) {
      html += "<OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"" + this.urlPrefix + "download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=" + this.version + "\" ";
      html += "id=\"" + this.id + "\" name=\"" + this.id + "\" WIDTH=\"" + this.width + "\" HEIGHT=\"" + this.height + "\" ALIGN=\"" + this.align + "\">";
      if ((this.file != "") && (this.file != null)) {
        html += "<PARAM NAME=movie VALUE=\"" + this.file + "\">";
      }
      if (!this.autoStart)  {
        html += "<PARAM NAME=play VALUE=" + this.autoStart + ">";
      }
      if (this.sAlign != "") {
        html += "<PARAM NAME=salign VALUE=\"" + this.sAlign + "\">";
      }
      if (this.scale != "") {
        html += "<PARAM NAME=scale VALUE=\"" + this.scale + "\">";
      }
      html += "<PARAM NAME=menu VALUE=" + this.menu + ">";
      html += "<PARAM NAME=loop VALUE=false>";
      html += "<PARAM NAME=quality VALUE=high>";
      html += "<PARAM NAME=bgcolor VALUE=\"" + this.bgColor + "\">";
      html += "<PARAM NAME=FlashVars VALUE='" + this.params + "'>";
      html += "</OBJECT>";
    }
    else  {
      html += "<embed  swliveconnect=\"true\" id=\"" + this.id + "\" name=\"" + this.id + "\" align=\"" + this.align + "\" ";
      if ((this.file != "") && (this.file != null)) {
        html += "src=\"" + this.file + "\" ";
      }
      if (!this.autoStart)  {
        html += "play=\"" + this.autoStart + "\" ";
      }
      if (this.sAlign != "") {
        html += "salign=\"" + this.sAlign + "\" ";
      }
      if (this.scale != "") {
        html += "scale=\"" + this.scale + "\" ";
      }
      html += "quality=high bgcolor=\"" + this.bgColor + "\" width=\"" + this.width + "\" height=\"" + this.height + "\" type=\"application/x-shockwave-flash\" ";  
      html += "FlashVars=\"" + this.params + "\" ";
      html += "allowScriptAccess=\"sameDomain\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\">";
      html += "</embed>";
    }
    */
    return html;
  }
}

function WmpAudioClip(file,kloObj) {
  this.file = file;
  this.id = "";
  this.width = 1;
  this.height = 1;
  this.autoStart = true;
  this.urlPrefix = "http://";
  this.classid = "";
  this.version = "";
  this.wmp7 = false;
  this.obj = null;
  this.type = "wmp";
  this.enabled = true;
  this.audioClip = null;
  var minVolume = 0;
  var maxVolume = 0;
  var volumeField = 0;

  var cwsObj = kloObj.getCwsObj();
  var contentWin = kloObj.contentWinObj.win;

  if ( navigator.appName != "Netscape" ){
    this.wmp7 = new ActiveXObject('WMPlayer.OCX');
  }
  //this.wmp7 = false;

  if (this.wmp7)  {
    this.classid = "CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6"; //7 classid
    this.version = "7,0,0,0";
    minVolume = 0;
    maxVolume = 100;
  }
  else  {
    this.classid = "CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"; //6 classid
    this.version = "6,4,5,715";
    minVolume = -3000; //-10000
    maxVolume = 0;
  }

  volumeField = maxVolume - minVolume;

  this.getVolume = function() {
    if (this.obj != null)  {
      if (this.wmp7)  {
        if (cwsObj.runInNewWindow)  {
          return contentWin.wmp7GetVolume(this.obj);
        }
        else  {
          return this.obj.settings.volume;
        }
      }
      else  {
        return getVolumePercent(this.obj.Volume);
      }
    }
    return 0;
  }

  this.setVolume = function(percentVolume) {
    if (this.obj != null)  {
      if (this.wmp7)  {
        if (cwsObj.runInNewWindow)  {
          contentWin.wmp7SetVolume(this.obj,percentVolume);
        }
        else  {
          this.obj.settings.volume = percentVolume;
        }
      }
      else  {
        this.obj.Volume = getVolumeValue(percentVolume);
      }
    }
  }
  
  this.isPlaying = function()  {
    var playing = false;
    var playState = 0;
    if (this.obj != null)  {
      if (this.wmp7)  {
        if (this.getPlayState() == 3) {
          playing = true;
        }
      }
      else  {
        if (this.getPlayState() == 2) {
          playing = true;
        }
      }
    }
    return playing;
  }
  
  this.isDone = function() {
    if (this.obj != null)  {
      //alert(this.getPlayState() + "?" + this.getPlayStateValue("stopped"));
      //alert("isOpen:" + this.isOpen());
      if ((this.getPlayState() == this.getPlayStateValue("stopped")) && (this.isOpen())) {
        return true;
      }
    }
    return false;
  }
  
  this.isOpen = function()  {
    if (this.obj != null)  {
      if (this.getOpenState() == this.getOpenStateValue("mediaOpen"))  {
        return true;
      }
    }
    return false;
  }
  
  this.getPlayStateValue = function(state)  {
    var undef = -1;
    var stopped = 0;
    var playing = 1;
    var paused = 2;
    var waiting = 3;
    var scanForward = 4;
    var scanReverse = 5;
    var skipForward = 6;
    var skipReverse = 7;
    var closed = 8;
    var hasEnded = -1;
    var buffering = -1;
    var transitioning = -1;
    var ready = -1;
    var reconnecting = 11;
    if (this.wmp7)  {
       undef = 0;
       stopped = 1;
       paused = 2;
       playing = 3;
       scanForward = 4;
       scanReverse = 5;
       buffering = 6;
       waiting = 7;
       closed = 8;
       hasEnded = 8;
       transitioning = 9;
       ready = 10;
       reconnecting = 11;
    }
    return eval(state + "");
  }
  
  this.getOpenStateValue = function(state)  {
    var mediaOpen = 6;
    /* wmp 6.4
    0 nsClosed
    1 nsLoadingASX
    2 nsLoadingNSC
    3 nsLocating
    4 nsConnecting
    5 nsOpening 
    6 nsOpen 
    */
    /* wmp 7-10
    0 Undefined 
    1 PlaylistChanging
    2 PlaylistLocating
    3 PlaylistConnecting
    4 PlaylistLoading 
    5 PlaylistOpening
    6 PlaylistOpenNoMedia
    7 PlaylistChanged
    8 MediaChanging
    9 MediaLocating
    10 MediaConnecting
    11 MediaLoading
    12 MediaOpening
    13 MediaOpen
    14 BeginCodecAcquisition
    15 EndCodecAcquisition
    16 BeginLicenseAcquisition
    17 EndLicenseAcquisition 
    18 BeginIndividualization
    19 EndIndividualization
    20 MediaWaiting
    21 OpeningUnknownURL 
    */
    if (this.wmp7)  {
       mediaOpen = 13;
    }
    return eval(state + "");
  }
  
  this.isOpenState = function(state)  {
    if ((this.wmp7) && (state == 13))  {
      return true;
    }
    if ((!this.wmp7) && (state == 6))  {
      return true;
    }
    return false;
  }
  
  this.getPlayState = function()  {
    var playState = 0;
    if (this.obj != null)  {
      if (this.wmp7)  {
        if (cwsObj.runInNewWindow)  {
          playState = contentWin.wmp7GetPlayState(this.obj);
        }
        else  {
          playState = this.obj.playState;
        }
      }
      else  {
        playState = 8;
        playState = this.obj.PlayState;
      }
    }
    return playState;
  }
  
  this.getOpenState = function()  {
    var openState = 0;
    if (this.obj != null)  {
      if (this.wmp7)  {
        if (cwsObj.runInNewWindow)  {
          openState = contentWin.wmp7GetOpenState(this.obj);
        }
        else  {
          openState = this.obj.openState;
        }
      }
      else  {
        openState = this.obj.OpenState;
      }
    }
    return openState;
  }
  
  this.play = function()  {
    if (this.obj != null)  {
      if (this.wmp7)  {
        if (cwsObj.runInNewWindow)  {
          contentWin.wmp7Play(this.obj);
        }
        else  {
          if (this.obj.controls.isAvailable('Play')) {
            this.obj.controls.play();
          }
        }
      }
      else  {
        this.obj.Play();
      }
    }
  }
  
  this.pause = function() {
    if (this.obj != null)  {
      if (this.wmp7)  {
        if (cwsObj.runInNewWindow)  {
          contentWin.wmp7Pause(this.obj);
        }
        else  {
          if (this.obj.controls.isAvailable('Pause')) {
            this.obj.controls.pause();
          }
        }
      }
      else  {
        this.obj.Pause();
      }
    }
  }
  
  this.stop = function()  {
    if (this.obj != null)  {
      if (this.wmp7)  {
        if (cwsObj.runInNewWindow)  {
          contentWin.wmp7Stop(this.obj);
        }
        else  {
          if (this.obj.controls.isAvailable('Stop')) {
            this.obj.controls.stop();
          }
        }
      }
      else  {
        this.obj.Stop();
      }
    }
  }

  this.getErrorCode = function()  {
    if (this.obj != null)  {
      if (this.wmp7)  {
        if (cwsObj.runInNewWindow)  {
          contentWin.wmp7GetErrorCode(this.obj);
        }
        else  {
          var errorCode = this.obj.error.item(this.obj.error.errorCount-1).errorCode;
          return errorCode;
        }
      }
      else  {
        return this.obj.ErrorCode;
      }
    }
  }

  this.getErrorDescription = function()  {
    if (this.obj != null)  {
      if (this.wmp7)  {
        if (cwsObj.runInNewWindow)  {
          contentWin.wmp7GetErrorDescription(this.obj);
        }
        else  {
          var errorDesc = this.obj.error.item(this.obj.error.errorCount-1).errorDescription;
          return errorDesc;
        }
      }
      else  {
        return this.obj.ErrorDescription;
      }
    }
  }

  this.clearErrorQueue = function() {
    if (this.obj != null)  {
      if (this.wmp7)  {
        if (cwsObj.runInNewWindow)  {
          contentWin.wmp7ClearErrorQueue(this.obj);
        }
        else  {
          this.obj.error.clearErrorQueue();
        }
      }
    }
  }

  this.playUrl = function(url)  {
    if (this.obj != null)  {
      if (this.wmp7)  {
        if (cwsObj.runInNewWindow)  {
          contentWin.wmp7PlayUrl(this.obj,url);
        }
        else  {
          this.obj.URL = url;
          this.obj.controls.play();
        }
      }
      else  {
        this.obj.Open(url);
        //this.obj.FileName = url;
        //this.obj.Play();
      }
    }
  }

  this.getHtml = function()  {
    var html = "";
    if (window.ActiveXObject &&
        (navigator.userAgent.indexOf("MSIE")!= -1) &&
        (navigator.userAgent.indexOf("Windows") != -1)) {
      html += "<OBJECT classid=\"" + this.classid + "\" id=\"" + this.id + "\" name=\"" + this.id + "\"";
      if (!this.wmp7)  {
        html += "codebase=\"" + this.urlPrefix + "activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=" + this.version + "\"";
      }
      html += " style='position:absolute;top:0;left:0;' WIDTH=\"" + this.width + "\" HEIGHT=\"" + this.height + "\" ALIGN=\"\">";
      if (this.wmp7)  {
        if ((this.file != "") && (this.file != null)) {
          html += "<PARAM NAME='url' VALUE='" + this.file + "'>";
        }
        html += "<PARAM NAME='uiMode' VALUE='invisible'>";

      }
      else  {
        if ((this.file != "") && (this.file != null)) {
          html += "<PARAM NAME='filename' VALUE='" + this.file + "'>";
        }
        html += "<PARAM NAME='AnimationatStart' VALUE='false'>";
        html += "<PARAM NAME='TransparentatStart' VALUE='true'>";
      }
      if ((this.file != "") && (this.file != null)) {
        html += "<PARAM NAME='AutoStart' VALUE='" + this.autoStart +"'>";
      }
      html += "<PARAM NAME='ShowControls' VALUE='false'>";
      html += "</OBJECT>";
    }
    else  {
      this.enabled = false;
      html += "<SCRIPT language=\"javascript\">alert(\"Unable to load audio. This course requires Internet Explorer.\");</SCRIPT>";
      /*
      document.write ('    <Embed type="application/x-mplayer2"');
      document.write ('        pluginspage="http://www.microsoft.com/windows/windowsmedia/"');
      document.write ('        filename="http://ncnetshow/station1.asx"');
      document.write ('        src="http://ncnetshow/station1.asx"');
      document.write ('        Name=MediaPlayer');
      document.write ('        ShowControls=1');
      document.write ('        ShowDisplay=1');
      document.write ('        ShowStatusBar=1');
      document.write ('        width=290');
      document.write ('        height=320>');
      document.write ('    </embed>');
     */
    }
    return html;
  }

  function getVolumeValue(percent) {
    return (volumeField - Math.round(percent * volumeField / 100)) * -1;
  }

  function getVolumePercent(value)  {
    return Math.round((volumeField - Math.abs(value)) / volumeField * 100);
  }
}

function InterfaceImage() {
  var name = "";
  var width = "0";
  var height = "0";
  var href = "";
  var onClick = "";
  var mouseOver = "";
  var mouseOut = "";
  var fileName = "";
  var extension = "";
  var imgDefault = new Image;
  var imgOver = new Image;
  var imgDisabled = new Image;
  var imgFlash = new Image;
  var imgOn = new Image;
  var imgOnOver = new Image;
  var altText = "";
  this.hasDisabled = false;
  this.hasFlash = false;
  this.hasOver = false;
  this.hasOn = false;
  this.flash = false;
  this.on = false;
  this.resetOnRun = true;
  var enabled = true;

  this.setName = function(n)  {
    name = n;
  }
  this.getName = function() {
    return name;
  }
  this.setWidth = function(w) {
    width = w;
  }
  this.getWidth = function()  {
    return width;
  }
  this.setHeight = function(h)  {
    height = h;
  }
  this.getHeight = function()  {
    return height;
  }
  this.setHref = function(h)  {
    href = h;
  }
  this.getHref = function() {
    return href;
  }
  this.setOnClick = function(oc)  {
    onClick = oc;
  }
  this.getOnClick = function()  {
    return onClick;
  }
  this.setFileName = function(fn) {
    fileName = fn;
  }
  this.getFileName = function() {
    return fileName;
  }
  this.setExtension = function(e) {
    extension = e;
  }
  this.getExtension = function()  {
    return extension;
  }
  this.setMouseOver = function(mo)  {
    mouseOver = mo;
  }
  this.getMouseOver = function()  {
    return mouseOver;
  }
  this.setMouseOut = function(mo) {
    mouseOut = mo;
  }
  this.getMouseOut = function() {
    return mouseOut;
  }
  this.setDefaultSrc = function(src)  {
    imgDefault.src = src;
  }
  this.setOverSrc = function(src)  {
    imgOver.src = src;
  }
  this.setDisabledSrc = function(src)  {
    imgDisabled.src = src;
  }
  this.setFlashSrc = function(src)  {
    imgFlash.src = src;
  }
  this.setOnSrc = function(src) {
    imgOn.src = src;
  }
  this.setOnOverSrc = function(src) {
    imgOnOver.src = src;
  }
  this.setAltText = function(txt) {
    altText = txt;
  }
  this.getAltText = function(txt) {
    return altText;
  }
  this.getDefaultImg = function() {
    return imgDefault;
  }
  this.getOverImg = function() {
    if ((!enabled) && (this.hasDisabled))  {
      return imgDisabled;
    }
    if ((this.hasOn) && (this.on))  {
      return imgOnOver;
    }
    return imgOver;
  }
  this.getDisabledImg = function() {
    return imgDisabled;
  }
  this.getFlashImg = function() {
    return imgFlash;
  }
  this.getCurrentImg = function() {
    if ((!enabled) && (this.hasDisabled))  {
      return imgDisabled;
    }
    if (enabled)  {
      if ((this.hasOn) && (this.on))  {
        return imgOn;
      }
      if ((this.flash) && (this.hasFlash))  {
        return imgFlash;
      }
    }
    return imgDefault;
  }
  this.setEnabled = function(bool)  {
    enabled = bool;
  }
  this.getEnabled = function()  {
    return enabled;
  }
  this.getHtml = function(img) {
    var html = "";
    var frontHref = "";
    var endHref = "";
    if (href != "") {
      frontHref = "<A href=\"" + href + "\"";
      frontHref += ">";
      endHref = "</A>";
    }
    var imageText = "<IMG name='" + name + "' border=0 width=" + width + " height=" + height + " SRC=\"" + img.src + "\"";
    if (altText != "")  {
      imageText += " alt=\"" + altText + "\"";
    }
    if (mouseOver != "")  {
      imageText += " onmouseover=\"" + mouseOver + "\"";
    }
    if (mouseOut != "") {
      imageText += " onmouseout=\"" + mouseOut + "\"";
    }
    if (onClick != "") {
      imageText += " style=\"cursor:hand;\" onclick=\"" + onClick + "\"";
    }
    imageText += ">";
    html = frontHref + imageText + endHref;
    return html;
  }
}

function ImageObj(src,width,height,alt) {
  this.src = src;
  this.width = width;
  this.height = height;
  this.alt = alt;
  if (this.alt == null) {
    this.alt = "";
  }
}

function FlashListener(kloObj,flashObj) {
  //this.pFlashId = flashId;
  //this.pFlashObj = document.getElementById(this.pFlashId);

  this.pKloObj = kloObj;
  this.pFlashObj = flashObj;
  this.pReset();
}
FlashListener.PLAYING_FRAME = 3; // if it gets to this frame it should be playing

FlashListener.prototype.setFlashObject = function(flashObj) {
  this.pFlashObj = flashObj;
  this.pReset();
}

FlashListener.prototype.start = function() {
  this.pTimerId = setInterval(getObjectFunction(this.pHandleTimer, this), 1000/24);
  //this.pTimerId = setInterval(getObjectFunction(this.pHandleTimer, this), 2000);
}

FlashListener.prototype.stop = function() {
  if (this.pTimerId) {
    this.pTimerId = clearInterval(this.pTimerId);
  }
}

FlashListener.prototype.pReset = function() {
  this.pDuplicates = 0;
  this.pSentPlaying = false;
  this.pSentDone = false;
  this.pLastFrame = 0;
  this.pSentFrames = new Array();
}

FlashListener.prototype.pGetCurrentFrame = function() {
  if (isValidFunction(this.pFlashObj)) {
    if (typeof(this.pFlashObj.CurrentFrame) == "number") {
      return this.pFlashObj.CurrentFrame;
    }
    else {
      try {
        return this.pFlashObj.CurrentFrame();
      }
      catch (e) {
        return -1;
      }
    }
  }
  else  {
    return -1;
  }
}
FlashListener.prototype.pGetTotalFrames = function() {
  if (isValidFunction(this.pFlashObj)) {
    if (typeof(this.pFlashObj.TotalFrames) == "number") {
      return this.pFlashObj.TotalFrames;
    }
    else {
      try {
        return this.pFlashObj.TotalFrames();
      }
      catch (e) {
        return -1;
      }
    }
  }
  else  {
    return -1;
  }
}

FlashListener.prototype.pHasStarted = function(currentFrame, totalFrames) {
  if (currentFrame > FlashListener.PLAYING_FRAME) return true;
  return false;
}
FlashListener.prototype.pHasEnded = function(currentFrame, totalFrames) {
  if (currentFrame+1 < totalFrames) return false;
  return true;
}

FlashListener.prototype.isPlaying = function() {
  return this.pHasStarted(this.pLastFrame, this.pTotalFrames) &&
         !this.pHasEnded(this.pLastFrame, this.pTotalFrames);
}

FlashListener.prototype.isDone = function() {
  if ((this.pLastFrame > FlashListener.PLAYING_FRAME) && (this.pLastFrame+1 == this.pTotalFrames)) {
    return true;
  }
  return false;
}

FlashListener.prototype.pProcessFrame = function(currentFrame, totalFrames) {
  this.pTotalFrames = totalFrames;

  if (this.pHasStarted(currentFrame, totalFrames)) {
    if (!this.pSentPlaying) {
      this.pSentPlaying = true;
      this.pKloObj.handleFlashShellPlaying();
    }

    for (var i=this.pLastFrame+1; i<=currentFrame; i++) {
      this.pKloObj.handleFlashShellFrame(i);
      this.pSentFrames.push(i);
    }
    this.pLastFrame = currentFrame;

    if (this.pHasEnded(currentFrame, totalFrames) && !this.pSentDone) {
      this.pSentDone = true;
      this.pKloObj.handleFlashShellDone();
      this.stop();
      //alert(this.pSentFrames);
    }
  }
}

FlashListener.prototype.pHandleTimer = function() {
  //this.pFlashObj = document.getElementById(this.pFlashId);
  var currentFrame = this.pGetCurrentFrame();
  var totalFrames = this.pGetTotalFrames();
  if (isNaN(currentFrame) || isNaN(totalFrames)) return;

  this.pProcessFrame(currentFrame, totalFrames);
}

