function CheckForm(){
	
	var fieldsArray = new Array();
	
	/* ############### EDIT THESE VARIABLES... ########################################################### */
	
	var formname = "enquiry"; //name of the form
	
	/* list of names of all fields that need validating and their associated labels (as they should appear in alert box) */
	fieldsArray["subject"] = "Nature of enquiry";
	fieldsArray["name"] = "Name";
	fieldsArray["address"] = "Address";
	fieldsArray["postcode"] = "Postcode";
	fieldsArray["telephone"] = "Telephone";
	fieldsArray["email"] = "Email";
	fieldsArray["message"] = "Enquiry";
	fieldsArray["validate"] = "Validation Code";
	
	var emailfieldsArray = new Array(
		/* comma-separated list of names of all email fields that need validating */
		"email"
	);
	
	/* #################################################################################################### */
	
	
	
	
	alertmessage = "";
	

	//Loop through each form field and for each field...
	for (var i=0; i < document.forms[formname].length; i++) {
				
		//...loop through each field in the array of fields to validate.	
		for (var array_item in fieldsArray) {
		
			//If the current form field is in the array of fields to validate... 
			if (document.forms[formname].elements[i].name == array_item) {
				
				//...check if field value is blank.
				if(document.forms[formname].elements[i].value == "") {
					
					alertmessage += '- ' + fieldsArray[array_item]  + '\n';
				
				}
				//If it's not blank...
				else {
					
					//...loop through the array of email fields.
					for (var j=0; j < emailfieldsArray.length; j++) {
				
						//If the current field exists in the array of email fields...
						if (emailfieldsArray[j] == array_item) {
							
							//...validate the email address.
							var email = document.forms[formname].elements[array_item].value;
							invalidChars = " /:,;?()"
							incorrect ='';
							for (k=0; k<invalidChars.length; k++){
								badChar = invalidChars.charAt(k)
								if(email.indexOf(badChar,0) > -1){
									incorrect += '- Invalid Email Address\n';
									break;
								}
							}
							atPos = email.indexOf("@",1)
							if(atPos == -1){
								incorrect += '- Invalid Email Address\n';
							}
							if(email.indexOf("@",atPos+1) > -1){
								incorrect += '- Invalid Email Address\n';
							}
							periodPos = email.indexOf(".",atPos)
							if(periodPos == -1){
								incorrect += '- Invalid Email Address\n';
							}
							if(periodPos+3 > email.length){
								incorrect += '- Invalid Email Address\n';
							}	
							if(incorrect != ''){
								alertmessage += '- Invalid Email Address\n';
							}
							
						}
							
					}	
						
				}
				
			}	
			
		}
		
	}
	
	if(alertmessage == ""){
		return true;
	}	
	else{
		TopMessage = "You have not entered the following form elements correctly: \n\n";
        BottomMessage = "\nPlease correct these fields to continue";
        alertmessage = TopMessage + alertmessage + BottomMessage;
        alert(alertmessage);
		return false;
	}
}


