function isNotEmpty(input){
  var str = input.value;
  var re = /.+/;
  if(!str.match(re)) {
    alert("This field is required.");
    setTimeout("setSelect('" + input.name + "')", 0);
    return false;
  } else {
    return true;
  }
}
function isChosen(select){
  if(select.selectedIndex == 0) {
    alert("Please select an option from the list.");
    setTimeout("setSelect('" + select.name + "')", 0);
    return false;
  } else {
    return true;
  }
}
function isValidEmail(input){
  var str = input.value;
  var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
  if(!str.match(re)) {
    alert("The email address you've entered has not been formatted correctly. Please enter a valid email address.");
    setTimeout("setSelect('" + input.name + "')", 0);
    return false;
  } else {
    return true;
  }
}
function setSelect(id) {
  if(document.getElementById(id)) {
    document.getElementById(id).focus();
    if(document.getElementById(id).tagName != "SELECT") {
      document.getElementById(id).select();
    }
  }
}
function addLoadEvent(func) {
  var oldonload = window.onload;
  if(typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}
function setFocus() {
  if(document.getElementById("focus")){
    document.getElementById("focus").focus();
  }
}
addLoadEvent(setFocus);