// JavaScript Document

/////////////////////////////////////
// 汎用確認メッセージ
/////////////////////////////////////
function ConfirmMsg(msg){
	return (confirm(msg))?true:false;
}

/////////////////////////////////////////////////////////////////////////////////
// 未入力及び不正入力のチェック（※Safariのバグ（エスケープ文字認識）を回避）
/////////////////////////////////////////////////////////////////////////////////
function inputChk(f,confirm_flg){

	// フラグの初期化
	var flg = false;
	var error_mes = "Please correct the form as instructed below.\r\n\r\n";

	// 未入力と不正入力のチェック

	
	if(!f.name.value){
		error_mes += "・Please fill in \"Your Name\" field.\r\n";flg = true;
	}

	if(f.tel.value && f.tel.value.match(/[^-0-9]/)){
		error_mes += "・Please use only numbers and hyphens (in single byte format) in \"Phone\" field.\r\n";flg = true;
	}

	if(f.fax.value && f.fax.value.match(/[^-0-9]/)){
		error_mes += "・Please use only numbers and hyphens (in single byte format) in \"Fax\" field.\r\n";flg = true;
	}

	if(!f.email.value){
		error_mes += "・Please fill in \"E-mail address\" field.\r\n";flg = true;
	}
	else if(!f.email.value.match(/^[^@]+@[^.]+\..+/)){
		error_mes += "・Please fill a valid E-mail address in \"E-mail address\" field.\r\n";flg = true;
	}

	if(!f.comment.value){
		error_mes += "・Please fill in \"Comments\" field.\r\n";flg = true;
	}

	// 判定
	if(flg){
		// アラート表示して再入力を警告
		window.alert(error_mes);return false;
	}
	else{

		// 確認メッセージ
		if(confirm_flg){
			return ConfirmMsg('Are you sure that you want submit this form?');
		}
		return true;
	}


}

