function CheckAffParm()  { 
	with(document.signup)
	{
		if(a_sa.checked == false)
		{
			a_sa.select()
			a_sa.focus();
			alert("You must check that you have read the Sure Fit service agreement.")
			return false;
		}

		if(a_pp.checked == false)
		{
			a_pp.select()
			a_pp.focus();
			alert("You must check that you have read the Sure Fit Privacy Policy.")
			return false;
		}

		if(a_age.checked == false)
		{
			a_age.select()
			a_age.focus();
			alert("You must check that you confirm you are at least 18 year old.")
			return false;
		}

		a_ws.value = AllTrim(a_ws.value);
		if(a_ws.value == '')
		{
			a_ws.select()
			a_ws.focus();
			alert("Web Site Name is a required field.")
			return false;
		}

		a_url.value = AllTrim(a_url.value);
		if(a_url.value == '')
		{
			a_url.select()
			a_url.focus();
			alert("Web Site URL is a required field.")
			return false;
		}

		a_desc.value = AllTrim(a_desc.value);
		if(a_desc.value == '')
		{
			a_desc.select()
			a_desc.focus();
			alert("Web Site Description is a required field.")
			return false;
		}

		a_prom.value = AllTrim(a_prom.value);
		if(a_prom.value == '')
		{
			a_prom.select()
			a_prom.focus();
			alert("How do you advertise your site is a required field.")
			return false;
		}

		a_incdesc.value = AllTrim(a_incdesc.value);
		if(a_incdesc.value == '')
		{
			a_incdesc.select()
			a_incdesc.focus();
			alert("Promotion Description is a required field.")
			return false;
		}

		a_name.value = AllTrim(a_name.value);
		if(a_name.value == '')
		{
			a_name.select()
			a_name.focus();
			alert("Full Contact Name is a required field.")
			return false;
		}

		a_title.value = AllTrim(a_title.value);
		if(a_title.value == '')
		{
			a_title.select()
			a_title.focus();
			alert("Title is a required field.")
			return false;
		}

		a_phone.value = AllTrim(a_phone.value);
		if(a_phone.value == '')
		{
			a_phone.select()
			a_phone.focus();
			alert("Contact Phone Number is a required field.")
			return false;
		}

		if(!validPhone(a_phone,false)) {
			a_phone.select()
			a_phone.focus();
			alert ("Please enter your 10-digit Contact Phone. Ex: (xxx) xxx-xxxx")
			return false;
		}
		
		a_email.value = AllTrim(a_email.value);
		if(a_email.value == '')
		{
			a_email.select()
			a_email.focus();
			alert("Email is a required field.")
			return false;
		}

		if (!VerifyEmail(a_email.value)) {
			alert ("Please enter a valid Email address.");
			a_email.select()
			a_email.focus();
			return false;
		}
    
		a_org.value = AllTrim(a_org.value);
		if(a_org.value == '')
		{
			a_org.select()
			a_org.focus();
			alert("Organization Name is a required field.")
			return false;
		}
    
		a_add1.value = AllTrim(a_add1.value);
		if(a_add1.value == '')
		{
			a_add1.select()
			a_add1.focus();
			alert("Address 1 is a required field.")
			return false;
		}
    
		a_city.value = AllTrim(a_city.value);
		if(a_city.value == '')
		{
			a_city.select()
			a_city.focus();
			alert("Company City is a required field.")
			return false;
		}
    
		a_st.value = AllTrim(a_st.value);
		if(a_st.value == '')
		{
			a_st.select()
			a_st.focus();
			alert("Company State is a required field.")
			return false;
		}
    
		if(a_st.value.length != 2)
		{
			a_st.select()
			a_st.focus();
			alert("Company State must be at exactly 2 characters.")
			return false;
		}

		a_zip.value = AllTrim(a_zip.value);
		if(a_zip.value == '')
		{
			a_zip.select()
			a_zip.focus();
			alert("Company Zip is a required field.")
			return false;
		}
    
		a_ophone.value = AllTrim(a_ophone.value);
		if(a_ophone.value == '')
		{
			a_ophone.select()
			a_ophone.focus();
			alert("Company Phone is a required field.")
			return false;
		}
    
		if(!validPhone(a_ophone,false)) {
			a_ophone.select()
			a_ophone.focus();
			alert ("Please enter your 10-digit Company Phone. Ex: (xxx) xxx-xxxx")
			return false;
		}
    
		a_ofax.value = AllTrim(a_ofax.value);
		if(a_ofax.value == '')
		{
			a_ofax.select()
			a_ofax.focus();
			alert("Company Fax is a required field.")
			return false;
		}
    
		if(!validPhone(a_ofax,false)) {
			a_ofax.select()
			a_ofax.focus();
			alert ("Please enter your 10-digit Company Fax. Ex: (xxx) xxx-xxxx")
			return false;
		}

		a_taxid.value = AllTrim(a_taxid.value);
		if(a_taxid.value == '')
		{
			a_taxid.select()
			a_taxid.focus();
			alert("Tax ID is a required field.")
			return false;
		}
    
		a_taxclass.value = AllTrim(a_taxclass.value);
		if(a_taxclass.value == '')
		{
			a_taxclass.select()
			a_taxclass.focus();
			alert("Tax Classification is a required field.")
			return false;
		}
		
		document.signup.submit();
	}
	return true;
}
function LTrim(str) {
	for (var k=0; k<str.length && str.charAt(k)<=" " ; k++) ;
	return str.substring(k,str.length);
}

function RTrim(str) {
	for (var j=str.length-1; j>=0 && str.charAt(j)<=" " ; j--) ;
	return str.substring(0,j+1);
}

function AllTrim(str) {
	return LTrim(RTrim(str));
}

function VerifyEmail(theField) {
    var validChars = "@0123456789-_.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	var allValid = true;
	var numAts = 0;
	var extension = "";

	for (var i = 0;  i < theField.length;  i++ )
	{
		ch = theField.charAt(i)
		for ( j = 0;  j < validChars.length;  j++ )
		{
			if ( ch == validChars.charAt(j) ) break
			if ( j == (validChars.length - 1))
			{
				allValid = false
				break
			}
		}
	    if ( ch == "@" )	numAts++
	}

	extension = "." + theField.charAt(theField.length-3) + theField.charAt(theField.length-2) + theField.charAt(theField.length-1) 
	extension = extension.toLowerCase();

	if ( numAts != 1 )
		allValid = false;

	if (!(extension == ".com" || extension == ".gov" || extension == ".net" || extension == ".org" || extension == ".edu" || extension == "..ca" || extension == "..us"))
		allValid = false;
	if ( !allValid )
		return false;

	return true;
}

function validPhone (theField, emptyOK) {
	if (emptyOK) if ( theField.value.length < 1 ) return true
	var phone = ""
	var validChars = "0123456789"
	var allValid = true

	// strip blanks,dots,dashes,parens
	for ( i=0; i<theField.value.length; i++ ) {
		ch = theField.value.charAt(i)
		if ( ch != " " && ch != "."  && ch != "-" && ch != "(" && ch != ")" ) phone+=ch
	}
	if ( phone.length != 10 ) allValid = false
	else for ( i=0; i<phone.length; i++ ) {
		ch = phone.charAt(i)
		for ( j=0; j<validChars.length; j++ ) {
			if ( ch == validChars.charAt(j) ) break
			if ( j == (validChars.length - 1) ) allValid = false
		}
	}
	return allValid
}
