function isEmailAddr(email) {
	var result = false;
	var theStr = new String(email);
	var index = theStr.indexOf("@");
	if (index > 0) {
		var pindex = theStr.indexOf(".",index);
		if ((pindex > index+1) && (theStr.length > pindex+1)) {
		result = true;
		}
	}
	return result;
}
function isAlpha(obj) {
	var result = false;
	var inThere = obj.match(/\D/);
	if (inThere) {
		result = true;
	}
	return result;
}
function isAlphaNum(obj) {
	var result = false;
	var inThere = obj.match(/\w/);
	if (inThere) {
		result = true;
	}
	return result;
}
function isNotAlphaNum(obj) {
	var result = false;
	var inThere = obj.match(/[^\w\s]/);
	if (inThere) {
		result = true;
	}
	return result;
}

function isNum(obj) {
	var result = false;
	var inThere = obj.match(/\d/);
	if (inThere) {
		result = true;
	}
	return result;
}

function hasWhiteSpace(obj) {
	var result = false;
	var inThere = obj.match(/\s/);
	if (inThere) {
		result = true;
	}
	return result;
}

// ***FormValidation ***
function formCheck(){

	// City
	/* if (document.contact.City.value != "") {
		if (isNum(document.contact.City.value)) {
			alert("Numbers are not allowed in the \"City\" field.");
			document.contact.City.focus();
			return false;
		} else if (isNotAlphaNum(document.contact.City.value)) {
			alert("Special characters are not allowed in the \"City\" field.");
			document.contact.City.focus();
			return false;
		}
	} else {
		alert("The \"City\" field cannot be left blank.");
		document.contact.City.focus();
		return false;
	}
	// State
	if (document.contact.State.value != "") {
		if (isNum(document.contact.State.value)) {
			alert("Numbers are not allowed in the \"State\" field.");
			document.contact.State.focus();
			return false;
		} else if (isNotAlphaNum(document.contact.State.value)) {
			alert("Special characters are not allowed in the \"State\" field.");
			document.contact.State.focus();
			return false;
		}
	} else {
		alert("The \"State\" field cannot be left blank.");
		document.contact.State.focus();
		return false;
	}*/
	// First Name
	if (document.contact.First_Name.value != "") {
		if (isNum(document.contact.First_Name.value)) {
			alert("Numbers are not allowed in the \"First Name\" field.");
			document.contact.First_Name.focus();
			return false;
		} else if (isNotAlphaNum(document.contact.First_Name.value)) {
			alert("Special characters are not allowed in the \"First Name\" field.");
			document.contact.First_Name.focus();
			return false;
		}
	} else {
		alert("The \"First Name\" field cannot be left blank.");
		document.contact.First_Name.focus();
		return false;
	}
	// Last Name
	if (document.contact.Last_Name.value != "") 
		{
		if (isNum(document.contact.Last_Name.value)) {
			alert("Numbers are not allowed in the \"Last Name\" field.");
			document.contact.Last_Name.focus();
			return false;
		} 
		else if (isNotAlphaNum(document.contact.Last_Name.value)) 
		{
			alert("Special characters are not allowed in the \"Last Name\" field.");
			document.contact.Last_Name.focus();
			return false;
		}
		} 
		else 
		{
		alert("The \"Last Name\" field cannot be left blank.");
		document.contact.Last_Name.focus();
		return false;
		}
	// EmailAddr
	if (document.contact.Email.value != "") {
		if (!isEmailAddr(document.contact.Email.value)) {
			alert("Please enter a complete Email address in the form: yourname@yourdomain.com");
			document.contact.Email.focus();
			return false;
		} else if (hasWhiteSpace(document.contact.Email.value)) {
			alert("Your Email address cannot contain blank spaces.");
			document.contact.Email.focus();
			return false;
		}
	} else {
		alert("The \"Email Address\" field cannot be left blank.");
		document.contact.Email.focus();
		return false;
	}
	
	// Phone
	if (document.contact.Phone.value != "") {
		if (isAlpha(document.contact.Phone.value)) {
			alert("Only numbers are allowed in a Phone Number.");
			document.contact.Phone.focus();
			return false;
		} else if (document.contact.Phone.value.length < 10) {
			alert("This \"Phone Number\" field must have 10 characters.");
			document.contact.Phone.focus();
			return false;
		}
	} else {
		alert("The \"Phone Number\" field cannot be left blank.");
		document.contact.Phone.focus();
		return false;
	}
	// Comments
	/*if (document.contact.Comments.value == ""){
		alert("The \"Comments\" field cannot be left blank.");
		document.contact.Comments.focus();
		return false;
	}*/
	if (document.contact.Comments.value != "") {
			if (document.contact.Comments.value.indexOf("http") != -1)
		 	{
			alert("Please do not enter http in Description of DWI / DUI Legal Problem field");
			document.contact.Comments.focus();
			return false;
			} 
	} else {
		alert("The \"Description of DWI / DUI Legal Problem\" field cannot be left blank.");
		document.contact.Comments.focus();
		return false;
	}	
}

