  function setupCustomRate()
  {
    var min = "";
    var max = "";
    var ele = findSelected(document.forms[0].preset);
    var json = eval('('+(Base64.decode(ele.attributes['value'].nodeValue))+')');
    var format = json.format;
    var rate = json.frames;
    var opts = document.getElementById("rate");
    var formatEle = document.getElementById("format");
    
    min = json.minframerate;
    max = json.maxframerate;

    var msg = "Frame rate";
    var val = 24;
    if ((min != undefined) && (max != undefined))
    {
      msg += " ("+min+"-"+max+"fps)";
      val = min;
    }
    
    var fps = prompt(msg, val);
    while( (!parseFloat(fps)) || (fps > max) || (fps < min) )
    {
      fps = prompt(msg, val);
    }
    
    var myNewOption = new Option(fps,fps);
    opts.appendChild(myNewOption);
    myNewOption.selected = true;
  }
  
  function rateChangeFilm()
  {
    var opts = document.getElementById("rate");
    
    if (findSelected(opts).value == "Custom")
     {
        setupCustomRate();
     }
  }
  
  function presetChangeFilm()
  {
    var min = "";
    var max = "";
    var ele = findSelected(document.forms[0].preset);
    var json = eval('('+(Base64.decode(ele.attributes['value'].nodeValue))+')');
    var format = json.format;
    var rate = json.frames;
    var opts = document.getElementById("rate");
    var formatEle = document.getElementById("format");
    
    min = json.minframerate;
    max = json.maxframerate;

    if (opts.hasChildNodes())
      while (opts.childNodes.length >= 1)
          opts.removeChild(opts.firstChild);       
    
    for (i = 0; i< rate.length; i++)
    {
      if ((rate[i] != parseFloat(rate[i])) && (rate[i] != "Custom"))
      {
        var optg = document.createElement("optgroup");
        optg.label = rate[i];
        opts.appendChild(optg);
      }
      else
      {
        var myNewOption = new Option(rate[i],rate[i]);
        opts.appendChild(myNewOption);
      }
    }
   if (rate == "Custom")
   {
      setupCustomRate();
   }
    
    if (formatEle.hasChildNodes())
      while (formatEle.childNodes.length >= 1)
          formatEle.removeChild(formatEle.firstChild);   
    
    for (i = 0; i< format.length; i++)
    {        
      var newFormat = new Option(format[i],format[i]);
      formatEle.appendChild(newFormat);
    }

   
  }
