// Following 5 functions deal with KeyPress events in Javascript
// The functions will cancel the event if a wrong key is pressed
function goodchars(e, goods)
{
	var key, keychar;
	key = getkey(e);
	if (key == null) return true;

	// get character
	keychar = String.fromCharCode(key);
	keychar = keychar.toLowerCase();
	goods = goods.toLowerCase();

	// check goodkeys
	if (goods.indexOf(keychar) != -1)
		return true;

	// control keys
	if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 )
	return true;

	// else return false
	return false;
}

function getkey(e)
{
	if (window.event)
		return window.event.keyCode;
	else if (e)
		return e.which;
	else
	
	return null;
}

function CheckRadioResponse(strRadioName, strTextName)
{
	var radioYes = eval('document.all.' + strRadioName + '_0');
	var textValue = eval('document.all.' + strTextName);
	textValue.disabled = (! radioYes.checked);
	if (! radioYes.checked)
		textValue.value = "";
}

function checkInteger(e)
{
	return goodchars(e, '0123456789');
}

function checkFloat(e)
{
	return goodchars(e, '0123456789.');
}

function checkAlphanumeric(e)
{
	return goodchars(e, 'abcdefghijklmnopqrstuvwxyz0123456789');
}

function checkDateKey(e)
{
	return goodchars(e, '0123456789');
}

function dateentry(lthis)
{
  if (!checkDateKey(lthis.value))
   return false;
  
  if (lthis.value.length == 2)
	lthis.value = lthis.value + '/'
	
  if (lthis.value.length == 5)
	lthis.value = lthis.value + '/'	
	
  return true;
}


function checkdate(a, lthis)
{
  var err=0
  if (a.length == 0) return true;
  if (a.length != 10) err=1
  b = a.substring(3, 5)// month
  c = a.substring(2, 3)// '/'
  d = a.substring(0, 2)// day
  e = a.substring(5, 6)// '/'
  f = a.substring(6, 10)// year

  //basic error checking
  if ((b<01 || b>12)||isNaN(parseInt(b))) err = 1
  if (c != '/') err = 1
  if ((d<01 || d>31)||isNaN(parseInt(d))) err = 1
  if (e != '/') err = 1
  if (f<1900 || f>3000||isNaN(parseInt(f))) err = 1
	
  //advanced error checking

  // months with 30 days
  if (b==4 || b==6 || b==9 || b==11)
  {
    if (d==31) err=1
  }

  // february, leap year
  if (b==2)
  {
    // feb
    var g=parseInt(f/4)
    if (isNaN(g))
    {
      err=1
    }

    if (d>29) err=1
  }

  if (err==1)
  {
	alert("Invalid date format.");
	lthis.focus();
    return false;
  }
  else
  {
    return true;
  }
}

function chk_submission_save()
{
  if (!confirm('Are you sure to save changes?'))
	  return false;
  else
	  return true;
}

function chk_submission_delete()
{
  if (!confirm('Are you sure to Delete'))
	  return false;
  else
	  return true;
}

function chk_submission_modify()
{
  if (!confirm('Are you sure to Modify?'))
	  return false;
  else
	  return true;
}

function chk_submission_login()
{

  if ((document.Login.txtUserName.value=="") && (document.Login.txtPassword.value==""))
	{
	  alert("LoginID and Password can not be empty!!!");
	  return false;
	  }
  else
	{
		if (document.Login.txtUserName.value=="")
		{
		alert("LoginID can not be empty!!!");
		return false;
		}
	  
		else
			{	
				if (document.Login.txtPassword.value=="")
				{
					alert("Password can not be empty!!!");
					return false;
				}
				else
					return true;
			}
	}
}

// -- To remove leading and trailing spaces, and returns the shortened string --
function TrimString(szString)
{
      var i = 0;
      var j = 0;

      for (i=0; i<parseInt(szString.length); i++) {
            if(szString.charAt(i) != " ") {
                  for (j=parseInt(szString.length) - 1; j > i; j--) {
                        if (szString.charAt(j) != " ") {
                              break;
                        }
                  }
                  break;
            }
      }

      if (i > j)
            i = j;

      if (szString.length > 0 && szString.charAt(j) != " ")
            j++;

      return szString.substring(i, j);
}

