/*

	Javascript functions for product module

*/


/***********************************************
	validate the input before adding to the shopping cart
	eg: colour, size, quantity
**************************************************/
function ValidateCart(ProductID)
{
	var AddToCart
	AddToCart = true;
	if (document.getElementById("QuanityInput"))
	{
		if (document.getElementById("QuanityInput").value == "")
		{
			AddToCart = false;
			alert("Please enter the quantity.");
		}
		else
		{
			if (isNaN(document.getElementById("QuanityInput").value))
			{
				AddToCart = false;
				alert("Quantity can not be non-numeric value.");
			}
			else
			{
				if (parseInt(document.getElementById("QuanityInput").value) <= 0)
				{
					AddToCart = false;
					alert("Quantity must be positive number.");
				}
			}
		}
	}

	if (document.getElementById("ColourSelector"))
	{
		if(document.getElementById("ColourSelector").value=="")
		{
			AddToCart = false;
			alert("Please Select Colour.");
		}
	}

	if (document.getElementById("SizeSelector"))
	{
		if(document.getElementById("SizeSelector").value=="")
		{
			AddToCart = false;
			alert("Please Select Size.");
		}
	}

	if (AddToCart == true)
	{
		if(document.getElementById("AddToCart_" + ProductID)) 
		{
			document.getElementById("AddToCart_" + ProductID).submit();
		}
		else
		{
			alert('shopping cart form not found');
		}
	}

}
