
	
	// holds an instance of XMLHttpRequest
var pxmlHttp = createXmlHttpRequestObject();
// creates an XMLHttpRequest instance
function createXmlHttpRequestObject()
{
// will store the reference to the XMLHttpRequest object
var pxmlHttp;
// this should work for all browsers except IE6 and older
try
{
// try to create XMLHttpRequest object
pxmlHttp = new XMLHttpRequest();
}
catch(e)
{
// assume IE6 or older
try
{
pxmlHttp = new ActiveXObject("Microsoft.XMLHttp");
}
catch(e) { }
}
// return the created object or display an error message
if (!pxmlHttp)
alert("Error creating the XMLHttpRequest object.");
else
return pxmlHttp;
}
	// called to read a file from the server
	function check(val)
	{
		
		if(val == 2)
		{
				
				if(document.frmtype.txtzip.value == "")
				{
					alert("Please Enter a ZIP Code");
					document.frmtype.txtzip.focus();
					return false;
				}
		}
		
				document.frmtype.val.value = val;
		
		var shipbool = false;
		var ship;
		var zip;
		var weight;
		
		var product = document.frmtype.product.value;
		var type = document.frmtype.type.value;
		var size = document.frmtype.size.value;
		var pages = document.frmtype.pages.value;
		var cover = document.frmtype.cover.value;
		var material = document.frmtype.material.value;
		var color = document.frmtype.color.value;
		var quantity = document.frmtype.quantity.value;
		var style = document.frmtype.style.value;
		var slot = document.frmtype.slot.value;
		//var turnaround = document.frmtype.turnaround.value;
		var binding = document.frmtype.binding.value;
		zip = document.frmtype.txtzip.value;
		weight = document.frmtype.weight.value;
		shipcost = document.frmtype.txtshipping.value;
		
		var mcount = document.frmtype.mcount.value;
		
		var check=0;
		
		
		
		if(document.frmtype.turnaround.length != undefined)
		{
		for(var a=0;a<= document.frmtype.turnaround.length-1;a++)
			{
				
				if(document.frmtype.turnaround[a].checked == true)
				{
					var turnaround = eval('document.frmtype.turnaround['+a+'].value');
				}
				
			}
		}
		else
		{
				
					var turnaround = document.frmtype.turnaround.value;
				
		}
		
			
		for(i=1;i<=mcount;i++)
			{
			
				if(document.frmtype.ship[i].checked == true)
				{
					ship = eval('document.frmtype.ship['+i+'].value');
					check =1;
				}
			}
			
		
		
	// only continue if xmlHttp isn't void
	if (pxmlHttp)
	{
	// try to connect to the server
	try
	{
	

	
	pxmlHttp.open("GET", "ajaxclassproduct3.php?val="+val+"&product="+product+"&type="+type+"&size="+size+"&pages="+pages+"&cover="+cover+"&material="+material+"&color="+color+"&quantity="+quantity+"&style="+style+"&slot="+slot+"&turnaround="+turnaround+"&binding="+binding+"&ship="+ship+"&zip="+zip+"&weight="+weight+"&shipcost="+shipcost, true);
	pxmlHttp.onreadystatechange = handleRequestStateChangeProd;
	pxmlHttp.send(null);
	}
	// display the error in case of failure
	catch (e)
	{
	alert("Can't connect to server:\n" + e.toString());
	}
	}
	}
	
	function handleRequestStateChangeProd()
	{
	
	if (pxmlHttp.readyState == 1)
	{
		if(document.frmtype.val.value == 1 || document.frmtype.val.value == 3)
		{
				document.frmtype.txtprice.value = "Loading Price.... ";
				
		}
	}
	
	else if (pxmlHttp.readyState == 4)
	{
			
		// continue only if HTTP status is "OK"
	//	document.getElementById("div_loading").style.display = "none";
		if (pxmlHttp.status == 200)
		{
				
			try
			{
			
			prod_response = pxmlHttp.responseText;
			prod_response = prod_response.replace(/^\s+/g, '').replace(/\s+$/g, '');
			check_handle(prod_response);
			
			
			
			/////////////////////////////////////////// END TRY /////////////////////////////
			}
			catch(e)
			{
				
				if(prod_response == '' || prod_response == '0^0' || prod_response == '0' )
				{
		document.getElementById("total").style.display="none";
		document.getElementById("noship").style.display="block";
		//document.frmtype.txtprice.value = result;
		document.frmtype.txtprice2.value = document.frmtype.txtprice.value;
		
			
		document.getElementById("shippingrate").style.display="none";
		//document.getElementById("cart").style.display="none";
		document.getElementById("calc").style.display="block";
		
		document.frmtype.txtshipping.value = "";
		document.frmtype.txtshipping1.value = "";
				}
		
			}
		}
		else
		{
			// display status message
		alert("There was a problem retrieving the data:\n" +
		pxmlHttp.statusText);
		}
	}
}
	
	