// -- To set the shortened value as the input field new value--
function TrimField(szFieldName)
{
  var szNewStr="";
  if (szFieldName.value == "")
  	return;
  if (szFieldName.value.length > 0) {
	szNewStr = TrimString(szFieldName.value);
	szFieldName.value = szNewStr;
	}
}

function IsEmpty(szFieldName)
{
      var i;
      var ch;

   if (szFieldName == "") 
   	return true;

   TrimField(szFieldName);

   if (parseInt(szFieldName.length) == 0)
         return true;

      for (i=0; i<parseInt(szFieldName.value.length); i++) {
            ch = szFieldName.value.charAt(i);
            if (ch != ' ' && ch != '\t')
                  return false;
      }
      return true;
}

function CheckApplication()
{
	if (document.all.dListMembership_type.selectedIndex == 0)
	{
		alert("Please choose a value for Type of Membership");
		document.all.dListMembership_type.focus();
		return false;
	}
	else if (document.all.dListSalutationPri.selectedIndex == 0)
	{
		alert("Please choose a value for salutation");
		document.all.dListSalutationPri.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtFirstName))
	{
		alert("Please enter a value for Name");
		document.all.txtFirstName.focus();
		return false;
	}
	else if (document.all.dListNricType.selectedIndex == 0)
	{
		alert("Please choose a value for NRIC type");
		document.all.dListNricType.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtNric))
	{
		alert("Please enter a value for NRIC");
		document.all.txtNric.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtNationality))
	{
		alert("Please enter a value for Nationality");
		document.all.txtNationality.focus();
		return false;
	}
	else if (document.all.dListRace.selectedIndex == 0)
	{
		alert("Please choose a value for Race");
		document.all.dListRace.focus();
		return false;
	}
	else if ((document.all.dListRace.value == "Others") && (IsEmpty(document.all.txtRace_Others)))
	{
		alert("Please enter a value for other race");
		document.all.txtRace_Others.focus();
		return false;
	}
	else if (document.all.radio_sex.value == "")
	{
		alert("Please enter a value for Gender");
		document.all.txtNationality.focus();
		return false;
	}
	else if (document.all.dListMarital.selectedIndex == 0)
	{
		alert("Please choose a value for Marital Status");
		document.all.dListMarital.focus();
		return false;
	}
	else if (document.all.dListEducation.selectedIndex == 0)
	{
		alert("Please choose a value for Education");
		document.all.dListEducation.focus();
		return false;
	}
	else if (document.all.dListResidence.selectedIndex == 0)
	{
		alert("Please choose a value for Residence Type");
		document.all.dListResidence.focus();
		return false;
	}
	else if (document.all.dListResidenceIS.selectedIndex == 0)
	{
		alert("Please choose a value for Residence Is");
		document.all.dListResidenceIS.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtAddress1))
	{
		alert("Please enter a value for Home Address");
		document.all.txtAddress1.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtCountry))
	{
		alert("Please enter a value for Country");
		document.all.txtCountry.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtPostalCode))
	{
		alert("Please enter a value for Postal Code");
		document.all.txtPostalCode.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtHomeTel))
	{
		alert("Please enter a value for Home Telephone");
		document.all.txtHomeTel.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtMobileNo))
	{
		alert("Please enter a value for Mobile Number");
		document.all.txtMobileNo.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtEmail))
	{
		alert("Please enter a value for Email address");
		document.all.txtEmail.focus();
		return false;
	}
	else if (document.all.dListPaymode.selectedIndex == 0)
	{
		alert("Please choose a value for Payment Mode");
		document.all.dListPaymode.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtCompanyname))
	{
		alert("Please enter a value for Company Name");
		document.all.txtCompanyname.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtWorkAddress1))
	{
		alert("Please enter a value for Office Address");
		document.all.txtWorkAddress1.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtWorkCountry))
	{
		alert("Please enter a value for Country");
		document.all.txtWorkCountry.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtWorkZipCode))
	{
		alert("Please enter a value for Postal Code");
		document.all.txtWorkZipCode.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtOfficeTel))
	{
		alert("Please enter a value for Office Telephone");
		document.all.txtOfficeTel.focus();
		return false;
	}
	else if (document.all.dListJobStatus.selectedIndex == 0)
	{
		alert("Please choose a value for Job Status");
		document.all.dListJobStatus.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtJobPostion))
	{
		alert("Please enter a value for Position");
		document.all.txtJobPostion.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtJobLengthYears))
	{
		alert("Please enter a value for Length of Employment (Years)");
		document.all.txtJobLengthYears.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtJobLengthMonths))
	{
		alert("Please enter a value for Length of Employment (Months)");
		document.all.txtJobLengthMonths.focus();
		return false;
	}
	else if (document.all.dListSalary.selectedIndex == 0)
	{
		alert("Please choose a value for Salary Range");
		document.all.dListSalary.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtLicense_no))
	{
		alert("Please enter a value for License Number");
		document.all.txtLicense_no.focus();
		return false;
	}
	else if (document.all.dlstLic_type.selectedIndex == 0)
	{
		alert("Please choose a value for License Type");
		document.all.dlstLic_type.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtLicenseDt))
	{
		alert("Please enter a value for License Date");
		document.all.txtLicenseDt.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtlic_country))
	{
		alert("Please enter a value for License Country");
		document.all.txtlic_country.focus();
		return false;
	}	
	else if (document.all.dListPast12.selectedIndex == 0)
	{
		alert("Please choose a value for hours of driving");
		document.all.dListPast12.focus();
		return false;
	}
	else if ((document.all.radio_IsOwnCar_0.checked) && ((IsEmpty(document.all.txtOwnCarYears))))
	{
		alert("Please enter a value for years owned");
		document.all.txtOwnCarYears.focus();
		return false;
	}
	else if (document.all.dlstOtherMeansTransport.selectedIndex == 0)
	{
		alert("Please choose a value for Other means of transport");
		document.all.dlstOtherMeansTransport.focus();
		return false;
	}
	else if ((document.all.radio_IsAccident_0.checked) && ((IsEmpty(document.all.txtDrivingAccident))))
	{
		alert("Please enter a value for accident type");
		document.all.txtDrivingAccident.focus();
		return false;
	}
	else if ((document.all.radio_IsTraffic_0.checked) && ((IsEmpty(document.all.txtTrafficDemerit))))
	{
		alert("Please enter a value for demerit points");
		document.all.txtTrafficDemerit.focus();
		return false;
	}
	else if (document.all.dListSalutationEme.selectedIndex == 0)
	{
		alert("Please choose a value for salutation");
		document.all.dListSalutationEme.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtEmergencyContactName))
	{
		alert("Please enter a value for Emergency Name");
		document.all.txtEmergencyContactName.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtRelationship))
	{
		alert("Please enter a value for Relationship");
		document.all.txtRelationship.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtEmergencyTel))
	{
		alert("Please enter a value for Emergency Home Telephone");
		document.all.txtEmergencyTel.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtEmergencyMobile))
	{
		alert("Please enter a value for Emergency Mobile");
		document.all.txtEmergencyMobile.focus();
		return false;
	}
	else if (document.all.dlstReferal_through.selectedIndex == 0)
	{
		alert("Please choose a value for Referral Through");
		document.all.dlstReferal_through.focus();
		return false;
	}
	else if ((document.all.dlstReferal_through.value == "Others" || document.all.dlstReferal_through.value == "Friends") && (IsEmpty(document.all.txtReferralDetail)))
	{
		alert("Please enter a value for other referals");
		document.all.txtReferralDetail.focus();
		return false;
	}
	else
		return true;
}

