/* topページ　期間限定お得情報 */
function disp_c(url){
	window.open(url, "campaign", "width=820, height=500, scrollbars=yes");
}

/* 会社案内ページ　地図 */
function disp_m(url){
	window.open(url, "map", "width=720, height=655, scrollbars=yes");
}

/* お問合せページ　確認画面遷移処理（変数宣言） */

	//表の項目の名前
	var name = new Array
			("お名前","Ｅメール","電話番号","郵便番号","ご住所","施工場所","お問合せ内容","返答方法");

	//表にするフォームの要素のID
	var element = new Array
			("name","email","tel","zipcode1","zipcode2","address1","address2","address3","address4",
			"place1","place2","place3","place4","place5","place6","place7","place8","place9","place10",
			"place11","place12","inquiry","response");

	//送信先とメールタイトル
	//var sendTo = "mailto:info@nissin-office.com?subject=お問合せ【日新土木株式会社】";
	var sendTo = "postmail.cgi";

	//送信後の移動先のページ
	var done = "thanks.html";

	var data = new Array();

/* お問合せページ　確認ボタン押下時 */
function check(){

	//未入力チェック
	if(document.form1.name.value == ''){
		alert("お名前を入力してください");
      		return false;
	}
	if(document.form1.email.value == ''){
		alert("Ｅメールを入力してください");
		return false;
	}
	if(document.form1.tel.value == ''){
		alert("電話番号を入力してください");
		return false;
	}
	if(document.form1.inquiry.value == ''){
		alert("お問合せ内容を入力してください");
		return false;
	}
	if(!document.form1.response[0].checked && !document.form1.response[1].checked && !document.form1.response[2].checked){
		alert("返答方法を入力してください");
		return false;
	}

	//文字数チェック
	if(document.form1.inquiry.value.length > 1000){
		alert("1000字以内で入力してください");
		return false;
	}

	//確認画面遷移　各項目に入力値を表示するための処理
	if(document.form1.name.value != ''){
		data[0] = document.form1.name.value;
	}
	if(document.form1.email.value != ''){
		data[1] = document.form1.email.value;
	}
	if(document.form1.tel.value != ''){
		data[2] = document.form1.tel.value;
	}
	if(document.form1.zipcode1.value != ''){
		data[3] = document.form1.zipcode1.value;
	}
	if(document.form1.zipcode2.value != ''){
		data[4] = document.form1.zipcode2.value;
	}
	if(document.form1.address1.value != ''){
		data[5] = document.form1.address1.value;
	}
	if(document.form1.address2.value != ''){
		data[6] = document.form1.address2.value;
	}
	if(document.form1.address3.value != ''){
		data[7] = document.form1.address3.value;
	}
	if(document.form1.address4.value != ''){
		data[8] = document.form1.address4.value;
	}
	if(document.form1.place1.checked){
		data[9] = document.form1.place1.value;
	}
	if(document.form1.place2.checked){
		data[10] = document.form1.place2.value;
	}
	if(document.form1.place3.checked){
		data[11] = document.form1.place3.value;
	}
	if(document.form1.place4.checked){
		data[12] = document.form1.place4.value;
	}
	if(document.form1.place5.checked){
		data[13] = document.form1.place5.value;
	}
	if(document.form1.place6.checked){
		data[14] = document.form1.place6.value;
	}
	if(document.form1.place7.checked){
		data[15] = document.form1.place7.value;
	}
	if(document.form1.place8.checked){
		data[16] = document.form1.place8.value;
	}
	if(document.form1.place9.checked){
		data[17] = document.form1.place9.value;
	}
	if(document.form1.place10.checked){
		data[18] = document.form1.place10.value;
	}
	if(document.form1.place11.checked){
		data[19] = document.form1.place11.value;
	}
	if(document.form1.place12.checked){
		data[20] = document.form1.place12.value;
	}
	if(document.form1.inquiry.value != ''){
		data[21] = document.form1.inquiry.value;
	}
	if(document.form1.response[0].checked){
		data[22] = document.form1.response[0].value;
	}
	if(document.form1.response[1].checked){
		data[22] = document.form1.response[1].value;
	}
	if(document.form1.response[2].checked){
		data[22] = document.form1.response[2].value;
	}

	//リセットボタンで一括ではなく、個々で値を消した場合（必須項目は不要）
	if(document.form1.zipcode1.value == ''){
		data[3] = '';
	}
	if(document.form1.zipcode2.value == ''){
		data[4] = '';
	}
	if(document.form1.address1.value == ''){
		data[5] = '';
	}
	if(document.form1.address2.value == ''){
		data[6] = '';
	}
	if(document.form1.address3.value == ''){
		data[7] = '';
	}
	if(document.form1.address4.value == ''){
		data[8] = '';
	}
	if(!document.form1.place1.checked){
		data[9] = '';
	}
	if(!document.form1.place2.checked){
		data[10] = '';
	}
	if(!document.form1.place3.checked){
		data[11] = '';
	}
	if(!document.form1.place4.checked){
		data[12] = '';
	}
	if(!document.form1.place5.checked){
		data[13] = '';
	}
	if(!document.form1.place6.checked){
		data[14] = '';
	}
	if(!document.form1.place7.checked){
		data[15] = '';
	}
	if(!document.form1.place8.checked){
		data[16] = '';
	}
	if(!document.form1.place9.checked){
		data[17] = '';
	}
	if(!document.form1.place10.checked){
		data[18] = '';
	}
	if(!document.form1.place11.checked){
		data[19] = '';
	}
	if(!document.form1.place12.checked){
		data[20] = '';
	}

	//確認画面に遷移
	document.open();
	document.writeln('<html>\n<head>');
	document.writeln('<title>お問合せ【日新土木株式会社】</title>');
	document.writeln('<link rel="stylesheet" href="../style.css" type="text/css">');
	document.writeln('</head>\n<body>');
	document.writeln('<h1 align="center">確認画面</h1>');
	document.writeln('<center>\n<form method="GET" name="form2" action="'+sendTo+'" enctype="multipart/form-data">');
	document.writeln('<table class="right_table" align="center">');
	
	//お名前
	document.writeln('<tr>');
	document.writeln('<td align="center" class="inquiry" height="30">'+name[0]+'</td>\n<td>'+data[0]);
	document.write('<input type="hidden" name="'+element[0]+'" value="'+data[0]+'">');
	document.writeln('</td>\n</tr>');

	//Ｅメール
	document.writeln('<tr>');
	document.writeln('<td align="center" class="inquiry" height="30">'+name[1]+'</td>\n<td>'+data[1]);
	document.write('<input type="hidden" name="'+element[1]+'" value="'+data[1]+'">');
	document.writeln('</td>\n</tr>');

	//電話番号
	document.writeln('<tr>');
	document.writeln('<td align="center" class="inquiry" height="30">'+name[2]+'</td>\n<td>'+data[2]);
	document.write('<input type="hidden" name="'+element[2]+'" value="'+data[2]+'">');
	document.writeln('</td>\n</tr>');

	//郵便番号
	document.writeln('<tr>');
	document.writeln('<td align="center" class="inquiry" height="30">'+name[3]+'</td>\n<td>'+data[3]+'−');
	document.writeln(data[4]);
	document.write('<input type="hidden" name="'+element[3]+'" value="'+data[3]+'">');
	document.write('<input type="hidden" name="'+element[4]+'" value="'+data[4]+'">');
	document.writeln('</td>\n</tr>');

	//ご住所
	document.writeln('<tr>');
	document.writeln('<td align="center" class="inquiry" height="30">'+name[4]+'</td>\n<td>'+data[5]);
	document.writeln(data[6]);
	document.writeln(data[7]+'<br>');
	document.writeln(data[8]);
	document.write('<input type="hidden" name="'+element[5]+'" value="'+data[5]+'">');
	document.write('<input type="hidden" name="'+element[6]+'" value="'+data[6]+'">');
	document.write('<input type="hidden" name="'+element[7]+'" value="'+data[7]+'">');
	document.write('<input type="hidden" name="'+element[8]+'" value="'+data[8]+'">');
	document.writeln('</td>\n</tr>');

	//施工場所
	document.writeln('<tr>');
	document.writeln('<td align="center" class="inquiry" height="30">'+name[5]+'</td>\n<td>'+data[9]);
	document.writeln(data[10]);
	document.writeln(data[11]);
	document.writeln(data[12]);
	document.writeln(data[13]);
	document.writeln(data[14]);
	document.writeln(data[15]);
	document.writeln(data[16]);
	document.writeln(data[17]);
	document.writeln(data[18]);
	document.writeln(data[19]);
	document.writeln(data[20]);
	document.write('<input type="hidden" name="'+element[9]+'" value="'+data[9]+'">');
	document.write('<input type="hidden" name="'+element[10]+'" value="'+data[10]+'">');
	document.write('<input type="hidden" name="'+element[11]+'" value="'+data[11]+'">');
	document.write('<input type="hidden" name="'+element[12]+'" value="'+data[12]+'">');
	document.write('<input type="hidden" name="'+element[13]+'" value="'+data[13]+'">');
	document.write('<input type="hidden" name="'+element[14]+'" value="'+data[14]+'">');
	document.write('<input type="hidden" name="'+element[15]+'" value="'+data[15]+'">');
	document.write('<input type="hidden" name="'+element[16]+'" value="'+data[16]+'">');
	document.write('<input type="hidden" name="'+element[17]+'" value="'+data[17]+'">');
	document.write('<input type="hidden" name="'+element[18]+'" value="'+data[18]+'">');
	document.write('<input type="hidden" name="'+element[19]+'" value="'+data[19]+'">');
	document.write('<input type="hidden" name="'+element[20]+'" value="'+data[20]+'">');
	document.writeln('</td>\n</tr>');

	//お問合せ内容
	document.writeln('<tr>');
	document.writeln('<td align="center" class="inquiry" height="30">'+name[6]+'</td>\n<td>'+data[21]);
	document.write('<input type="hidden" name="'+element[21]+'" value="'+data[21]+'">');
	document.writeln('</td>\n</tr>');

	//返答方法
	document.writeln('<tr>');
	document.writeln('<td align="center" class="inquiry" height="30">'+name[7]+'</td>\n<td>'+data[22]);
	document.write('<input type="hidden" name="'+element[22]+'" value="'+data[22]+'">');
	document.writeln('</td>\n</tr>');


	//フォーム送信
	document.writeln('</tr>\n</table>\n<br>');
	//document.writeln('<img src="../img/inquiry/send_button.gif" onClick="javascript:document.form2.submit(); location.href=\''+done+'\'">');
	document.writeln('<img src="../img/inquiry/send_button.gif" onClick="javascript:document.form2.submit();">');
	document.writeln('<img src="../img/inquiry/modify_button.gif" onClick="history.back()">');
	document.writeln('</center>');
	document.writeln('</form>\n</body>');
	document.writeln('<html>');
	document.close();
}

/* お問合せページ　リセットボタン押下時 */
function resetform(){

	//確認ダイアログを表示
	if(window.confirm('リセットしてもよろしいですか？')){

		//form1の値をリセット
		document.form1.name.value = '';
		document.form1.email.value = '';
		document.form1.tel.value = '';
		document.form1.zipcode1.value = '';
		document.form1.zipcode2.value = '';
		document.form1.address1.value = '';
		document.form1.address2.value = '';
		document.form1.address3.value = '';
		document.form1.address4.value = '';
		document.form1.place1.checked = false;
		document.form1.place2.checked = false;
		document.form1.place3.checked = false;
		document.form1.place4.checked = false;
		document.form1.place5.checked = false;
		document.form1.place6.checked = false;
		document.form1.place7.checked = false;
		document.form1.place8.checked = false;
		document.form1.place9.checked = false;
		document.form1.place10.checked = false;
		document.form1.place11.checked = false;
		document.form1.place12.checked = false;
		document.form1.inquiry.value = '';
		document.form1.response[0].checked = false;
		document.form1.response[1].checked = false;
		document.form1.response[2].checked = false;

	//「キャンセル」時の処理（リセットを中止）	
	}else{
		return false;
	}
}
