function validateEmail(field) {
  obj = document.getElementById(field);  
  var reg = new RegExp('[0-9a-z_]+@[0-9a-z_^.]+\.[a-z]', 'i');  
  if (!obj.value.length  || !reg.test(obj.value)) {
    return false;
  } 
  return true;
}

function isEmpty(field) {
  obj = document.getElementById(field);
  if (!obj.value.length) {
    return true;
  }
  return false;
}

function fail(out, text) {
  obj = document.getElementById(out);
  obj.innerHTML = text;
  location.href = '#err';
}

function validateCarrer(out) {

 if (isEmpty('name')) {
   fail(out, 'Be sure to provide your "Name"');
   return false;
 }

 if (isEmpty('email') || !validateEmail('email')) {
   fail(out, 'Be sure to provide your "Contact Email"');
   return false;
 }

 return true;
}

function validateBusiness(out) {

 if (isEmpty('company_name')) {
   fail(out, 'Be sure to provide your "Company Name"');
   return false;
 }

 if (isEmpty('name')) {
   fail(out, 'Be sure to provide your "Contact First Name" This will be your project manager username.');
   return false;
 }

 if (isEmpty('email') || !validateEmail('email')) {
   fail(out, 'Be sure to provide your "Contact Email"');
   return false;
 }

 return true;
}


function validateTalk(out) {

 if (isEmpty('contact_name')) {
   fail(out, 'Be sure to provide your "Contact First Name" This will be your project manager username.');
   return false;
 }

 if (isEmpty('contact_email') || !validateEmail('contact_email')) {
   fail(out, 'Be sure to provide your "Contact Email"');
   return false;
 }

 if (isEmpty('hear_about')) {
   fail(out, 'Be sure to provide your "Where did you hear about us"');
   return false;
 }

 if (isEmpty('contact_method')) {
   fail(out, 'Be sure to provide your "Method of Contact"');
   return false;
 }

 if (isEmpty('objectives')) {
   fail(out, 'Be sure to provide your "Inquiry"');
   return false;
 }

 input = document.getElementById('secretcode');
 if (input.value.length != 4) {
   fail(out, 'Be sure to provide your "Type security code"');
   return false;
 }


 return true;
}