function makerequest(method, URL, params) 
{
	var http = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("MSXML2.XMLHTTP.3.0");

	if(method=='GET')  {
		http.open("GET", URL+"?"+params, true);
		http.onreadystatechange = function() {//Call a function when the state changes.
			if(http.readyState == 4 && http.status == 200) {
				//alert(http.responseText);
				document.getElementById('myspan').innerHTML = http.responseText;
			}
		}
		http.send(null);
		if(!http.getResponseHeader("Date"))
		{
			var cached = http;
			http = (typeof(XMLHttpRequest) != "undefined") ? new XMLHttpRequest() : new ActiveXObject("Msxml2.XMLHTTP");
			var ifModifiedSince = cached.getResponseHeader("Last-Modified");
			ifModifiedSince = (ifModifiedSince) ? ifModifiedSince : new Date(0); // January 1, 1970
			http.open("GET", URL+"?"+params, false);
			http.setRequestHeader("If-Modified-Since", ifModifiedSince);
			http.send("");
			if(http.status == 304)
			{
				http = cached;
			}
		}
	}

	if(method=='POST')  {
		http.open("POST", URL, true);

		//Send the proper header information along with the request
		http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		http.setRequestHeader("Content-length", params.length);
		http.setRequestHeader("Connection", "close");
		http.onreadystatechange = function() 
		{
			if(http.readyState == 4 && http.status == 200) 
			{
				//alert(http.responseText);
				document.getElementById('myspan').innerHTML = http.responseText;
			}
		}
		http.send(params);
	}
}


function getpage(URL, poststr) 
{
	//poststr = '';
	makerequest('POST', URL, poststr);
}

function deletepage(URL, poststr) 
{
	var delconf = confirm("Are you sure you want to delete this record?");
	if(delconf == true)
		makerequest('POST', URL, poststr);
}

function postform(URL, fname) 
{
	poststr = buildPOST(fname);
	makerequest('POST', URL, poststr);
}

function buildPOST(theFormName) 
{
    theForm = document.forms[theFormName];
    var qs = ''
    for (e=0;e<theForm.elements.length;e++) {
        if (theForm.elements[e].name!='') {
            var name = theForm.elements[e].name;
            qs+=(qs=='')?'':'&'
            qs+= name+'='+escape(theForm.elements[e].value);
        }
    }
    //qs+="\n";
    return qs
}

function postselect(URL, selectval) 
{	poststr = 'memid=' + selectval.value;
	makerequest('POST', URL, poststr);
}