/*
	Shopping cart form routines
*/

function ProcessCart()
{	
	if(ValidateCartForm())
	{
		document.frmShopCart.submit();
	}
}

function GoCatalog(url)
{
	if(url=="")
		document.location="/";
	else
		document.location=unescape(url);
}

function ValidateCartForm()
{
	
	var frm=document.frmShopCart;
	var len=frm.length;
	var cur_name="";
	var upos;
	
	for(var i=0;i<len;i++)
	{
		cur_name=frm.elements[i].name;
		
		upos=cur_name.lastIndexOf("_q");
		//alert("name="+cur_name+"; upos="+upos.toString()+"; length="+cur_name.length.toString());
		if(upos!=-1 && cur_name.length==upos+2)
		{
			if(!CheckNumeric(frm.elements[i].value) || frm.elements[i].value=="" || frm.elements[i].value=="0")
			{
				alert("Product quantity should be a positive integer.\n");
				frm.elements[i].focus();
				return false;
			}
		}
		
	}
	
	return true;
}