function validateAndSubmit( f ) {
	if ( f.firstname.value == "" ) {
		alert("Please enter your first name.");
		f.firstname.focus();
	} else if ( f.lastname.value == "" ) {
		alert("Please enter your last name.");
		f.lastname.focus();
	} else if ( f.email.value == "" || !checkEmail( f.email.value ) ) {
		alert("Please enter a valid email address.");
		f.email.focus();
	} else {
		return (true);
	}
	return (false);
}
function checkEmail( address ) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(address)) return (true);
	return (false);
}
function checkPhone( number ) {
	s = stripCharsInBag( number, validWorldPhoneChars );
	return ( isInteger(s) && s.length >= minDigitsInIPhoneNumber );
}
function checkZipCode( zip ) {
	return ( isInteger(zip) && zip.length == 5 );
}
function isInteger(s)
{   var i;
	for (i = 0; i < s.length; i++)
	{
		// Check that current character is number.
		var c = s.charAt(i);
		if (((c < "0") || (c > "9"))) return false;
	}
	// All characters are numbers.
	return true;
}

function stripCharsInBag(s, bag)
{   var i;
	var returnString = "";
	for (i = 0; i < s.length; i++)
	{
		// Check that current character is not whitespace.
		var c = s.charAt(i);
		if (bag.indexOf(c) == -1) returnString += c;
	}
	return returnString;
}