


	// javascript checking for the cart form
	// on the products.php page ...
	function cartForm(orderform) 
	{
   	var why = "";
		why += checkQty(orderform.qty.value);
   	if (why != "") {
      	 alert(why);
       	return false;
  	   }
		else
		{
			return true;
		}
	}

	function checkQty(strng)
	{
		var error = "";
		if (strng == "")
		{
			error = "Please enter a Quantity.\n";
		}
		else if (parseInt(strng) != strng)
		{
			error = "Quantity is not a number.\n";
		}
		return error;
	}



	// javascript checking for the customer form
	// on the checkout.php page ...
	function checkForm(theForm) 
	{
   	var why = "";
		why += checkLast(theForm.last.value);
		why += checkAddress(theForm.address.value);
		why += checkTown(theForm.town.value);
		why += checkState(theForm.state.value);
		why += checkPostcode(theForm.postcode.value);
		why += checkCountry(theForm.country.value);
		why += checkEmail(theForm.emailaddress.value);
		why += checkPhone(theForm.phone.value);
		why += checkPaymethod(theForm.paymethod.value);
   	if (why != "") {
      	 alert(why);
       	return false;
  	   }
		else
		{
			return true;
		}
	}

	function checkLast(strng)
	{
		var error = "";
		if (strng == "")
		{
			error = "Please enter a Last / Company Name.\n";
		}
		return error;
	}

	function checkAddress(strng)
	{
		var error = "";
		if (strng == "")
		{
			error = "Please enter an Address.\n";
		}
		return error;
	}

	function checkTown(strng)
	{
		var error = "";
		if (strng == "")
		{
			error = "Please enter a Town.\n";
		}
		return error;
	}

	function checkState(strng)
	{
		var error = "";
		if (strng == "")
		{
			error = "Please enter a State.\n";
		}
		else if (strng.length < 2)
		{
			error = "State is less than 2 characters.\n";
		}
		return error;
	}

	function checkPostcode(strng)
	{
		var error = "";
		if (strng == "")
		{
			error = "Please enter a Postcode.\n";
		}
		else if (parseInt(strng) != strng)
		{
			error = "Postcode is not a number.\n";
		}
		return error;
	}

	function checkCountry(strng)
	{
		var error = "";
		if (strng == "")
		{
			error = "Please enter a Country.\n";
		}
		return error;
	}

	function checkEmail(strng)
	{
		var error = "";
		var emailFilter=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/
		if (strng == "")
		{
			error = "Please enter an Email Address.\n";
		}
		else if (strng.match(illegalChars)) 
		{
		   error = "The email address contains illegal characters.\n";
		}
		else if (!(emailFilter.test(strng))) 
		{ 
	       error = "Please enter a valid email address.\n";
	   }
		return error;
	}

	function checkPhone(strng)
	{
		var error = "";
		if (strng == "")
		{
			error = "Please enter a Phone Number.\n";
		}
		return error;
	}

	function checkPaymethod(strng)
	{
		var error = "";
		if (strng == "")
		{
			error = "Please select a Payment Method.\n";
		}
		return error;
	}