function chk_submission_save_application()
{
	if (! CheckApplication())
		return false;

	if(document.application.btnSubmit.value=="Submit")
			{
			if (!confirm('Are you sure to submit?'))
				return false;
			else
				return true;
			}
	else
				return true;
}


function CheckPaymentMode(){
}

function CheckGiroReject(){
    if (document.all.dListGrioStatus.value != "Rejected")
		document.all.txtGiroReject.disabled = true;
	else
		document.all.txtGiroReject.disabled = false;
}

function CheckReferal_Through(){
    if (document.all.dlstReferal_through.value == "Others" || document.all.dlstReferal_through.value == "Friends")
		document.all.txtReferralDetail.disabled = false;
	else
		document.all.txtReferralDetail.disabled = true;
}

function CheckRace(){
    if (document.all.dListRace.value == "Others")
		document.all.txtRace_Others.disabled = false;
	else
		document.all.txtRace_Others.disabled = true;
}

function nric_licno()
{
	if (document.all.txtLicense_no.value == "")
		document.all.txtLicense_no.value= document.all.txtNric.value;

	if ((document.all.txtWebPassword) && (document.all.txtWebPassword.value == ""))
		document.all.txtWebPassword.value= document.all.txtNric.value;
}

function mailaddress()
{
}

function checkMonthYear(lthis)
{
  var err=0
  var a = lthis.value;
  
  if (a.length == 0) return true;
  if (a.length != 7) err=1
  b = a.substring(0, 2)// month
  c = a.substring(2, 3)// '/'
  f = a.substring(3, 7)// year

  //basic error checking
  if ((b<01 || b>12)||isNaN(parseInt(b))) err = 1
  if (c != '/') err = 1
  if (f<1900 || f>3000||isNaN(parseInt(f))) err = 1
	
  //advanced error checking

  if (err==1)
  {
	alert("Invalid date format.");
	lthis.focus();
    return false;
  }
  else
  {
    return true;
  }
}


