function setQueryString(ArrNames,ArrVals){
 //initialize the top-level variable; also reset the variable to cover when
 //the user clicks multiple times
 queryString="";
 if(ArrNames==undefined || ArrVals==undefined){
 	return;
 }
 var numberElements = ArrNames.length;
 queryArr = new Array;
 for(var i = 0; i < numberElements; i++) {
 		queryArr[i] = ArrNames[i]+"="+ArrVals[i];
 }
 queryString += queryArr.join("&");
}


var request;
var queryString; //will hold the POSTed data
var Method;
var TargetId;

function sendData(url,Method){
 if(url==undefined){
 	url = '';
 }
 if(Method==undefined){
 	Method='POST';
 }
 httpRequest(Method,url,true);
}

/* Initialize a Request object that is already constructed
 reqType: The HTTP request type such as "GET" or "POST." 
 url: The URL of the server program.
 isAsynch: Whether to send the request asynchronously or not. */
function initReq(reqType,url,isAsynch){
 /* Specify the function that will handle the HTTP response */
 request.onreadystatechange=handleResponse;
 if(reqType=="POST"){
 	request.open(reqType,url,isAsynch);
 	/* set the Content-Type header for a POST request */
	request.setRequestHeader("Content-Type",
 	"application/x-www-form-urlencoded; charset=UTF-8");
 	request.send(queryString);
 } else {
 	request.open(reqType,url+"?"+queryString);
 	/* set the Content-Type header for a POST request */
 	request.send(null);
 }
}

/* Wrapper function for constructing a Request object.
 Parameters:
 reqType: The HTTP request type such as GET or POST.
 url: The URL of the server program.
 asynch: Whether to send the request asynchronously or not. */

function httpRequest(reqType,url,asynch){
//Mozilla-based browsers
	if (window.ActiveXObject){
		request=new ActiveXObject("Msxml2.XMLHTTP");
		if (! request){
			request=new ActiveXObject("Microsoft.XMLHTTP");
		}
		if(request){
			initReq(reqType,url,asynch);
			/* Unlikely to branch here, as IE uses will be able to use either one of the constructors*/
		} else {
			alert("Your browser does not permit the use of all "+"of this application's features!");}
	} else if(window.XMLHttpRequest){
		request = new XMLHttpRequest();
		initReq(reqType,url,asynch);
	} else {
		alert("Your browser does not permit the use of all "+"of this application's features!");
	}
}


//event handler for XMLHttpRequest
function handleResponse(){
//	alert("request.readyState: "+request.readyState);
//	alert("request.status: "+request.status);
 if(request.readyState == 4){
 	if(request.status == 200){
	
		if(document.getElementById(TargetId)){
	 		document.getElementById(TargetId).innerHTML = request.responseText;
	 	} else {
	 		ReturnedData = request.responseText;
	 	}
	 	
	 } else {
	 	
 		ReturnedData = 'NoConnection';
// alert("A problem occurred with communicating between "+ "the XMLHttpRequest object and the server program.");
	 }
 }
}