// JavaScript Document

function isValidEmail(str)
    {
        return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);    
    }
    function validateForm()
    {
        var msg="";
        var mail=document.getElementById("email").value;
        if(document.getElementById("first_name").value =="")
        {
            msg+="First Name\n";
        }
        if(document.getElementById("last_name").value =="")
        {
            msg+="Last Name\n";
        }
        if(mail=="")
        {
            msg+="Email\n";
        }
        if(msg=="")
        {
            if(isValidEmail(mail))
            {
                document.getElementById('ContactUs').submit();
                return true;
            }
            else
            {
                alert("Please enter a valid e-mail address.");
                return false;
                
            }
        }
        else
        {
            alert("The following form field(s) were incomplete or incorrect:\n\n" + msg + "\nPlease complete or correct the form and try again.");
            return false;
        }
}

function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  } 
}
 
