<!--//--><![CDATA[//><!--
var globals = new Array();
var i, count, father, mother;
globals['max_family'] = 6;
globals['max_apaper'] = 10;
globals['req_apaper'] = 5;
globals['max_ibpaper'] = 10;
globals['req_ibpaper'] = 5;
globals['max_actnuspaper'] = 10;
globals['req_actnuspaper'] = 5;
globals['max_sat2paper'] = 4;
globals['max_language'] = 5;

$(document).ready(function() {
	if (document.getElementById("education_level2"))
		toggleJCDiploma(document.getElementById("education_level2"));
	$(".family_dob").datepicker({
		changeMonth:true,
		changeYear:true,
		dateFormat:'yy-mm-dd',
		yearRange:'-70:+20'
	});
	$(".dp_date:not(.family_dob)").datepicker({
		changeMonth:true,
		changeYear:true,
		dateFormat:'yy-mm-dd',
		yearRange:'-30:+20'
	});
	$("#education_institution1").autocomplete("suggest.php", {
		extraParams: {param:'school_olvl'},
		max:25,
		width: 250,
		selectFirst: false
	});
	$("#education_institution2").autocomplete("suggest.php", {
		extraParams: {param:'school_alvl'},
		max:25,
		width: 250,
		selectFirst: false
	});
	$(".subject_olvl").autocomplete("suggest.php", {
		extraParams: {param:'subject_olvl'},
		width: 250,
		selectFirst: false
	});
	$(".subject_alvl").autocomplete("suggest.php", {
		extraParams: {param:'subject_alvl'},
		width: 250,
		selectFirst: false
	});
	$(".subject_iblvl").autocomplete("suggest.php", {
		extraParams: {param:'subject_iblvl'},
		width: 250,
		selectFirst: false
	});
	$(".subject_actnuslvl_major").autocomplete("suggest.php", {
		extraParams: {param:'subject_actnuslvl'},
		width: 250,
		selectFirst: false
	});
	var $sectionTabs = $('#profileForm').tabs({
		select: function(event, ui) {
			var tmp, previousIndex;
			previousIndex = $('#tabIndex').val();
			switch (previousIndex) {
				case '0':
					tmp = $("#personalparticulars input, #personalparticulars textarea, #personalparticulars select, #tabIndex").serialize();
					break;
				case '1':
					tmp = $("#familyparticulars input, #familyparticulars textarea, #familyparticulars select, #tabIndex").serialize();
					break;
				case '2':
					tmp = $("#nationalservice input, #nationalservice textarea, #nationalservice select, #tabIndex").serialize();
					break;
				case '3':
					tmp = $("#education_all input, #education_all textarea, #education_all select, #tabIndex").serialize();
					break;
				case '4':
					tmp = $("#testresult input, #testresult textarea, #testresult select, #tabIndex").serialize();
					break;
				case '5':
					tmp = $("#language input, #language textarea, #language select, #tabIndex").serialize();
					break;
				default:
					break;
			}
			$.ajax({
				type:"POST",
				url:"/ops/jsProfileAjax.php",
				async:false,
				data:tmp,
				success: function(html){
					if (html>0)
						$.jGrowl('Some updates failed!');
				}
			});
			$('#tabIndex').val(ui.index);
			return true;
		}
	});
});

