
function intOnly(i, strLength) {
	if(i.value.length>0) {
		i.value = i.value.replace(/[^\d]+/g, ''); 
	}
if (strLength == '10') {
	if (i.value.length > 10) {
		i.value = i.value.substring(0, 10);
	}
	if (document.forms["Apply"].elements["txtHomePhone"].value.length > 10) {
		document.forms["Apply"].elements["txtHomePhone"].value = document.forms["Apply"].elements["txtHomePhone"].value.substring(0, 10);
	}
	if (document.forms["Apply"].elements["txtMobilePhone"].value.length > 10) {
		document.forms["Apply"].elements["txtMobilePhone"].value = document.forms["Apply"].elements["txtMobilePhone"].value.substring(0, 10);
	}
	if (document.forms["Apply"].elements["txtEmpPhone1"].value.length > 10) {
		document.forms["Apply"].elements["txtEmpPhone1"].value = document.forms["Apply"].elements["txtEmpPhone1"].value.substring(0, 10);
	}
	if (document.forms["Apply"].elements["txtEmpPhone2"].value.length > 10) {
		document.forms["Apply"].elements["txtEmpPhone2"].value = document.forms["Apply"].elements["txtEmpPhone2"].value.substring(0, 10);
	}
	if (document.forms["Apply"].elements["txtEmpPhone3"].value.length > 10) {
		document.forms["Apply"].elements["txtEmpPhone3"].value = document.forms["Apply"].elements["txtEmpPhone3"].value.substring(0, 10);
	}
	if (document.forms["Apply"].elements["txtRefPhone1"].value.length > 10) {
		document.forms["Apply"].elements["txtRefPhone1"].value = document.forms["Apply"].elements["txtRefPhone1"].value.substring(0, 10);
	}
	if (document.forms["Apply"].elements["txtRefPhone2"].value.length > 10) {
		document.forms["Apply"].elements["txtRefPhone2"].value = document.forms["Apply"].elements["txtRefPhone2"].value.substring(0, 10);
	}
}
if (strLength == '4') {
	if (document.forms["Apply"].elements["txtAppliedBeforeStartDate"].value.length > 4) {
		document.forms["Apply"].elements["txtAppliedBeforeStartDate"].value = document.forms["Apply"].elements["txtAppliedBeforeStartDate"].value.substring(0, 4);
	}
	if (document.forms["Apply"].elements["txtAppliedBeforeEndDate"].value.length > 4) {
		document.forms["Apply"].elements["txtAppliedBeforeEndDate"].value = document.forms["Apply"].elements["txtAppliedBeforeEndDate"].value.substring(0, 4);
	}
	if (document.forms["Apply"].elements["txtEmpDateFrom1"].value.length > 4) {
		document.forms["Apply"].elements["txtEmpDateFrom1"].value = document.forms["Apply"].elements["txtEmpDateFrom1"].value.substring(0, 4);
	}
	if (document.forms["Apply"].elements["txtEmpDateTo1"].value.length > 4) {
		document.forms["Apply"].elements["txtEmpDateTo1"].value = document.forms["Apply"].elements["txtEmpDateTo1"].value.substring(0, 4);
	}
	if (document.forms["Apply"].elements["txtEmpDateFrom2"].value.length > 4) {
		document.forms["Apply"].elements["txtEmpDateFrom2"].value = document.forms["Apply"].elements["txtEmpDateFrom2"].value.substring(0, 4);
	}
	if (document.forms["Apply"].elements["txtEmpDateTo2"].value.length > 4) {
		document.forms["Apply"].elements["txtEmpDateTo2"].value = document.forms["Apply"].elements["txtEmpDateTo2"].value.substring(0, 4);
	}
	if (document.forms["Apply"].elements["txtEmpDateFrom3"].value.length > 4) {
		document.forms["Apply"].elements["txtEmpDateFrom3"].value = document.forms["Apply"].elements["txtEmpDateFrom3"].value.substring(0, 4);
	}
	if (document.forms["Apply"].elements["txtEmpDateTo3"].value.length > 4) {
		document.forms["Apply"].elements["txtEmpDateTo3"].value = document.forms["Apply"].elements["txtEmpDateTo3"].value.substring(0, 4);
	}
}
}

