// JavaScript Document

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

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

	// フラグの初期化
	var flg = false;
	var error_mes = "Error Message\r\n恐れ入りますが、下記の内容をご確認ください\r\n\r\n";

	// 未入力と不正入力のチェック
	if(!confirm_flg){
		if(!f.kind[0].checked && !f.kind[1].checked && !f.kind[2].checked){
			error_mes += "・お問い合わせ種別をご選択ください。\r\n";flg = true;
		}
	}else{
		if(!f.kind.value){
			error_mes += "・お問い合わせ種別をご選択ください。\r\n";flg = true;
		}
	}

	if(!f.company.value){
		error_mes += "・貴社名をご記入ください。\r\n";flg = true;
	}
	
	if(!f.name.value){
		error_mes += "・ご担当者名をご記入ください。\r\n";flg = true;
	}

	if( f.zip.value && f.zip.value.match(/[^-0-9]/) ){
		error_mes += "・郵便番号は半角数字とハイフンのみでご記入ください。\r\n";flg = true;
	}

	if(f.tel.value && f.tel.value.match(/[^-0-9]/)){
		error_mes += "・TELは半角数字とハイフンのみでご記入ください。\r\n";flg = true;
	}

	if(f.fax.value && f.fax.value.match(/[^-0-9]/)){
		error_mes += "・FAXは半角数字とハイフンのみでご記入ください。\r\n";flg = true;
	}

	if(!f.email.value){
		error_mes += "・E-mailをご記入ください。\r\n";flg = true;
	}
	else if(!f.email.value.match(/^[^@]+@[^.]+\..+/)){
		error_mes += "・E-mailの形式に誤りがあります。\r\n";flg = true;
	}

	if(!f.comment.value){
		error_mes += "・お問い合わせ内容をご記入ください。\r\n";flg = true;
	}

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

		// 確認メッセージ
		if(confirm_flg){
			return ConfirmMsg('ご入力いただいた内容で送信します。\nよろしいですか？');
		}
		return true;
	}


}