function validate(obj) {
	var $sectionTabs = $('#profileForm').tabs();

	// Personal Particulars
	if (trim(obj.fullname.value)=="") {
		$sectionTabs.tabs('select','#personalparticulars');
		$.jGrowl("Please enter your fullname.");
		obj.fullname.focus();
		return false;
	}
	if (obj.nationality.selectedIndex==0) {
		$sectionTabs.tabs('select','#personalparticulars');
		$.jGrowl("Please enter your nationality.");
		obj.nationality.focus();
		return false;
	}
	if (trim(obj.nric.value)=="") {
		$sectionTabs.tabs('select','#personalparticulars');
		$.jGrowl("Please enter your NRIC / Passport No.");
		obj.nric.focus();
		return false;
	}
	if (obj.nationality.selectedIndex==1 ||	obj.nationality.selectedIndex==2) {
		if (!checkNRIC(obj.nric.value)) {
			$sectionTabs.tabs('select','#personalparticulars');
			$.jGrowl("The NRIC you key in is invalid.");
			obj.nric.focus();
			return false;
		}
	}
	if (obj.gender.selectedIndex==0) {
		$sectionTabs.tabs('select','#personalparticulars');
		$.jGrowl("Please select your gender.");
		obj.gender.focus();
		return false;
	}
	if (obj.marital_status.selectedIndex==0) {
		$sectionTabs.tabs('select','#personalparticulars');
		$.jGrowl("Please select your marital status.");
		obj.marital_status.focus();
		return false;
	}
	if (trim(obj.dob_date.value)=="" || trim(obj.dob_date.value)=="0000-00-00") {
		$sectionTabs.tabs('select','#personalparticulars');
		$.jGrowl("Please enter your date of birth.");
		obj.dob_date.focus();
		return false;
	}
	if (obj.birth_country.selectedIndex==0) {
		$sectionTabs.tabs('select','#personalparticulars');
		$.jGrowl("Please select your birth country.");
		obj.birth_country.focus();
		return false;
	}
	if (obj.race.selectedIndex==0) {
		$sectionTabs.tabs('select','#personalparticulars');
		$.jGrowl("Please select your race.");
		obj.race.focus();
		return false;
	}
	if (obj.religion.selectedIndex==0) {
		$sectionTabs.tabs('select','#personalparticulars');
		$.jGrowl("Please select your religion.");
		obj.religion.focus();
		return false;
	}
	if (trim(obj.address.value)=="") {
		$sectionTabs.tabs('select','#personalparticulars');
		$.jGrowl("Please enter your address.");
		obj.address.focus();
		return false;
	}
	if (obj.address_country.selectedIndex==0) {
		$sectionTabs.tabs('select','#personalparticulars');
		$.jGrowl("Please select the country of your current address.");
		obj.address_country.focus();
		return false;
	}
	if (obj.address_country.selectedIndex==1) {
		if (trim(obj.address_postal.value)=="") {
			$sectionTabs.tabs('select','#personalparticulars');
			$.jGrowl("Please enter your current postal code.");
			obj.address_postal.focus();
			return false;
		}
		if (!checkSingaporePostalCode(obj.address_postal.value)) {
			$sectionTabs.tabs('select','#personalparticulars');
			$.jGrowl("Please enter a valid Singapore postal code.\nInclude the leading zero if it is less than 6 digits.\nExample: 054267");
			obj.address_postal.focus();
			return false;
		}
	}
	if (trim(obj.mailing_address.value)!="") {
		if (obj.mailing_country.selectedIndex==0) {
			$sectionTabs.tabs('select','#personalparticulars');
			$.jGrowl("Please select the country of your mailing address.");
			obj.mailing_country.focus();
			return false;
		}
		if (trim(obj.mailing_postal.value)=="") {
			$sectionTabs.tabs('select','#personalparticulars');
			$.jGrowl("Please enter your mailing postal code.");
			obj.mailing_postal.focus();
			return false;
		}
		if (obj.mailing_country.selectedIndex==1) {
			if (!checkSingaporePostalCode(obj.mailing_postal.value)) {
				$sectionTabs.tabs('select','#personalparticulars');
				$.jGrowl("Please enter a valid Singapore postal code.\nInclude the leading zero if it is less than 6 digits.\nExample: 054267");
				obj.mailing_postal.focus();
				return false;
			}
		}
	}
	if (trim(obj.contact_main.value)=="") {
		$sectionTabs.tabs('select','#personalparticulars');
		$.jGrowl("Please enter your main contact.");
		obj.contact_main.focus();
		return false;
	}

	// Family Particulars
	father = mother = 0;
	for (i=1; i<=globals['max_family']; i++) {
		if (trim(obj['family_fullname'+i].value)!='') {
			if (obj['family_relationship'+i].selectedIndex==0) {
				$sectionTabs.tabs('select','#familyparticulars');
				$.jGrowl("Please select your relationship with this person.");
				obj['family_relationship'+i].focus();
				return false;
			}
			else if (obj['family_relationship'+i].selectedIndex==1)
				father = i;
			else if (obj['family_relationship'+i].selectedIndex==2)
				mother = i;
			if (obj['family_nationality'+i].selectedIndex==0) {
				$sectionTabs.tabs('select','#familyparticulars');
				$.jGrowl("Please enter the person's nationality.");
				obj['family_nationality'+i].focus();
				return false;
			}
			if (trim(obj['family_dob_date'+i].value)=='' || trim(obj['family_dob_date'+i].value)=='0000-00-00') {
				$sectionTabs.tabs('select','#familyparticulars');
				$.jGrowl("Please enter the person's date of birth.");
				obj['family_dob_date'+i].focus();
				return false;
			}
			if (obj['family_birth_country'+i].selectedIndex==0) {
				$sectionTabs.tabs('select','#familyparticulars');
				$.jGrowl("Please enter the person's country of birth.");
				obj['family_birth_country'+i].focus();
				return false;
			}
			if (trim(obj['family_occupation'+i].value)=='') {
				$sectionTabs.tabs('select','#familyparticulars');
				$.jGrowl("Please enter the person's occupation.");
				obj['family_occupation'+i].focus();
				return false;
			}
		}
	}
	if (father==0 && mother==0) {
		$sectionTabs.tabs('select','#familyparticulars');
		$.jGrowl("Please enter one of your parents' details.");
		obj['family_fullname1'].focus();
		return false;
	}/*
	// Family Particulars
	father = mother = 0;
	for (i=1; i<=globals['max_family']; i++) {
		if (i==1 && trim(obj['family_fullname'+i].value)=='') {
			$sectionTabs.tabs('select','#familyparticulars');
			$.jGrowl("Please enter your father's fullname.");
			obj['family_fullname'+i].focus();
			return false;
		}
		else if (i==2 && trim(obj['family_fullname'+i].value)=='') {
			$sectionTabs.tabs('select','#familyparticulars');
			$.jGrowl("Please enter your mother's fullname.");
			obj['family_fullname'+i].focus();
			return false;
		}
		if (trim(obj['family_fullname'+i].value)!='') {
			if (i>2 && obj['family_relationship'+i].selectedIndex==0) {
				$sectionTabs.tabs('select','#familyparticulars');
				$.jGrowl("Please select your relationship with this person.");
				obj['family_relationship'+i].focus();
				return false;
			}
			if (obj['family_nationality'+i].selectedIndex==0) {
				$sectionTabs.tabs('select','#familyparticulars');
				$.jGrowl("Please enter the person's nationality.");
				obj['family_nationality'+i].focus();
				return false;
			}
			if (trim(obj['family_dob_date'+i].value)=='' || trim(obj['family_dob_date'+i].value)=='0000-00-00') {
				$sectionTabs.tabs('select','#familyparticulars');
				$.jGrowl("Please enter the person's year of birth.");
				obj['family_dob_date'+i].focus();
				return false;
			}
			if (obj['family_birth_country'+i].selectedIndex==0) {
				$sectionTabs.tabs('select','#familyparticulars');
				$.jGrowl("Please enter the person's country of birth.");
				obj['family_birth_country'+i].focus();
				return false;
			}
			if (trim(obj['family_occupation'+i].value)=='') {
				$sectionTabs.tabs('select','#familyparticulars');
				$.jGrowl("Please enter the person's occupation.");
				obj['family_occupation'+i].focus();
				return false;
			}
		}
	}*/

	// National Service Details
	if ((obj.nationality.selectedIndex==1 || obj.nationality.selectedIndex==2) && obj.gender.selectedIndex==1) {
		if (obj.ns_status.selectedIndex==0) {
			$sectionTabs.tabs('select','#nationalservice');
			$.jGrowl("Please select your national service status.");
			obj.ns_status.focus();
			return false;
		}
		if (obj.ns_status.selectedIndex==1 || obj.ns_status.selectedIndex==2 || obj.ns_status.selectedIndex==3) {
			if (trim(obj['ns_enlistment_date'].value)=='' || trim(obj['ns_enlistment_date'].value)=='0000-00-00') {
				$sectionTabs.tabs('select','#nationalservice');
				$.jGrowl("Please enter your enlistment date.");
				obj.ns_enlistment_date.focus();
				return false;
			}
			if (obj.ns_rank.selectedIndex==0) {
				$sectionTabs.tabs('select','#nationalservice');
				$.jGrowl("Please select your rank.");
				obj.ns_rank.focus();
				return false;
			}
		}
		if (obj.ns_status.selectedIndex==3 || obj.ns_status.selectedIndex==5) {
			if (trim(obj.ns_reason.value)=="") {
				$sectionTabs.tabs('select','#nationalservice');
				$.jGrowl("Please enter your reason for exemption/deferment from National Service.");
				obj.ns_reason.focus();
				return false;
			}
		}
	}

	// Education Records - O Level
	if (trim(obj.education_institution1.value)=="") {
		$sectionTabs.tabs('select','#education_all');
		$.jGrowl("Please enter your GCE 'O' Level or Equivalent Institution name.");
		obj.education_institution1.focus();
		return false;
	}
	if (trim(obj.education_start_date1.value)=="" || trim(obj.education_start_date1.value)=="0000-00-00") {
		$sectionTabs.tabs('select','#education_all');
		$.jGrowl("Please enter your GCE 'O' Level or Equivalent start date.");
		obj.education_start_date1.focus();
		return false;
	}
	if (trim(obj.education_institution2.value)!="") {
		if (trim(obj.education_end_date1.value)=="" || trim(obj.education_end_date1.value)=="0000-00-00") {
			$sectionTabs.tabs('select','#education_all');
			$.jGrowl("Please enter your GCE 'O' Level or Equivalent examination date.");
			obj.education_end_date1.focus();
			return false;
		}
	}
	if (obj.education_country1.selectedIndex==0) {
		$sectionTabs.tabs('select','#education_all');
		$.jGrowl("Please select the country of your GCE 'O' Level or Equivalent Institution.");
		obj.education_country1.focus();
		return false;
	}
	if (obj.education_course1.selectedIndex==0) {
		$sectionTabs.tabs('select','#education_all');
		$.jGrowl("Please select your GCE 'O' Level or Equivalent Stream.");
		obj.education_course1.focus();
		return false;
	}
	if (obj.education_level1.selectedIndex==0) {
		if (trim(obj.education_o_subject1.value)=="") {
			$sectionTabs.tabs('select','#education_all');
			$.jGrowl("Please enter the subject which you had taken.");
			obj.education_o_subject1.focus();
			return false;
		}
	}
	else if (obj.education_level1.selectedIndex==1) {
		if (trim(obj.education_ips_subject1.value)=="") {
			$sectionTabs.tabs('select','#education_all');
			$.jGrowl("Please enter the subject which you had taken.");
			obj.education_ips_subject1.focus();
			return false;
		}
	}
	else if (obj.education_level1.selectedIndex==2) {
		if (trim(obj.education_os_subject1.value)=="") {
			$sectionTabs.tabs('select','#education_all');
			$.jGrowl("Please enter the subject which you had taken.");
			obj.education_os_subject1.focus();
			return false;
		}
	}
	if (obj.education_country1.selectedIndex==1 && trim(obj.education_start_date2.value)!="" && trim(obj.education_start_date2.value)!="0000-00-00" && trim(obj.education_cumulative_score1.value)=="") {
		$sectionTabs.tabs('select','#education_all');
		$.jGrowl("Please enter your Aggregate L1 R5 / CAP / GPA Score.");
		obj.education_cumulative_score1.focus();
		return false;
	}

	// Education Records - A Level
	if (obj.school.value!="secondary" && obj.school.value!="overseas") {
		if (trim(obj.education_institution2.value)=="") {
			$sectionTabs.tabs('select','#education_all');
			$.jGrowl("Please enter your GCE 'A' Level or Equivalent Institution name.");
			obj.education_institution2.focus();
			return false;
		}
		if (trim(obj.education_start_date2.value)=="" || trim(obj.education_start_date2.value)=="0000-00-00") {
			$sectionTabs.tabs('select','#education_all');
			$.jGrowl("Please enter your GCE 'A' Level or Equivalent start date.");
			obj.education_start_date2.focus();
			return false;
		}/*
		if (trim(obj.education_end_date2.value)=="" || trim(obj.education_end_date2.value)=="0000-00-00") {
			$sectionTabs.tabs('select','#education_all');
			$.jGrowl("Please enter your GCE 'A' Level or Equivalent examination / expected completion date.");
			obj.education_end_date2.focus();
			return false;
		}*/
		if (obj.education_country2.selectedIndex==0) {
			$sectionTabs.tabs('select','#education_all');
			$.jGrowl("Please select the country of your GCE 'A' Level or Equivalent Institution.");
			obj.education_country2.focus();
			return false;
		}
		if (obj.education_level2.selectedIndex==0) {
			if (obj.education_course2_JC.selectedIndex==0) {
				$sectionTabs.tabs('select','#education_all');
				$.jGrowl("Please select your A Level Stream.");
				obj.education_course2_JC.focus();
				return false;
			}
			count = 0;
			for (i=1; i<=globals['max_apaper']; i++) {
				if (obj['education_a_level'+i].selectedIndex!=0 && obj['education_a_subject'+i].value!='')
					count++;
			}
			if (count<globals['req_apaper']) {
				$sectionTabs.tabs('select','#education_all');
				$.jGrowl('Please enter at least '+globals['req_apaper']+' subjects which you take including your S/H3 Paper if applicable.');
				obj['education_a_level1'].focus();
				return false;
			}
		}
		else if (obj.education_level2.selectedIndex==1) {
			if (trim(obj.education_course2_Diploma.value)=="") {
				$sectionTabs.tabs('select','#education_all');
				$.jGrowl("Please enter your Diploma Name.");
				obj.education_course2_Diploma.focus();
				return false;
			}
			if (obj.education_current_year2.selectedIndex==0) {
				$sectionTabs.tabs('select','#education_all');
				$.jGrowl("Please select your current year.");
				obj.education_current_year2.focus();
				return false;
			}
			if (trim(obj.education_cumulative_score2_Diploma.value)!="" && isNaN(obj.education_cumulative_score2_Diploma.value)) {
				$sectionTabs.tabs('select','#education_all');
				$.jGrowl('Please enter your cumulative GPA.\nPlease only insert numerical value.');
				obj.education_cumulative_score2_Diploma.focus();
				return false;
			}
		}
		else if (obj.education_level2.selectedIndex==2) {
			count = 0;
			for (i=1; i<=globals['max_ibpaper']; i++) {
				if (obj['education_ib_level'+i].selectedIndex!=0 && obj['education_ib_subject'+i].value!='')
					count++;
			}
			if (count<globals['req_ibpaper']) {
				$sectionTabs.tabs('select','#education_all');
				$.jGrowl('Please enter at least '+globals['req_ibpaper']+' subjects which you take.');
				obj['education_ib_level'+(count+1)].focus();
				return false;
			}
			if (trim(obj.education_cumulative_score2_IB.value)=="" || isNaN(obj.education_cumulative_score2_IB.value)) {
				$sectionTabs.tabs('select','#education_all');
				$.jGrowl('Please enter your total IB score.\nPlease only insert numerical value.');
				obj.education_cumulative_score2_IB.focus();
				return false;
			}
		}
		else if (obj.education_level2.selectedIndex==3) {
			count = 0;
			for (i=1; i<=globals['max_actnuspaper']; i++) {
				if (obj['education_actnus_subject'+i].value!='')
					count++;
			}
			if (count<globals['req_actnuspaper']) {
				$sectionTabs.tabs('select','#education_all');
				$.jGrowl('Please enter at least '+globals['req_actnuspaper']+' subjects which you take.');
				obj['education_actnus_subject1'].focus();
				return false;
			}
		}
	}
	// Education Records - Tertiary
	if (trim(obj.education_institution3.value)!="") {
		if (obj.education_level3.selectedIndex==0) {
			$sectionTabs.tabs('select','#education_all');
			$.jGrowl("Please select your tertiary level.");
			obj.education_level3.focus();
			return false;
		}
		if (trim(obj.education_start_date3.value)=="" || trim(obj.education_start_date3.value)=="0000-00-00") {
			$sectionTabs.tabs('select','#education_all');
			$.jGrowl("Please select your tertiary start date.");
			obj.education_start_date3.focus();
			return false;
		}
		if (obj.education_country3.selectedIndex==0) {
			$sectionTabs.tabs('select','#education_all');
			$.jGrowl("Please select the country of your Tertiary Institution.");
			obj.education_country3.focus();
			return false;
		}
		if (trim(obj.education_course3.value)=="") {
			$sectionTabs.tabs('select','#education_all');
			$.jGrowl("Please enter your course of study.");
			obj.education_course3.focus();
			return false;
		}
		if (obj.education_current_year3.selectedIndex==0) {
			$sectionTabs.tabs('select','#education_all');
			$.jGrowl("Please select your current year.");
			obj.education_current_year3.focus();
			return false;
		}
		if (trim(obj.education_cumulative_score3.value)=="" || isNaN(obj.education_cumulative_score3.value)) {
			$sectionTabs.tabs('select','#education_all');
			$.jGrowl('Please enter your cumulative GPA.\nPlease only insert numerical value.');
			obj.education_cumulative_score3.focus();
			return false;
		}
		if (obj.education_cumulative_score3.value>0 && obj.education_tertiaryAux_max_gpa.selectedIndex==0) {
			$sectionTabs.tabs('select','#education_all');
			$.jGrowl('Please select the maximum GPA.');
			obj.education_tertiaryAux_max_gpa.focus();
			return false;
		}
	}

	// TOEFL, SAT 1 & 2, GMAT & GRE
	if (trim(obj.test_sat1_date.value)!="" && trim(obj.test_sat1_date.value)!="0000-00-00" && trim(obj.test_sat1_center.value)=="") {
		$sectionTabs.tabs('select','#testresult');
		$.jGrowl("Please enter your SAT 1 Test Centre.");
		obj.test_sat1_center.focus();
		return false;
	}/*
	if (obj.test_sat1_center.value!="" && obj.test_sat1_verbal.value==0 && obj.test_sat1_written.value==0 && obj.test_sat1_math.value==0) {
		$sectionTabs.tabs('select','#testresult');
		$.jGrowl("Please enter your SAT 1 score.");
		obj.test_sat1_verbal.focus();
		return false;
	}*/
	if (obj.test_sat1_verbal.value>0 && (obj.test_sat1_verbal.value > 800 || obj.test_sat1_verbal.value < 200)) {
		$sectionTabs.tabs('select','#testresult');
		$.jGrowl("Your SAT 1 verbal score range from 200-800.");
		obj.test_sat1_verbal.focus();
		return false;
	}
	if (obj.test_sat1_written.value>0 && (obj.test_sat1_written.value > 800 || obj.test_sat1_written.value < 200)) {
		$sectionTabs.tabs('select','#testresult');
		$.jGrowl("Your SAT 1 writing score range from 200-800.");
		obj.test_sat1_written.focus();
		return false;
	}
	if (obj.test_sat1_math.value>0 && (obj.test_sat1_math.value > 800 || obj.test_sat1_math.value < 200)) {
		$sectionTabs.tabs('select','#testresult');
		$.jGrowl("Your SAT 1 math score range from 200-800.");
		obj.test_sat1_math.focus();
		return false;
	}
	if (trim(obj.test_sat2_date.value)!="" && trim(obj.test_sat2_date.value)!="0000-00-00" && trim(obj.test_sat2_center.value)=="") {
		$sectionTabs.tabs('select','#testresult');
		$.jGrowl("Please enter your SAT 2 Test Centre.");
		obj.test_sat2_center.focus();
		return false;
	}
	count = 0;
	for (i=1; i<=globals['max_sat2paper']; i++) {
		obj['test_sat2_paper'+i].value = trim(obj['test_sat2_paper'+i].value);
		if (obj['test_sat2_paper'+i].value!='') {
			count++;/*
			if (obj['test_sat2_result'+i].value==0) {
				$sectionTabs.tabs('select','#testresult');
				$.jGrowl("Please enter the score for your SAT 2 paper.");
				obj['test_sat2_result'+i].focus();
				return false;
			}*/
			if (obj['test_sat2_result'+i].value > 800) {
				$sectionTabs.tabs('select','#testresult');
				$.jGrowl("Your SAT 2 subject score range from 0-800.");
				obj['test_sat2_result'+i].focus();
				return false;
			}
		}
	}
	if (trim(obj.test_sat2_center.value)!="" && count==0) {
		$sectionTabs.tabs('select','#testresult');
		$.jGrowl("Please enter your SAT 2 paper.");
		obj.test_sat2_paper1.focus();
		return false;
	}
	if (trim(obj.test_toefl_date.value)!="" && trim(obj.test_toefl_date.value)!="0000-00-00" && trim(obj.test_toefl_center.value)=="") {
		$sectionTabs.tabs('select','#testresult');
		$.jGrowl("Please enter your TOEFL Test Centre.");
		obj.test_toefl_center.focus();
		return false;
	}/*
	if (trim(obj.test_toefl_center.value)!="" && (obj.test_toefl_result.value=="" || obj.test_toefl_result.value==0)) {
		$sectionTabs.tabs('select','#testresult');
		$.jGrowl("Please enter your TOEFL score.");
		obj.test_toefl_result.focus();
		return false;
	}*/
	if (obj.test_toefl_result.value > 800) {
		$sectionTabs.tabs('select','#testresult');
		$.jGrowl("Your TOEFL score can not exceed 800.");
		obj.test_toefl_result.focus();
		return false;
	}
	if (trim(obj.test_gmat_date.value)!="" && trim(obj.test_gmat_date.value)!="0000-00-00" && trim(obj.test_gmat_center.value)=="") {
		$sectionTabs.tabs('select','#testresult');
		$.jGrowl("Please enter your GMAT Test Centre.");
		obj.test_gmat_center.focus();
		return false;
	}/*
	if (trim(obj.test_gmat_center.value)!= "" && (obj.test_gmat_result.value=="" || obj.test_gmat_result.value==0)) {
		$sectionTabs.tabs('select','#testresult');
		$.jGrowl("Please enter your GMAT score.");
		obj.test_gmat_result.focus();
		return false;
	}*/
	if (obj.test_gmat_result.value > 800) {
		$sectionTabs.tabs('select','#testresult');
		$.jGrowl("Your GMAT score can not exceed 800.");
		obj.test_gmat_result.focus();
		return false;
	}
	if (trim(obj.test_gre_date.value)!="" && trim(obj.test_gre_date.value)!="0000-00-00" && trim(obj.test_gre_center.value)=="") {
		$sectionTabs.tabs('select','#testresult');
		$.jGrowl("Please enter your GRE Test Centre.");
		obj.test_gre_center.focus();
		return false;
	}/*
	if (trim(obj.test_gre_center.value)!= "" && (obj.test_gre_analytical.value==0 && obj.test_gre_verbal.value==0 && obj.test_gre_quantitative.value==0)) {
		$sectionTabs.tabs('select','#testresult');
		$.jGrowl("Please enter your GRE score.");
		obj.test_gre_analytical.focus();
		return false;
	}*/
	if (obj.test_gre_analytical.value > 6) {
		$sectionTabs.tabs('select','#testresult');
		$.jGrowl("Your GRE analytical writing score range from 0-6.");
		obj.test_gre_analytical.focus();
		return false;
	}
	if (obj.test_gre_verbal.value>0 && (obj.test_gre_verbal.value > 800 || obj.test_gre_verbal.value < 200)) {
		$sectionTabs.tabs('select','#testresult');
		$.jGrowl("Your GRE verbal reasoning score range from 200-800.");
		obj.test_gre_verbal.focus();
		return false;
	}
	if (obj.test_gre_quantitative.value>0 && (obj.test_gre_quantitative.value > 800 || obj.test_gre_quantitative.value < 200)) {
		$sectionTabs.tabs('select','#testresult');
		$.jGrowl("Your GRE quantitative reasoning score range from 200-800.");
		obj.test_gre_quantitative.focus();
		return false;
	}
	countTotalSAT1(obj);
	countTotalSAT2(obj);
	countTotalGRE(obj);

	// Language
	for (i=1; i<=globals['max_language']; i++) {
		if (obj['language_languageid'+i].selectedIndex!=0) {
			if (obj['language_proficiency_speak'+i].selectedIndex==0) {
				$sectionTabs.tabs('select','#language');
				$.jGrowl("Please select your speak proficiency.");
				obj['language_proficiency_speak'+i].focus();
				return false;
			}
			if (obj['language_proficiency_read'+i].selectedIndex==0) {
				$sectionTabs.tabs('select','#language');
				$.jGrowl("Please select your read proficiency.");
				obj['language_proficiency_read'+i].focus();
				return false;
			}
			if (obj['language_proficiency_write'+i].selectedIndex==0) {
				$sectionTabs.tabs('select','#language');
				$.jGrowl("Please select your write proficiency.");
				obj['language_proficiency_write'+i].focus();
				return false;
			}
		}
	}
	obj.submit();
	return true;
}

