function appletLoaded() {
    var f = document.frmSelect;
    if (f.cbComputer.options.length == 0) {
      populateSelect(f.cbComputer,document.JEMU.getComputers(),0,0);
      populateSelect(f.cbGame,document.JEMU.getFiles(),1,0);
    }

  }
function appletStarted() {
    var f = document.frmSelect;
    populateSelect(f.cbGame,document.JEMU.getFiles(),1,0);
  }

  function selectComputer() {
    var f = document.frmSelect;
    var o = f.cbComputer.options;
    document.JEMU.setComputer(o[f.cbComputer.selectedIndex].value);
    populateSelect(f.cbGame,document.JEMU.getFiles(),1,0);
  }

  function selectGame() {
    var f = document.frmSelect;
    var o = f.cbGame.options;
    var value = o[f.cbGame.selectedIndex].value;
    if (value != "") {
      if (document.JEMU != "") {
        document.JEMU.loadFile(value);
        document.JEMU.focus();
      }
    }  
  }

  function resetComputer() {
    var f = document.frmSelect;
    //f.cbGame.selectedIndex = 0;
    document.JEMU.resetComputer();
    document.JEMU.focus;
  }

  function ejectComputer() {
    var f = document.frmSelect;
    f.cbGame.selectedIndex = 0;
    document.JEMU.ejectComputer();
    document.JEMU.focus;
  }

  function loaddata() {
    document.JEMU.insertDisk();
    document.JEMU.focus;
  }

  function toggleFullSize() {
    fullSize = document.frmSelect.cbFullSize.checked;
    document.JEMU.setFullSize(fullSize);
    w = document.JEMU.getPreferredSize().width;
    h = document.JEMU.getPreferredSize().height;
    document.JEMU.width = w;
    document.JEMU.height = h;
    document.JEMU.focus();
  }

  function toggleDoubleSize() {
    doubleSize = document.frmSelect.cbDoubleSize.checked;
    document.JEMU.setDoubleSize(doubleSize);
    w = document.JEMU.getPreferredSize().width;
    h = document.JEMU.getPreferredSize().height;
    document.JEMU.width = w;
    document.JEMU.height = h;
    document.JEMU.focus();
  }

  function toggleTripleSize() {
    tripleSize = document.frmSelect.cbTripleSize.checked;
    document.JEMU.setTripleSize(tripleSize);
    w = document.JEMU.getPreferredSize().width;
    h = document.JEMU.getPreferredSize().height;
    document.JEMU.width = w;
    document.JEMU.height = h;
    document.JEMU.focus();
  }

  function toggleAudio() {
  	Audio = document.frmSelect.cbAudio.checked;
  	document.JEMU.setAudio(Audio);    
  	document.JEMU.focus();
  	}

  function toggleFloppy() {
  	Floppy = document.frmSelect.cbFloppy.checked;
  	document.JEMU.setFloppy(Floppy);    
  	document.JEMU.focus();
  	}

  function toggleJoystick() {
  	Joystick = document.frmSelect.cbJoy.checked;
  	document.JEMU.setJoy(Joystick);    
  	document.JEMU.focus();
  	}

  function toggleTurbo() {
  	Turbo = document.frmSelect.cbTurbo.checked;
  	document.JEMU.setTurbo(Turbo);    
  	document.JEMU.focus();
  	}

  function populateSelect(select,vector,leave,index) {
    var o = select.options;
    if (leave == 1)
      o[0].text = "(None)";
    var i;
    for (i = o.length - 1; i >= leave; i--)
      o[i] = null;
    for (i = 0; i < vector.size(); ) {
      var option = new Option(vector.elementAt(i++));
      option.value = vector.elementAt(i++);
      o[leave++] = option;
    }
    select.selectedIndex = index;
  }