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.pspCustomerEmail.value == "" )
  {
    errorMsg += 'An email address is required\n';
	form.pspCustomerEmail.focus();
  }
  else
  {
	x = form.pspCustomerEmail.value.indexOf('@');
	y = form.pspCustomerEmail.value.indexOf('.');

    if (x < 1 || x == (form.pspCustomerEmail.value.length-1) || y < 1 ) 
	{
	  errorMsg += 'You must give a valid email address.\n';
	  form.pspCustomerEmail.focus();
	  form.pspCustomerEmail.select();
	}
	  
    s = form.pspCustomerEmail.value.indexOf(' ');
    if (s != -1)
	{
	  errorMsg += 'Please check the email address. It should not contain spaces\n';
	  form.pspCustomerEmail.focus();
	  form.pspCustomerEmail.select();
	}
  }
  	
  if (form.pspCustomerFirstName.value == "" )
  {
    errorMsg += 'Your forename is required\n';
	form.pspCustomerFirstName.focus();
	form.pspCustomerFirstName.select();
   }
	
  if (form.pspCustomerLastName.value == "" )
  {
    errorMsg += 'Your surname is required\n';
	form.pspCustomerLastName.focus();
	form.pspCustomerLastName.select();
  }
	
 if (form.pspCustomerAddress.value == "" )
 {
    errorMsg += 'A delivery address is required\n';
	form.pspCustomerAddress.focus();
	form.pspCustomerAddress.select();
 }
 
  if (form.pspCustomerPostcode.value == "" )
 {
    errorMsg += 'A Postcode or Zipcode is required\n';
	form.pspCustomerPostcode.focus();
	form.pspCustomerPostcode.select();
 }	
	

  if (form.overseas.value == "Y" )
  {
    if (((form.country.options[form.country.selectedIndex].value).toUpperCase()).indexOf("UK") == 0)
    {
       errorMsg += 'You have selected an international delivery to a UK address\n';
	     form.country.focus();
		}
  }
	else
	{
    if (((form.country.options[form.country.selectedIndex].value).toUpperCase()).indexOf("UK") < 0)
    {
       errorMsg += 'You have selected UK delivery to an international 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 == '');
}
 // Below is for recommend form data checking
function validateFormData2(form) 
{
  //alert('Checking form...');
  var errorMsg = '';
  
  // Test that all the required fields are filled out ok
  	
  if (form.To.value == "" )
    errorMsg += 'A Recipients first name (Dear ...) is required\n';
  	
  if (form.From.value == "" )
    errorMsg += 'Your own first name (Signed...)  is required\n';

  if (form.Email.value == "" )
  {
    errorMsg += 'An email (To...) 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 (errorMsg) 
	alert('Required form fields:\n'+errorMsg);
  document.returnValue = (errorMsg == '');
}
 // Below is for contact us form data checking
function validateQueryForm(form) 
{
  //alert('Checking form...');
  var errorMsg = '';
  
  // Test that all the required fields are filled out ok
  	
  if (form.name.value == "" )
    errorMsg += 'Your name is required\n';
  	
  if (form.address.value == "" )
    errorMsg += 'Your address is required\n';
	
  if (form.query.value == "" )
    errorMsg += 'Please tell us the nature of your enquiry\n';
  	
  if (form.phone.value == "" )
    errorMsg += 'Your phone number is required\n';

  if (form.Email.value == "" )
  {
    errorMsg += 'An 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 (errorMsg) 
	alert('Required form fields:\n'+errorMsg);
  document.returnValue = (errorMsg == '');
}
