/**
 * @todo add author and information
 *
 */

 /**
 * Ajaxrequest for Umkreissuche
 * sends search parameters and returns a rendered result list
 */
function doUmkreissuche(suchwort, umkreis)
{
    if(suchwort==''){
        suchwort = $('#suchEingabe').val();
        umkreis = $('#suchUmkreis').val();
    }
    var vorherigePid = $('#umkreissuche_vorherigePid').val();
    
    $.ajax({
        type: "POST",
        url: "index.php",
        data: 'eID=umkreissucheajax&suchwort='+suchwort+'&umkreis='+umkreis+'&vorherigePid='+vorherigePid + "&currentPageURL=" + $('#marktSelectActionJSTargetURL').attr('href'),
        beforeSend: function(){
               $('#ajax_umkreissuche_result').html('<img class="loading_image" src="fileadmin/images/construct/ajax-loader.gif" />');
            },
        success: function(msg){
            $('#ajax_umkreissuche_result').html(msg);
        }
    });
}

/*
 * Ajax request for Marktliste
 * returns a rendered result list
 */
function listAllMarkets(currentPageURL)
{
    if(!$('#ajax_marktliste_result').empty()){
        return;
    }
    var vorherigePid = $('#marktliste_vorherigePid').val();
    $.ajax({
        type: "POST",
        url: "index.php",
        data: 'eID=marktlisteajax&vorherigePid='+vorherigePid + "&currentPageURL=" + $('#marktSelectActionJSTargetURL').attr('href'),
        beforeSend: function(){
               $('#ajax_marktliste_result').html('<img class="loading_image" src="fileadmin/images/construct/ajax-loader.gif" />');
            },
        success: function(msg){
            $('#ajax_marktliste_result').html(msg);
            marktleistenMenueAusfahren = false;
        }
    });
}

/*
 * Ajax request for Marktdetails
 * returns the details for the selected Markt
 */
function showMarketdetails(){
    var selectedBKZ = $('#selectedBKZ').val();
    $.ajax({
        type: "POST",
        url: "index.php",
        data: 'eID=showmarktdetailsajax&bkz='+selectedBKZ,
        beforeSend: function(){
               $('#ajax_marktdetails_result').html('<div id="ajax_loader"><img class="loading_image" src="fileadmin/images/construct/ajax-loader.gif" /><span>Inhalt wird geladen...</span></div>');
            },
        success: function(msg){
            $('#ajax_marktdetails_result').html(msg);
        }
    });
}
