function contact_div(div){

	//基本フォーム
	var base = '<div class="indent">';
		base +='	<h3>必要事項を入力してください。</h3><br>';
		base +='	<div class="indent">';
		base +='		<table cellpadding="0" cellspacing="2" border="0">';
		base +='		<tr> ';
		base +='		<td width="100" align="left" valign="top"> ';
		base +='		氏名：<br> ';
		base +='		</td> ';
		base +='		<td width="500" align="left" valign="top"> ';
		base +='		<input type="text" name="name" size="30" maxlength="64" id="name"><br> ';
		base +='		</td> ';
		base +='		</tr> ';
		base +='		<tr> ';
		base +='		<td width="100" align="left" valign="top"> ';
		base +='		ふりがな：<br> ';
		base +='		</td> ';
		base +='		<td width="500" align="left" valign="top"> ';
		base +='		<input type="text" name="kana" size="30" maxlength="64" id="kana"><br> ';
		base +='		</td> ';
		base +='		</tr> ';
		if(div != "3"){
			base +='		<tr> ';
			base +='		<td width="100" align="left" valign="top"> ';
			base +='		会社名：<br> ';
			base +='		</td> ';
			base +='		<td width="500" align="left" valign="top"> ';
			base +='		<input type="text" name="company" size="30" maxlength="64" id="company"><br> ';
			base +='		</td> ';
			base +='		</tr> ';
			base +='		<tr> ';
			base +='		<td width="100" align="left" valign="top"> ';
			base +='		所属部署：<br> ';
			base +='		</td> ';
			base +='		<td width="500" align="left" valign="top"> ';
			base +='		<input type="text" name="division" size="30" maxlength="64" id="division"><br> ';
			base +='		</td> ';
			base +='		</tr> ';
		}else{
			base +='		<tr> ';
			base +='		<td width="100" align="left" valign="top"> ';
			base +='		年齢：<br> ';
			base +='		</td> ';
			base +='		<td width="500" align="left" valign="top"> ';
			base +='		<input type="text" name="old" size="3" maxlength="2" id="old"> 歳<br> ';
			base +='		</td> ';
			base +='		</tr> ';
			base +='		<tr> ';
			base +='		<td width="100" align="left" valign="top"> ';
			base +='		ご質問：<br> ';
			base +='		</td> ';
			base +='		<td width="500" align="left" valign="top"> ';
			base +='		<textarea rows="5" cols="30" name="rec_q" id="rec_q"></textarea><br> ';
			base +='		</td> ';
			base +='		</tr> ';
		}
		base +='		<tr> ';
		base +='		<td width="100" align="left" valign="top"> ';
		base +='		e-mail：<br> ';
		base +='		</td> ';
		base +='		<td width="500" align="left" valign="top"> ';
		base +='		<input type="text" name="email" size="30" maxlength="64" id="email"><br> ';
		base +='		</td> ';
		base +='		</tr> ';
		base +='		<tr> ';
		base +='		<td width="100" align="left" valign="top"> ';
		base +='		e-mail (確認)：<br> ';
		base +='		</td> ';
		base +='		<td width="500" align="left" valign="top"> ';
		base +='		<input type="text" name="email_con" size="30" maxlength="64" id="email_con"><br> ';
		base +='		</td> ';
		base +='		</tr> ';
		base +='		</table> ';
		base +='		<br>'
		base +='		<hr size="1">';
		base +='		<input type="hidden" value="' + div + '" name="chk_mode" id="chk_mode"><br> ';
		base +='		<input type="button" value="入力確認" OnClick="return confirm();"><br> ';
		base +='		</div>';
		base +='	</div>';
		base +='</div>';
		base +='<br>';
	
	//プロダクト
	var div1='<div class="indent">';
		div1+='	<h3>製品を選択してください。(複数選択可能)</h3><br>';
		div1+='	<div class="indent">';
		div1+='		<input type="checkbox" name="pro1" value="Defreal" >Defreal <span class="GR">(DRMシステム)</span><br> ';
		div1+='		<input type="checkbox" name="pro2" value="HellaMTA" >HellaMTA <span class="GR">(e-mail検閲システム)</span><br> ';
		div1+='		<input type="checkbox" name="pro3" value="Diglogger" >Diglogger <span class="GR">(サーバフォルダログ収集)</span> ';
		div1+='		<input type="checkbox" name="pro4" value="Digwatcher" >Digwatcher <span class="GR">(サーバフォルダ監視)</span><br> ';
		div1+='		<input type="checkbox" name="pro5" value="Acecript" >Acecript <span class="GR">(相互認証暗号ツール)</span> ';
		div1+='		<input type="checkbox" name="pro6" value="Acebase" >Acebase <span class="GR">(拠点間データ暗号)</span> ';
		div1+='		<input type="checkbox" name="pro7" value="Acecore" >acecore <span class="GR">(相互認証暗号ライブラリ)</span><br> ';
		div1+='		<input type="checkbox" name="pro8" value="Trustbit" >Trustbit全般について<br> ';
		div1+='	</div>';
		div1+='</div>';
		div1+='<br>';
		div1+='<div class="indent">';
		div1+='	<h3>お問合わせ内容を入力してください。</h3><br>';
		div1+='	<div class="indent">';
		div1+='		<textarea rows="8" cols="60" name="pro_txt"></textarea><br> ';
		div1+='	</div>';
		div1+='</div>';
		div1+='<br>';
		div1+= base;
	
	//ソリューション
	var div2='<div class="indent">';
		div2+='	<h3>ご相談内容を入力してください。</h3><br>';
		div2+='	<div class="indent">';
		div2+='		<textarea rows="8" cols="60" name="sol_div"></textarea><br> ';
		div2+='	</div>';
		div2+='</div>';
		div2+='<br>';
		div2+= base;
	
	//採用
	var div3='<div class="indent">';
		div3+='	<h3>応募職種を選択してください。</h3><br>';
		div3+='	<div class="indent">';
		div3+='		<input type="radio" name="rec_div" value="rec_se" checked>システムエンジニア<br> ';
		div3+='		<input type="radio" name="rec_div" value="rec_sa">ITソリューション営業<br> ';
		div3+='	</div>';
		div3+='</div>';
		div3+='<br>';
		div3+= base;

	eval('if(document.all){document.all("contact1").innerHTML = div' + div + '}');
	eval('if(document.getElementById){document.getElementById("contact1").innerHTML=div' + div + '}');
}

