function Plot() {
  x = document.options.xvalues.value.replace(/\s+$/g, '');
  y = document.options.yvalues.value.replace(/\s+$/g, '');
  if (x.length > 0)
    xn = x.split('\n').length;
  else
    xn = 0;
  if (y.length > 0)
    yn = y.split('\n').length;
  else
    yn = 0;

  if (xn != yn)
    alert("X and Y have different lengths");
  else
  {
    var main = document.options.mainlab.value;
    var xvalue = document.options.xvalues.value;
    var yvalue = document.options.yvalues.value;
    var xlab = document.options.xlabel.value;
    var ylab = document.options.ylabel.value;
    var xlabrot = document.options.xlabrot.checked;
    var plotype = document.options.plotype.value;
    var medline = document.options.medline.value;

    Element.show('spinner');
    new Ajax.Updater( 'plot', '/~graywh/brew/dotplot',
      {
        'method': 'post',
        'parameters': {
          'main':main,
          'x':xvalue,
          'y':yvalue,
          'xlab':xlab,
          'ylab':ylab,
          'xlabrot':xlabrot,
          'type':plotype,
          'medline':medline
        },
        'onSuccess': function(r) { Element.hide('spinner') }
      }
    );
  }
}

function Count() {
  x = document.options.xvalues.value.replace(/\s+$/g, '');
  y = document.options.yvalues.value.replace(/\s+$/g, '');
  if (x.length > 0)
    xn = x.split('\n').length;
  else
    xn = 0;
  if (y.length > 0)
    yn = y.split('\n').length;
  else
    yn = 0;
  document.getElementById('xcount').innerHTML = xn + ' items';
  document.getElementById('ycount').innerHTML = yn + ' items';
}
/* vim: sw=2 ts=2
*/
