
//Check QTY value entered is on numerical and is not blank
function validate(frm) {
  
    if (frm.qty.value.length == 0)
    {
        alert("Please enter the quantity you require.")
        frm.qty.focus()
        return false;
    }
	
	if (frm.qty.value == '0')
    {
        alert("Please enter a quantity greater than 0")
        frm.qty.focus()
        return false;
    }
	
 var iChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
        for (var i = 0; i < frm.qty.value.length; i++) {
                if (iChars.indexOf(frm.qty.value.charAt(i)) != -1) {
                alert ("The quantity you have entered is not a numerical value. \n Please try again");
				 frm.qty.focus();
				 frm.qty.value = "";
                return false;
        }
                }
			return true;
}



//Check email address confirms to standard layout
function isEmailAddr(email)
{
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}



//Check customer details form is completed
function validateDetails(frm) {

    if (frm.name.value.length == 0)
    {
        alert("Please enter your Name.")
        frm.name.focus()
        return false
    }


    if (frm.email.value.length == 0)
    {
        alert("Please enter your email address.")
        frm.email.focus()
        return false
    }
	
  	if (!isEmailAddr(frm.email.value))
  	{
    	alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    	frm.email.focus();
    	return (false);
  	}



    if (frm.country.value == 'Please select a country')
    {
        alert("Please select a Country.")
        frm.country.focus()
        return false
    }
  	
}



