function FormValidation(theForm){
 
	if(theForm.username.value == ""){
		alert("You must enter a Username");
		theForm.username.focus();
		return(false);
	}
	if(theForm.pass.value == ""){
		alert("You must enter a Password");
		theForm.pass.focus();
		return(false);
	}
	if(theForm.pass.value != theForm.passCon.value){
		alert("Your Password must match Confirm Password");
		theForm.pass.focus();
		return(false);
	}
	if(theForm.compName.value == ""){
		alert("You must enter a Company Name");
		theForm.compName.focus();
		return(false);
	}
	if(theForm.conName.value == ""){
		alert("Who is the point of contact");
		theForm.conName.focus();
		return(false);
	}
	if(theForm.centre.value == ""){
		alert("Are you an Accredited NI DP Training Centre");
		theForm.centre.focus();
		return(false);
	}
	if(theForm.centre.value == "N"){
		alert("You must be a Accredited NI Centre to sign up, otherwise you should apply to be a corporate member");
		theForm.centre.focus();
		return(false);
	}
	if(theForm.centreNo.value == ""){
		alert("How many centres does your organisation control");
		theForm.centreNo.focus();
		return(false);
	}
	if(theForm.dp_equip.value == ""){
		alert("What DP equipment do you use?");
		theForm.dp_equip.focus();
		return(false);
	}
	if(theForm.reg.value == ""){
		alert("Are you registered within the EU?");
		theForm.reg.focus();
		return(false);
	}
	if(theForm.add1.value == ""){
		alert("What is the first line of your Address");
		theForm.add1.focus();
		return(false);
	}
	if(theForm.city.value == ""){
		alert("Whar city you are based in");
		theForm.city.focus();
		return(false);
	}
	if(theForm.county.value == ""){
		alert("What county you are based in");
		theForm.county.focus();
		return(false);
	}
	if(theForm.zip.value == ""){
		alert("What Zip/Postcode you are based in");
		theForm.zip.focus();
		return(false);
	}
	if(theForm.country.value == ""){
		alert("What country you are based in");
		theForm.country.focus();
		return(false);
	}
	if(theForm.tel1.value == ""){
		alert("The telephone number most frequently used");
		theForm.tel1.focus();
		return(false);
	}
	if(theForm.email.value == ""){
		alert("You must enter a Email");
		theForm.email.focus();
		return(false);
	}
	var checkEmail = "@.";
	var checkStr = theForm.email.value;
	var EmailValid = false;
	var EmailAt = false;
	var EmailPeriod = false;
	var EmailMatch = false;
	for (i = 0;  i < checkStr.length;  i++)	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkEmail.length;  j++)	{
			if (ch == checkEmail.charAt(j) && ch == "@") { EmailAt = true; }
			if (theForm.email.value == theForm.emailCon.value) { EmailMatch = true; }
			if (ch == checkEmail.charAt(j) && ch == ".") { EmailPeriod = true; }
			if (EmailAt && EmailPeriod) {	break; }
			if (j == checkEmail.length) {	break; }
		}
		// if both the @ and . were in the string
		if (EmailAt && EmailPeriod && EmailMatch)	{
			EmailValid = true
			break;
		}
	}
	if (!EmailValid) {
		alert("The \"Email\" field must contain a valid email address and both \"Email\" and \"Verify Email\" fields must match");
		theForm.email.focus();
		return (false);
	}
	if(theForm.tandc.checked != 1){
		alert("You must agree to our Terms and Conditions");
		theForm.tandc.focus();
		return(false);
	}
}
function checkCourse(theform){
	
	var total = theform.length;
	var div = document.getElementById("errorMessage");
	var errors = 0;
	var errorInclude = new Array();
	var errorMessage = new Array(11);
	errorMessage[0]="<li>You must complete the 'Course Type' field</li>";
	errorMessage[1]="<li>You must complete the 'Course Sub Category' field</li>";
	errorMessage[2]="";
	errorMessage[3]="<li>You must complete the 'Day Start Date' field</li>";
	errorMessage[4]="<li>You must complete the 'Month Start Date' field</li>";
	errorMessage[5]="<li>You must complete the 'Year Start Date' field</li>";
	errorMessage[6]="";
	errorMessage[7]="<li>You must complete the 'Contact Name' field</li>";
	errorMessage[8]="<li>You must complete the 'Email Address' field</li>";
	errorMessage[9]="<li>You must complete the 'Confirm Email Address' field</li>";
	errorMessage[10]="<li>You must complete the 'Telephone' field</li>";
	errorMessage[11]="<li>You must complete the 'Fax' field</li>";
	errorMessage[12]="<li>You must complete the 'Website' field</li>";
	errorMessage[13]="<li>The 'Email' field must contain a valid email address and both 'Email' and 'Confirm Email' fields must match</li>";
	
	for(i = 0; i < (total - 1); i++){
		theform[i].style.backgroundColor = "";
		theform[i].style.border = "1px solid";
		//alert(i);
		//if(theform[i].value == "" && (i<=12 && i <= 2 && i >= 7)){
		if(theform[i].value == "" && i<=12 && i!=2 && i!=3 && i!=4 && i!=5 && i!=6){
			//alert(theform[i].value + '-' +i);
			theform[i].style.backgroundColor = "#ff7777";
			theform[i].style.border = "2px solid #bd2424";
			errorInclude = errorInclude.concat(errorMessage[i]);
			errors = 1;
		}
	}
	if(theform.email.value != "" && theform.emailcon.value != ""){
		var checkEmail = "@.";
		var checkStr = theform.email.value;
		var EmailValid = false;
		var EmailAt = false;
		var EmailPeriod = false;
		var EmailMatch = false;
		for (i = 0;  i < checkStr.length;  i++)	{
			ch = checkStr.charAt(i);
			for (j = 0;  j < checkEmail.length;  j++)	{
				if (ch == checkEmail.charAt(j) && ch == "@") { EmailAt = true; }
				if (theform.email.value == theform.emailcon.value) { EmailMatch = true; }
				if (ch == checkEmail.charAt(j) && ch == ".") { EmailPeriod = true; }
				if (EmailAt && EmailPeriod) {	break; }
				if (j == checkEmail.length) {	break; }
			}
			// if both the @ and . were in the string
			if (EmailAt && EmailPeriod && EmailMatch)	{
				EmailValid = true
				break;
			}
		}
		if (!EmailValid) {
			theform[7].style.backgroundColor = "#ff7777";
			theform[7].style.border = "2px solid #bd2424";
			theform[8].style.backgroundColor = "#ff7777";
			theform[8].style.border = "2px solid #bd2424";
			errorInclude = errorInclude.concat(errorMessage[12]);
			errors = 1;
		}
	}
	
	if(!theform[6].checked){
		if(theform[3].value == ""){
			theform[3].style.backgroundColor = "#ff7777";
			theform[3].style.border = "2px solid #bd2424";
			errorInclude = errorInclude.concat(errorMessage[3]);
			errors = 1;
		}
		if(theform[4].value == ""){
			theform[4].style.backgroundColor = "#ff7777";
			theform[4].style.border = "2px solid #bd2424";
			errorInclude = errorInclude.concat(errorMessage[4]);
			errors = 1;
		}
		if(theform[5].value == ""){
			theform[5].style.backgroundColor = "#ff7777";
			theform[5].style.border = "2px solid #bd2424";
			errorInclude = errorInclude.concat(errorMessage[5]);
			errors = 1;
		}
	}
	
	if(errors == 1){
		var totalE = errorInclude.length;
		div.innerHTML = "<h4 style='width:390px;'>Errors</h4><ul>" + errorInclude.join("") +"</ul>";
		div.style.backgroundColor = "#ff7777";
		div.style.border = "2px solid #bd2424";
		div.style.width = "400px";
		div.style.color = "#000";
		div.style.margin = "0px 0px 10px 10px";
		div.style.padding = "10px 10px 10px 20px";
		return (false);
	}
	
}
