var XHR;

function CreateRequest() {
	if (window.XMLHttpRequest) {return new XMLHttpRequest();}
	else if (window.ActiveXObject) { return new ActiveXObject("Microsoft.XMLHTTP");}
}

function callSort(sql,showCats){
	var ts = new Date().getTime();
	var url = "inc/ReSort.asp?sql="+encodeURIComponent(sql)+"&showCats="+encodeURIComponent(showCats)+"&ts="+encodeURIComponent(ts);
	XHR = CreateRequest();
	XHR.onreadystatechange = DisplaySort;
	XHR.open("GET",url,true);
	XHR.send(null)	
}

function DisplaySort(){
	if (XHR.readyState==4 && XHR.status==200) {
		var html = XHR.responseText;
		if (html != "" && html != null) {
			var div = document.getElementById("inventoryresults");
			while (div.childNodes.length > 0) {div.removeChild(div.childNodes[0]);}
			div.innerHTML = html;
		}
	}
}