function dateentry_month_year(lthis)
{
  if (!checkDateKey(lthis.value))
   return false;
   
   if (lthis.value.length == 2)
	lthis.value = lthis.value + '/'
	
	 return true;
}

function check_month_year(lthis)
{
  if (!checkMonthYear(lthis.value))
	return false;
  else
	return true;
}

function cardentry(lthis)
{

  if (!checkInteger(lthis))
	return false;
  
  if (lthis.value.length == 4)
	lthis.value = lthis.value + '-'
	
  if (lthis.value.length == 9)
	lthis.value = lthis.value + '-'	
	
  if (lthis.value.length == 14)
	lthis.value = lthis.value + '-'	
	
  return true;
}	


function CheckSupplementApplication()
{
	if (IsEmpty(document.all.txtMemFirstName))
	{
		alert("Please enter a value for Principal Member Name");
		document.all.txtMemFirstName.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtMemNric))
	{
		alert("Please enter a value for Principal Member NRIC");
		document.all.txtMemNric.focus();
		return false;
	}
	else if (document.all.dListSalutationPri.selectedIndex == 0)
	{
		alert("Please choose a value for salutation");
		document.all.dListSalutationPri.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtFirstName))
	{
		alert("Please enter a value for Name");
		document.all.txtFirstName.focus();
		return false;
	}
	else if (document.all.dListNricType.selectedIndex == 0)
	{
		alert("Please choose a value for NRIC type");
		document.all.dListNricType.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtNric))
	{
		alert("Please enter a value for NRIC");
		document.all.txtNric.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtNationality))
	{
		alert("Please enter a value for Nationality");
		document.all.txtNationality.focus();
		return false;
	}
	else if (document.all.dListRace.selectedIndex == 0)
	{
		alert("Please choose a value for Race");
		document.all.dListRace.focus();
		return false;
	}
	else if ((document.all.dListRace.value == "Others") && (IsEmpty(document.all.txtRace_Others)))
	{
		alert("Please enter a value for other race");
		document.all.txtRace_Others.focus();
		return false;
	}
	else if (document.all.radio_sex.value == "")
	{
		alert("Please enter a value for Gender");
		document.all.txtNationality.focus();
		return false;
	}
	else if (document.all.dListMarital.selectedIndex == 0)
	{
		alert("Please choose a value for Marital Status");
		document.all.dListMarital.focus();
		return false;
	}
	else if (document.all.dListEducation.selectedIndex == 0)
	{
		alert("Please choose a value for Education");
		document.all.dListEducation.focus();
		return false;
	}
	else if (document.all.dListResidence.selectedIndex == 0)
	{
		alert("Please choose a value for Residence Type");
		document.all.dListResidence.focus();
		return false;
	}
	else if (document.all.dListResidenceIS.selectedIndex == 0)
	{
		alert("Please choose a value for Residence Is");
		document.all.dListResidenceIS.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtAddress1))
	{
		alert("Please enter a value for Home Address");
		document.all.txtAddress1.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtCountry))
	{
		alert("Please enter a value for Country");
		document.all.txtCountry.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtPostalCode))
	{
		alert("Please enter a value for Postal Code");
		document.all.txtPostalCode.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtRelationship1))
	{
		alert("Please enter a value for Relationship");
		document.all.txtRelationship1.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtHomeTel))
	{
		alert("Please enter a value for Home Telephone");
		document.all.txtHomeTel.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtMobileNo))
	{
		alert("Please enter a value for Mobile Number");
		document.all.txtMobileNo.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtEmail))
	{
		alert("Please enter a value for Email address");
		document.all.txtEmail.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtCompanyname))
	{
		alert("Please enter a value for Company Name");
		document.all.txtCompanyname.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtWorkAddress1))
	{
		alert("Please enter a value for Office Address");
		document.all.txtWorkAddress1.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtWorkCountry))
	{
		alert("Please enter a value for Country");
		document.all.txtWorkCountry.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtWorkZipCode))
	{
		alert("Please enter a value for Postal Code");
		document.all.txtWorkZipCode.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtOfficeTel))
	{
		alert("Please enter a value for Office Telephone");
		document.all.txtOfficeTel.focus();
		return false;
	}
	else if (document.all.dListJobStatus.selectedIndex == 0)
	{
		alert("Please choose a value for Job Status");
		document.all.dListJobStatus.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtJobPostion))
	{
		alert("Please enter a value for Position");
		document.all.txtJobPostion.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtJobLengthYears))
	{
		alert("Please enter a value for Length of Employment (Years)");
		document.all.txtJobLengthYears.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtJobLengthMonths))
	{
		alert("Please enter a value for Length of Employment (Months)");
		document.all.txtJobLengthMonths.focus();
		return false;
	}
	else if (document.all.dListSalary.selectedIndex == 0)
	{
		alert("Please choose a value for Salary Range");
		document.all.dListSalary.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtLicense_no))
	{
		alert("Please enter a value for License Number");
		document.all.txtLicense_no.focus();
		return false;
	}	
	else if (document.all.dlstLic_type.selectedIndex == 0)
	{
		alert("Please choose a value for License Type");
		document.all.dlstLic_type.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtLicenseDt))
	{
		alert("Please enter a value for License Date");
		document.all.txtLicenseDt.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtlic_country))
	{
		alert("Please enter a value for License Country");
		document.all.txtlic_country.focus();
		return false;
	}	
	else if (document.all.dListPast12.selectedIndex == 0)
	{
		alert("Please choose a value for hours of driving");
		document.all.dListPast12.focus();
		return false;
	}
	else if ((document.all.radio_IsOwnCar_0.checked) && ((IsEmpty(document.all.txtOwnCarYears))))
	{
		alert("Please enter a value for years owned");
		document.all.txtOwnCarYears.focus();
		return false;
	}
	else if (document.all.dlstOtherMeansTransport.selectedIndex == 0)
	{
		alert("Please choose a value for Other means of transport");
		document.all.dlstOtherMeansTransport.focus();
		return false;
	}
	else if ((document.all.radio_IsAccident_0.checked) && ((IsEmpty(document.all.txtDrivingAccident))))
	{
		alert("Please enter a value for accident type");
		document.all.txtDrivingAccident.focus();
		return false;
	}
	else if ((document.all.radio_IsTraffic_0.checked) && ((IsEmpty(document.all.txtTrafficDemerit))))
	{
		alert("Please enter a value for demerit points");
		document.all.txtTrafficDemerit.focus();
		return false;
	}
	else if (document.all.dListSalutationEme.selectedIndex == 0)
	{
		alert("Please choose a value for salutation");
		document.all.dListSalutationEme.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtEmergencyContactName))
	{
		alert("Please enter a value for Emergency Name");
		document.all.txtEmergencyContactName.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtRelationship))
	{
		alert("Please enter a value for Relationship");
		document.all.txtRelationship.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtEmergencyTel))
	{
		alert("Please enter a value for Emergency Home Telephone");
		document.all.txtEmergencyTel.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtEmergencyMobile))
	{
		alert("Please enter a value for Emergency Mobile");
		document.all.txtEmergencyMobile.focus();
		return false;
	}
	else
		return true;
}

