/* Contact Form Javascript - Sta-Collar&reg; */
/* $Id: contact.js,v 1.5 2007/08/27 21:33:32 pete Exp pete $ */


function isRadioChecked(formField)
{
	for(x=0;x < formField.length;x++)
	{
  			if(formField[x].checked == true)
			{
				return true;
			}
	}
 	return false;
}


function SubmitForm()
{
	if (document.contact.name.value == "")
	{
    	alert("Please enter a value for the Name field.");
	    document.contact.name.focus();
    	return (false);
	}

	if (document.contact.company.value == "")
	{
    	alert("Please enter a value for the Company field.");
	    document.contact.company.focus();
    	return (false);
	}
	
	if (document.contact.address1.value == "")
	{
    	alert("Please enter a value for the Address field.");
	    document.contact.address1.focus();
    	return (false);
	}

	if (document.contact.city.value == "")
	{
    	alert("Please enter a value for the City field.");
	    document.contact.city.focus();
    	return (false);
	}

	if (document.contact.state.value == "")
	{
    	alert("Please enter a value for the State field.");
	    document.contact.state.focus();
    	return (false);
	}

	if (document.contact.zipcode.value == "")
	{
    	alert("Please enter a value for the ZIP Code field.");
	    document.contact.zipcode.focus();
    	return (false);
	}

	if (document.contact.phone.value == "")
	{
    	alert("Please enter a value for the Phone field.");
	    document.contact.phone.focus();
    	return (false);
	}

	if (!isRadioChecked(document.contact.jobfunction))
	{
    	alert("Please select a Primary Job Function.");
	    document.contact.phone.focus();
    	return (false);
	}

	if (document.contact.email.value.length < 1)
	{
    	alert("Please enter a value for the Email field.");
	    document.contact.email.focus();
    	return (false);
	}
	else
	{
		var emailexp = /^[a-z][a-z_0-9\.]+@[a-z_0-9\-\.]+\.[a-z]{2,4}$/i
		
		if ( !emailexp.test( document.contact.email.value ) )
		{
			alert( "Please enter the Email address in the following format: xxx@xxx.xxx" );
			document.contact.email.focus();
    		return (false);
		}
	}

}

