
//globale Variablen
var ajax_http;
var target_id;

//Ajaxobjekt erstellen
function initAjax()
{
    if (window.XMLHttpRequest) 
    {
        ajax_http = new XMLHttpRequest();
    } 
    else if (window.ActiveXObject) 
    {
        ajax_http = new ActiveXObject("Microsoft.XMLHTTP");
    } 
}

//ID des Elements in welchem das Ergebnis geladen werden soll.
//Pfad zur Funktion welche den Request behandelt (zB. ajax/ajax_worker.php?work=volltext&volltextsuche=test)
//show_ladeajax = Adresse des ladebildes
function ajax_get_result(ajax_target_id, pfad, img_ladeajax)
{	
    initAjax();

    target_id = ajax_target_id;
        
    //Ladebild wird eingeblendet...
    if(img_ladeajax != null && img_ladeajax != "")
    {
    	document.getElementById(ajax_target_id).innerHTML = "<img src='" + img_ladeajax + "'>";
    }
    
    if (ajax_http != null) 
    {    
        ajax_http.open("GET", pfad, true);
        ajax_http.onreadystatechange = handleAjax;
        ajax_http.send(null);
    }
}

function handleAjax()
{
    if (ajax_http.readyState == 4) 
    {        
        document.getElementById(target_id).innerHTML = ajax_http.responseText;        
    }
}
