function check_number (str) {
	if (str.length == 0) {
		return true;
	} else if (isNaN(str)) {
		return false;
	} else {
		return true;
	}
}

function check_email (str) {
	if (str.match(/[\w\.\-.\_]+@([\w\-]+\.)+[\w]+/ig) == str) {
		return true;
	} else {
		return false;
	}
}

function check_zenkaku (str) {
	var char_length = ("あ".length);

	//スペースを取り除く
	var str2 = str.replace(/ /g,"");
	if(str2.length == 0){
		return true;
	}

	var s;
	for (var i = 0; i < str2.length; i += char_length) {
		s = str2.charAt(i);
		if ((s >= "!" && s <= "~") || (s >= "｡" && s <= "ﾟ")) {
			return false;
		}
	}
	return true;
}

function check_hankaku (str) {
	//スペースを取り除く
	var str2 = str.replace(/ /g,"");
	if(str2.length == 0){
		return true;
	}

	var s;
	for (var i = 0; i < str2.length; i ++) {
		s = str2.charAt(i);
		if (s < "!" || s > "~") {
			return false;
		}
	}
	return true;
}

function check_hiragana (str) {
	var char_length = ("あ".length);

	//スペースを取り除く
	var str2 = str.replace(/ /g,"");
	if(str2.length == 0){
		return true;
	}

	var s;
	for (var i = 0; i < str2.length; i += char_length) {
		s = str2.charCodeAt(i);
		if (!((s >= 12353 && s <= 12435) || s == 12445 || s == 12446)) {
			return false;
		}
	}
	return true;
}

function send_inquiry () {
	// 必須項目チェック
	if (document.getElementById("ta_content").value.length <= 0) {
		my_alert("お問い合わせ内容 を入力して下さい。");
		return;
	}
	if (document.getElementById("ta_content").value.length >= 10000) {
		my_alert("お問い合わせ内容 が長すぎます。");
		return;
	}
	if (document.getElementById("tf_name").value.length <= 0) {
		my_alert("お名前 を入力して下さい。");
		return;
	}
	if (document.getElementById("tf_email_1").value.length <= 0) {
		my_alert("E-mail を入力して下さい。");
		return;
	}
	if (document.getElementById("tf_email_2").value.length <= 0) {
		my_alert("E-mail (確認用) を入力して下さい。");
		return;
	}

	// 数値バリデーション

	// E-mailチェック
	if (!check_email(document.getElementById("tf_email_1").value)) {
		my_alert("E-mail を正しく入力して下さい。");
		return;
	}
	if (!check_email(document.getElementById("tf_email_2").value)) {
		my_alert("E-mail (確認用) を正しく入力して下さい。");
		return;
	}

	// 全角チェック
	if (!check_zenkaku(document.getElementById("tf_name").value)) {
		my_alert("お名前 は全角で入力して下さい。");
		return;
	}

	// E-mail確認
	if (document.getElementById("tf_email_1").value != document.getElementById("tf_email_2").value) {
		my_alert("E-mail が確認用ものと異なっています。");
		return;
	}

	document.getElementById("contact_form").submit();
}

function my_alert (msg) {
	alert(msg);
}