function CheckSampleForm(){
	
	var fieldsArray = new Array();
	
	
	
	
	/* ############### EDIT THESE VARIABLES... ########################################################### */
	
	var formname = "samplerequest"; //name of the form
	
	/* list of names of all fields that need validating and their associated labels (as they should appear in alert box) */
	fieldsArray["use"] = "What do you require a LazyLawn for?";
	fieldsArray["installation"] = "Do you require installation?";
	fieldsArray["name"] = "Name";
	fieldsArray["address"] = "Address";
	fieldsArray["postcode"] = "Postcode";
	fieldsArray["telephone"] = "Telephone";
	fieldsArray["email"] = "Email";
	fieldsArray["validate"] = "Validation Code";
	
	var emailfieldsArray = new Array(
		/* comma-separated list of names of all email fields that need validating */
		"email"
	);
	
	/* #################################################################################################### */
	
	
	
	
	alertmessage = "";
	

	//Loop through each form field and for each field...
	for (var i=0; i < document.forms[formname].length; i++) {
				
		//...loop through each field in the array of fields to validate.	
		for (var array_item in fieldsArray) {
		
			//If the current form field is in the array of fields to validate... 
			if (document.forms[formname].elements[i].name == array_item) {
				
				//...check if field value is blank.
				if(document.forms[formname].elements[i].value == "") {
					
					alertmessage += '- ' + fieldsArray[array_item]  + '\n';
				
				}
				//If it's not blank...
				else {
					
					//...loop through the array of email fields.
					for (var j=0; j < emailfieldsArray.length; j++) {
				
						//If the current field exists in the array of email fields...
						if (emailfieldsArray[j] == array_item) {
							
							//...validate the email address.
							var email = document.forms[formname].elements[array_item].value;
							invalidChars = " /:,;?()"
							incorrect ='';
							for (k=0; k<invalidChars.length; k++){
								badChar = invalidChars.charAt(k)
								if(email.indexOf(badChar,0) > -1){
									incorrect += '- Invalid Email Address\n';
									break;
								}
							}
							atPos = email.indexOf("@",1)
							if(atPos == -1){
								incorrect += '- Invalid Email Address\n';
							}
							if(email.indexOf("@",atPos+1) > -1){
								incorrect += '- Invalid Email Address\n';
							}
							periodPos = email.indexOf(".",atPos)
							if(periodPos == -1){
								incorrect += '- Invalid Email Address\n';
							}
							if(periodPos+3 > email.length){
								incorrect += '- Invalid Email Address\n';
							}	
							if(incorrect != ''){
								alertmessage += '- Invalid Email Address\n';
							}
							
						}
							
					}	
						
				}
				
			}	
			
		}
		
	}
	
	if(alertmessage == ""){
		return true;
	}	
	else{
		TopMessage = "You have not entered the following form elements correctly: \n\n";
        BottomMessage = "\nPlease correct these fields to continue";
        alertmessage = TopMessage + alertmessage + BottomMessage;
        alert(alertmessage);
		return false;
	}
}


function CheckSubscribeForm(){
	
	var fieldsArray = new Array();
	
	
	
	
	/* ############### EDIT THESE VARIABLES... ########################################################### */
	
	var formname = "newsletter"; //name of the form
	
	/* list of names of all fields that need validating and their associated labels (as they should appear in alert box) */
	fieldsArray["email"] = "Email";
	
	var emailfieldsArray = new Array(
		/* comma-separated list of names of all email fields that need validating */
		"email"
	);
	
	/* #################################################################################################### */
	
	
	
	
	alertmessage = "";
	

	//Loop through each form field and for each field...
	for (var i=0; i < document.forms[formname].length; i++) {
				
		//...loop through each field in the array of fields to validate.	
		for (var array_item in fieldsArray) {
		
			//If the current form field is in the array of fields to validate... 
			if (document.forms[formname].elements[i].name == array_item) {
				
				//...check if field value is blank.
				if(document.forms[formname].elements[i].value == "") {
					
					alertmessage += '- ' + fieldsArray[array_item]  + '\n';
				
				}
				//If it's not blank...
				else {
					
					//...loop through the array of email fields.
					for (var j=0; j < emailfieldsArray.length; j++) {
				
						//If the current field exists in the array of email fields...
						if (emailfieldsArray[j] == array_item) {
							
							//...validate the email address.
							var email = document.forms[formname].elements[array_item].value;
							invalidChars = " /:,;?()"
							incorrect ='';
							for (k=0; k<invalidChars.length; k++){
								badChar = invalidChars.charAt(k)
								if(email.indexOf(badChar,0) > -1){
									incorrect += '- Invalid Email Address\n';
									break;
								}
							}
							atPos = email.indexOf("@",1)
							if(atPos == -1){
								incorrect += '- Invalid Email Address\n';
							}
							if(email.indexOf("@",atPos+1) > -1){
								incorrect += '- Invalid Email Address\n';
							}
							periodPos = email.indexOf(".",atPos)
							if(periodPos == -1){
								incorrect += '- Invalid Email Address\n';
							}
							if(periodPos+3 > email.length){
								incorrect += '- Invalid Email Address\n';
							}	
							if(incorrect != ''){
								alertmessage += '- Invalid Email Address\n';
							}
							
						}
							
					}	
						
				}
				
			}	
			
		}
		
	}
	
	if(alertmessage == ""){
		return true;
	}	
	else{
		TopMessage = "You have not entered the following form elements correctly: \n\n";
        BottomMessage = "\nPlease correct these fields to continue";
        alertmessage = TopMessage + alertmessage + BottomMessage;
        alert(alertmessage);
		return false;
	}
}