function validateFormOnSubmit1(theForm) {
var reason = "";
  
  reason += validateName1(theForm.Name1);
  reason += validateEmail1(theForm.Email1);
  reason += validatePhone1(theForm.Phone1);


      
  if (reason != "") {
    alert("Following field(s) need to be Filled:\n" + reason);
    return false;
  }
  if(checkValue(theForm)) { 
	insitePost(theForm); 
  }
  setTimeout(function(){theForm.submit();},500); // increase this value if it's not tracking properly
  return true;
}


function validateName1(fld) {
    var error = "";
 
    if (fld.value == "* Name" || fld.value == "") {
        fld.style.color = '#0f0802'; 
        error = "- Enter your name.\n"
    } else {
        fld.style.color = '#0f0802';
    }
    return error;  
}



function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
}

function validateEmail1(fld) {
    var error="";
    var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
   
    if (fld.value == "* E-mail" || fld.value == "") {
        fld.style.color = '#0f0802';
        error = "- Enter your email address.\n";
    } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
        fld.style.color = '#0f0802';
        error = "- Please enter a valid email address.\n";
    } else {
        fld.style.color = '#0f0802';
    }
    return error;
}

function isNumeric(v) {
	return v.length > 0 && !isNaN(v) && v.search(/[A-Z]|[#]/ig) == -1;
};
		
function validatePhone1(fld) {
    var error = "";
    var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');    

   if (fld.value == "" || fld.value == "* Phone") {
        error = "- Please enter your telephone number.\n";
        fld.style.background = '#efe6cc';
    } else {
		if (isNumeric(fld.value) == false) {
			error = "- Please enter only numeric values for the telephone number.\n";
		}
		else{
			fld.style.background = '#efe6cc';
		}
    }
    return error;
}


