function makeRequest(url, callback, postParms) { 
	var httpRequest; 
	if (window.XMLHttpRequest) {
       		// Mozilla, Safari, ... 
		httpRequest = new XMLHttpRequest(); 
		if (httpRequest.overrideMimeType) { 
			httpRequest.overrideMimeType('text/plain'); 
			// See note below about this line 
		} 
	} else if (window.ActiveXObject) { 
		// IE 
		try { 
			httpRequest = new ActiveXObject("Msxml2.XMLHTTP"); 
		} catch (e) { 
			try { 
				httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); 
			} catch (e) {} 
		} 
	} 
	
	if (!httpRequest) { 
		alert('Giving up  Cannot create an XMLHTTP instance'); 
		return false; 
	} 
	httpRequest.onreadystatechange = function() { alertContents(httpRequest, callback); }; 
	if(postParms === undefined){
		httpRequest.open('GET', url, true);
       		httpRequest.send('');
	} else {
		httpRequest.open('POST', url, true);
		httpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		httpRequest.setRequestHeader("Content-length", postParms.length);
		httpRequest.setRequestHeader("Connection", "close");
       		httpRequest.send(postParms);
	}
} 

function alertContents(httpRequest, callback) { 
	if (httpRequest.readyState == 4) { 
		if (httpRequest.status == 200) { 
			//alert(httpRequest.responseText); 
			callback(httpRequest.responseText); 
		} else { 
			//alert('There was a problem with the request.'); 
		} 
	} 
}

function URLEncode (clearString) { 
	var output = ''; 
	var x = 0; 
	clearString = clearString.toString(); 
	var regex = /(^[a-zA-Z0-9_.]*)/; 
	while (x < clearString.length) { 
		var match = regex.exec(clearString.substr(x)); 
		if (match != null && match.length > 1 && match[1] != '') { 
			output += match[1]; 
			x += match[1].length; 
		} else { 
			if (clearString[x] == ' ') 
				output += '+'; 
			else { 
				var charCode = clearString.charCodeAt(x); 
				var hexVal = charCode.toString(16); 
				output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase(); 
			} x++; 
		} 
	} 
	return output;
}
