function formSubmit()
{
	var f = document.Corporate_RFP;
		if(validateForm(f))
			f.submit();
}

function validateForm(f)
{
		//alert ("validation");
		var msg;
		var errors = 0;
		var number_errors = 0;
		var empty_fields = "";
		var error_fields = "";
		var number_error_fields = "";
		
		// indicate all the required fields
		
		if (f.First_Name.value=="")
		{
			errors = errors + 1;
			empty_fields += "\n          First Name";
		} 
		if (f.Last_Name.value=="")
		{
			errors = errors + 1;
			empty_fields += "\n          Last Name";
		} 
		
		if (f.Address.value=="")
		{
			errors = errors + 1;
			empty_fields += "\n          Address";
		} 
		
		if (f.City.value=="")
		{
			errors = errors + 1;
			empty_fields += "\n          City";
		} 
		
		
		if (f.Country.options[f.Country.selectedIndex].value=="")
		{
			errors = errors + 1;
			empty_fields += "\n          Country";
		}
		else
		{	
			if (f.Country.options[f.Country.selectedIndex].value=="United States")
			{
				if(f.StateList.options[f.StateList.selectedIndex].value=="")
				{
					errors = errors + 1;
					empty_fields += "\n          State";
				}
			}
		} 
		
		if (f.Daytime_Phone_Number != null)
		{
			if (f.Daytime_Phone_Number.value=="")
			{
				errors = errors + 1;
				empty_fields += "\n          Daytime Phone";
			}
			else
			{
				// first take out all the '-' and '(' and ')'
				var numValue = (f.Daytime_Phone_Number.value).replace(/-/gi, "");
		
					//alert (numValue);
					var v = parseFloat(numValue);
					if (isNaN(v))
					{
						errors = errors + 1;
						number_errors = number_errors + 1;
						number_error_fields += "\n          Daytime Phone";
					}
			}
		
		}
		
		if (f.emailFrom.value=="")
				{
					errors = errors + 1;
					empty_fields += "\n          E-mail Address";
				}
				else
				{
					if ((f.emailFrom.value).search("@") == -1 )
					{
						errors = errors + 1;
						error_fields += "'" + f.emailFrom.value + "' is not a valid e-mail address.\n";
					}
				}
		

		if (f.functionType.value=="")
		{
			errors = errors + 1;
			empty_fields += "\n          Meeting Name";
		} 
		
		if (f.company.value=="")
		{
			errors = errors + 1;
			empty_fields += "\n          Company or Organization";
		} 
		
		
		
		//alert(errors);
		if (errors > 0 ) 
		{
			msg =  "____________________________________________________________\n\n";
			msg += "The form was not submitted because of the following error(s).\n";
			msg += "Please correct these error(s) and resubmit.\n";
			msg += "____________________________________________________________\n\n";

			if(empty_fields != "")
			{
				msg += "- The following required fields were left empty:" + empty_fields + "\n";
			}
			
			if (number_errors != "")
			{
				msg += "\n- The following fields should be numbers:" + number_error_fields + "\n" ;
			}

			if (error_fields != "")
			{
				msg += "\n- " + error_fields + "\n";
			}

			alert (msg);

			return false;
		}
		else
		{
			return true;
		}

}

function spaFormSubmit()
{
	var f = document.Spa_Inquiry;
		if(validateSpa())
			f.submit();
}

function validateSpa()
{
          if ((document.Spa_Inquiry.First_Name.value == '') || (document.Spa_Inquiry.Last_Name.value == '') || (document.Spa_Inquiry.Address.value == '') || (document.Spa_Inquiry.City.value == '') || (document.Spa_Inquiry.Telephone.value == '') || (!( (document.Spa_Inquiry['timeMorning'].checked) || (document.Spa_Inquiry['timeAfternoon'].checked) || (document.Spa_Inquiry['timeEvening'].checked) )))
                {
                        alert('Please fill in all requried fields.');
                        return false;
                }
                else
                        return true;
        }

function sfpFormSubmit()
{
	var f = document.Social_Function_Planning;
		if(validateSfp(f))
			f.submit();
}

function validateSfp(f)
{
		//alert ("validation");
		var msg;
		var errors = 0;
		var number_errors = 0;
		var empty_fields = "";
		var error_fields = "";
		var number_error_fields = "";
		
		// indicate all the required fields
		
		if (f.First_Name.value=="")
		{
			errors = errors + 1;
			empty_fields += "\n          First Name";
			
		} 
		if (f.Last_Name.value=="")
		{
			errors = errors + 1;
			empty_fields += "\n          Last Name";
		} 
		
		if (f.Address.value=="")
		{
			errors = errors + 1;
			empty_fields += "\n          Address";
		} 
		
		if (f.City.value=="")
		{
			errors = errors + 1;
			empty_fields += "\n          City";
		} 
		
		
		if (f.Country.options[f.Country.selectedIndex].value=="")
		{
			errors = errors + 1;
			empty_fields += "\n          Country";
		}
		else
		{	
			if (f.Country.options[f.Country.selectedIndex].value=="United States")
			{
				if(f.StateList.options[f.StateList.selectedIndex].value=="")
				{
					errors = errors + 1;
					empty_fields += "\n          State";
				}
			}
		} 
		
		if (f.Daytime_Phone_Number != null)
		{
			if (f.Daytime_Phone_Number.value=="")
			{
				errors = errors + 1;
				empty_fields += "\n          Daytime Phone";
			}
			else
			{
				// first take out all the '-' and '(' and ')'
				var numValue = (f.Daytime_Phone_Number.value).replace(/-/gi, "");
		
					//alert (numValue);
					var v = parseFloat(numValue);
					if (isNaN(v))
					{
						errors = errors + 1;
						number_errors = number_errors + 1;
						number_error_fields += "\n          Daytime Phone";
					}
			}
		
		}
		
		if (f.emailFrom.value=="")
				{
					errors = errors + 1;
					empty_fields += "\n          E-mail Address";
				}
				else
				{
					if ((f.emailFrom.value).search("@") == -1 )
					{
						errors = errors + 1;
						error_fields += "'" + f.emailFrom.value + "' is not a valid e-mail address.\n";
					}
				}
		

		if (f.functionType.value=="")
		{
			errors = errors + 1;
			empty_fields += "\n          Function Type or Name";
		} 
		
		
		
		//alert(errors);
		if (errors > 0 ) 
		{
			msg =  "____________________________________________________________\n\n";
			msg += "The form was not submitted because of the following error(s).\n";
			msg += "Please correct these error(s) and resubmit.\n";
			msg += "____________________________________________________________\n\n";

			if(empty_fields != "")
			{
				msg += "- The following required fields were left empty:" + empty_fields + "\n";
			}
			
			if (number_errors != "")
			{
				msg += "\n- The following fields should be numbers:" + number_error_fields + "\n" ;
			}

			if (error_fields != "")
			{
				msg += "\n- " + error_fields + "\n";
			}

			alert (msg);

			return false;
		}
		else
		{
			return true;
		}

}