function confirm(){
	var frm = document.forms[0];
	var chk_flg = 0;
	switch(document.getElementById("chk_mode").value){
		case '1':
			//入力チェック (プロダクト)
			var select_flg = 0;
			for(i=1; i<=8; i++){
				eval('if(frm.pro' + i + '.checked == true){select_flg = 1;}');
			}
			if(select_flg == 0){
				frm.pro1.focus();
				alert("最低でも１つの製品を選択してください。");
				return false;
			}
			if(frm.pro_txt.value == ""){
				frm.pro_txt.focus();
				alert("問い合わせ内容を入力してください。");
				return false;
			}
			break;
		case '2':
			//入力チェック (ソリューション)
			if(frm.sol_div.value == ""){
				frm.sol_div.focus();
				alert("ご相談内容を入力してください。");
				return false;
			}
			break;
	}
	
	//入力チェック (必要事項)
	if(document.getElementById("name").value == ""){
		document.getElementById("name").focus();
		alert("氏名を入力してください。");
		return false;
	}
	if(document.getElementById("chk_mode").value != "3"){
		if(frm.company.value == ""){
			document.getElementById("company").focus();
			alert("会社名を入力してください。");
			return false;
		}
	}else{
		if(document.getElementById("old").value == ""){
			document.getElementById("old").focus();
			alert("年齢を入力してください。");
			return false;
		}
		if(!chkhalfnum(document.getElementById("old").value)){
			document.getElementById("old").focus();
			alert("年齢は半角数字で入力してください。");
			return false;
		}
	}
	if(!document.getElementById("email").value){
		document.getElementById("email").focus();
		alert("e-mail アドレスを入力してください。");
		return false;
	}
	if(!chkmail(document.getElementById("email").value)){
		document.getElementById("email").focus();
		alert("e-mail アドレスが正しくありません。");
		return false;
	}
	if(!chkmailhalf(document.getElementById("email").value)){
		document.getElementById("email").focus();
		alert("e-mail アドレスが正しくありません。");
		return false;
	}
	if(document.getElementById("email_con").value == ""){
		document.getElementById("email_con").focus();
		alert("e-mail アドレス (確認)を入力してください。");
		return false;
	}
	if(document.getElementById("email").value != document.getElementById("email_con").value){
		document.getElementById("email_con").focus();
		alert("e-mail アドレス (確認)が正しくありません。");
		return false;
	}
	if(chk_flg == 0){
		dig_open();
		return true;
	}
	return true;
}

