function checkForm() {
	var f 	= document.form1;
	var chk = 1;
	document.getElementById("warn_msg").innerHTML= '';
	document.getElementById("alert_msg").innerHTML= '';

	

	document.getElementById("t_p1_name").className ="txt_normal";
	document.getElementById("t_p1_gender").className ="txt_normal";
	document.getElementById("t_p1_passport_no").className ="txt_normal";
	document.getElementById("t_p1_place_birth").className ="txt_normal";	
	document.getElementById("t_p1_hk_resident").className ="txt_normal";	
	document.getElementById("t_p1_b_date").className ="txt_normal";	
	document.getElementById("t_p1_citizenship").className ="txt_normal";	
	document.getElementById("t_p1_applying_grade").className ="txt_normal";	
	document.getElementById("t_p1_lang_native").className ="txt_normal";	
	
	
	document.getElementById("t_p2_grade").className ="txt_normal";
	document.getElementById("t_p2_school").className ="txt_normal";
	document.getElementById("t_p2_address").className ="txt_normal";
	document.getElementById("t_p2_phone").className ="txt_normal";	
	document.getElementById("t_p2_fax").className ="txt_normal";

	document.getElementById("t_p2_q1").className ="txt_normal";
	document.getElementById("t_p2_q1_grade").className ="txt_normal";
	document.getElementById("t_p2_q2").className ="txt_normal";
	document.getElementById("t_p2_q3").className ="txt_normal";
	document.getElementById("t_p2_q4").className ="txt_normal";
	document.getElementById("t_p2_q5").className ="txt_normal";
	document.getElementById("t_p2_q6").className ="txt_normal";
	document.getElementById("t_p2_q7").className ="txt_normal";
	document.getElementById("t_p2_details").className ="txt_normal";
	document.getElementById("t_p2_sign_confirm").className ="txt_normal";
	document.getElementById("t_p2_essay").className ="txt_normal";
	document.getElementById("t_p2_email").className ="txt_normal";
	document.getElementById("t_p2_awards").className ="txt_normal";
	//add community and service activities of applicant
    document.getElementById("t_p2_community").className ="txt_normal";
	
	
	document.getElementById("t_p3_parents").className ="txt_normal";
	document.getElementById("t_p3_billing").className ="txt_normal";

	document.getElementById("t_p3_fa_name").className ="txt_normal";
	document.getElementById("t_p3_fa_citizenship").className ="txt_normal";
	document.getElementById("t_p3_fa_native_lang").className ="txt_normal";
	document.getElementById("t_p3_fa_home_address").className ="txt_normal";
	document.getElementById("t_p3_fa_home_phone").className ="txt_normal";
	document.getElementById("t_p3_fa_company_name").className ="txt_normal";
	document.getElementById("t_p3_fa_company_position").className ="txt_normal";
	document.getElementById("t_p3_fa_company_address").className ="txt_normal";
	document.getElementById("t_p3_fa_company_phone").className ="txt_normal";
	document.getElementById("t_p3_fa_mobile").className ="txt_normal";
	document.getElementById("t_p3_fa_fax").className ="txt_normal";
	document.getElementById("t_p3_fa_email").className ="txt_normal";
	document.getElementById("t_p3_fa_degree").className ="txt_normal";

	document.getElementById("t_p3_ma_name").className ="txt_normal";
	document.getElementById("t_p3_ma_citizenship").className ="txt_normal";
	document.getElementById("t_p3_ma_native_lang").className ="txt_normal";
	document.getElementById("t_p3_ma_home_address").className ="txt_normal";
	document.getElementById("t_p3_ma_home_phone").className ="txt_normal";
	document.getElementById("t_p3_ma_company_name").className ="txt_normal";
	document.getElementById("t_p3_ma_company_position").className ="txt_normal";
	document.getElementById("t_p3_ma_company_address").className ="txt_normal";
	document.getElementById("t_p3_ma_company_phone").className ="txt_normal";
	document.getElementById("t_p3_ma_mobile").className ="txt_normal";
	document.getElementById("t_p3_ma_fax").className ="txt_normal";
	document.getElementById("t_p3_ma_email").className ="txt_normal";
	document.getElementById("t_p3_ma_degree").className ="txt_normal";
	document.getElementById("t_p3_parents_other").className ="txt_normal";
	document.getElementById("t_p3_both_live_hk").className ="txt_normal";
	document.getElementById("t_p3_both_live_hk_elaborate").className ="txt_normal";

	document.getElementById("t_p4_note_holder").className ="txt_normal";
	document.getElementById("t_p4_agreement_no").className ="txt_normal";


	document.getElementById("t_p5_act_od").className ="txt_normal";
	document.getElementById("t_p5_act_st").className ="txt_normal";
	document.getElementById("t_p5_act_bs").className ="txt_normal";
	document.getElementById("t_p5_act_ps").className ="txt_normal";
	document.getElementById("t_p5_act_ee").className ="txt_normal";

	document.getElementById("t_sur_q1").className ="txt_normal";
	document.getElementById("t_sur_q2").className ="txt_normal";
	document.getElementById("t_sur_q2_txt").className ="txt_normal";
	document.getElementById("t_sur_q3").className ="txt_normal";
	document.getElementById("t_agreement").className ="txt_normal";

	alert_msg_txt = "";
	phone_msg = "Phone and Fax number should be 8-20 characters. Please use \' ( \' , \' ) \' , \' - \' and numbers only.<br><br>";

	// ------ Part 1 ------ 

	if ((f.p1_surname.value == "") && (f.p1_first_name.value == "") && (f.p1_middle_name.value == "")) {
		document.getElementById("t_p1_name").className ="txt_alert";
		chk = 0;
	}

	if (!f.p1_gender[0].checked && !f.p1_gender[1].checked) {
		document.getElementById("t_p1_gender").className ="txt_alert";
		chk = 0;
	}

	if (f.p1_passport_no.value == "") {
		document.getElementById("t_p1_passport_no").className ="txt_alert";
		chk = 0;
	}

	if (f.p1_place_birth.value == "") {
		document.getElementById("t_p1_place_birth").className ="txt_alert";
		chk = 0;
	}

	if (!f.p1_hk_resident[0].checked && !f.p1_hk_resident[1].checked) {
		document.getElementById("t_p1_hk_resident").className ="txt_alert";
		chk = 0;
	}

	if ((f.p1_b_year.value == "") || (f.p1_b_month.value == "") || (f.p1_b_day.value == "")) {
		document.getElementById("t_p1_b_date").className ="txt_alert";
		chk = 0;
	}

	if (f.p1_citizenship.value == "") {
		document.getElementById("t_p1_citizenship").className ="txt_alert";
		chk = 0;
	}
	
	document.getElementById("show_link").className ="txt_normal";
	if (f.p1_applying_grade.value == "") {
		document.getElementById("t_p1_applying_grade").className ="txt_alert";
		chk = 0;
	}//else if (f.p1_applying_grade.value != 'FY' && f.p1_applying_grade.value != '01' && f.click_link.value != '1' ) {
	else if (f.p1_applying_grade.value != 'FY' && f.p1_applying_grade.value != '01' && f.click_link.value != '1') {
		document.getElementById("show_link").className ="txt_alert";
		chk = 0;	 
	}

	if (f.p1_lang_native.value == "") {
		document.getElementById("t_p1_lang_native").className ="txt_alert";
		chk = 0;
	}
	
	if (f.p1_lang_native.value == "other" && f.p1_lang_native_other.value == "") {
		document.getElementById("t_p1_lang_native").className ="txt_alert";
		chk = 0; 
	}
	
	// --------------------

	// ------ Part 2 ------
	if (f.p2_grade.value == "") {
		document.getElementById("t_p2_grade").className ="txt_alert";
		chk = 0;
	}

	if (f.p2_school.value == "") {
		document.getElementById("t_p2_school").className ="txt_alert";
		chk = 0;
	}
	
	// if (f.p2_email.value == "") {
		// document.getElementById("t_p2_email").className ="txt_alert";
		// chk = 0;
	// }


	if (f.p2_address.value == "") {
		document.getElementById("t_p2_address").className ="txt_alert";
		chk = 0;
	}
	
	if (f.p2_essay.value == "") {
		document.getElementById("t_p2_essay").className ="txt_alert";
		chk = 0;
	}	
	
	if(f.p3_parents[3].checked){
		if (f.p3_parents_other.value == "") {
			document.getElementById("t_p3_parents_other").className ="txt_alert";
			chk = 0;
		}
	}
	// if (f.p2_awards.value == "") {
		// document.getElementById("t_p2_awards").className ="txt_alert";
		// chk = 0;
	// }

	if (!checkPhone(f.p2_phone.value)) {
		document.getElementById("t_p2_phone").className = "txt_alert";		
		alert_msg_txt = phone_msg;
		chk = 0;
	}

	if (!checkPhone(f.p2_fax.value)) {
		document.getElementById("t_p2_fax").className ="txt_alert";
		alert_msg_txt = phone_msg;
		chk = 0;
	}

	if (!f.p2_q1[0].checked && !f.p2_q1[1].checked) {
		document.getElementById("t_p2_q1").className ="txt_alert";
		chk = 0;
	}

	if (f.p2_q1[1].checked && f.p2_q1_grade.value == "") {
		document.getElementById("t_p2_q1_grade").className ="txt_alert";
		chk = 0;
	}

	if (!f.p2_q2[0].checked && !f.p2_q2[1].checked) {
		document.getElementById("t_p2_q2").className ="txt_alert";
		chk = 0;
	}

	if (!f.p2_q3[0].checked && !f.p2_q3[1].checked) {
		document.getElementById("t_p2_q3").className ="txt_alert";
		chk = 0;
	}

	if (!f.p2_q4[0].checked && !f.p2_q4[1].checked) {
		document.getElementById("t_p2_q4").className ="txt_alert";
		chk = 0;
	}

	if (!f.p2_q5[0].checked && !f.p2_q5[1].checked) {
		document.getElementById("t_p2_q5").className ="txt_alert";
		chk = 0;
	}
 
	if (!f.p2_sign_confirm.checked) {
		document.getElementById("t_p2_sign_confirm").className ="txt_alert";
		chk = 0;
	}

	if (!f.p2_q6[0].checked && !f.p2_q6[1].checked) {
		document.getElementById("t_p2_q6").className ="txt_alert";
		chk = 0;
	}else if (f.p2_q6[1].checked && !f.p2_q7[0].checked && !f.p2_q7[1].checked) {
		document.getElementById("t_p2_q7").className ="txt_alert";
		chk = 0; 
	}

	if ( (f.p2_q1[1].checked || f.p2_q2[1].checked || f.p2_q3[1].checked || f.p2_q4[1].checked || f.p2_q5[1].checked || f.p2_q6[1].checked) && (f.p2_details.value == "") ) {
		document.getElementById("t_p2_details").className ="txt_alert";
		chk = 0;
	}
	// --------------------


	// ------ Part 3 ------

	if (!f.p3_parents[0].checked && !f.p3_parents[1].checked && !f.p3_parents[2].checked && !f.p3_parents[3].checked) {
		document.getElementById("t_p3_parents").className ="txt_alert";
		chk = 0;
	}

	if (!f.p3_billing_1[0].checked && !f.p3_billing_1[1].checked && !f.p3_billing_1[2].checked) {
		document.getElementById("t_p3_billing").className ="txt_alert";
		chk = 0;
	}

	if (!f.p3_billing_2[0].checked && !f.p3_billing_2[1].checked) {
		document.getElementById("t_p3_billing").className ="txt_alert";
		chk = 0;
	}

	if (f.p3_fa_name.value == "") {
		document.getElementById("t_p3_fa_name").className ="txt_alert";
		chk = 0;
	}

	if (f.p3_fa_citizenship.value == "") {
		document.getElementById("t_p3_fa_citizenship").className ="txt_alert";
		chk = 0;
	}

	if (f.p3_fa_native_lang.value == "") {
		document.getElementById("t_p3_fa_native_lang").className ="txt_alert";
		chk = 0;
	}
	
	if (f.p3_fa_native_lang.value == "other" && f.p3_fa_native_lang_other.value == "") {
		document.getElementById("t_p3_fa_native_lang").className ="txt_alert";
		chk = 0; 
	}	
	
	if (f.p3_ma_native_lang.value == "other" && f.p3_ma_native_lang_other.value == "") {
		document.getElementById("t_p3_ma_native_lang").className ="txt_alert";
		chk = 0; 
	}	

	if (f.p3_fa_home_address.value == "") {
		document.getElementById("t_p3_fa_home_address").className ="txt_alert";
		chk = 0;
	}

	if (!checkPhone(f.p3_fa_home_phone.value)) {
		document.getElementById("t_p3_fa_home_phone").className ="txt_alert";
		alert_msg_txt = phone_msg;
		chk = 0;
	}

	if (f.p3_fa_company_name.value == "") {
		document.getElementById("t_p3_fa_company_name").className ="txt_alert";
		chk = 0;
	}
	if (f.p3_fa_company_position.value == "") {
		document.getElementById("t_p3_fa_company_position").className ="txt_alert";
		chk = 0;
	}
	if (f.p3_fa_company_address.value == "") {
		document.getElementById("t_p3_fa_company_address").className ="txt_alert";
		chk = 0;
	}
	if (!checkPhone(f.p3_fa_company_phone.value)) {
		document.getElementById("t_p3_fa_company_phone").className ="txt_alert";
		alert_msg_txt = phone_msg;
		chk = 0;
	}
	if (!checkPhone(f.p3_fa_mobile.value)) {
		document.getElementById("t_p3_fa_mobile").className ="txt_alert";
		alert_msg_txt = phone_msg;
		chk = 0;
	}
	if (!checkPhone(f.p3_fa_fax.value)) {
		document.getElementById("t_p3_fa_fax").className ="txt_alert";
		alert_msg_txt = phone_msg;
		chk = 0;
	}
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(f.p3_fa_email.value) == false){
		document.getElementById("t_p3_fa_email").className ="txt_alert";
		chk = 0;
	}
	if (f.p3_fa_degree.value == "") {
		document.getElementById("t_p3_fa_degree").className ="txt_alert";
		chk = 0;
	}

	if (f.p3_ma_home_phone.value != ""){
		if (!checkPhone(f.p3_ma_home_phone.value)) {
			document.getElementById("t_p3_ma_home_phone").className ="txt_alert";
			alert_msg_txt = phone_msg;
			chk = 0;
		}
	}

	if (f.p3_ma_company_phone.value != ""){	
		if (!checkPhone(f.p3_ma_company_phone.value)) {
			document.getElementById("t_p3_ma_company_phone").className ="txt_alert";
			alert_msg_txt = phone_msg;
			chk = 0;
		}
	}
	if (f.p3_ma_mobile.value != ""){
		if (!checkPhone(f.p3_ma_mobile.value)) {
			document.getElementById("t_p3_ma_mobile").className ="txt_alert";
			alert_msg_txt = phone_msg;
			chk = 0;
		}
	}
	if (f.p3_ma_fax.value != ""){
		if (!checkPhone(f.p3_ma_fax.value)) {
			document.getElementById("t_p3_ma_fax").className ="txt_alert";
			alert_msg_txt = phone_msg;
			chk = 0;
		}
	}
	if (f.p3_ma_email.value != ""){
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(f.p3_ma_email.value) == false){
			document.getElementById("t_p3_ma_email").className ="txt_alert";
			chk = 0;
		}
	}
	
	if (!f.p3_both_live_hk[0].checked && !f.p3_both_live_hk[1].checked) {
		document.getElementById("t_p3_both_live_hk").className ="txt_alert";
		chk = 0;
	}else if (f.p3_both_live_hk[1].checked && f.p3_both_live_hk_elaborate.value == "") {
		document.getElementById("t_p3_both_live_hk_elaborate").className ="txt_alert";
		chk = 0;
	}
	


	// --------------------

	// ------ Part 4 ------

	// if (!f.p4_note_holder[0].checked && !f.p4_note_holder[1].checked) {
		// document.getElementById("t_p4_note_holder").className ="txt_alert";
		// chk = 0;
	// }
	// if (f.p4_note_holder[0].checked && f.p4_agreement_no.value == "") {
		// document.getElementById("t_p4_agreement_no").className ="txt_alert";
		// chk = 0;
	// }

	// --------------------

	// ------ Comments ----
	if (f.p5_act_od.checked && ((f.p5_act_od_year.value == "") || (f.p5_act_od_month.value == "") || (f.p5_act_od_day.value == "")) ) {
		document.getElementById("t_p5_act_od").className ="txt_alert";
	}
	if (f.p5_act_st.checked && ((f.p5_act_st_year.value == "") || (f.p5_act_st_month.value == "") || (f.p5_act_st_day.value == "")) ) {
		document.getElementById("t_p5_act_st").className ="txt_alert";
	}
	// if (f.p5_act_bs.checked && ((f.p5_act_bs_year.value == "") || (f.p5_act_bs_month.value == "") || (f.p5_act_bs_day.value == "")) ) {
		// document.getElementById("t_p5_act_bs").className ="txt_alert";
	// }
	if (f.p5_act_ps.checked && ((f.p5_act_ps_year.value == "") || (f.p5_act_ps_month.value == "") || (f.p5_act_ps_day.value == "")) ) {
		document.getElementById("t_p5_act_ps").className ="txt_alert";
	}
	if (f.p5_act_ee.checked && ((f.p5_act_ee_year.value == "") || (f.p5_act_ee_month.value == "") || (f.p5_act_ee_day.value == "")) ) {
		document.getElementById("t_p5_act_ee").className ="txt_alert";
	}
	// --------------------

	// ------ Survey ------

	if (f.sur_q1.value == "") {
		document.getElementById("t_sur_q1").className ="txt_alert";
		chk = 0;
	}

	if (!f.sur_q2[0].checked && !f.sur_q2[1].checked) {
		document.getElementById("t_sur_q2").className ="txt_alert";
		chk = 0;
	}

	if (f.sur_q2[0].checked && f.sur_q2_txt.value == "") {
		document.getElementById("t_sur_q2_txt").className ="txt_alert";
		chk = 0;
	}

	if (f.sur_q3.value == "") {
		document.getElementById("t_sur_q3").className ="txt_alert";
		chk = 0;
	}


	// --------------------

	if (!f.agreement[0].checked) {
		document.getElementById("t_agreement").className ="txt_alert";
		chk = 0;
	}

	if (chk == 0) {
		document.getElementById("warn_msg").innerHTML= 'Please input the required field(s).<br>'+alert_msg_txt;
	} else {
		f.submit();
	}
}

