// JavaScript Document
//Browser Support Code
function ajaxFunction()
{
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try
	{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer Browsers
		try
		{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				// Something went wrong
				alert("This function requires the use of Javascript. Please enable Javascript from the Tools menu of your web browser. We apologize for any inconvenience.");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function()
	{
		if(ajaxRequest.readyState == 4  && ajaxRequest.status == 200)
		{
			document.getElementById('searchbox').innerHTML = ajaxRequest.responseText;
			//document.getElementById("ajaxstatus").innerHTML= "Find The Perfect Wine";
		}
		
		if(ajaxRequest.readyState!=4)
		{
			//document.getElementById("ajaxstatus").innerHTML= "One moment please ...";
		}
	}
	
	//var sid = document.getElementById('sid').value; // regions or subcat
	//var wtid = document.getElementById('wtid').value; // wine types
	//var mid = document.getElementById('mid').value; // wineries or manufacturers
	//var gid = document.getElementById('gid').value; // grapes
//	var btls = document.getElementById('btls').value; // btls per case
	var cid = document.getElementById('cid').value; // vintage or year
//	var price = document.getElementById('price').value; // bottle price
	var wsid = document.getElementById('wsid').value; // wine style type colour
	var pr = document.getElementById('pr').value; // wine price range
//	var spid = document.getElementById('spid').value; // wine delivery region
	
	//var queryString = "?sid=" + sid + "&wtid=" + wtid + "&mid=" + mid + "&gid=" + gid + "&btls=" + btls + "&vin=" + vin + "&wsid=" + wsid + "&price=" + price + "&spid=" + spid + "&rannum="+Math.random()
	//var queryString = "?sid=" + sid + "&mid=" + mid + "&gid=" + gid + "&vin=" + vin + "&wsid=" + wsid + "&pr=" + pr + "&rannum="+Math.random();
	var queryString = "?cid=" + cid + "&wsid=" + wsid + "&pr=" + pr + "&rannum="+Math.random();
	ajaxRequest.open("GET", "includes/searchbox_inc.php" + queryString, true);
	ajaxRequest.send(null);
}