function dig_open(){
	var frm = document.forms[0];
	window.scroll(0,0);
	//確認画面
	var conf='';
		conf+='<table width="400" cellpadding="2" cellspacing="2" border="0" bgcolor="#555555">';
		conf+='<tr> ';
		conf+='<td width="400" align="left" valign="top"> ';
		conf+='	<table width="400" cellpadding="2" cellspacing="2" border="0" bgcolor="#ffffff"> ';
		conf+='	<tr> ';
		conf+='	<td colspan="2" width="300" align="left" valign="top"> ';
		conf+='	以下の入力内容で送信します。<br> ';
		conf+='	</td> ';
		conf+='	</tr> ';

	if(document.getElementById("chk_mode").value == '1'){
		conf+='	<tr> ';
		conf+='	<td width="100" align="left" valign="top" bgcolor="#99CC99"> ';
		conf+='	お問合せ：<br> ';
		conf+='	</td> ';
		conf+='	<td width="300" align="left" valign="top" bgcolor="#99CC99"> ';
		conf+='	プロダクト [Trustbit]<br> ';
		conf+='	</td> ';
		conf+='	</tr> ';
		conf+='	<tr> ';
		conf+='	<td width="100" align="left" valign="top" bgcolor="#eeeeff"> ';
		conf+='	お問合せ製品：<br> ';
		conf+='	</td> ';
		conf+='	<td width="300" align="left" valign="top" bgcolor="#eeeeff"> ';
		for(i=1; i<=8; i++){
			$print_ok = true;
			eval('if(document.getElementById("pro' + i + '").checked == false){ $print_ok = false; }');
			
			if($print_ok){
				eval('conf+= 	document.getElementById("pro' + i + '").value + \'<br> \'');
			}
		}
		conf+='	</td> ';
		conf+='	</tr> ';
		conf+='	<tr> ';
		conf+='	<td width="100" align="left" valign="top" bgcolor="#eeeeff"> ';
		conf+='	お問合わせ内容：<br> ';
		conf+='	</td> ';
		conf+='	<td width="300" align="left" valign="top" bgcolor="#eeeeff"> ';
		conf+= 	document.getElementById("pro_txt").value + '<br> ';
		conf+='	</td> ';
		conf+='	</tr> ';
	}else if(document.getElementById("chk_mode.value") == '2'){
		conf+='	<tr> ';
		conf+='	<td width="100" align="left" valign="top" bgcolor="#99CC99"> ';
		conf+='	お問合せ：<br> ';
		conf+='	</td> ';
		conf+='	<td width="300" align="left" valign="top" bgcolor="#99CC99"> ';
		conf+='	ソリューション<br> ';
		conf+='	</td> ';
		conf+='	</tr> ';
		conf+='	<tr> ';
		conf+='	<td width="100" align="left" valign="top" bgcolor="#eeeeff"> ';
		conf+='	ご相談内容：<br> ';
		conf+='	</td> ';
		conf+='	<td width="300" align="left" valign="top" bgcolor="#eeeeff"> ';
		conf+= 	document.getElementById("sol_div").value + '<br> ';
		conf+='	</td> ';
		conf+='	</tr> ';
	}else if(document.getElementById("chk_mode").value == '3'){
		conf+='	<tr> ';
		conf+='	<td width="100" align="left" valign="top" bgcolor="#99CC99"> ';
		conf+='	お問合せ：<br> ';
		conf+='	</td> ';
		conf+='	<td width="300" align="left" valign="top" bgcolor="#99CC99"> ';
		conf+='	採用<br> ';
		conf+='	</td> ';
		conf+='	</tr> ';
		conf+='	<tr> ';
		conf+='	<td width="100" align="left" valign="top" bgcolor="#eeeeff"> ';
		conf+='	ご相談内容：<br> ';
		conf+='	</td> ';
		conf+='	<td width="300" align="left" valign="top" bgcolor="#eeeeff"> ';
		
		if(document.getElementsByName("rec_div")[0].checked == true){
			conf+= 'システムエンジニア<br> ';
		}else{
			conf+= 'ITソリューション営業<br> ';
		}
		
		conf+='	</td> ';
		conf+='	</tr> ';
	}

		conf+='	<tr> ';
		conf+='	<td width="100" align="left" valign="top" bgcolor="#eeeeff"> ';
		conf+='	氏名：<br> ';
		conf+='	</td> ';
		conf+='	<td width="300" align="left" valign="top" bgcolor="#eeeeff"> ';
		conf+= 	document.getElementById("name").value + '<br> ';
		conf+='	</td> ';
		conf+='	</tr> ';
	if(document.getElementById("kana").value){
		conf+='	<tr> ';
		conf+='	<td width="100" align="left" valign="top" bgcolor="#eeeeff"> ';
		conf+='	ふりがな：<br> ';
		conf+='	</td> ';
		conf+='	<td width="300" align="left" valign="top" bgcolor="#eeeeff"> ';
		conf+= 	document.getElementById("kana").value + '<br> ';
		conf+='	</td> ';
		conf+='	</tr> ';
	}

	if(document.getElementById("chk_mode").value != "3"){
		if(document.getElementById("company").value){
			conf+='	<tr> ';
			conf+='	<td width="100" align="left" valign="top" bgcolor="#eeeeff"> ';
			conf+='	会社名：<br> ';
			conf+='	</td> ';
			conf+='	<td width="300" align="left" valign="top" bgcolor="#eeeeff"> ';
			conf+= 	document.getElementById("company").value + '<br> ';
			conf+='	</td> ';
			conf+='	</tr> ';
		}
		if(document.getElementById("division").value){
			conf+='	<tr> ';
			conf+='	<td width="100" align="left" valign="top" bgcolor="#eeeeff"> ';
			conf+='	所属部署：<br> ';
			conf+='	</td> ';
			conf+='	<td width="300" align="left" valign="top" bgcolor="#eeeeff"> ';
			conf+= 	document.getElementById("division").value + '<br> ';
			conf+='	</td> ';
			conf+='	</tr> ';
		
		}
	}else{
		if(document.getElementById("old").value){
			conf+='	<tr> ';
			conf+='	<td width="100" align="left" valign="top" bgcolor="#eeeeff"> ';
			conf+='	年齢：<br> ';
			conf+='	</td> ';
			conf+='	<td width="300" align="left" valign="top" bgcolor="#eeeeff"> ';
			conf+= 	document.getElementById("old").value + '<br> ';
			conf+='	</td> ';
			conf+='	</tr> ';
		
		}
		if(document.getElementById("rec_q").value){
			conf+='	<tr> ';
			conf+='	<td width="100" align="left" valign="top" bgcolor="#eeeeff"> ';
			conf+='	ご質問：<br> ';
			conf+='	</td> ';
			conf+='	<td width="300" align="left" valign="top" bgcolor="#eeeeff"> ';
			conf+= 	document.getElementById("rec_q").value + '<br> ';
			conf+='	</td> ';
			conf+='	</tr> ';
		
		}
	}
		conf+='	<tr> ';
		conf+='	<td width="100" align="left" valign="top" bgcolor="#eeeeff"> ';
		conf+='	e-mail：<br> ';
		conf+='	</td> ';
		conf+='	<td width="300" align="left" valign="top" bgcolor="#eeeeff"> ';
		conf+= 	document.getElementById("email").value + '<br> ';
		conf+='	</td> ';
		conf+='	</tr> ';

		conf+='	<tr> ';
		conf+='	<td colspan="2" width="300" align="left" valign="top"> ';
		conf+='	<br> ';
		conf+='	<input type="button" value="キャンセル" OnClick="dig_close();"> ';
		conf+='	<input type="button" value="送信" OnClick="send_mail();"> ';
		conf+='	</td> ';
		conf+='	</tr> ';
		conf+='	</table> ';
		conf+='</td> ';
		conf+='</tr> ';
		conf+='</table> ';
	
	if(document.all){document.all("confirm").innerHTML = conf;}
	if(document.getElementById){document.getElementById("confirm").innerHTML= conf;}

}

