
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          名";
		} 
		if (f.Last_Name.value=="")
		{
			errors = errors + 1;
			empty_fields += "\n          姓";
		} 
		
		if (f.Address.value=="")
		{
			errors = errors + 1;
			empty_fields += "\n          住所";
		} 
		
		if (f.City.value=="")
		{
			errors = errors + 1;
			empty_fields += "\n          市町村";
		} 
		
		
		if (f.Country.options[f.Country.selectedIndex].value=="")
		{
			errors = errors + 1;
			empty_fields += "\n          国名";
		}
		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          州";
				}
			}
		} 
		
		if (f.Daytime_Phone_Number != null)
		{
			if (f.Daytime_Phone_Number.value=="")
			{
				errors = errors + 1;
				empty_fields += "\n          電話番号（昼間）";
			}
			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          電話番号（昼間）";
					}
			}
		
		}
		
		if (f.emailFrom.value=="")
				{
					errors = errors + 1;
					empty_fields += "\n          Eメール アドレス";
				}
				else
				{
					if ((f.emailFrom.value).search("@") == -1 )
					{
						errors = errors + 1;
						error_fields += "'" + f.emailFrom.value + "' が無効です。\n";
					}
				}
		

		if (f.functionType.value=="")
		{
			errors = errors + 1;
			empty_fields += "\n          ミーティング名";
		} 
		
		if (f.company.value=="")
		{
			errors = errors + 1;
			empty_fields += "\n          会社または組織名";
		} 
		
		
		
		//alert(errors);
		if (errors > 0 ) 
		{
			msg =  "____________________________________________________________\n\n";
			msg += "次のエラーのため、フォームは送信されませんでした。\n";
			msg += "エラーを修正し、もう一度送信してください。\n";
			msg += "____________________________________________________________\n\n";

			if(empty_fields != "")
			{
				msg += "- 以下の必須項目が入力されていません:" + empty_fields + "\n";
			}
			
			if (number_errors != "")
			{
				msg += "\n- 以下の項目には数字を入力してください:" + 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('すべての必須項目を入力してください。');
                        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          名";
			
		} 
		if (f.Last_Name.value=="")
		{
			errors = errors + 1;
			empty_fields += "\n          姓";
		} 
		
		if (f.Address.value=="")
		{
			errors = errors + 1;
			empty_fields += "\n          住所";
		} 
		
		if (f.City.value=="")
		{
			errors = errors + 1;
			empty_fields += "\n          市町村";
		} 
		
		
		if (f.Country.options[f.Country.selectedIndex].value=="")
		{
			errors = errors + 1;
			empty_fields += "\n          国名";
		}
		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          州";
				}
			}
		} 
		
		if (f.Daytime_Phone_Number != null)
		{
			if (f.Daytime_Phone_Number.value=="")
			{
				errors = errors + 1;
				empty_fields += "\n          電話番号（昼間）";
			}
			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          電話番号（昼間）";
					}
			}
		
		}
		
		if (f.emailFrom.value=="")
				{
					errors = errors + 1;
					empty_fields += "\n          Eメール アドレス";
				}
				else
				{
					if ((f.emailFrom.value).search("@") == -1 )
					{
						errors = errors + 1;
						error_fields += "'" + f.emailFrom.value + "' が無効です。\n";
					}
				}
		

		if (f.functionType.value=="")
		{
			errors = errors + 1;
			empty_fields += "\n          お集まりの種類または名前";
		} 
		
		
		
		//alert(errors);
		if (errors > 0 ) 
		{
			msg =  "____________________________________________________________\n\n";
			msg += "次のエラーのため、フォームは送信されませんでした。\n";
			msg += "エラーを修正し、もう一度送信してください。\n";
			msg += "____________________________________________________________\n\n";

			if(empty_fields != "")
			{
				msg += "- 以下の必須項目が入力されていません:" + empty_fields + "\n";
			}
			
			if (number_errors != "")
			{
				msg += "\n- 以下の項目には数字を入力してください:" + number_error_fields + "\n" ;
			}

			if (error_fields != "")
			{
				msg += "\n- " + error_fields + "\n";
			}

			alert (msg);

			return false;
		}
		else
		{
			return true;
		}

}