function getXmlhttpObject() {
    if (window.XMLHttpRequest)
    {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
    }
    else if (window.ActiveXObject)
    {
        // code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    if (xmlhttp) {
        return xmlhttp;
    }
    else
    {
        alert ('Your browser does not support XMLHTTP; we suggest upgrading.');
    }
}

function ajax_loader(data_container_id, file_location, post_string) {

    var xmlhttp = getXmlhttpObject();
    document.getElementById(data_container_id).innerHTML = "<img class='loading' src='/wp-content/themes/interfaithing/images/loading.gif' alt='Loading' />";
    
    xmlhttp.open('POST', file_location, true);
    xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');   
    xmlhttp.send(post_string);
    
    xmlhttp.onreadystatechange = function()
    {
        if (xmlhttp.readyState == 4)
        {
            document.getElementById(data_container_id).innerHTML = xmlhttp.responseText;
        }
    }
}
