function form_blur(controller_name)
{
  var serialized_form = $(controller_name + '_form').serialize(true);
  if (Object.toJSON(window.itg_last_serialized_form) != Object.toJSON(serialized_form)) {
    window.itg_last_serialized_form = serialized_form;
    new Ajax.Request('/' + controller_name + '/validate', {
      parameters: serialized_form
    });
  }
}

function activite_change()
{
  if ($('activite_select').getValue() == 3) {
    Element.show('activite_field')
  } else {
    Element.hide('activite_field')
  }
}

function excuse_toggle(participant_id)
{
  checkbox_presence = $('participant_presence_' + participant_id)
  checkbox_excuse = $('participant_excuse_' + participant_id);
  checkbox_share = $('participant_share_' + participant_id);
  td_excuse = $('participant_excuse_td_' + participant_id);
  td_share = $('participant_share_td_' + participant_id);
  if (checkbox_presence.checked == true) {
    checkbox_excuse.disabled = true;
    checkbox_excuse.checked = false;
    td_excuse.style.backgroundColor = '#ACABBA';
    checkbox_share.disabled = false;
    td_share.style.backgroundColor = 'transparent';
  } else {
    checkbox_excuse.disabled = false;
    td_excuse.style.backgroundColor = 'transparent';
    checkbox_share.disabled = true;
    checkbox_share.checked = false;
    td_share.style.backgroundColor = '#ACABBA';
  }
}

function select_table(hide_ids,selected_id)
{
  hide_ids.each(function(element){
    $(element).hide();
  });
  $(selected_id).show();
}

