function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
function ValidateRadioButton(rdName){
   var check=false;
   var i=0;
   
     
   for (i=0;i<rdName.length;i++){
       if(rdName[i].checked==true) 
       check=true
   } 
  
   if (check==false)
      return false;
   else
      return true;
}

function IsValidEmail(txt){
    var stremail="";
	if(txt.value !=""){ 
		var goodEmail = txt.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
		if (goodEmail){
		    return true;
		} else {
			stremail="- The Email address is not valid\n";
			return stremail;
		}
	}
}


function openWindow()
		{
			var w = 420;
			var h = 470;
			var left = screen.width/2 - w/2;
			var top = screen.height/2 - h/2;
			 
			window.open('locator.html','','width='+w+',height='+h+',left='+left+',top='+top)
		}

function ValidateApplication(){
	var strPersonal="";
	
	var strType="";
	if (ValidateRadioButton(document.Form1.rdCard)==false)
		strType+="- Please indicate Your Card Choice \n";
	if (ValidateRadioButton(document.Form1.rdCardType)==false)
		strType+="- Please Select a Card Type \n";
	
	if (strType!=""){
		document.Form1.rdCard[0].focus();
		alert(strType);
		return false;
	}
	
	
	if (ValidateRadioButton(document.Form1.rdTitle)==false)
		strPersonal+="- Title\n"
	if (Trim(document.Form1.txtFName.value)=="")
		strPersonal+="- First Name\n"
	if (Trim(document.Form1.txtFatherName.value)=="")
		strPersonal+="- Father's Name\n"
	if (Trim(document.Form1.txtLName.value)=="")
		strPersonal+="- Last Name\n"
	if (Trim(document.Form1.txtMotherName.value)=="")
		strPersonal+="- Mother's maiden name\n"
	if (Trim(document.Form1.txtPassport.value)=="")
		strPersonal+="- Passport#\n"
	if (Trim(document.Form1.txtNationality.value)=="")
		strPersonal+="- Nationality\n"
	if (Trim(document.Form1.txtBirth.value)=="")
		strPersonal+="- Place&Date of Birth\n"
	if (Trim(document.Form1.txtRegister.value)=="")
		strPersonal+="- Register# \n"
	if (ValidateRadioButton(document.Form1.rdMaritalStatus)==false)
		strPersonal+="- Marital Status\n";
	else{
		if (document.Form1.rdMaritalStatus[1].checked==true && Trim(document.Form1.txtSpouseName.value)=="")
			strPersonal="-Spouse's full name\n"
		}
	if (ValidateRadioButton(document.Form1.rdHomeAddress)==false)
		strPersonal+="- Home Address\n"
	if (Trim(document.Form1.txtBldg.value)=="")
		strPersonal+="- Building\n"
	if (Trim(document.Form1.txtStreet.value)=="")
		strPersonal+="- Street\n"
	if (Trim(document.Form1.txtRegion.value)=="")
		strPersonal+="- Region\n"
	if (Trim(document.Form1.txtCountry.value)=="")
		strPersonal+="- Country\n"
	if (Trim(document.Form1.txtPOBox.value)=="")
		strPersonal+="- P.O.Box\n"
	if (Trim(document.Form1.txtEmail.value)=="")
		strPersonal+="- Email\n"
	else{
		var strvalmail=IsValidEmail(document.Form1.txtEmail);
	    if (strvalmail.length>0)
	    	strPersonal+=" - Email address is not valid\n";
		 }
	if (Trim(document.Form1.txtPhone.value)=="")
		strPersonal+="- Phone\n"
	if (ValidateRadioButton(document.Form1.rdEducation)==false)
		strPersonal+="- Educational Background\n"
	
	if (strPersonal!=""){
		strPersonal="A. Personal Info\n" + strPersonal;
		document.Form1.rdTitle[0].focus();
		alert(strPersonal);
		return false;
	}
	
	
	var strProf="";
	if (ValidateRadioButton(document.Form1.rdOccupation)==false)
		strProf+="- Occupation\n"
		
	var strPrev="";
	if (Trim(document.Form1.txtPrevCompany.value)=="")
		strPrev+=" - Company/Employer "  
	if (Trim(document.Form1.txtPrevBusiness.value)=="")
		strPrev+=" - Nature of Business\n"
	if (Trim(document.Form1.txtPrevDate.value)=="")
		strPrev+=" - Employment Date \n"
	if (Trim(document.Form1.txtPrevPosition.value)=="")
		strPrev+=" - Position\n"
	if (Trim(document.Form1.txtPrevIncome.value)=="")
		strPrev+=" - Monthly Income\n"
	if (strPrev!="")
		strProf+="Previous Occupation \n" + strPrev
	
	var strPresent="";
	if (Trim(document.Form1.txtPresentCompany.value)=="")
		strPresent+=" - Company/Employer "  
	if (Trim(document.Form1.txtPresentBusiness.value)=="")
		strPresent+=" - Nature of Business\n"
	if (Trim(document.Form1.txtPresentDate.value)=="")
		strPresent+=" - Employment Date \n"
	if (Trim(document.Form1.txtPresentPosition.value)=="")
		strPresent+=" - Position\n"
	if (Trim(document.Form1.txtPresentIncome.value)=="")
		strPresent+=" - Monthly Income\n"
	if (strPresent!="")
		strProf+="Present Occupation \n" + strPresent
		
	var strComp="";	
	if (Trim(document.Form1.txtCompanyBldg.value)=="")
		strComp+=" - Building\n"
	if (Trim(document.Form1.txtCompanyStreet.value)=="")
		strComp+=" - Street\n"
	if (Trim(document.Form1.txtCompanyRegion.value)=="")
		strComp+=" - Region\n"
	if (Trim(document.Form1.txtCompanyCountry.value)=="")
		strComp+=" - Country\n"
	if (Trim(document.Form1.txtCompanyPOBox.value)=="")
		strComp+=" - P.O.Box\n"
	if (Trim(document.Form1.txtCompanyEmail.value)=="")
		strComp+=" - Email\n"
	else{
		var strvalmail2=IsValidEmail(document.Form1.txtCompanyEmail);
	    if (strvalmail2.length>0)
	    	strComp+=" - Email address is not valid\n";
		 }
	if (Trim(document.Form1.txtCompanyPhone.value)=="")
		strComp+=" - Phone\n"
	if (strComp!="")
		strProf+="Company Address \n" + strComp
	
	if (strProf!=""){
		strProf="B. Professional Information \n" + strProf;
		document.Form1.rdOccupation[0].focus();
		alert(strProf);
		return false;
	}
	
	var strBank="";
	if (ValidateRadioButton(document.Form1.rdCustomer)==false)
		strBank+=" - Are you FBL customer\n"
	if (Trim(document.Form1.txtBankName1.value)=="")
		strBank+=" - Bank 1 Name\n"
	if (Trim(document.Form1.txtAccountType1.value)=="")
		strBank+=" - Account 1 Type\n"
	if (Trim(document.Form1.txtAccountNumb1.value)=="")
		strBank+=" - Account 1 Number\n"
	if (Trim(document.Form1.txtBankName2.value)=="")
		strBank+=" - Bank 2 Name\n"
	if (Trim(document.Form1.txtAccountType2.value)=="")
		strBank+=" - Account 2 Type\n"
	if (Trim(document.Form1.txtAccountNumb2.value)=="")
		strBank+=" - Account 2 Number\n"
	if (strBank!=""){
		strBank="C. Banking Information / Reference \n" + strBank;
		document.Form1.rdCustomer[0].focus();
		alert(strBank);
		return false;
	}
	
	var strCard="";
	if (Trim(document.Form1.txtApplicantName.value)=="")
		strCard+=" - Princial card applicant name \n"
	if (Trim(document.Form1.txtNameOnCard.value)=="")
		strCard+=" - Name as you wish to appear on the card \n"
	var strFunding="";
	if (Trim(document.Form1.txtFundingBankName.value)=="")
		strFunding+=" - Bank Name \n"
	if (Trim(document.Form1.txtFundingBranch.value)=="")
		strFunding+=" - Branch\n"
	if (Trim(document.Form1.txtFundingAccount.value)=="")
		strFunding+=" - Account#\n"
	if (strFunding!=""){
		strCard+="Funding Account\n" + strFunding
		}
	
	var strSupp="";
	if (Trim(document.Form1.txtSupplementaryName1.value)=="")
		strSupp+=" - Supplementary card applicant's 1 name \n"
	if (Trim(document.Form1.txtSuppBirth1.value)=="")
		strSupp+=" - Date Of Birth 1\n"
	if (Trim(document.Form1.txtSuppPlace1.value)=="")
		strSupp+=" - Place & Register # 1\n"
	if (Trim(document.Form1.txtSuppPassport1.value)=="")
		strSupp+=" - Passport # 1\n"
	if (Trim(document.Form1.txtSuppRelation1.value)=="")
		strSupp+=" - Relation 1\n"
	
	if (Trim(document.Form1.txtSupplementaryName2.value)=="")
		strSupp+=" - Supplementary card applicant's 2 name \n"
	if (Trim(document.Form1.txtSuppBirth2.value)=="")
		strSupp+=" - Date Of Birth 2\n"
	if (Trim(document.Form1.txtSuppPlace2.value)=="")
		strSupp+=" - Place & Register # 2\n"
	if (Trim(document.Form1.txtSuppPassport2.value)=="")
		strSupp+=" - Passport # 2\n"
	if (Trim(document.Form1.txtSuppRelation2.value)=="")
		strSupp+=" - Relation 2\n"
		
	if (strSupp!=""){
		strCard+="Supplementary card applicant Information \n" + strSupp
		}
		
		
	if (strCard!=""){
		strCard="D. Card(s) Issuance \n" + strCard;
		document.Form1.txtApplicantName.focus();
		alert(strCard);
		return false;
	}
	
	if (document.Form1.chkAccept.checked==false){
		alert("You have to accept the Acknowledgement in order to proceed.");
		document.Form1.chkAccept.focus();
		return false;
		}
	
	}


//TRIM Functions
function Trim(TRIM_VALUE){
if(TRIM_VALUE.length < 1){
return"";
}
TRIM_VALUE = RTrim(TRIM_VALUE);
TRIM_VALUE = LTrim(TRIM_VALUE);
if(TRIM_VALUE==""){
return "";
}
else{
return TRIM_VALUE;
}
} //End Function

function RTrim(VALUE){
var w_space = String.fromCharCode(32);
var v_length = VALUE.length;
var strTemp = "";
if(v_length < 0){
return"";
}
var iTemp = v_length -1;

while(iTemp > -1){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(0,iTemp +1);
break;
}
iTemp = iTemp-1;

} //End While
return strTemp;

} //End Function

function LTrim(VALUE){
var w_space = String.fromCharCode(32);
if(v_length < 1){
return"";
}
var v_length = VALUE.length;
var strTemp = "";

var iTemp = 0;

while(iTemp < v_length){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(iTemp,v_length);
break;
}
iTemp = iTemp + 1;
} //End While
return strTemp;
} //End Function