function handleHttpResponse() { 
    if (http.readyState < 4) { }

    if (http.readyState == 4) {
        if(http.status==200) {
            var results = http.responseText;
            result = results.split('|');
            
            //alert(result[0]);
            if ( result[0] == true ) {
                document.getElementById(result[1]+'_mailcontainer').innerHTML = 
'<span style="color:green; line-height:1.5em;">Thank you.  Your request for the <b>'+result[1]+'</b> list has been sent.  <span style="color:blue;"><a href="javascript:history.go(0)">Click here to do another.</a></span></span>';
            } else {
                document.getElementById(result[1]+'_mailcontainer').innerHTML = 
'<span style="color:red; line-height:1.5em;">Your request seems to have failed for the <b>'+result[1]+'</b> list.  <a href="javascript:history.go(0)">Try again</a> or send us an email describing the issue.</span>';
            }
            return false; 
        }   
    }
}

function ajax_submit(action, list) { 
    email = encodeURI(document.getElementById(list + '_client_email').value);

    // set an action graphic so user knows we are working
    document.getElementById(list + '_mailcontainer').innerHTML = 
            '<img src="' + ML_BASE + 'indicator.white.gif' + '" alt="wait"/>';

    //alert(email);
    url1 = ML_BASE + 'handle_ajax.php?e=' + email + '&a=' + action + '&l=' + list;

    //alert(url1);
    http.open('get',url1,true);
    http.onreadystatechange = handleHttpResponse;
    http.send(null);
    return false;
}

function getHTTPObject() { //this function checks what the browser is
    var xmlhttp;

    if(window.XMLHttpRequest){
        xmlhttp = new XMLHttpRequest();
    } else if (window.ActiveXObject){
        xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
        if (!xmlhttp) {
            xmlhttp=new ActiveXObject('Msxml2.XMLHTTP');
        }
    }
    return xmlhttp; 
}

var http = getHTTPObject(); // We create the HTTP Objects