function validate() {
	
	
	var FirstIndex = document.Apply.txtEmailAddress.value.indexOf ('@',0)
	var PerPos = document.Apply.txtEmailAddress.value.indexOf ('.',0)
	
	if (document.Apply.txtLastName.value == "") {
		alert('Your last name is required.');
		document.Apply.txtLastName.focus();
		return false;
	}
	
	if (document.Apply.txtFirstName.value == "") {
		alert('Your first name is required.');
		document.Apply.txtFirstName.focus();
		return false;
	}
	
	if (document.Apply.txtEmailAddress.value == "") {
		alert('Your email address is required.');
		document.Apply.txtEmailAddress.focus();	
		return false;
	}

	if ((document.Apply.txtEmailAddress.value.indexOf ('@',0) == -1) || (document.Apply.txtEmailAddress.value.indexOf('@',0) == 0) || (PerPos == -1)){				       
		alert("Invalid email address.")      
		document.Apply.txtEmailAddress.select()      
		document.Apply.txtEmailAddress.focus()      
		return false      
	}   

	if (document.Apply.txtEmailAddress.value.indexOf ('@',FirstIndex + 1) > -1) {      
		alert("Invalid email address.")      
		document.Apply.txtEmailAddress.select()      
		document.Apply.txtEmailAddress.focus()      
		return false      
	}   
	
	if (document.Apply.txtHomePhone.value == "") {
		alert('Your daytime phone number is required.');
		document.Apply.txtHomePhone.focus();	
		return false;
	}
	
	if (document.Apply.txtAddress.value == "") {
		alert('Your address is required.');
		document.Apply.txtAddress.focus();	
		return false;
	}
	
	if (document.Apply.txtCity.value == "") {
		alert('Your City is required.');
		document.Apply.txtCity.focus();	
		return false;
	}
	
	if (document.Apply.txtZipCode.value == "") {
		alert('Your zip code is required.');
		document.Apply.txtZipCode.focus();	
		return false;
	}

	if (document.Apply.txtZipCode.value.length != 5 && document.Apply.txtZipCode.value.length != 10){
		alert("Zip Code is invalid.")
		return false
	}

	for (i = 0; i < document.Apply.txtZipCode.length; i++){
		if (document.Apply.txtZipCode.value.charAt(i) < "0" && document.Apply.txtZipCode.value.charAt(i) != "-" && document.Apply.txtZipCode.value.charAt(i) != " "){
			alert ("Zip Code is invalid.")
			return false
		}
		if (document.Apply.txtZipCode.value.charAt(i) > "9" && document.Apply.txtZipCode.value.charAt(i) != "-" && document.Apply.txtZipCode.value.charAt(i) != " "){
			alert ("Zip Code is invalid.")
			return false
		}
	}
	
	if(document.Apply.optStatus[0].checked == false && document.Apply.optStatus[1].checked == false){
		alert('Please select your desired work status.');
		return false;
	}
	
	if(document.Apply.optWorkEligible[0].checked == false && document.Apply.optWorkEligible[1].checked == false){
		alert('Please verify your eligibilty to work.');
		return false;
	}
	
	if(document.Apply.optAppliedBefore[0].checked == false && document.Apply.optAppliedBefore[1].checked == false){
		alert('Please indicate if you have applied or worked for MED-TECH before.');
		return false;
	}
			
	if (document.Apply.optAppliedBefore(0).checked == true) {
		if (document.Apply.txtAppliedBeforeStartDate.value == ""){
			alert('Please enter an approxiamte date that you previously applied or started with us.');
			document.Apply.txtAppliedBeforeDate.focus();	
			return false;
		}		
	}
	
	if(document.Apply.optCurrentlyEmployed[0].checked == false && document.Apply.optCurrentlyEmployed[1].checked == false){
		alert('Please indicate your current employment status.');
		return false;
	}
	
	if(document.Apply.optImmigrationStatus[0].checked == false && document.Apply.optImmigrationStatus[1].checked == false){
		alert('Please indicate your eligibility to legally work in the US due to a limited visa or immigration status.');
		return false;
	}
	
	if(document.Apply.optDrugTest[0].checked == false && document.Apply.optDrugTest[1].checked == false){
		alert('Please indicate if you would submit to a drug test.');
		return false;
	}
	
	if (document.Apply.txtStartDate.value == "") {
		alert('Please enter the date that you would be available to start.');
		document.Apply.txtStartDate.focus();	
		return false;
	}
	
	if (document.Apply.txtEmployer1.value == "") {
		alert('Please enter the name of your current or most recent employer.');
		document.Apply.txtEmployer1.focus();	
		return false;
	}
	if (document.Apply.txtEmpTitle1.value == "") {
		alert('Please enter your job title for your current or most recent employer.');
		document.Apply.txtEmpTitle1.focus();	
		return false;
	}
	if (document.Apply.txtEmpSalary1.value == "") {
		alert('Please enter the hourly pay rate for your current or most recent employer.');
		document.Apply.txtEmpSalary1.focus();	
		return false;
	}
	if (document.Apply.txtEmpDuties1.value == "") {
		alert('Please enter the duties performed for your current or most recent employer.');
		document.Apply.txtEmpDuties1.focus();	
		return false;
	}
	if (document.Apply.txtEmpAddress1.value == "") {
		alert('Please enter the address for your current or most recent employer.');
		document.Apply.txtEmpAddress1.focus();	
		return false;
	}
	if (document.Apply.txtEmpContact1.value == "") {
		alert('Please enter a contact name at your current or most recent employer.');
		document.Apply.txtEmpContact1.focus();	
		return false;
	}
	if (document.Apply.txtEmpContactTitle1.value == "") {
		alert('Please enter the job title of the given contact for your current or most recent employer.');
		document.Apply.txtEmpContactTitle1.focus();	
		return false;
	}
	if (document.Apply.txtEmpPhone1.value == "") {
		alert('Please enter the contact phone number for your current or most recent employer.');
		document.Apply.txtEmpPhone1.focus();	
		return false;
	}
	if (document.Apply.txtLeaving1.value == "") {
		alert('Please enter a reason for leaving at your current or most recent employer.');
		document.Apply.txtLeaving1.focus();	
		return false;
	}
	if (document.Apply.txtEmpDateFrom1.value == "") {
		alert('Please enter the approximate starting date at your current or most recent employer.');
		document.Apply.txtEmpDateFrom1.focus();	
		return false;
	}
	if (document.Apply.txtEmpDateTo1.value == "") {
		alert('Please enter the approximate ending date at your current or most recent employer. If you are currently employed with this organization, please enter "current"');
		document.Apply.txtEmpDateTo1.focus();	
		return false;
	}
	
	if (document.Apply.txtEmployer2.value == "") {
		alert('Please enter the name for this employer.');
		document.Apply.txtEmployer2.focus();	
		return false;
	}
	if (document.Apply.txtEmpTitle2.value == "") {
		alert('Please enter your job title for this employer.');
		document.Apply.txtEmpTitle2.focus();	
		return false;
	}
	if (document.Apply.txtEmpSalary2.value == "") {
		alert('Please enter the hourly pay rate for this employer.');
		document.Apply.txtEmpSalary2.focus();	
		return false;
	}
	if (document.Apply.txtEmpDuties2.value == "") {
		alert('Please enter the duties performed for this employer.');
		document.Apply.txtEmpDuties2.focus();	
		return false;
	}
	if (document.Apply.txtEmpAddress2.value == "") {
		alert('Please enter the address for this employer.');
		document.Apply.txtEmpAddress2.focus();	
		return false;
	}
	if (document.Apply.txtEmpContact2.value == "") {
		alert('Please enter a contact name for this employer.');
		document.Apply.txtEmpContact2.focus();	
		return false;
	}
	if (document.Apply.txtEmpContactTitle2.value == "") {
		alert('Please enter the job title of the given contact for this employer.');
		document.Apply.txtEmpContactTitle2.focus();	
		return false;
	}
	if (document.Apply.txtEmpPhone2.value == "") {
		alert('Please enter the contact phone number for this employer.');
		document.Apply.txtEmpPhone2.focus();	
		return false;
	}
	if (document.Apply.txtLeaving2.value == "") {
		alert('Please enter a reason for leaving for this employer.');
		document.Apply.txtLeaving2.focus();	
		return false;
	}
	if (document.Apply.txtEmpDateFrom2.value == "") {
		alert('Please enter the approximate starting date for this employer.');
		document.Apply.txtEmpDateFrom2.focus();	
		return false;
	}
	if (document.Apply.txtEmpDateTo2.value == "") {
		alert('Please enter the approximate ending date for this employer.');
		document.Apply.txtEmpDateTo2.focus();	
		return false;
	}
	
	if (document.Apply.txtEmployer3.value == "") {
		alert('Please enter the name for this employer.');
		document.Apply.txtEmployer3.focus();	
		return false;
	}
	if (document.Apply.txtEmpTitle3.value == "") {
		alert('Please enter your job title for this employer.');
		document.Apply.txtEmpTitle3.focus();	
		return false;
	}
	if (document.Apply.txtEmpSalary3.value == "") {
		alert('Please enter the hourly pay rate for this employer.');
		document.Apply.txtEmpSalary3.focus();	
		return false;
	}
	if (document.Apply.txtEmpDuties3.value == "") {
		alert('Please enter the duties performed for this employer.');
		document.Apply.txtEmpDuties3.focus();	
		return false;
	}
	if (document.Apply.txtEmpAddress3.value == "") {
		alert('Please enter the address for this employer.');
		document.Apply.txtEmpAddress3.focus();	
		return false;
	}
	if (document.Apply.txtEmpContact3.value == "") {
		alert('Please enter a contact name for this employer.');
		document.Apply.txtEmpContact3.focus();	
		return false;
	}
	if (document.Apply.txtEmpContactTitle3.value == "") {
		alert('Please enter the job title of the given contact for this employer.');
		document.Apply.txtEmpContactTitle3.focus();	
		return false;
	}
	if (document.Apply.txtEmpPhone3.value == "") {
		alert('Please enter the contact phone number for this employer.');
		document.Apply.txtEmpPhone3.focus();	
		return false;
	}
	if (document.Apply.txtLeaving3.value == "") {
		alert('Please enter a reason for leaving for this employer.');
		document.Apply.txtLeaving3.focus();	
		return false;
	}
	if (document.Apply.txtEmpDateFrom3.value == "") {
		alert('Please enter the approximate starting date for this employer.');
		document.Apply.txtEmpDateFrom3.focus();	
		return false;
	}
	if (document.Apply.txtEmpDateTo3.value == "") {
		alert('Please enter the approximate ending date for this employer.');
		document.Apply.txtEmpDateTo3.focus();	
		return false;
	}
	if (document.Apply.txtRefName1.value == "") {
		alert('Please enter the name of a personal reference.');
		document.Apply.txtRefName1.focus();	
		return false;
	}
	if (document.Apply.txtRefPhone1.value == "") {
		alert('Please enter the phone number of personal reference 1.');
		document.Apply.txtRefPhone1.focus();	
		return false;
	}
	if (document.Apply.txtRefHowLongKnown1.value == "") {
		alert('How long have you known personal reference 1.');
		document.Apply.txtRefHowLongKnown1.focus();	
		return false;
	}
	if (document.Apply.txtRefBestContact1.value == "") {
		alert('Please enter the best time to contact personal reference 1 at the number you have provided.');
		document.Apply.txtRefBestContact1.focus();	
		return false;
	}
	if (document.Apply.txtRefName2.value == "") {
		alert('Please enter the name of personal reference 2.');
		document.Apply.txtRefName2.focus();	
		return false;
	}
	if (document.Apply.txtRefPhone2.value == "") {
		alert('Please enter the phone number of personal reference 2.');
		document.Apply.txtRefPhone2.focus();	
		return false;
	}
	if (document.Apply.txtRefHowLongKnown2.value == "") {
		alert('How long have you known personal reference 2.');
		document.Apply.txtRefHowLongKnown2.focus();	
		return false;
	}
	if (document.Apply.txtRefBestContact2.value == "") {
		alert('Please enter the best time to contact personal reference 2 at the number you have provided.');
		document.Apply.txtRefBestContact2.focus();	
		return false;
	}
	if (document.Apply.chkAgreement.checked == 0) {
		alert('You must agree to all terms of the disclaimer before submitting your employment application.');
		document.Apply.chkAgreement.focus();	
		return false;
	}
	if (document.Apply.chkApplicantSignature.checked == 0) {
		alert('You must agree to all terms of the disclaimer before submitting your employment application.');
		document.Apply.chkApplicantSignature.focus();	
		return false;
	}
}
