// William James AJAX Price Lookup

var prodinfo = "";
var prodprice = "";
var prodvid = "";


function getAjaxPrice(){
		
	var x = $F('xvalue');
	var y = $F('yvalue');
	var pid = $F('prodpid');
	
	var url = 'ajpc.php?pid=' + pid + '&x=' + x + '&y=' + y;
	
	//alert(url);
	
	$('working').style.display = 'inline';
	
	var ajax = new Ajax.Updater(
						'ajaxjs',
						url,
						{
							method: 'get',
							evalScripts: true,
							onFailure: reportError,
							onComplete: updateFields
						}
					);

}

function reportError(request) {
	// Handle the error, reset the fields accordingly.
	$('working').style.display = 'none';
	$('prodinfo').innerHTML = "Sorry there was an error";
	$('prodprice').innerHTML = "---";
	$('prodvid').value = 0;

}

function updateFields(request) {
	// Update the bits we need.
	// We should have vars for prodinfo, prodprice and prodvid
	$('working').style.display = 'none';
	//$('prodinfo').innerHTML = prodinfo;
	//$('prodprice').value = prodprice;
	//$('prodvid').value = prodvid;
	
}
