function checkService(formElement)
{
	with (document.frmApp) {
		for (i = 0; i < formElement.length; i++) {
			if(formElement[i].checked == true) {
				if(formElement[i].value == 'EPF') {
					if (!TextNoEmpty(epfNo, 'Please enter EPF number.')) 
						return false;
				}		
				if(formElement[i].value == 'Socso') {
					if (!TextNoEmpty(socsoNo, 'Please enter SOCSO number.')) 
						return false;
				
				}
				if(formElement[i].value == 'Tax') {
					if (!TextNoEmpty(irbNo, 'Please enter IRB number.')) 
						return false;
				
				}
			}	
		}
 	}
  	return true;  
}

function validation() {

	with (document.frmApp) {
		if (!TextNoEmpty(compName, 'Please enter Company Name.')) 
			return false;
		if (!TextNoEmpty(compReg, 'Please enter Registration No.')) 
			return false;
		if (!TextNoEmpty(compAdd, 'Please enter your company address.')) 
			return false;
		
		if (!TextNoEmpty(compTel_a, 'Please enter your company telephone no.')) 
			return false;
		if (!isNumeric(compTel_a, 'Telephone no. must be numeric.')) 
			return false;	
		if (!TextNoEmpty(compTel_b, 'Please enter your company telephone no.')) 
			return false;	
		if (!isNumeric(compTel_b, 'Telephone no. must be numeric.')) 
			return false;	
			
		if (!isNumeric(compFax_a, 'Fax no. must be numeric.')) 
			return false;	
		if (!isNumeric(compFax_b, 'Fax no. must be numeric.')) 
			return false;		
				
		if (!TextNoEmpty(contName1, 'Please enter name of contact person.')) 
			return false;

		if (!TextNoEmpty(contDesign1, 'Please enter Designation.')) 
			return false;

		if (!TextNoEmpty(contTel1_a, 'Please enter telephone no. of contact person.')) 
			return false;
		if (!isNumeric(contTel1_a, 'Telephone no. must be numeric.')) 
			return false;	
		if (!TextNoEmpty(contTel1_b, 'Please enter telephone no. of contact person.')) 
			return false;
		if (!isNumeric(contTel1_b, 'Telephone no. must be numeric.')) 
			return false;	
			
		if (!TextNoEmpty(contEmail1, 'Please enter e-mail address of contact person.')) 
			return false;
		else if (!isEmail(contEmail1, 'Invalid e-mail address.')) 
			return false;	
		
		if (!isNumeric(contTel2_a, 'Telephone no. must be numeric.')) 
			return false;	
		if (!isNumeric(contTel2_b, 'Telephone no. must be numeric.')) 
			return false;	
		
		if ((contEmail2.value != '') && (!isEmail(contEmail2, 'Invalid e-mail address.'))) 
			return false;	
		
		if (!isMinimumCheck(hrServices, 1) && !isMinimumCheck(payServices, 1)) {
			if (!TextNoEmpty(otherService, 'Please select the service(s) you require.')) 
				return false; 			
		}
		
		if (!checkService(hrServices))
			return false;
		
		if (payroll[1].checked)
			if (!TextNoEmpty(otherPayroll, 'Please enter a payroll service.')) 
				return false;
	}	
	return true;
}	

function NSValidation() {
	if (validation() == true) {
		document.frmApp.submit();
	}	
	else {
		return false;
	}	
}