function countTotalSAT1(objForm) {
  if (isNaN(objForm.test_sat1_verbal.value) || objForm.test_sat1_verbal.value=="")
    objForm.test_sat1_verbal.value = 0;
  if (isNaN(objForm.test_sat1_written.value) || objForm.test_sat1_written.value=="")
    objForm.test_sat1_written.value = 0;
  if (isNaN(objForm.test_sat1_math.value) || objForm.test_sat1_math.value=="")
    objForm.test_sat1_math.value = 0;
  objForm.test_sat1_result.value = parseInt(objForm.test_sat1_verbal.value) + parseInt(objForm.test_sat1_written.value) + parseInt(objForm.test_sat1_math.value);
}

function countTotalSAT2(objForm) {
  if (isNaN(objForm.test_sat2_result1.value) || objForm.test_sat2_result1.value=="")
    objForm.test_sat2_result1.value = 0;
  if (isNaN(objForm.test_sat2_result2.value) || objForm.test_sat2_result2.value=="")
    objForm.test_sat2_result2.value = 0;
  if (isNaN(objForm.test_sat2_result3.value) || objForm.test_sat2_result3.value=="")
    objForm.test_sat2_result3.value = 0;
  if (isNaN(objForm.test_sat2_result4.value) || objForm.test_sat2_result4.value=="")
    objForm.test_sat2_result4.value = 0;
  objForm.test_sat2_result.value = parseInt(objForm.test_sat2_result1.value) + parseInt(objForm.test_sat2_result2.value) + parseInt(objForm.test_sat2_result3.value) + parseInt(objForm.test_sat2_result4.value);
}

