// validation

function emailValidate(email) 
{
     var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
     var regex = new RegExp(emailReg);
     return regex.test(email);
}

function checkFields() {
							
missinginfo = "";
							
				
if(document.contact.name.value == "") {
missinginfo += "\n     -  Name";
}

if(document.contact.telephone.value == "") {
missinginfo += "\n     -  Telephone";
}

if(!emailValidate(document.contact.email.value)) {
missinginfo += "\n     -  Email";
}

if(document.contact.enquiry.value == "") {
missinginfo += "\n     -  Enquiry";
}
							
			
							
if (missinginfo != "") {
missinginfo ="_____________________________\n" +
"You have not correctly filled in your:\n" +
missinginfo + "\n_____________________________" +
"\nPlease re-enter and submit again";
							
alert(missinginfo);
							
return false;
}
else return true;
}


function contactValidate(myForm)
{
	var error = '';
	if(myForm.name.value == '')
	{
		error += '- Please enter your name.\n';
	}
	if(myForm.company.value == '')
	{
		error += '- Please enter your company name.\n';
	}
	if(!emailValidate(myForm.email.value))
	{
		error += '- Please enter a valid email address.\n';
	}
	if(myForm.tel.value == '')
	{
		error += '- Please enter your phone number.\n';
	}
	if(myForm.enquiry.value == '')
	{
		error += '- Please enter your message.\n';
	}
	if(error != '')
	{
		error = 'The form has not been completed correctly:\n' + error;
		alert(error);
		return false;
	}
	else
	{
	return true;
	}
}


function qValidate(myForm)
{
	var error = '';
	
// Questions
Opt = -1; for (i=myForm.q1.length-1; i > -1; i--) {if (myForm.q1[i].checked) {Opt = i; i = -1;}}if (Opt == -1) {error += '- You have not answered Question 1.\n';}
Opt = -1; for (i=myForm.q2.length-1; i > -1; i--) {if (myForm.q2[i].checked) {Opt = i; i = -1;}}if (Opt == -1) {error += '- You have not answered Question 2.\n';}
Opt = -1; for (i=myForm.q3.length-1; i > -1; i--) {if (myForm.q3[i].checked) {Opt = i; i = -1;}}if (Opt == -1) {error += '- You have not answered Question 3.\n';}
Opt = -1; for (i=myForm.q4.length-1; i > -1; i--) {if (myForm.q4[i].checked) {Opt = i; i = -1;}}if (Opt == -1) {error += '- You have not answered Question 4.\n';}
Opt = -1; for (i=myForm.q5.length-1; i > -1; i--) {if (myForm.q5[i].checked) {Opt = i; i = -1;}}if (Opt == -1) {error += '- You have not answered Question 5.\n';}
Opt = -1; for (i=myForm.q6.length-1; i > -1; i--) {if (myForm.q6[i].checked) {Opt = i; i = -1;}}if (Opt == -1) {error += '- You have not answered Question 6.\n';}
Opt = -1; for (i=myForm.q7.length-1; i > -1; i--) {if (myForm.q7[i].checked) {Opt = i; i = -1;}}if (Opt == -1) {error += '- You have not answered Question 7.\n';}
Opt = -1; for (i=myForm.q8.length-1; i > -1; i--) {if (myForm.q8[i].checked) {Opt = i; i = -1;}}if (Opt == -1) {error += '- You have not answered Question 8.\n';}
Opt = -1; for (i=myForm.q9.length-1; i > -1; i--) {if (myForm.q9[i].checked) {Opt = i; i = -1;}}if (Opt == -1) {error += '- You have not answered Question 9.\n';}
Opt = -1; for (i=myForm.q10.length-1; i > -1; i--) {if (myForm.q10[i].checked) {Opt = i; i = -1;}}if (Opt == -1) {error += '- You have not answered Question 10.\n';}
Opt = -1; for (i=myForm.q11.length-1; i > -1; i--) {if (myForm.q11[i].checked) {Opt = i; i = -1;}}if (Opt == -1) {error += '- You have not answered Question 11.\n';}
Opt = -1; for (i=myForm.q12.length-1; i > -1; i--) {if (myForm.q12[i].checked) {Opt = i; i = -1;}}if (Opt == -1) {error += '- You have not answered Question 12.\n';}
Opt = -1; for (i=myForm.q13.length-1; i > -1; i--) {if (myForm.q13[i].checked) {Opt = i; i = -1;}}if (Opt == -1) {error += '- You have not answered Question 13.\n';}
Opt = -1; for (i=myForm.q14.length-1; i > -1; i--) {if (myForm.q14[i].checked) {Opt = i; i = -1;}}if (Opt == -1) {error += '- You have not answered Question 14.\n';}
Opt = -1; for (i=myForm.q15.length-1; i > -1; i--) {if (myForm.q15[i].checked) {Opt = i; i = -1;}}if (Opt == -1) {error += '- You have not answered Question 15.\n';}
Opt = -1; for (i=myForm.q16.length-1; i > -1; i--) {if (myForm.q16[i].checked) {Opt = i; i = -1;}}if (Opt == -1) {error += '- You have not answered Question 16.\n';}
Opt = -1; for (i=myForm.q17.length-1; i > -1; i--) {if (myForm.q17[i].checked) {Opt = i; i = -1;}}if (Opt == -1) {error += '- You have not answered Question 17.\n';}
Opt = -1; for (i=myForm.q18.length-1; i > -1; i--) {if (myForm.q18[i].checked) {Opt = i; i = -1;}}if (Opt == -1) {error += '- You have not answered Question 18.\n';}
Opt = -1; for (i=myForm.q19.length-1; i > -1; i--) {if (myForm.q19[i].checked) {Opt = i; i = -1;}}if (Opt == -1) {error += '- You have not answered Question 19.\n';}
Opt = -1; for (i=myForm.q20.length-1; i > -1; i--) {if (myForm.q20[i].checked) {Opt = i; i = -1;}}if (Opt == -1) {error += '- You have not answered Question 20.\n';}
Opt = -1; for (i=myForm.q21.length-1; i > -1; i--) {if (myForm.q21[i].checked) {Opt = i; i = -1;}}if (Opt == -1) {error += '- You have not answered Question 21.\n';}
Opt = -1; for (i=myForm.q22.length-1; i > -1; i--) {if (myForm.q22[i].checked) {Opt = i; i = -1;}}if (Opt == -1) {error += '- You have not answered Question 22.\n';}
Opt = -1; for (i=myForm.q23.length-1; i > -1; i--) {if (myForm.q23[i].checked) {Opt = i; i = -1;}}if (Opt == -1) {error += '- You have not answered Question 23.\n';}
Opt = -1; for (i=myForm.q24.length-1; i > -1; i--) {if (myForm.q24[i].checked) {Opt = i; i = -1;}}if (Opt == -1) {error += '- You have not answered Question 24.\n';}
Opt = -1; for (i=myForm.q25.length-1; i > -1; i--) {if (myForm.q25[i].checked) {Opt = i; i = -1;}}if (Opt == -1) {error += '- You have not answered Question 25.\n';}

	/* Contact Details*/
	if(myForm.name.value == 'Name')
	{
		error += '- Please enter your name.\n';
	}
	if(!emailValidate(myForm.email.value))
	{
		error += '- Please enter a valid email address.\n';
	}
	if(error != '')
	{
		error = 'The form has not been completed correctly:\n' + error;
		alert(error);
		return false;
	}
	else
	{
	return true;
	}
}
