var relatives;
var course;
var study;
var studymode;
var licensed;
var read_rate;
var write_rate;
var speak_rate;
var dialect_rate;
var disability;
var illness;

function ValidateFields()
{

	// Section A: Personal Particulars
	if (document.fmCareer.txtName.value == "") 
	{
		alert('Enter your FULL NAME')
		document.fmCareer.txtName.focus()
		
		return false;
	}
	else if (document.fmCareer.txtEmail.value == "")
	{
		alert('Enter your EMAIL ADDRESS')
		document.fmCareer.txtEmail.focus()
		
		return false;
	}
	// Validate Email Address
	else if (document.fmCareer.txtEmail.value != "")
	{
		var i = 0
		testString = document.fmCareer.txtEmail.value
		if (testString.length < 3) {
			alert ("e-mail address too short to be valid")
			document.fmCareer.txtEmail.focus()
			document.fmCareer.select()
			return (false)
		}
		if ((i = testString.indexOf ("@",1)) < 1 && testString.length > 0) {
			alert ("e-mail address must include an '@' sign")
			document.fmCareer.txtEmail.focus()
			document.fmCareer.select()
			return (false)
		}
		if (testString.indexOf (".",i) <= i+3 && testString.length > 0) {
			alert ("e-mail address must have at least three characters \rbetween the '@' and the first dot.")
			document.fmCareer.txtEmail.focus()
			document.fmCareer.select()
			return (false)
		}	
	}
	else if (document.fmCareer.txtAddress.value == "")
	{
		alert('Enter your ADDRESS')
		document.fmCareer.txtAddress.focus()
		
		return false;
	}
	else if (document.fmCareer.txtHomePhone.value == "")
	{
		alert('Enter your HOME CONTACT NO.')
		return false;
	}
	else if (document.fmCareer.txtNRIC.value == "")
	{
		alert('Enter your NRIC NO.')
		document.fmCareer.txtNRIC.focus()
		
		return false;
	}
	
	// Section B: Employment
	else if (document.fmCareer.txtPosition.value == "")
	{
		alert('Enter the POSITION you desired')
		document.fmCareer.txtPosition.focus()
		
		return false;
	}
	else if (document.fmCareer.txtSalary.value == "")
	{
		alert('Enter your EXPECTED SALARY')
		document.fmCareer.txtSalary.focus()

		return false;
	}
	
	// Section A: Personal Particulars
	// If Married, the following fields have to be checked
	else if (document.fmCareer.cboMarital.options[document.fmCareer.cboMarital.selectedIndex].value == "Married")
	{
		if (document.fmCareer.txtSpouseName.value == "")
		{
			alert('Enter your SPOUSE NAME');
			document.fmCareer.txtSpouseName.focus();

			return false;
		}
		else if (document.fmCareer.txtSpouseOccupation.value == "")
		{	
			alert('Enter your SPOUSE OCCUPATION');
			document.fmCareer.txtSpouseOccupation.focus();

			return false;
		}
		else if (document.fmCareer.txtChild.value == "")
		{
			alert('Enter the NO. OF CHILDREN you have');
			document.fmCareer.txtChild.focus();

			return false;
		}
		else if (document.fmCareer.txtAgeRange.value == "")
		{
			alert('Enter AGE RANGE of your children');
			document.fmCareer.txtAgeRange.focus();

			return false;
		}
	}
		
	// Section B: Employment
	// Check whether relatives/friends working in the company
	else if (relatives == "Yes")
	{
		if (document.fmCareer.txtNamesPositions.value == "")
		{
			alert('Enter the NAMES & POSITIONS of your relatives/friends working in this company')
			document.fmCareer.txtNamesPositions.focus();			
			
			return false;
		}			
	}
	
	// Section C: Education/Training
	// Check whether currently taking any course
	else if (course == "Yes")
	{
		if (document.fmCareer.txtCourse.value == "")		{
			
			alert('Enter the COURSE NAME you are currently taking')
			document.fmCareer.txtCourse.focus();
			
			return false;
		}
		else if (document.fmCareer.cboCompletionmonth.options[document.fmCareer.cboCompletionmonth.selectedIndex].value == "")
		{
			alert('Select the MONTH of the date of completion of the course you are currently undertaking')
			document.fmCareer.cboCompletionmonth.focus();
			
			return false;
		}
		else if (document.fmCareer.cboCompletionyear.options[document.fmCareer.cboCompletionyear.selectedIndex].value == "")
		{
			alert('Select the YEAR of the date of completion of the course you are currently undertaking')
			document.fmCareer.cboCompletionyear.focus();
			
			return false;
		}
	}
	
	// Section C: Education/Training
	// Check whether planning to further study
	else if (study == "Yes")
	{
		if (document.fmCareer.txtStudy.value == "")
		{
			alert('Enter WHEN you are planning to go for futher study')
			document.fmCareer.txtStudy.focus();
			
			return false;
		}
		else if (studymode == "")
		{
			alert('Select the mode of study')
			document.fmCareer.rdoStudyMode.focus()
			
			return false;
		}
	}

	// Section C: Education/Training
	// Check whether licensed in any profession and/or trade
	else if (licensed == "Yes")
	{
		if (document.fmCareer.txtLicensed.value == "")
		{
			alert('State the kind and where your profession/trade is registered');
			document.fmCareer.txtLicensed.focus();
			
			return false;
		}
	}
	
	
	// Section D: Linguistic Ability
	else if (document.fmCareer.txtRead.value != "")
	{
		if (read_rate == "")
		{
			alert('Rate your on reading ability')
			document.fmCareer.rdoRead.focus()
			
			return false;
		}
	}	
	
	else if (document.fmCareer.txtWrite.value != "")
	{
		if (write_rate == "")
		{
			alert('Rate your on writing ability')
			document.fmCareer.rdoWrite.focus()
			
			return false;
		}
	}
	else if (document.fmCareer.txtSpeak.value != "")
	{
		if (speak_rate == "")
		{
			alert('Rate your on speaking ability')
			document.fmCareer.rdoSpeak.focus()
			
			return false;
		}
	}
	else if (document.fmCareer.txtDialect.value != "")
	{
		if (dialect_rate == "")
		{
			alert('Rate your on DIALECT speaking ability')
			document.fmCareer.rdoDialect.focus()
			
			return false;
		}
	}
	
	
	// E: Medical History
	// Check on Physical Disablity
	else if (disability == "Yes")
	{
		if (document.fmCareer.txtDisability.value == "")
		{
			alert('Specify your physical disability');
			document.fmCareer.txtDisability.focus();
			
			return false;
		}
	}

	// Check on Illness
	else if (illness == "Yes")
	{
		if (document.fmCareer.txtIllness.value == "")
		{
			alert('Specify the illness/accident you had in the past six month');
			document.fmCareer.txtIllness.focus();
			
			return false;
		}
	}
		
	document.fmCareer.action = "careerresponse.asp";
	document.fmCareer.submit();
}

