function qfValidate(theForm)
{
	/// Validation function
	/// Created 12/5/2006 - AWK Vantage Internet.
	
	var errStr = "";
	var isValid = true;
	
	// Firstname required
	if( theForm.Firstname.value.length == 0 )
	{
		errStr += "You must enter a First-Name.\n";
		isValid=false;	
	}
	
	// LastName required
	if( theForm.Lastname.value.length == 0 )
	{
		errStr += "You must enter a Last-Name.\n";
		isValid=false;	
	}

	// Strip chars from phone and check to make sure it is only numbers.
	var phone = new String( theForm.Phone.value );
	phone = phone.replace(/-/g,"");
	phone = phone.replace(/\./g,"");
	phone = phone.replace(/ /g,"");
	phone = phone.replace(/\(/g,"");
	phone = phone.replace(/\)/g,"");
	
	if( phone.length != 10 || isNaN(phone) )
	{
		errStr += "You must enter a 10-digit phone number. Only numbers are allowed.\n";
		isValid=false;	
	}
	else
	{
		theForm.Phone.value = phone;	
	}

	
	
	// Check for valid email
	if( !validateEmail( theForm.Email.value ) )
	{
		errStr += "You must enter a valid email address.\n";
		isValid=false;	
	}
	
	
	// Address required
	if( theForm.Address.value.length == 0 )
	{
		errStr += "You must enter an Address.\n";
		isValid=false;	
	}

	// City required
	if( theForm.City.value.length == 0 )
	{
		errStr += "You must enter a City.\n";
		isValid=false;	
	}

	// State required
	if(  theForm.State.options[theForm.State.selectedIndex].value=="")
	{
		errStr += "You must enter a State.\n";
		isValid=false;	
	}

	// Check for valid zipcode
	if( isNaN(theForm.Zip.value) || theForm.Zip.value.length != 5 )
	{
		errStr += "You must enter a 5-digit ZipCode.\n";
		isValid=false;	
	}
	
	// Check for selected Info
	if( theForm.Info.options[theForm.Info.selectedIndex].value=="Select" )
	{
		errStr += "You must select a value for Receive-Info.\n";
		isValid=false;	
	}
	
	// Show validation errors
	if ( isValid==false ) 
		alert(errStr);
	
	return isValid;
}

function validateEmail( theEmail )
{
	var isValid = true;
	if( theEmail.length == 0 )
		isValid = false;
	else
  	{ //test for @ char...
  
  		var tStr = theEmail;
  		var atChar = tStr.indexOf("@");
		var ptChar = -432;

		if(atChar <= 0)	isValid = false;

		else{ //test for . char...
			tStr=tStr.substring(atChar,tStr.length);
			ptChar = tStr.indexOf(".");
			if(ptChar <= 1) isValid = false;
		}
  	}
	return isValid;
}
