// JavaScript Document
// Written by Stephen Hepden
// 
<!--hide from old browsers 
function checkform() {
var valerror = 0;
var valcontactset = 0;
var strErrorMessage = "Please correct the following:\n";
var varfieldvalue = "";

// Check the length of the title field
varfieldvalue = removeWhitespace(document.feedback.title.value);	
if (varfieldvalue == '' )
	{
	valerror = valerror + 1;
	strErrorMessage = strErrorMessage + "Title cannot be empty\n";
	}
// Check the length of the Surname field
varfieldvalue = removeWhitespace(document.feedback.surname.value);	
if (varfieldvalue == '' )
	{
	valerror = valerror + 1;
	strErrorMessage = strErrorMessage + "Surname cannot be empty\n";
	}	
// Check the length of the Address1 field
varfieldvalue = removeWhitespace(document.feedback.address1.value);	
if (varfieldvalue == '' )
	{
	valerror = valerror + 1;
	strErrorMessage = strErrorMessage + "Address1 cannot be empty\n";
	}	
// Check the length of the Town field
varfieldvalue = removeWhitespace(document.feedback.town.value);	
if (varfieldvalue == '' )
	{
	valerror = valerror + 1;
	strErrorMessage = strErrorMessage + "Town cannot be empty\n";
	}		
// Check the length of the County field
varfieldvalue = removeWhitespace(document.feedback.county.value);	
if (varfieldvalue == '' )
	{
	valerror = valerror + 1;
	strErrorMessage = strErrorMessage + "County cannot be empty\n";
	}		
// Check the length of the Postcode field
varfieldvalue = removeWhitespace(document.feedback.postcode.value);	
if (varfieldvalue == '' )
	{
	valerror = valerror + 1;
	strErrorMessage = strErrorMessage + "Postcode cannot be empty\n";
	}		
	
	
// Check email address for certain characters
var sentence=document.feedback.theemail.value;
if (sentence.indexOf("@")!=-1 && sentence.indexOf(".")!=-1)
	{
	//alert("Email Good")		
	}
	else
	{
	//alert("Email Bad")		
	strErrorMessage = strErrorMessage + "Invalid Email Address\n";
	valerror = valerror + 1;
	}


// Now see if the error count is > 0, if so then the validation has failed, abort form submit and prompt user	
if (valerror>0)
	{
	alert (strErrorMessage);
	return false;	
	}
	else
	{
	//alert ('Passed');	
	return true;	
	}

}

function check_newsletter()
{
var valerror = 0;
var valcontactset = 0;
var strErrorMessage = "Please correct the following:\n";
var varfieldvalue = "";

// Check the length of the title field
varfieldvalue = removeWhitespace(document.feedback.title.value);	
if (varfieldvalue == '' )
	{
	valerror = valerror + 1;
	strErrorMessage = strErrorMessage + "Title cannot be empty\n";
	}
// Check the length of the Surname field
varfieldvalue = removeWhitespace(document.feedback.surname.value);	
if (varfieldvalue == '' )
	{
	valerror = valerror + 1;
	strErrorMessage = strErrorMessage + "Surname cannot be empty\n";
	}	
// Check email address for certain characters
var sentence=document.feedback.theemail.value;
if (sentence.indexOf("@")!=-1 && sentence.indexOf(".")!=-1)
	{
	//alert("Email Good")		
	}
	else
	{
	//alert("Email Bad")		
	strErrorMessage = strErrorMessage + "Invalid Email Address\n";
	valerror = valerror + 1;
	}
	
// Now see if the error count is > 0, if so then the validation has failed, abort form submit and prompt user	
if (valerror>0)
	{
	alert (strErrorMessage);
	return false;	
	}
	else
	{
	//alert ('Passed');	
	return true;	
	}	

}


function removeWhitespace(str){
  return str.replace(/^\s+/,"").replace(/\s+$/,"").replace(/\s+/g," ");
}
// -->