function checkPhone(str) 
{
	var phone2 = /^(\+\d)*\s*(\(\d+\)\s*)*\d+(-{0,1}|\s{0,1})\d+(-{0,1}|\s{0,1})\d+$/;

	if (str.length<7)
	{
		return false;
	}

	if (str.match(phone2)) {
   		return true;
 	} else {
 		return false;
 	}
}


function p2_display_grade(val){
	if (val==1){
		document.getElementById('div_p2_q1_grade').style.display = "";
	} else {
		document.getElementById('div_p2_q1_grade').style.display = "none";
	}
}

function updateStartDate()
{
	var currentTime = new Date();
	var cur_year = currentTime.getFullYear();
	var cur_month = currentTime.getMonth() + 1;

	var x=document.getElementById("p1_applying_grade");
	if (x.length>0)
	{
		if (cur_month>=9)
		{
			year = currentTime.getFullYear() + 1;
		} else {
			year = currentTime.getFullYear();
		}
		
		document.getElementById("p1_start_year").value = year;
		document.getElementById("p1_start_month").value = 9;
		document.getElementById("p1_start_date").innerHTML = '09/'+year;
	} else {
		document.getElementById("p1_start_year").value = '';
		document.getElementById("p1_start_month").value = '';
		document.getElementById("p1_start_date").innerHTML = '';
	}

}

