// Entries have a different company name label
dIsEntries ? sCompName = "Entrant Company Name" : sCompName = "Company Name"
		
function fRegJobRolewatch(oField) {
	// Student Job Role
	if(oField.value == 99) {
		if($('#job_title').val() == "") { $('#job_title').val("Student"); }
		$('#agency_network').val("9999")
		$('#cotype').val("STU")
		$('#for_company_name').html("College/University");
	} else {
		if($('#job_title').value == "Student") $('#job_title').val("");
		if($('#cotype').val("STU")) $('#cotype').val("0")
		$('#for_company_name').html(sCompName);
	}
	// Other Job Role
	if(oField.value=="100"){ $("#otherRole").show(); } else { $("#otherRole").hide(); }
}

function validateForm ( form ) {

	resetFormStyles(form.name)	
	
	var themessage = "";
	window["vFieldList"] = "";
	
	// PERSONAL DETAILS
	themessage = validateSelect(themessage, form, "title_id", "Title");
	themessage = validateText(themessage, form, "first_name", "First Name");
	themessage = validateText(themessage, form, "last_name", " Last Name");
	themessage = validateText(themessage, form, "job_title", " Job Title");
	themessage = validateSelect(themessage, form, "job_role_id", "Job Role");
	if ($("#job_role_id").val() == 100) {
		$("#otherRole").show();
		themessage = validateText(themessage, form, "job_role_other", "Describe Job Role");
	} else {
		$("#job_role_other").val("")
	}
	themessage = validateEmail(themessage, form, "email", "Email Address", true);
	themessage = validateEmail(themessage, form, "email_check", "Confirm Email Address", true);
	themessage = validateConfirmation(themessage, form, "email", "email_check", "The email addresses you entered do not match");
	
	// COMPANY DETAILS
	if($("#job_role_id").val() == 99) {
		themessage = validateText(themessage, form, "company_name", "College/University");
	} else {
		themessage = validateText(themessage, form, "company_name", sCompName);
	}
	themessage = validateText(themessage, form, "address1", "Address");
	themessage = validateText(themessage, form, "city", "City");
	themessage = validateText(themessage, form, "postcode", "Postcode/ZIP");
	themessage = validateSelect(themessage, form, "countrycode", "Country");
	if (bValidateSplitTel) {
		if ( form.telephone_country.value == "" || form.telephone_area.value == "" || form.telephone_number.value == "") {
			themessage = themessage + "- Telephone: Main Switchboard\n";
			vFieldList = vFieldList + "telephone,telephone_country,telephone_area,telephone_number,";
		}
	} else {
		themessage = validateText(themessage, form, "telephone", "Telephone number");
	}
	themessage = validateURLOptionalHttp(themessage, form, "web_address", "Company Website Address", true);
	themessage = validateSelect(themessage, form, "cotype", "Company Activity");
	if (!dIsPress) {
		themessage = validateSelect(themessage, form, "agency_network", "Agency Network ");
		themessage = validateSelect(themessage, form, "ultimategroupcode", "Holding Company");
	}
	
	if (dIsDelegates || dIsEntries) {
		if (!$("#i_agree").attr("checked"))
		themessage = validateBox(themessage, form, "i_agree", "Agreement to " + sSiteName + " sending me Festival-related information.");
	}
	
	//alert if fields are empty and cancel form submit
	if (themessage == "") {
			return true;
	} else {
		showMissingFields(window["vFieldList"])
		fErrorValidation(themessage);
		return false;
	}

}