CONFMAN.submission_dates = function(form) {
  var form = form;
  
  var toggle_dates = function(value) {
    if (value === '1') {
      $$('.submission_date_form').first().appear({ duration: 0.2 });
    } else {
      $$('.submission_date_form').first().fade({ duration: 0.2 });      
    }
  }
  
  form.select('input[type=radio][name=include_dates]').invoke('observe', 'click', function(e) {
      var value = Event.findElement(e, 'input').value;
      toggle_dates(value);
  });
};

CONFMAN.abstract_upload_setup = function() {
  var upload_count = $('number_of_uploads');

  var set_upload_status = function() {
    var count = parseInt(upload_count.value);
    var status_field, i;

    for (i=1; i<=count; i++) {
      status_field_0 = $('upload_'+i+'_status_0');
      status_field_1 = $('upload_'+i+'_status_1');
      status_field_2 = $('upload_'+i+'_status_2');
      if (!status_field_0.checked && !status_field_1.checked && !status_field_2.checked) {
        status_field_0.checked = true;
      }
    }
  };

	var display_upload_header = function(add_effect) {
    var upload_header = $('upload_header');

    if (parseInt($F('upload_count')) > 0) {
      if (add_effect) {
        upload_header.appear();
      } else {
        upload_header.show();
      }
    } else {
      if (add_effect) {
        upload_header.fade();
      } else {
        upload_header.hide();
      }
    }
  };

  display_upload_header(false);

  upload_count.observe('change', function() {
    CONFMAN.add_multiple_fields_div('upload', upload_count.value);
    display_upload_header(true);
    set_upload_status()
  });
};

