  // initialise the play/stop button images
  var play0, play1;

  cantalia_buttons = new Array(2);  
  for (i = 0; i < 2; i++)
  {
     cantalia_buttons[i]     = new Image();
     cantalia_buttons[i].src = "images/play" + i + ".gif";
  }

  // initialise music variables
  var playing = 0;

  // music functions //////////////////////////////////////////////////////
  function load()
  {
		/* load a cantalia seed */

    // stop the player if it's already playing
    if (playing) play();

    // load the currently selected seed
    var seed = document.form1.seedlist.options[document.form1.seedlist.selectedIndex].value;		    
//    alert("seed = " + seed);
		
		eval('document.player.onLoad("' + seed + '")');
  }

  function play()
  {
    // toggle the play button
    document.playbutton.src = cantalia_buttons[playing].src;

    // start/stop the cantalia player
    if (playing)
    {
      document.player.onStop();
    }
    else
    {
      document.player.onPlay();
    }

     // flip the playing flag
     playing^=1;     
  }

  function stop()
  {
		// toggle the play button
		document.playbutton.src = cantalia_buttons[playing].src;
		
		// stop the cantalia player
		if (playing)
		{
		  document.player.onStop();
		}
		
		// flip the playing flag
		playing = 0;    
  }

  function newRange()
  {
		// change the cantalia player range
		document.player.onNewRange();
  }

  function newInstrument()
  {
    // change the cantalia player instrument(s)
    document.player.onNewInstrument();
  }

  function reset()
  {
    // reset the cantalia player
    document.player.onReset();
  }

  // GUI functions //////////////////////////////////////////////////////
  function show(hint)
  {
    // update the hint zone
    document.getElementById('hintzone').firstChild.nodeValue = hint;
  }

  function setLoaded(state)
  {
    // inform the user that the cantalia applet has been loaded
    if (state) 
       show("");
    else
       show("loading... please wait...");
  }