function chk_submission_save_suppliment()
{
//if (document.supplement.btnSave.value=="Save" || document.supplement.btnSubmit.value=="Submit")
if (document.supplement.btnSubmit.value=="Submit")
		{
		if (! CheckSupplementApplication())
			return false;
		if (!confirm('Are you sure to save changes?'))
			return false;
		else
			return true;
		}
else
		return true;
//		{
//		if (!confirm('Are you sure to Modify?'))
//			return false;
//		else
//			return true;
//		}
	  
}

function chk_submission_save_suppliment2()
{
//if (document.supplement.btnSave.value=="Save" || document.supplement.btnSubmit.value=="Submit")
		if (! CheckSupplementApplication2())
			return false;

		if (!confirm('Are you sure to save changes?'))
			return false;
		else
			return true;
}

function CheckSupplementApplication2()
{
	if (document.all.dListSalutationPri.selectedIndex == 0)
	{
		alert("Please choose a value for salutation");
		document.all.dListSalutationPri.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtFirstName))
	{
		alert("Please enter a value for Name");
		document.all.txtFirstName.focus();
		return false;
	}
	else if (document.all.dListNricType.selectedIndex == 0)
	{
		alert("Please choose a value for NRIC type");
		document.all.dListNricType.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtNric))
	{
		alert("Please enter a value for NRIC");
		document.all.txtNric.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtNationality))
	{
		alert("Please enter a value for Nationality");
		document.all.txtNationality.focus();
		return false;
	}
	else if (document.all.dListRace.selectedIndex == 0)
	{
		alert("Please choose a value for Race");
		document.all.dListRace.focus();
		return false;
	}
	else if ((document.all.dListRace.value == "Others") && (IsEmpty(document.all.txtRace_Others)))
	{
		alert("Please enter a value for other race");
		document.all.txtRace_Others.focus();
		return false;
	}
	else if (document.all.radio_sex.value == "")
	{
		alert("Please enter a value for Gender");
		document.all.txtNationality.focus();
		return false;
	}
	else if (document.all.dListMarital.selectedIndex == 0)
	{
		alert("Please choose a value for Marital Status");
		document.all.dListMarital.focus();
		return false;
	}
	else if (document.all.dListEducation.selectedIndex == 0)
	{
		alert("Please choose a value for Education");
		document.all.dListEducation.focus();
		return false;
	}
	else if (document.all.dListResidence.selectedIndex == 0)
	{
		alert("Please choose a value for Residence Type");
		document.all.dListResidence.focus();
		return false;
	}
	else if (document.all.dListResidenceIS.selectedIndex == 0)
	{
		alert("Please choose a value for Residence Is");
		document.all.dListResidenceIS.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtRelationship))
	{
		alert("Please enter a value for Relationship");
		document.all.txtRelationship.focus();
		return false;
	}

	else if (IsEmpty(document.all.txtCompanyname))
	{
		alert("Please enter a value for Company Name");
		document.all.txtCompanyname.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtWorkAddress1))
	{
		alert("Please enter a value for Address");
		document.all.txtWorkAddress1.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtWorkCountry))
	{
		alert("Please enter a value for Country");
		document.all.txtWorkCountry.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtWorkZipCode))
	{
		alert("Please enter a value for Postal Code");
		document.all.txtWorkAddress3.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtOfficeTel))
	{
		alert("Please enter a value for Office Telephone");
		document.all.txtOfficeTel.focus();
		return false;
	}
	else if (document.all.dListJobStatus.selectedIndex == 0)
	{
		alert("Please choose a value for Job Status");
		document.all.dListJobStatus.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtJobPostion))
	{
		alert("Please enter a value for Position");
		document.all.txtJobPostion.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtJobLengthYears))
	{
		alert("Please enter a value for Length of Employment (Years)");
		document.all.txtJobLengthYears.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtJobLengthMonths))
	{
		alert("Please enter a value for Length of Employment (Months)");
		document.all.txtJobLengthMonths.focus();
		return false;
	}
	else if (document.all.dListSalary.selectedIndex == 0)
	{
		alert("Please choose a value for Salary Range");
		document.all.dListSalary.focus();
		return false;
	}

	else if (IsEmpty(document.all.txtLicense_no))
	{
		alert("Please enter a value for License Number");
		document.all.txtLicense_no.focus();
		return false;
	}
	else if (document.all.dlstLic_type.selectedIndex == 0)
	{
		alert("Please choose a value for License Type");
		document.all.dlstLic_type.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtLicenseDt))
	{
		alert("Please enter a value for License Date");
		document.all.txtLicenseDt.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtlic_country))
	{
		alert("Please enter a value for License Country");
		document.all.txtlic_country.focus();
		return false;
	}
	else if (document.all.dListPast12.selectedIndex == 0)
	{
		alert("Please choose a value for hours of driving");
		document.all.dListPast12.focus();
		return false;
	}
	else if ((document.all.radio_IsTraffic_0.checked) && ((IsEmpty(document.all.txtTrafficDemerit))))
	{
		alert("Please enter a value for demerit points");
		document.all.txtTrafficDemerit.focus();
		return false;
	}
	else if ((document.all.radio_IsAccident_0.checked) && ((IsEmpty(document.all.txtDrivingAccident))))
	{
		alert("Please enter a value for accident type");
		document.all.txtDrivingAccident.focus();
		return false;
	}
	else if ((document.all.radio_IsOwnCar_0.checked) && ((IsEmpty(document.all.txtOwnCarYears))))
	{
		alert("Please enter a value for years owned");
		document.all.txtOwnCarYears.focus();
		return false;
	}
	else if (document.all.dlstOtherMeansTransport.selectedIndex == 0)
	{
		alert("Please choose a value for Other means of transport");
		document.all.dlstOtherMeansTransport.focus();
		return false;
	}
	
	else if (document.all.dListSalutationEme.selectedIndex == 0)
	{
		alert("Please choose a value for salutation");
		document.all.dListSalutationEme.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtEmergencyContactName))
	{
		alert("Please enter a value for Emergency Name");
		document.all.txtEmergencyContactName.focus();
		return false;
	}
	else if (IsEmpty(document.all.tbEmeRelMember))
	{
		alert("Please enter a value for Emergency Relationship to member");
		document.all.tbEmeRelMember.focus();
		return false;
	}	
	else if (IsEmpty(document.all.txtEmergencyTel))
	{
		alert("Please enter a value for Emergency Home Telephone");
		document.all.txtEmergencyTel.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtEmergencyMobile))
	{
		alert("Please enter a value for Emergency Mobile");
		document.all.txtEmergencyMobile.focus();
		return false;
	}
	else
		return true;
}

// Consuming the above functions
//<asp:TextBox CssClass="RightAlign" Enabled="False" Font-Size="8pt" ID="txtQty" MaxLength="6"
//Runat="server" Width="70px" onKeyPress="javascript: return checkInteger(event);" />

function ChangePassword()
{
	if (IsEmpty(document.all.txtOldPwd))
	{
		alert("Please enter old password");
		document.all.txtOldPwd.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtPassword))
	{
		alert("Please enter new password");
		document.all.txtPassword.focus();
		return false;
	}
	else if (IsEmpty(document.all.txtCnfPwd))
	{
		alert("Please confirm new password");
		document.all.txtCnfPwd.focus();
		return false;
	}
	else if (document.all.txtPassword.value != document.all.txtCnfPwd.value)
	{
		alert("New password and confirm new password didn\'t match");
		document.all.txtPassword.focus();
		return false;
	}
	
	return true;
}

function popUp(URL) 
{
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=1,width=800,height=600,left = 240,top = 212');");
}