function check_email(e) {
ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";

for(i=0; i < e.length ;i++){
if(ok.indexOf(e.charAt(i))<0){ 
return (false);
}	
} 

if (document.images) {
re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
if (!e.match(re) && e.match(re_two)) {
return (-1);		
} 

}

}

function contactCheck() {
var themessage = "All Fields are required to be filled in: ";
if (document.contact.firstname.value=="") {
themessage = themessage + "\n * First Name";
}
if (document.contact.lastname.value=="") {
themessage = themessage + "\n * Last Name";
}
if (!check_email(document.contact.email.value)) {
themessage = themessage + "\n * Invalid Email";
document.contact.email.focus(); 
}
if (document.contact.question.value=="") {
themessage = themessage + "\n * Question";
}
if (document.contact.phone.value=="") {
themessage = themessage + "\n * Phone";
}
 if (document.contact.company.value=="") {
themessage = themessage + "\n * Company Name";
}

if (document.contact.location.value=="") {
themessage = themessage + "\n * Company Location";
}



//alert if fields are empty and cancel form submit
if (themessage == "All Fields are required to be filled in: ") {
document.contact.submit();
}

else {
alert(themessage);
return false;
   }
}


function applicationCheck() {
var themessage = "All Fields are required to be filled in: ";
if (document.application.company.value=="") {
themessage = themessage + "\n * Company Name";
}
if (document.application.companyAddress.value=="") {
themessage = themessage + "\n * Company Address";
}
if (document.application.companyCity.value=="") {
themessage = themessage + "\n * City";
}
if (document.application.companyState.value=="") {
themessage = themessage + "\n * State";
}
if (document.application.companyZip.value=="") {
themessage = themessage + "\n * Zip Code";
}
if (document.application.companyTelephone.value=="") {
themessage = themessage + "\n * Telephone";
}

if (document.application.companyFax.value=="") {
themessage = themessage + "\n * Fax";
}
if (document.application.companyWebsite.value=="") {
themessage = themessage + "\n * Website";
}
if (document.application.BusinessType.value=="") {
themessage = themessage + "\n * BusinessType";
}
if (document.application.NumberEmployees.value=="") {
themessage = themessage + "\n * Number of Employees";
}

if (document.application.YearEstablished.value=="") {
themessage = themessage + "\n * Company Established Date";
}

if (document.application.PrimaryContact.value=="") {
themessage = themessage + "\n * Primary Contact Name";
}
if (document.application.PrimaryEmail.value=="") {
themessage = themessage + "\n * Primary Email";
}
if (document.application.PrimaryTitle.value=="") {
themessage = themessage + "\n * Primary Contact Title";
}

if (document.application.BillingContact.value=="") {
themessage = themessage + "\n * Billing Contact Name";
}
if (document.application.BillingEmail.value=="") {
themessage = themessage + "\n * Billing Contact Email";
}
if (document.application.BillingTitle.value=="") {
themessage = themessage + "\n * Billing Contact Title";
}

if (document.application.paymentType.value=="") {
themessage = themessage + "\n * Payment Type";
}

if (document.application.membershipType.value=="") {
themessage = themessage + "\n * Membership Type";
}
//alert if fields are empty and cancel form submit
if (themessage == "All Fields are required to be filled in: ") {
document.application.submit();
}

else {
alert(themessage);
return false;
   }
}

 
 