function makerequest(method, URL, params, div) 
{
	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(div).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')  {
		//alert('hello');
		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(div).innerHTML = http.responseText;
			}
		}
		http.send(params);
	}
}

function getpage(URL, poststr) 
{	makerequest('POST', URL, poststr, 'ajaxcontent');
}

function deletepage(URL, poststr) 
{	var delconf = confirm("Are you sure you want to delete this record?");
	if(delconf == true)
		makerequest('POST', URL, poststr, 'ajaxcontent');
}

function postform(URL, fname) 
{	poststr = buildPOST(fname);
	makerequest('POST', URL, poststr, 'ajaxcontent');
}

function buildPOST(theFormName) 
{	theForm = document.forms[theFormName];
	var qs = ''
	for (e=0;e<theForm.elements.length;e++) 
	{	if (theForm.elements[e].name!='')
		{	if(theForm.elements[e].type == 'radio')
			{	if(theForm.elements[e].checked)
				{	var name = theForm.elements[e].name;
					qs+=(qs=='')?'':'&'
					qs+= name+'='+escape(theForm.elements[e].value);
				}
			}
			else if(theForm.elements[e].type == 'checkbox')
			{	var name = theForm.elements[e].name;
				qs+=(qs=='')?'':'&'
				if(theForm.elements[e].checked)
					qs+= name+'='+escape(theForm.elements[e].value);
				else
					qs+= name+'=';
			}			
			else
			{	var name = theForm.elements[e].name;
				var val = theForm.elements[e].value;
				 if(val.substring(0, 3) == '<p>')
					val = val.substring(3, val.length - 4);
				qs+=(qs=='')?'':'&'
				qs+= name+'='+escape(val);
			}
		}
	}
	return qs
}

function postselect(URL, selectval) 
{	poststr = selectval.name + '=' + selectval.value;
	makerequest('POST', URL, poststr, 'ajaxcontent');
}

function uploadimage(URL, poststr) 
{	poststr = poststr + '&img=' + document.getElementById("uploadFile").value;
	makerequest('POST', URL, poststr, 'imgholder');
}

function startCallback() 
{	return true;
}

function completeimgCallback(response)
{	document.getElementById('imgholder').innerHTML = response;
}

function completedocCallback(response)
{	document.getElementById('docholder').innerHTML = response;
}