// JavaScript Document
function checkdigit(e)
{
	if(window.event)
  {
		if((event.keyCode>=48 && event.keyCode<=57) || event.keyCode == 8 || event.keyCode == 13 || event.keyCode == 0) 
		{
			return true;	
		}
		else
		{	
			event.keyCode=0;
			//alert("Only numbers are allowed");
			return false;
		}
	}
	else
  {
		key = e.which;     //firefox
		if((key >=48 && key <= 57) || key == 8 || key == 13 || key == 0) 
		{
			return true;	
		}
		else
		{	
			key=0;
			//alert("Only numbers are allowed");
			return false;
		}
	}

}
function validate_productdetail(frm)
{
	if (!checkInt(frm.hdnqty.value) || frm.hdnqty.value == 0)
	{
		alert("Invalid quantity.");
		return false;
	}
	frm.action = "shoppingcart_db.php";
}

function addtocart(frm, qty, pid, price)
{
	if (!checkInt(qty) || qty == 0)
	{
		alert("Invalid quantity.");
		return false;
	}
	
	frm.hdnqty.value = qty;
	frm.hdnproductid.value = pid;
	frm.hdnproductprice.value = price;
	frm.action = "shoppingcart_db.php";
	
}
function updatecart(frm, pid, qty)
{
	if (!checkInt(qty) || qty == 0)
	{
		alert("Invalid quantity.");
		return false;
	}
	frm.hdnproductid.value = pid;
	frm.hdnqty.value = qty;
	frm.mode.value = "update";
	frm.action = "shoppingcart_db.php";
}
function deleteitem(frm, pid)
{
	if (confirm("Are you sure you want to remove product from cart?"))
	{
		frm.hdnproductid.value = pid;
		frm.mode.value = "delete";
		frm.action = "shoppingcart_db.php";
	}
	else
		return false;
}
function printlisting()
{
	//var url;
	//url = "compressed-air-product-listing-print.php?cmblimit="+document.frm.cmblimit.value+"&frmhdnorderby="+document.frm.frmhdnorderby.value+"&frmhdnorder="+document.frm.frmhdnorder.value+"&cmborderby="+document.frm.cmborderby.value;
	//window.open(url,"ProductListPrint","status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no");
	document.frm.action = "compressed-air-product-listing-print.php";
	document.frm.target = "_blank";
	document.frm.submit();
	document.frm.action = "";
	document.frm.target = "";
	
}