function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}
window.onload = externalLinks;

function validateFormOnSubmit2(theForm) {
var reason = "";

  reason += validateName(theForm.fname);
  reason += validateName1(theForm.lname);
  reason += validateEmail(theForm.email);
  reason += validatePhone(theForm.phone);
      
  if (reason != "") {
    alert("Some Fields Need Corrected:\n" + reason);
    return false;
  }
}
function validateEmpty(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.background = '#ff0000'; 
        error = "The required field(s) has not been filled in.\n"
    } else {
        fld.style.background = 'White';
    }
    return error;  
}
function validateName(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores
 
    if (fld.value == "" || fld.value == " your first name..") {
        fld.style.background = '#ff0000'; 
        error = "First Name was not entered.\n";
    } else if (illegalChars.test(fld.value)) {
        fld.style.background = '#ff0000'; 
        error = "The first name contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}
function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
}
function validateName1(fld) {
    var error = "";
    var illegalChars = /\W /; // allow letters, numbers, and underscores
 
    if (fld.value == "" || fld.value == " your last name..") {
        fld.style.background = '#ff0000'; 
        error = "Lat Name was not entered.\n";
    } else if (illegalChars.test(fld.value)) {
        fld.style.background = '#ff0000'; 
        error = "The last name contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}
function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
}
function validateEmail(fld) {
    var error="";
    var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
   
    if (fld.value == "" || fld.value == " your email address..") {
        fld.style.background = '#ff0000';
        error = "Email was not entered.\n";
    } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
        fld.style.background = '#ff0000';
        error = "Please enter a valid email address.\n";
    } else if (fld.value.match(illegalChars)) {
        fld.style.background = '#ff0000';
        error = "The email address contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}
function validatePhone(fld) {
    var error = "";
    var illegalChars = /\W /; // allow letters, numbers, and underscores
 
    if (fld.value == "") {
        fld.style.background = '#ff0000'; 
        error = "Phone Number was not entered.\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}