function dig_close(){
	if(document.all){document.all("confirm").innerHTML = " ";}
	if(document.getElementById){document.getElementById("confirm").innerHTML= " ";}
}

function send_mail(){
	var frm = document.forms[0];
	var chk_flg = 0;
	
	var send_dat = document.getElementById("chk_mode").value + ' ;';
	
	switch(document.getElementById("chk_mode").value){
	/*
		case '1':
			for(i=1; i<=8; i++){
				eval('if(document.getElementById("pro' + i + '").checked == true){send_dat+= document.getElementById("pro' + i + '").value; send_dat += " / "}');
			}
			send_dat += ' ;';
			send_dat += frm.pro_txt.value + ' ;';
			send_dat += frm.name.value + ' ;';
			send_dat += frm.kana.value + ' ;';
			send_dat += frm.company.value + ' ;';
			send_dat += frm.division.value + ' ;';
			
			break;
		case '2':
			send_dat += frm.sol_div.value + ' ;';
			send_dat += frm.name.value + ' ;';
			send_dat += frm.kana.value + ' ;';
			send_dat += frm.company.value + ' ;';
			send_dat += frm.division.value + ' ;';
			break;
	*/
		case '3':
			if(document.getElementsByName("rec_div")[0].checked == true){
				send_dat += 'システムエンジニア ;';
			}else{
				send_dat += 'ITソリューション営業 ;';
			}
			send_dat += document.getElementById("name").value + ' ;';
			send_dat += document.getElementById("kana").value + ' ;';
			send_dat += document.getElementById("old").value + ' ;';
			send_dat += document.getElementById("rec_q").value + ' ;';
			
			break;
	}
	send_dat += document.getElementById("email").value + ' ;';

	dig_close();
	mail_dig_open();
	sendRequest(call_back,'&data=' + send_dat,'POST','contact/sendmail.php',true,true);
}

