// Sends an AJAX request to the specified URL, 
// putting the recieved content in the element with id elementId.
// Params is an associative array with parameters to send to the server.
//
function ck_ajax_xmlhttpPost(strURL,elementId,params)
{
    var xmlHttpReq = false;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlHttpReq.open('POST', strURL, true);
    xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlHttpReq.onreadystatechange = function() 
	    {
	        if (xmlHttpReq.readyState == 4)
	        {
				document.getElementById(elementId).innerHTML = xmlHttpReq.responseText;
	        }
	    }
    var queryString = "";
    for (var p in params)
    {
    	if(queryString.length > 0) queryString += "&";
    	queryString += p + "=" + params[p];
    }
    
    xmlHttpReq.send(queryString);
}

