/*
This can be loaded in the HTML code like so...
<script language="javascript" type="text/javascript" src="ajax_request.js">
</script>
*/

/*
The following function creates an XMLHttpRequest object... 
It determines which call is appropriate for the browser and returns the object
*/
function createRequestObject()
{
	var request_o; //declare the variable to hold the object.
	var browser = navigator.appName; //find the browser name
	if(browser == "Microsoft Internet Explorer"){
		/* Create the object using MSIE's method */
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		/* Create the object using other browser's method */
		request_o = new XMLHttpRequest();
	}
	return request_o; //return the object
}

/*
You can get more specific with version information by using 
parseInt(navigator.appVersion)
Which will extract an integer value containing the version 
of the browser being used.

The variable http will hold our new XMLHttpRequest object.
*/
var http = createRequestObject(); 

/*  **********************************************************  */
function UpdateShoppingCart(isbn,qty)
{
	http.open('get', 'ajax_request.php?action=update_sc&isbn=' + isbn + '&qty=' + qty);
	/* Define a function to call once a response has been received. This will be our
		handleResponse function that we define below. */
//	http.onreadystatechange = showTitle(descid); 
	http.onreadystatechange = function() {
//location.reload(true);
	/* Nothing visible to show
		var response = http.responseText;
		delim = response.search('~');
		document.getElementById('booktitle').value  = response.substr(0,delim);
		document.getElementById('bookauthor').value = response.substr(delim+1);
	*/
}
	/* Send the data. We use something other than null when we are sending using the POST method. */
	http.send(null);
}
