/* This implementation of the XMLHttpRequest object is taken from digg.com */
var xmlhttp
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
	try {
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
	} catch (e) {
		try {
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	} catch (E) {
		xmlhttp=false
	}
}
@else
	xmlhttp=false
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false
	}
}
function myXMLHttpRequest() {
	var xmlhttplocal;
	try {
		xmlhttplocal= new ActiveXObject("Msxml2.XMLHTTP")
	} catch (e) {
		try {
			xmlhttplocal= new ActiveXObject("Microsoft.XMLHTTP")
		} catch (E) {
			xmlhttplocal=false;
		}
	}

	if (!xmlhttplocal && typeof XMLHttpRequest!='undefined') {
		try {
			var xmlhttplocal = new XMLHttpRequest();
		} catch (e) {
			var xmlhttplocal=false;
			alert('couldn\'t create xmlhttp object');
		}
	}
	return(xmlhttplocal);
}



function showList()
{
	var category = document.getElementById('category').value;

	var url="/content/getList.php?cat=";
	url=url+category;

	xmlhttp.open("GET", url, true);

	xmlhttp.onreadystatechange = displayItems;
	xmlhttp.send(null);
}


/* Function called to handle the list that was returned from the internal_request.php file.. */
function displayItems(){
	/* Make sure that the transaction has finished. The XMLHttpRequest object
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(xmlhttp.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of
			the XMLHttpRequest object. */

		var response = "";

		response = response + xmlhttp.responseText;
		
		/* And now we want to change the <div> content.
			we do this using an ability to get/change the content of a page element
			that we can find: innerHTML. */
		document.getElementById('shopslist').innerHTML = response;
	}
}