function call_back(oj){
	var res = decodeURIComponent(oj.responseText);
	//alert(res);
	dig_close();
	thanks_dig_open();
}

function mail_dig_open(){
	var frm = document.forms[0];
	window.scroll(0,0);
	var conf='';
		conf+='<table width="500" cellpadding="2" cellspacing="2" border="0" bgcolor="#555555">';
		conf+='<tr> ';
		conf+='<td width="500" align="left" valign="top"> ';
		conf+='	<table width="500" cellpadding="2" cellspacing="2" border="0" bgcolor="#eeeeff"> ';
		conf+='	<tr> ';
		conf+='	<td colspan="2" width="300" align="center" valign="top"> ';
		conf+='	<br> ';
		conf+='	<br> ';
		conf+='	<br> ';
		conf+='	しばらくお待ちください。<br> ';
		conf+='	<br> ';
		conf+='	<br> ';
		conf+='	<br> ';
		conf+='	</td> ';
		conf+='	</tr> ';
		conf+='	</table> ';
		conf+='</td> ';
		conf+='</tr> ';
		conf+='</table> ';
	
	if(document.all){document.all("confirm").innerHTML = conf;}
	if(document.getElementById){document.getElementById("confirm").innerHTML= conf;}
}

function thanks_dig_open(){
	var frm = document.forms[0];
	window.scroll(0,0);
	var conf='';
		conf+='<table width="400" cellpadding="2" cellspacing="2" border="0" bgcolor="#555555">';
		conf+='<tr> ';
		conf+='<td width="400" align="left" valign="top"> ';
		conf+='	<table width="400" cellpadding="2" cellspacing="2" border="0" bgcolor="#ffffee"> ';
		conf+='	<tr> ';
		conf+='	<td  width="400" align="center" valign="top"> ';
		conf+='	<br> ';
		conf+='	お問合わせありがとうございました。<br> ';
		conf+='	担当者より数日以内にご連絡いたします。<br> ';
		conf+='	<br> ';
		conf+='	</td> ';
		conf+='	</tr> ';
		conf+='	<tr> ';
		conf+='	<td width="400" align="center" valign="top"> ';
		conf+='	<input type="button" value="閉じる" OnClick="dig_close();"> ';
		conf+='	</td> ';
		conf+='	</tr> ';
		conf+='	</table> ';
		conf+='</td> ';
		conf+='</tr> ';
		conf+='</table> ';
	
	if(document.all){document.all("confirm").innerHTML = conf;}
	if(document.getElementById){document.getElementById("confirm").innerHTML= conf;}
}

