/*** javascript for The Inventor Guide: saved as contact.js and to be used by contact_us.htm ***/

// the following function places the cursor in the first field of a form when the page loads and when the form is reset or cleared. 
function toContact() {
document.contactus.firstname.focus();
}

// Checks form fields to verify that required field is not left empty. Displays a warning message if any empty fields are present.  
function verify () {
  var str = "";
  with (document.contactus) 
  {  
	if (firstname.value == "" ) { str += "First Name\n";	}
	if (lastname.value == "" ) { str += "Last Name\n";	}
	if (email.value == "" ) { str += "E-mail Address\n"; }
	if (phnumber.value == "" ) { str += "Phone Number\n";	}
	if (bestime.value == "" ) { str += "Best Time to Call\n";	}
  }
  if (str == "") {
    document.contactus.submit();
  }	
  else {
    alert ("You are required to complete the following fields: \n\n" + str);
	return false;
  }
}