function countTotalGRE(objForm) {
  if (isNaN(objForm.test_gre_analytical.value) || objForm.test_gre_analytical.value=="")
    objForm.test_gre_analytical.value = 0;
  if (isNaN(objForm.test_gre_verbal.value) || objForm.test_gre_verbal.value=="")
    objForm.test_gre_verbal.value = 0;
  if (isNaN(objForm.test_gre_quantitative.value) || objForm.test_gre_quantitative.value=="")
    objForm.test_gre_quantitative.value = 0;
  objForm.test_gre_result.value = parseInt(objForm.test_gre_verbal.value) + parseInt(objForm.test_gre_quantitative.value);
}

function checkPercentile(obj) {
	if (isNaN(obj.value) || obj.value=="" || obj.value<0)
	  obj.value = 0;
	if (obj.value>100)
	  obj.value = 100;
}

//CHECK SINGAPORE POSTAL CODE
function checkSingaporePostalCode(p) {
	if (p.length!=6)
	  return false;
	var pattern = /[0-9]{6}/;
	if (p.match(pattern))
	  return 1;
	return false;
}

function toggleSection(formID, newSectionID) {
	var objForm, currentSectionID, currentSection, newSection;
	objForm = document.getElementById(formID);
	currentSectionID = objForm['currentSection'].value;
	if (currentSectionID!=newSectionID) {
		newSection = document.getElementById(newSectionID);
		objForm['currentSection'].value = newSectionID;
		if (currentSectionID)
			currentSection = document.getElementById(currentSectionID);
	  else
      currentSection = newSection;
	  currentSection.style.display = "none";
	  newSection.style.display = "block";
		newSection.focus();
	}
}

