<!--

//ラジオボタンの選択されている値を取得する
function GetRadioValue(targetradio) {
	var value = "";																//取得した値
	for (i = 0; i < targetradio.length; i++) {
		//チェック状態かどうか
		if (targetradio[i].checked) {
			// 値を取得する
			value = targetradio[i].value;
			break;
		}
	}
	return value;
}

//メールアドレスが正しく入力されているかどうかをチェックする
function EmailCheck(email) {
	var str = email;
	var chkflg;
	if (str.match(/[\x21-\x7E]/) && !str.match(/[\(\)<>,;:\\"[\]]/) && str.match(/^[^@]+@[^@]+$/)) {
		chkflg = true;
	} else {
		chkflg = false;
	}
	return chkflg;
}


//必須項目と値の入力範囲をチェックする（お問い合わせ画面用）
function ChkVal_contact(){
	var dispstr = "";																			//メッセージ表示文字列
	var errcount = 0;																			//チェックエラーカウント
	var resultflg = false;																		//チェック結果フラグ
	var arremptyitem = new Array();																//未入力項目名
	
	//必須項目の未入力チェック
	
	//種類
	var resvalue = GetRadioValue(document.getElementsByName("kind"));
	if(resvalue ==""){
		arremptyitem.push("[種類]");
		errcount++;
	}
	//内容
	var resvalue = document.getElementById("contentsform").value;
	if(resvalue ==""){
		arremptyitem.push("[内容]");
		errcount++;
	}
	
	//お客様氏名
	var resvalue = document.getElementById("to_name").value;
	if(resvalue ==""){
		arremptyitem.push("[お名前]");
		errcount++;
	}
	//ご希望連絡方法
	resvalue = document.getElementById("to_distribution").value;
	if(resvalue =="" || resvalue =="0"){
		arremptyitem.push("[ご希望連絡方法]");
		errcount++;
	}
	//ご希望連絡方法の値によって必須項目を変える
	switch(resvalue){
		case "1":
			//電話が必須項目
			var to_tel = document.getElementById("to_tel").value;
			if(to_tel ==""){
				arremptyitem.push("電話番号]");
				errcount++;
			}
			break;
		case "2":
			//FAXが必須項目
			var to_fax = document.getElementById("to_fax").value;
			if(to_fax ==""){
				arremptyitem.push("[ファックス番号]");
				errcount++;
			}
			break;
		case "3":
			//メールアドレス
			var to_email = document.getElementById("to_email").value;
			if(to_email ==""){
				arremptyitem.push("[メールアドレス]");
				errcount++;
			}
			break;
	}
	
	if (errcount > 0){
		dispstr = "必須項目で未入力の項目があります";
		
		for (index in arremptyitem) {
			dispstr = dispstr + "\n\n　・" + arremptyitem[index];
		}
		window.alert(dispstr);
		
		return resultflg;
	}
	
	//正しい値が入力されているかどうかのチェック
	var arrngitem = new Array();
	//メールアドレス
	var mailconf = document.getElementById("to_email").value;
	if(mailconf !=""){
		if (!EmailCheck(mailconf)) {
			var msgtemp = "";
			msgtemp = msgtemp + "メールアドレスが正しく入力されていません。次のことが考えられます。\n";
			msgtemp = msgtemp + "　　全角で入力されている\n";
			msgtemp = msgtemp + "　　メールアドレスとして使用できない文字が入力されている\n";
			msgtemp = msgtemp + "　　「@」が入力されていない\n";
			msgtemp = msgtemp + "　　「@」が2個以上入力されている";
			
			arrngitem.push(msgtemp);
			errcount++;
		}
	}
	
	//入力エラー項目があった場合
	if (errcount > 0){
		dispstr = "入力エラーの項目があります";
		
		for (index in arrngitem) {
			dispstr = dispstr + "\n\n　・" + arrngitem[index];
		}
		window.alert(dispstr);
		
		return resultflg;
	}
	
	resultflg = true;
	
	if (resultflg) {
		document.getElementById("contact").submit();
	}
	
}


//連絡方法によって任意画像と必須画像を分ける
function changeMust(){
	
	//連絡方法１：電話２：FAX３：メール
	var distribution = document.getElementById("to_distribution").value;
	
	switch(distribution){
		case "1":
				document.getElementById("telmust").src = 'img/essential.jpg';
				document.getElementById("telmust").alt = '必須';
				document.getElementById("faxmust").src = 'img/optional.jpg';
				document.getElementById("faxmust").alt = '任意';
				document.getElementById("mailmust").src = 'img/optional.jpg';
				document.getElementById("mailmust").alt = '任意';
			break;
		case "2":
				document.getElementById("telmust").src = 'img/optional.jpg';
				document.getElementById("telmust").alt = '任意';
				document.getElementById("faxmust").src = 'img/essential.jpg';
				document.getElementById("faxmust").alt = '必須';
				document.getElementById("mailmust").src = 'img/optional.jpg';
				document.getElementById("mailmust").alt = '任意';
			break;
		case "3":
				document.getElementById("telmust").src = 'img/optional.jpg';
				document.getElementById("telmust").alt = '任意';
				document.getElementById("faxmust").src = 'img/optional.jpg';
				document.getElementById("faxmust").alt = '任意';
				document.getElementById("mailmust").src = 'img/essential.jpg';
				document.getElementById("mailmust").alt = '必須';
			break;
		default:
				//処理なし
			break;
	}
	
}

//戻るボタン
function ConvertValue(){
	var buttonname = document.getElementById("screenid").value;
	if(buttonname == "conf"){
		document.getElementById("screenid").value = "back";
		document.getElementById("contact").submit();
	}
}


//送信ボタン
function RegistContact(){
	
	document.getElementById("contact").submit();
	
}

//ブラウザ戻るボタン対応
function Clear(){
	document.getElementById("screenid").value ="conf";
	
}







// -->