function updateApplyingGrade()
{
	if ( (document.getElementById("p1_b_year").value != "") && (document.getElementById("p1_b_month").value != "")  && (document.getElementById("p1_b_day").value != "") && (     document.getElementById("p1_applying_ays").value != "") )
	{
	
		var sel = document.getElementById("p1_applying_grade");
		while (sel.firstChild) {
		sel.removeChild(sel.firstChild);
		}
		
		var val=new Array("FY","01","02","03","04","05","06","07","08","09","10","11","12");
		var label=new Array("FY","Grade 1","Grade 2","Grade 3","Grade 4","Grade 5","Grade 6","Grade 7","Grade 8","Grade 9","Grade 10","Grade 11","Grade 12");
		var arr_tmp = new Array();
		var x=document.getElementById("p1_applying_grade");
		var y = document.getElementById("p1_b_year").value;
		var m = document.getElementById("p1_b_month").value - 1;
		var d = document.getElementById("p1_b_day").value;
		var applying_ays = document.getElementById("p1_applying_ays").value;
		var stud_date = new Date(y,m,d); 

		if(applying_ays == '2011 / 2012' ){
	  
			if( stud_date  >= (new Date(2005,8,1)) && stud_date <= (new Date(2006,11,31)) )
					arr_tmp.push(0);
			
 			if( stud_date  >= (new Date(2004,8,1)) && stud_date <= (new Date(2005,11,31)) )
					arr_tmp.push(1);
			
 			if( stud_date  >= (new Date(2003,8,1)) && stud_date <= (new Date(2004,11,31)) )
					arr_tmp.push(2);
			
 			if( stud_date  >= (new Date(2002,8,1)) && stud_date <= (new Date(2003,11,31)) )
					arr_tmp.push(3);
			 
			 if( stud_date  >= (new Date(2001,8,1)) && stud_date <= (new Date(2002,11,31)) )
					arr_tmp.push(4);
			
 			if( stud_date  >= (new Date(2000,8,1)) && stud_date <= (new Date(2001,11,31)) )
					arr_tmp.push(5);
			
 			if( stud_date  >= (new Date(1999,8,1)) && stud_date <= (new Date(2000,11,31)) )
					arr_tmp.push(6);
			
 			if( stud_date  >= (new Date(1998,8,1)) && stud_date <= (new Date(1999,11,31)) )
					arr_tmp.push(7);
			
 			if( stud_date  >= (new Date(1997,8,1)) && stud_date <= (new Date(1998,11,31)) )
					arr_tmp.push(8);
			
 			if( stud_date  >= (new Date(1996,8,1)) && stud_date <= (new Date(1997,11,31)) )
					arr_tmp.push(9);
			
 			if( stud_date  >= (new Date(1995,8,1)) && stud_date <= (new Date(1996,11,31)) )
					arr_tmp.push(10);
			
 			if( stud_date  >= (new Date(1994,8,1)) && stud_date <= (new Date(1995,11,31)) )
					arr_tmp.push(11);
	 		
			if( stud_date  >= (new Date(1993,8,1)) && stud_date <= (new Date(1994,11,31)) )
					arr_tmp.push(12);
			
 
		}else if(applying_ays == '2010 / 2011'){ 
 
			if( stud_date  >= (new Date(2004,8,1)) && stud_date <= (new Date(2005,11,31)) )
					arr_tmp.push(0);
			
			if( stud_date  >= (new Date(2003,8,1)) && stud_date <= (new Date(2004,11,31)) )
					arr_tmp.push(1);
			
 			if( stud_date  >= (new Date(2002,8,1)) && stud_date <= (new Date(2003,11,31)) )
					arr_tmp.push(2);
			
 			if( stud_date  >= (new Date(2001,8,1)) && stud_date <= (new Date(2002,11,31)) )
					arr_tmp.push(3);
			
 			if( stud_date  >= (new Date(2000,8,1)) && stud_date <= (new Date(2001,11,31)) )
					arr_tmp.push(4);
			 
			 if( stud_date  >= (new Date(1999,8,1)) && stud_date <= (new Date(2000,11,31)) )
					arr_tmp.push(5);
			
 			if( stud_date  >= (new Date(1998,8,1)) && stud_date <= (new Date(1999,11,31)) )
					arr_tmp.push(6);
			
 			if( stud_date  >= (new Date(1997,8,1)) && stud_date <= (new Date(1998,11,31)) )
					arr_tmp.push(7);
			
 			if( stud_date  >= (new Date(1996,8,1)) && stud_date <= (new Date(1997,11,31)) )
					arr_tmp.push(8);
			
 			if( stud_date  >= (new Date(1995,8,1)) && stud_date <= (new Date(1996,11,31)) )
					arr_tmp.push(9);
			
 			if( stud_date  >= (new Date(1994,8,1)) && stud_date <= (new Date(1995,11,31)) )
					arr_tmp.push(10);
			
 			if( stud_date  >= (new Date(1993,8,1)) && stud_date <= (new Date(1994,11,31)) )
					arr_tmp.push(11);
			
 			if( stud_date  >= (new Date(1992,8,1)) && stud_date <= (new Date(1993,11,31)) )
					arr_tmp.push(12);
	 		
		} 
		  if(arr_tmp.length > 0) 
			for (i=0; i<arr_tmp.length; i++)
			{		

					var y=document.createElement('option');
					y.text = label[arr_tmp[i]];
					y.value = val[arr_tmp[i]]; 
					try
					  {
					  x.add(y,null); // standards compliant
					  }
					catch(ex)
					  {
					  x.add(y); // IE only
					  }
	 
			}
		
		x.selectedIndex = 0;		
 
		if(x.value != 'FY' && x.value != '01' && x.value != '')
			document.getElementById('show_link').style.display = 'block';
		else
			document.getElementById('show_link').style.display = 'none';
	 	
	}
}