function toggleJCDiploma(obj) {
	var target, objLength, i, tmp, course;
	objLength = obj.options.length;
	for (i=0; i<objLength; i++) {
		tmp = obj.options[i].value;
		target = document.getElementById("a_"+tmp);
		course = document.getElementById("education_course2_"+tmp);
		cum_score = document.getElementById("education_cumulative_score2_"+tmp);
		if (tmp=='Diploma' || tmp=='ACT_NUS') {
			for (j=1; j<=5; j++)
				aux[j] = document.getElementById("education_aux2_"+tmp+"_"+j);
		}
		else
			aux = document.getElementById("education_aux2_"+tmp);
		if (tmp==obj.value) {
			target.style.display = "block";
			course.disabled = false;
			cum_score.disabled = false;
			if (tmp=='Diploma' || tmp=='ACT_NUS')
				for (j=1; j<=5; j++)
					aux[j].disabled = false;
			else
				aux.disabled = false;
		}
		else {
			target.style.display = "none";
			course.disabled = true;
			cum_score.disabled = true;
			if (tmp=='Diploma' || tmp=='ACT_NUS')
				for (j=1; j<=5; j++)
					aux[j].disabled = true;
			else
				aux.disabled = true;
		}
	}
}

function toggleSecondary(obj) {
	var target, objLength, i, tmp;
	objLength = obj.options.length;
	for (i=0; i<objLength; i++) {
	  tmp = obj.options[i].value;
	  target = document.getElementById("o_"+tmp);
		if (tmp==obj.value) {
		  target.style.display = "block";
		}
		else {
			target.style.display = "none";
		}
	}
}

