function formcheck(){
	var errormsg = '';
	errormsg += isEmpty(document.Application.fname.value,'First Name');
	errormsg += isEmpty(document.Application.lname.value,'Last Name');
	errormsg += checkEmail(document.Application.email.value);
	errormsg += ZipCheck(document.Application.zip.value,'Zip');
	errormsg += PhoneCheck(document.Application.phone1.value,document.Application.phone2.value,document.Application.phone3.value,'Primary Phone');
	errormsg += PhoneCheck(document.Application.altphone1.value,document.Application.altphone2.value,document.Application.altphone3.value,'Alternate Phone');
	errormsg += isEmpty(document.Application.debt_behind.value,'Payments Age');
	errormsg += isEmpty(document.Application.debt_amount.value,'Unsecured Debt');
	errormsg += isEmpty(document.Application.contacttime.value,'Best time to contact');
	
    if (errormsg != "") {
		alert('The following fields require your attention:\r\n\r\n' + errormsg);
		return false;
    }
	return true;
}
function isEmpty(strng,val){
	var error=''
	if (strng == "") {
		error = '- '+val+'\r\n';
		return error;
	}	
	return '';
}
function checkEmail(strng){
	var error=''
	if (strng == "") {
		error = '- Email Address\r\n';
		return error;
	}
	var emailFilter=/^.+@.+\..{2,4}$/;
	if (!(emailFilter.test(strng))) { 
		error = '- Email Address Incorrectly Formatted\r\n';
		return error;
	}
	return '';
}
function PhoneCheck(day1,day2,day3,val){
	var error=''
	if ((day1 == "")||(day2 == "")||(day3 == "")||(day1.length < 3)||(day2.length < 3)||(day3.length < 4)) {
		error = '- '+val+'\r\n';
		return error;
	}
	var filter='0123456789';
	var strng=day1+day2+day3
 	for (i=0; i<strng.length; i++) {
		if (filter.indexOf(strng.charAt(i),0) == -1){
			error = '- '+val+' must only be numbers\r\n';
			return error;}
	}
	var filter2='23456789';
	if (filter2.indexOf(day1.charAt(0),0) == -1){
		error = '- '+val+' - US residents only\r\n';
		return error;}
	return '';
}
function BalanceCheck(num1,val){
	var error=''
	if (num1 == ""){
		error = '- '+val+'\r\n';
		return error;
	}
	var filter='0123456789.';
 	for (i=0; i<num1.length; i++) {
		if (filter.indexOf(num1.charAt(i),0) == -1){
			error = '- '+val+' can only be numbers\r\n';
			return error;}
	}
	return '';
}
function ZipCheck(num1,val){
	var error=''
	if (num1 == ""){
		error = '- '+val+'\r\n';
		return error;
	}
	if (num1.length > 5){
		error = '- Invalid '+val+'\r\n';
		return error;
	}
	var filter='0123456789';
 	for (i=0; i<num1.length; i++) {
		if (filter.indexOf(num1.charAt(i),0) == -1){
			error = '- '+val+' must be numbers only\r\n';
			return error;}
	}
	return '';
}