function chkstrlength(txt){
/*
	var chkByte = 0;
	var maxlength = 0;
	// 半角の文字列を定義
	var chkstring = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~｡｢｣､ｦｧｨｩｪｫｬｭｯｰｱｲｳｴｵｶｷｸｹｺｻｼｽｾｿﾀﾁﾂﾃﾄﾅﾆﾇﾈﾉﾊﾋﾌﾍﾎﾏﾐﾑﾒﾓﾔﾕﾖﾗﾘﾙﾚﾛﾜﾝﾟﾞ ";
	for (var i = 0 ; i < txt.length;i++){
		chkByte = 2;
		if (chkstring.indexOf(txt.charAt(i),0) != -1){
			chkByte = 1;
		}
		maxlength += chkByte;
	}
	if (maxlength > 255){
		return false;
	}
*/
	return true;
}

function chktel(telno){
	for(var i=0 ; i < telno.length ; i++){
		if("0123456789-".indexOf(telno.charAt(i),0) == -1){
			return false;
		}
	}
	return true;
}

function chkzip(zip){
	if (zip.search(/^\d{3}-\d{4}$/) != -1){
		return true;
	}
	return false;
}

function chkmail(email){
	if (email.search(/^[\w|\W]+@[\w|\W]/ig) != -1){
		return true;
	}else{
		return false;
	}
}

function chkmailhalf(email){
	if (email.search(/[^a-zA-Z0-9\@\-\_\.]/) != -1){
		return false;
	}else{
		return true;
	}
}

function chkhalfnum(num){
	if (num.search(/[^0-9]/ig) != -1){
		return false;
	}else{
		return true;
	}
}

function chkmaildouble(email){

	var str;
	var atcount = 0;
	for(var i = 0; i < email.length; i++){
		if(email.charAt(i) == "@"){
			atcount++;
		}
	}
	if(atcount == 1){
		return true;
	}else{
		return false;
	}

}

