$(document).ready(function(){
    $('#slidersection').tinycarousel({interval:true, intervaltime: 12000});

    $('#sucheStart').click(function(){
        startSuche();
    });
    
      $('#ort').keyup(function(e) {
        if(e.keyCode == 13) {
            startSuche();
        }
      });
    
    function startSuche(){
        $.ajax({
          url: '/agentur/ajax/getAgenturVonRegion',
          type: 'post', 
          data: 'eingabe='+$('#ort').val(),
          beforeSend: function(){
            $('#sucheFormular').hide();
            $('#sucheLade').show();
          },
          success: function(data) {
            $('#sucheLade').hide();
            $('#sucheRueckgabe').html(data);
            $('#betr').val($('#ort').val());
            $('#sucheErgebnis').show();
          }
        });
        return false;
    }
    
    $('#sucheReset').click(function(){
        $('#sucheErgebnis').hide();
        $('#sucheRueckgabe').html('');
        $('#sucheFormular').show();
        return false;
    });
});