function show_link(){
	
		var x=document.getElementById("p1_applying_grade");	 
		if(x.value != 'FY' && x.value != '01')
			document.getElementById('show_link').style.display = 'block';
		else
			document.getElementById('show_link').style.display = 'none';
}

function calTotalMonth(year, month){
	var currentTime = new Date();
	var cur_year = currentTime.getFullYear(); 
	var cur_month = currentTime.getMonth() + 1;

	cur_month = 9;

	if (month>cur_month)
	{
		cur_year-=1;
		cur_month+=12;
	}

	total_month = ((cur_year-year)*12) + (cur_month-month);

	if (total_month<0)
	{
		total_month = 0;
	}


	return total_month;
}

function checkNum(e) {	

	var   ev   =   window.event||   e; 

	if (ev.keyCode == 16)
		ev.returnValue = false; 

	// Enable 110 if "." need
    if ((ev.keyCode >= 48 && ev.keyCode <= 57) || (ev.keyCode >= 96 && ev.keyCode <= 105) || ev.keyCode == 8 || ev.keyCode == 9  || ev.keyCode == 46) {
		ev.returnValue = true;
    }   
	else{
		if (window.event){ //IE
		  ev.returnValue = false;
		}
		else{ //Firefox
		  e.preventDefault();
		}
	}
}

function isChar(s) {	
	var namevalid=/^[a-zA-Z ]+$/;
	if(s == "")
	 return false;

	if(s.search(namevalid)==-1)
	 return false;
}

function isHKID(s) {
  var re = new RegExp(document.form1.regex.value);
  if (s.match(re)) {
	return true;
  }	
  else {
    return false;
  }	
} 
 
function show_other( v , id ){

	if(v == 'other'){
		
		show  = 'block';
			
	}else{
	
		show  = 'none';
	
	}
	
	document.getElementById(id+'_other').style.display = show;
	document.getElementById(id+'_other').focus();
							
}					
						