function changeALevelGrade(gradeIndex) {
	var prolist = document.getElementById('education_promo_grade'+gradeIndex);
	var prelist = document.getElementById('education_prelim_grade'+gradeIndex);
	var reslist = document.getElementById('education_result_grade'+gradeIndex);
	var i;

	for (i=0; i < prolist.length;) {
		prolist.options[0] = null;
		prelist.options[0] = null;
		reslist.options[0] = null;
	}
	var gradelevel = document.getElementById('education_a_level'+gradeIndex).value;
	for (i=0; i < grade[gradelevel].length; i++) {
		prolist.options[i] = new Option(grade[gradelevel][i]);
		prolist.options[i].value = grade[gradelevel][i];
		prelist.options[i] = new Option(grade[gradelevel][i]);
		prelist.options[i].value = grade[gradelevel][i];
		reslist.options[i] = new Option(grade[gradelevel][i]);
		reslist.options[i].value = grade[gradelevel][i];
	}
}

function changeIBLevelGrade(gradeIndex) {
	var prolist = document.getElementById('education_ib_promo_grade'+gradeIndex);
	var prelist = document.getElementById('education_ib_prelim_grade'+gradeIndex);
	var reslist = document.getElementById('education_ib_result_grade'+gradeIndex);
	var i;

	for (i=0; i < prolist.length;) {
		prolist.options[0] = null;
		prelist.options[0] = null;
		reslist.options[0] = null;
	}
	var gradelevel = document.getElementById('education_ib_level'+gradeIndex).value;
	for (i=0; i < grade[gradelevel].length; i++) {
		prolist.options[i] = new Option(grade[gradelevel][i]);
		prolist.options[i].value = grade[gradelevel][i];
		prelist.options[i] = new Option(grade[gradelevel][i]);
		prelist.options[i].value = grade[gradelevel][i];
		reslist.options[i] = new Option(grade[gradelevel][i]);
		reslist.options[i].value = grade[gradelevel][i];
	}
}
//--><!]]>