$(document).ready(
  function() {
    if ( $('#select_branche_ma').length > 0 ) {
      $('#select_branche_ma').change(
         submitFormMa
      );
    }
    if ( $('#select_branche_ma_sub').length > 0 ) {
      $('#select_branche_ma_sub').change(
         submitFormMa
      );
    }
  }
  
);

function submitFormMa () {
  xoForm = $(this).parents('form');
  url = $(xoForm).attr('action');
  if ( $(this).attr('id') == 'select_branche_ma' ) {
    xoForm.find('#select_branche_ma_sub').first().val(null);
  }
  $.ajax(
    {
      url:xoForm.attr('action'),
      cache:false,
      dataType: 'json',
      data:xoForm.serializeArray(),
      success: function( data, textStatus ) {
        html = "";
        $('#branche_auswahl_ergebnis').html(
          data.html_mitarbeiter
        )
        $('#select_branche_ma_sub').html(
          data.select_options
        )
        if (  data.select_options == null ) {
          $('#select_branche_ma_sub').hide();
        } else {
          $('#select_branche_ma_sub').show();
        }
      }
    }
  );
  
}

function StopEvent(pE)
{
   if (!pE)
     if (window.event)
	     pE = window.event;
     else
	     return;
       if (pE.cancelBubble != null)
          pE.cancelBubble = true;
       if (pE.stopPropagation)
          pE.stopPropagation();
       if (pE.preventDefault)
          pE.preventDefault();
       if (window.event)
          pE.returnValue = false;
       if (pE.cancel != null)
          pE.cancel = true;
}  // StopEvent
