﻿function CheckRequired()
	{
	var b = 0;
	var c = 0;
	var g = 0;
	var numberOfAts = 0;
	var numberOfDots = 0;
	var numberOfGAts = 0;
	var numberOfGDots = 0;

	var FirstName;
	var LastName;
	var Email;

			
document.theform1.comments.value = document.theform1.comments.value.replace(/^\s*(.*?)\s*$/,"$1");

if (document.theform1.firstname.value.length < 2)

			{	
			print("<span style='color:red;font-size:120%;'>Please enter your first name.</span>");
			document.theform1.firstname.focus();
			return false;
			}
			

if (document.theform1.lastname.value.length < 2)

			{	
			print("<span style='color:red;font-size:120%;'>Please enter your last name.</span>");
			document.theform1.lastname.focus();
			return false;
			}
			
for (c = 0; c < document.theform1.replyto.value.length; ++c)
	{
if (document.theform1.replyto.value.charAt(c) == '@') 
++numberOfAts;
			else if (numberOfAts==1) 
			{
				if (document.theform1.replyto.value.charAt(c) == '.') 
++numberOfDots;
				}
	}
			if ((numberOfAts != 1) || (numberOfDots==0))
			{
			print("<span style='color:red;font-size:120%;'>Please enter a valid (From) email address. (i.e. youremail@somewhere.com)</span>");
			document.theform1.replyto.focus();
			return false;
			}


for (b = 0; b < document.theform1.replyto.value.length; ++b)
	{
			if (document.theform1.replyto.value.charAt(b) == '@') 
++numberOfGAts;
			else if (numberOfGAts==1) 
			{
				if (document.theform1.replyto.value.charAt(b) == '.') 
++numberOfGDots;
				}
	}
			//if ((numberOfGAts != 1) || (numberOfGDots==0))
		//	{
		//alert("Please select a value for (Send To)");
		//document.theform1.replyto.focus();
		//	return false
		//	}
			
if(document.theform1.replyto.value != document.theform1.replyto2.value)
	{
	print("<span style='color:red;font-size:120%;'>Your email address does not match your re-typed email address.</span>")
	document.theform1.replyto2.value="";
	document.theform1.replyto2.focus();
	return false
	}


if(document.theform1.phonefirst3.value.length!=3 || isNaN(document.theform1.phonefirst3.value))
			{
			print("Please enter an area code.");	
			//alert("Please enter an area code.")
			document.theform1.phonefirst3.focus();
			return false
			}
			
if(document.theform1.phonesecond3.value.length!=3 || isNaN(document.theform1.phonesecond3.value))
		        {	
			//alert("Please enter the first three digits of your phone number after the area code.")
			print("<span style='color:red;font-size:120%;'>Please enter the first three digits of your phone number after the area code.</span>");
			//document.writeln("this is a test");
			document.theform1.phonesecond3.focus();
			return false
			}
			
if(document.theform1.phonelast4.value.length!=4 || isNaN(document.theform1.phonelast4.value))
			{	
			print("<span style='color:red;font-size:120%;'>Please enter the last four digits of your phone number.</span>");
			document.theform1.phonelast4.focus();
			return false;
			}	
		
if (document.theform1.city.value.length <= 2) {
			print("Please enter a City.");
			document.theform1.city.focus();
		  return false;
		}
		
if (document.theform1.state.value.length != 2) {
		print("Please select a State.");
		document.theform1.city.focus();
		return false;
	  }
			
if (document.theform1.zip.value.length !=5 || isNaN(document.theform1.zip.value))

			{	
			print("<span>Please enter a zip code</span>");
			document.theform1.probableinvestmentlevel.focus();
			return false;
			}


if (document.theform1.probableinvestmentlevel.value=="")

			{	
			print("Please select a probable investment level.");
			document.theform1.probableinvestmentlevel.focus();
			return false;
			}
			

if (document.theform1.consultation.value=="")

			{	
			print("<span style='color:red;font-size:120%;'>Please select Yes or No for Free Consultation</span>");
			document.theform1.consultation.focus();
			return false;
			}
			
if (document.theform1.subject.value.length == 0)

			{	
			print("Please enter a subject.");
			document.theform1.subject.focus();
			return false;
			}

window.location.replace("ProcessSuggest-a-Site.aspx?contactid="+
document.theform1.SendingTo.value+
"&"+
"firstname="+document.theform1.firstname.value+
"&"+
"lastname="+document.theform1.lastname.value+
"&"+
"fromemail="+document.theform1.replyto.value+
"&"+
"replyto="+document.theform1.replyto.value+
"&"+
"email="+document.theform1.email.value+
"&"+
"phone="+document.theform1.phonefirst3.value+document.theform1.phonesecond3.value+document.theform1.phonelast4.value+
"&"+
"city="+document.theform1.city.value+
"&"+
"state="+document.theform1.state.value+
"&"+
"zip="+document.theform1.zip.value+
"&"+
"probableinvestmentlevel="+document.theform1.probableinvestmentlevel.value+
"&"+
"consultation="+document.theform1.consultation.value+
"&"+
"subject="+document.theform1.subject.value+
"&"+
"comments="+document.theform1.comments.value+

"&"+
"feed="+document.theform1.feed.value);

return true;
}
