function validateFormData(form) 
{
  //alert('Checking form...');
  var errorMsg = '';
  
  // Test that all the required fields are filled out ok
  
  if (form.email.value == "" )
  {
    errorMsg += 'Your email address is required\n';
	form.email.focus();
  }
  else
  {
	x = form.email.value.indexOf('@');
	y = form.email.value.indexOf('.');

    if (x < 1 || x == (form.email.value.length-1) || y < 1 ) 
	{
	  errorMsg += 'You must give a valid email address.\n';
	  form.email.focus();
	  form.email.select();
	}
	  
    s = form.email.value.indexOf(' ');
    if (s != -1)
	{
	  errorMsg += 'Please check your email address. It should not contain spaces\n';
	  form.email.focus();
	  form.email.select();
	}
  }
  	
  if (form.firstname.value == "" )
    errorMsg += 'Your first name is required\n';
	
  if (form.tel.value == "" )
    errorMsg += 'Your telephone number is required\n';
	
   if (errorMsg) 
	alert('Required form fields:\n'+errorMsg);
  document.returnValue = (errorMsg == '');
}


function validateOrderForm(form) 
{
  //!! alert('Checking form...');
  var errorMsg = '';
  
  // Test that all the required fields are filled out ok
  
  if (form.ewayCustomerEmail.value == "" )
  {
    errorMsg += 'An email address is required\n';
	form.ewayCustomerEmail.focus();
  }
  else
  {
	x = form.ewayCustomerEmail.value.indexOf('@');
	y = form.ewayCustomerEmail.value.indexOf('.');

    if (x < 1 || x == (form.ewayCustomerEmail.value.length-1) || y < 1 ) 
	{
	  errorMsg += 'You must give a valid email address.\n';
	  form.ewayCustomerEmail.focus();
	  form.ewayCustomerEmail.select();
	}
	  
    s = form.ewayCustomerEmail.value.indexOf(' ');
    if (s != -1)
	{
	  errorMsg += 'Please check the email address. It should not contain spaces\n';
	  form.ewayCustomerEmail.focus();
	  form.ewayCustomerEmail.select();
	}
  }
  	
  if (form.ewayCustomerFirstName.value == "" )
  {
    errorMsg += 'Your forename is required\n';
	form.ewayCustomerFirstName.focus();
	form.ewayCustomerFirstName.select();
   }
	
  if (form.ewayCustomerLastName.value == "" )
  {
    errorMsg += 'Your surname is required\n';
	form.ewayCustomerLastName.focus();
	form.ewayCustomerLastName.select();
  }
	
 if (form.ewayCustomerAddress.value == "" )
 {
    errorMsg += 'A delivery address is required\n';
	form.ewayCustomerAddress.focus();
	form.ewayCustomerAddress.select();
 }
 
  if (form.ewayCustomerPostcode.value == "" )
 {
    errorMsg += 'A Postcode or Zipcode is required\n';
	form.ewayCustomerPostcode.focus();
	form.ewayCustomerPostcode.select();
 }	
	

  if (form.overseas.value == "Y" )
  {
    if (((form.country.options[form.country.selectedIndex].value).toUpperCase()).indexOf("AUSTRALIA") == 0)
    {
       errorMsg += 'You have selected overseas delivery to a mainland Australian address\n';
	     form.country.focus();
		}
  }
	else
	{
    if (((form.country.options[form.country.selectedIndex].value).toUpperCase()).indexOf("AUSTRALIA") < 0)
    {
       errorMsg += 'You have selected Australian delivery to an overseas address\n';
	     form.country.focus();
		}
	}
	
	if (form.Tel.value == "" )
    {
    errorMsg += 'Please give a telephone number where we can reach you\n';
	form.Tel.focus();
	form.Tel.select();
    }
	
   if (!form.termsconditions.checked)
  	errorMsg += 'Please indicate that you are in agreement with our Terms & Conditions\n';

	
  if (errorMsg) 
	alert('Required form fields:\n'+errorMsg);
	
  document.returnValue = (errorMsg == '');
}
