/*
V1.01 - 11/03/10 TS
- removed cv file as a required field (still checks format if a file is supplied)
*/
function JobListing() {
	this.GotoApply = GotoApply;
	this.CheckJobApplication = CheckJobApplication;
}

function GotoApply(jobid) {
	var formName = "JobAppyForm"+this.gadgetId;
	var formObject = document.forms[formName];
	formObject.jobid.value = jobid;
	formObject.submit();
}

function CheckJobApplication() {
	var formName = "JobAppyForm"+this.gadgetId;
	var formObject = document.forms[formName];
	var errorMessage = '';
	var rootObj = new Root;
	if (formObject.fullname.value == '') errorMessage += "\n- You must enter your full name";
	if (!rootObj.IsValidEmailAddress(formObject.email.value) && formObject.phone.value == '') {
		errorMessage += "\n- You must enter either a contact phone number or email address";
	}
	if (formObject.apply_message.value == '') errorMessage += "\n- You must enter a message";
	var cvCheck = formObject.cv.value.toLowerCase();
	if (cvCheck != '') { // only check the file type if a file is supplied (i.e. not mandatory)
		if (cvCheck.indexOf('.doc') == -1 && cvCheck.indexOf('.pdf') == -1 && cvCheck.indexOf('.ods') == -1) {
			errorMessage += "\n- If you are supplying a CV it must be in one of our supported formats";
		}
	}
	if (errorMessage != '') {
		alert(errorMessage);
	} else {
		formObject.submit();
	}
}

