





function Form_Validator(optin)
{
var alertsay = "";
var checkOK = "0123456789-:.()";
var allValid = true;
var allNum = "";

//Full Name
	if (optin.name.value == "")
	{
	alert("You must enter the first and last name.");
	optin.name.focus();
	return (false);
	}	
		//Split NAME to Separate Fields
		if (optin.name.value != "")
		{
		fullname = document.optin.name.value
		SplitName = fullname.split(" ")
		first = SplitName[0]
		second = SplitName[1]
		
		document.optin.fname.value = first
		document.optin.lname.value = second
		}
		
//EMAIL VALIDATE
	if (optin.email.value == "")
	{
	alert("Please enter a value for the \"Email\" field.");
	optin.email.focus();
	return (false);
	}
		
		
	// test if valid email address, must have @ and .
	var checkEmail = "@.";
	var checkStr = optin.email.value;
	var EmailValid = false;
	var EmailAt = false;
	var EmailPeriod = false;
	for (i = 0;  i < checkStr.length;  i++)
	{
	ch = checkStr.charAt(i);
	for (j = 0;  j < checkEmail.length;  j++)
	{
	if (ch == checkEmail.charAt(j) && ch == "@")
	EmailAt = true;
	if (ch == checkEmail.charAt(j) && ch == ".")
	EmailPeriod = true;
		  if (EmailAt && EmailPeriod)
			break;
		  if (j == checkEmail.length)
			break;
	}
		
		// if both the @ and . were in the string
		if (EmailAt && EmailPeriod)
		{
				EmailValid = true
				break;
			}
		}
		if (!EmailValid)
		{
		alert("The \"email\" field must contain an \"@\" and a \".\".");
		optin.email.focus();
		return (false);
		}
		
//phone
		if (optin.phone.value == "")
		{
		alert("Please enter your phone number.");
		optin.phone.focus();
		return (false);
		}
		
		var checkValue = optin.phone.value;
		for (i = 0;  i < checkValue.length;  i++)
		{
		ch = checkValue.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		if (ch == checkOK.charAt(j))
		break;
		if (j == checkOK.length)
		{
		allValid = false;
		break;
		}
		if (ch != ",")
		allNum += ch;
		}
		if (!allValid)
		{
		alert("Please enter only numbers for your \"phone number\".");
		optin.phone.focus();
		return (false);
		}
				
	//STATE	
		if (optin.state.selectedIndex == 0)
		{
		alert("Please select your state.");
		optin.state.focus();
		return (false);
		}
		
	//country
		if (optin.country.selectedIndex == 0)
		{
		alert("Please select your country.");
		optin.country.focus();
		return (false);
		}
		
		//PASSWORD
		if (optin.pass1.value == "")
		{
		alert("You must enter an password.");
		optin.pass1.focus();
		return (false);
		}
		//Password Compare
		if (optin.pass1.value != optin.pass2.value)
		{
			alert("The two passwords are not the same.");
			optin.pass2.focus();
			return (false);
		}




}
