function writeFlash(id){
	var str ='<div align="center">';
	str += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="840" height="233" align="middle">';
	str += '<param name="allowScriptAccess" value="sameDomain" />';
	str += '<param name="FlashVars" value="plus='+id+'"/>';
	str += '<param name="movie" value="images/top/top_flash.swf?id='+ Math.floor(Math.random() * 16) +'" />';
	str += '<param name="quality" value="high" />';
	str += '<param name="bgcolor" value="#ffffff" />';
	str += '<embed src="images/top/top_flash.swf?id='+ Math.floor(Math.random() * 16) +'" FlashVars="plus='+id+'" quality="high" bgcolor="#ffffff" width="840" height="233" name="movie" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	str += '</object>';
	str += '</div>';
	document.write(str);
}

ncount = 0;
pcount = 0;

//テキスト読み込み
function bibiPager(pg){
	var dobj   = document.getElementById('quickDetBox');
	temp = dobj.getElementsByTagName('input');
	for(i=0;i<temp.length;i++){
		if(temp[i].getAttribute('name') == 'quickPage'){
			page = temp[i].getAttribute('value');
			if(pg == 'next'){
				if(ncount == 0 && pcount == 0){
					temp[i].setAttribute('value',(Number(page)+2));
				}else{
					temp[i].setAttribute('value',(Number(page)+1));
				}
			}else if(pg == 'prev'){
				if(page > 0){
					temp[i].setAttribute('value',(Number(page)-1));
				}else{
					temp[i].setAttribute('value',0);
				}
			}
		}
	}
	if(window.XMLHttpRequest != null){
		x = new XMLHttpRequest;
	}else{
		x = new ActiveXObject('MSXML2.XMLHTTP');
	}

	//カウント
	if(pg == 'next' && ncount == 0){
		ncount = Number(ncount)+1;
	}
	if(pg == 'prev' && pcount == 0){
		pcount = Number(pcount)+1;
	}

	//ページ数調整
	if(pg == 'next' && pcount > 0){
		if(page == 0){
			page = Number(page)+1;
		}else{
			page = Number(page)+2;
		}
		pcount = 0;
	}
	if(pg == 'prev' && ncount > 0){
		page = Number(page)-2;
		ncount = 0;
	}

	var target = '/front/bibi/' + page + '/' + pg;
	x.open('GET', target, true);
	x.onreadystatechange = function(){
		if(x.readyState==4){
			var str = x.responseText;
			if(str != 'none'){
				dobj.innerHTML = str;
			}
		}
	} 
	x.send('');
}

//選択エリア削除
function front_del_area(){
	btn = "<a href=\"javascript:;\" onclick=\"window.open('http://cocoaru.jp/work/area/', 'winName', 'width=780,height=600,status=0,scrollbars=1,menubar=0,location=0,toolbar=0,resizable=0');\"><img src=\"/images/uniq/btn_area_off.gif\" alt=\"エリアを選択\" width=\"128\" height=\"23\" border=\"0\" onmouseover=\"this.src='/images/uniq/btn_area_on.gif'\"  onmouseout=\"this.src='/images/uniq/btn_area_off.gif'\" /><br /></a>";
	msg = "現在勤務エリアは指定されていません。";
	document.getElementById('area').innerHTML = btn + msg;

	//GET検索用のhiddenも削除
	if(document.getElementById('h_area')){
		area_box = document.getElementById('s_area');
		area_box.removeChild(area_box.firstChild);
	}
}
//トップ用
function front_del_area_top(){
	btn = "<a href=\"javascript:;\" onclick=\"window.open('http://cocoaru.jp/work/area_top/', 'winName', 'width=780,height=600,status=0,scrollbars=1,menubar=0,location=0,toolbar=0,resizable=0');\"><img src=\"/images/uniq/btn_area_off.gif\" alt=\"エリアを選択\" width=\"128\" height=\"23\" border=\"0\" onmouseover=\"this.src='/images/uniq/btn_area_on.gif'\"  onmouseout=\"this.src='/images/uniq/btn_area_off.gif'\" /><br /></a>";
	msg = "現在勤務エリアは指定されていません。";
	document.getElementById('area').innerHTML = btn + msg;

	//GET検索用のhiddenも削除
	if(document.getElementById('h_area')){
		area_box = document.getElementById('s_area');
		area_box.removeChild(area_box.firstChild);
	}
}
//選択エリア削除test
function front_del_areatest(){
	btn = "<a href=\"javascript:;\" onclick=\"window.open('/work/areatest/', 'winName', 'width=780,height=600,status=0,scrollbars=1,menubar=0,location=0,toolbar=0,resizable=0');\">エリアを選択</a><br />";
	msg = "現在勤務エリアは指定されていません。";
	document.getElementById('area').innerHTML = btn + msg;

	//GET検索用のhiddenも削除
	if(document.getElementById('h_area')){
		area_box = document.getElementById('s_area');
		area_box.removeChild(area_box.firstChild);
	}
}


//選択沿線削除
function front_del_rail(){
	btn = "<a href=\"javascript:;\" onclick=\"window.open('http://cocoaru.jp/work/railways/', 'winName', 'width=780,height=600,status=0,scrollbars=1,menubar=0,location=0,toolbar=0,resizable=0');\"><img src=\"/images/uniq/btn_line_off.gif\" alt=\"最寄沿線を選択\" width=\"128\" height=\"23\" border=\"0\" onmouseover=\"this.src='/images/uniq/btn_line_on.gif'\"  onmouseout=\"this.src='/images/uniq/btn_line_off.gif'\" /><br /></a>";
	msg = "現在勤務エリアは指定されていません。";
	document.getElementById('railway').innerHTML = btn + msg;

	//GET検索用のhiddenも削除
	if(document.getElementById('h_rail')){
		rail_box = document.getElementById('s_rail');
		rail_box.removeChild(rail_box.firstChild);
	}

}
//トップ用
function front_del_rail_top(){
	btn = "<a href=\"javascript:;\" onclick=\"window.open('http://cocoaru.jp/work/railways_top/', 'winName', 'width=780,height=600,status=0,scrollbars=1,menubar=0,location=0,toolbar=0,resizable=0');\"><img src=\"/images/uniq/btn_line_off.gif\" alt=\"最寄沿線を選択\" width=\"128\" height=\"23\" border=\"0\" onmouseover=\"this.src='/images/uniq/btn_line_on.gif'\"  onmouseout=\"this.src='/images/uniq/btn_line_off.gif'\" /><br /></a>";
	msg = "現在勤務エリアは指定されていません。";
	document.getElementById('railway').innerHTML = btn + msg;

	//GET検索用のhiddenも削除
	if(document.getElementById('h_rail')){
		rail_box = document.getElementById('s_rail');
		rail_box.removeChild(rail_box.firstChild);
	}
}
//選択沿線削除test
function front_del_railtest(){
	btn = "<a href=\"javascript:;\" onclick=\"window.open('/work/railwaystest/', 'winName', 'width=780,height=600,status=0,scrollbars=1,menubar=0,location=0,toolbar=0,resizable=0');\">最寄沿線を選択</a><br />";
	msg = "現在勤務エリアは指定されていません。";
	document.getElementById('railway').innerHTML = btn + msg;

	//GET検索用のhiddenも削除
	if(document.getElementById('h_rail')){
		rail_box = document.getElementById('s_rail');
		rail_box.removeChild(rail_box.firstChild);
	}

}


//新規登録 最寄沿線フォームをプラス
function stationPlus(num){
	var node = document.getElementById('entryTbl').getElementsByTagName('tbody')[0];
	var lgth = node.getElementsByTagName('tr').length;
	var staid = 0;

	for(var i = 0;i < lgth;i++){
		if(node.getElementsByTagName('tr')[i].getAttribute('id') == 'plustr'){
			staid = i;
			break;
		}
	}

	var row = node.insertRow(num+staid);
	var th = document.createElement("th");
	var td = document.createElement("td");
	row.appendChild(th);
	row.appendChild(td);

	cel1 = '<img src="/images/uniq/form_tit_station_nom.gif" alt="自宅最寄駅" width="166" height="22" />';
	cel2 = '<input name="station[]" type="text" class="txt150 inputBg active" />駅';
	if(num != 2){
		cel2 += ' <a href="javascript:stationPlus('+(num+1)+');">自宅最寄駅を追加する</a>';
	}
	motocel = node.getElementsByTagName('tr')[num+staid-1].cells[1].innerHTML;

	node.getElementsByTagName('tr')[num+staid].cells[0].innerHTML = cel1;
	node.getElementsByTagName('tr')[num+staid].cells[1].innerHTML = cel2;
	
	flength = document.regist.elements['station[]'].length;

	//入力内容の取得(ブラウザ分岐)
	//Firefox
	if(FF=/a/[-1]=='a'){
		st_val = document.regist.elements['station[]'][flength-num-1].value;
	//IEとか
	}else{
		st_val = document.regist.elements['station[]'][num-1].value;
	}

	//追加リンク削除
//	node.getElementsByTagName('tr')[num+staid-1].cells[1].innerHTML = motocel.replace(/<a.+$/i,'');
	node.getElementsByTagName('tr')[num+staid-1].cells[1].innerHTML = '<input type="text" value="'+st_val+'" class="txt150 inputBg active" name="station[]"/>駅 ';
}

//----------------------------------------------
//新規登録・基本情報編集：郵便番号から住所取得
//----------------------------------------------

//郵便番号APIを叩く
function search(){
	var zipcode = document.getElementById( 'zipcode1' ).value + document.getElementById( 'zipcode2' ).value;

	if(!check_zipcode(zipcode))
		return false;
	var target = document.createElement('script');
	target.charset = 'utf-8';
	target.src = 'https://cocoaru.jp/front/getJSON/' + zipcode;

	document.body.appendChild(target);
}

//JSONを解析＆データ充当
function callback1(data){
	zip_data = data;

	var pref = new Array();
		pref["北海道"] = 1;
		pref["青森県"] = 2;
		pref["秋田県"] = 3;
		pref["山形県"] = 4;
		pref["岩手県"] = 5;
		pref["宮城県"] = 6;
		pref["福島県"] = 7;
		pref["群馬県"] = 8;
		pref["栃木県"] = 9;
		pref["茨城県"] = 10;
		pref["埼玉県"] = 11;
		pref["千葉県"] = 12;
		pref["東京都"] = 13;
		pref["神奈川県"] = 14;
		pref["静岡県"] = 15;
		pref["山梨県"] = 16;
		pref["新潟県"] = 17;
		pref["長野県"] = 18;
		pref["石川県"] = 19;
		pref["富山県"] = 20;
		pref["福井県"] = 21;
		pref["愛知県"] = 22;
		pref["滋賀県"] = 23;
		pref["岐阜県"] = 24;
		pref["三重県"] = 25;
		pref["和歌山県"] = 26;
		pref["奈良県"] = 27;
		pref["京都府"] = 28;
		pref["大阪府"] = 29;
		pref["兵庫県"] = 30;
		pref["岡山県"] = 31;
		pref["広島県"] = 32;
		pref["島根県"] = 33;
		pref["鳥取県"] = 34;
		pref["山口県"] = 35;
		pref["香川県"] = 36;
		pref["愛媛県"] = 37;
		pref["徳島県"] = 38;
		pref["高知県"] = 39;
		pref["福岡県"] = 40;
		pref["長崎県"] = 41;
		pref["大分県"] = 42;
		pref["熊本県"] = 43;
		pref["宮崎県"] = 44;
		pref["佐賀県"] = 45;
		pref["鹿児島県"] = 46;
		pref["沖縄県"] = 47;

	for (var i in zip_data.zipcode ){
		document.regist.address.value = data.zipcode[i].prefecture + data.zipcode[i].city + data.zipcode[i].town;
	}
}

//郵便番号チェック(7桁入力)
function check_zipcode(zipcode){
	if(!zipcode) return false;
	if(0 == zipcode.length) return false;

	if(!zipcode.match(/^[0-9]{7}$/)){
		return false;
	}
	return true;
}

//------------------------------------------------------------------
//　フロント求人検索の検索用GET値整形JS
//------------------------------------------------------------------

//勤務期間
function searchPeriod(){
	h_period = document.createElement('input');
	h_period.type = 'hidden';
	h_period.name = 'period';
	h_period.id = 'h_period';

	check_flg = 0;

	for(i=1;i<=2;i++){
		if(document.getElementById('period' + i).checked == true){
			if(!h_period.value){
				h_period.value = i;
			}else{
				h_period.value += "_" + i;
			}
			//チェックがあったらフラグを立てる
			check_flg = 1;
		}
	}

	//フラグがたってて、hiddenがある場合
	if(check_flg && document.getElementById('h_period')){
		period_box = document.getElementById('s_period');
		period_box.removeChild(period_box.firstChild);
		document.getElementById('s_period').appendChild(h_period);
	//フラグがたってて、hiddenがない場合
	}else if(check_flg && !document.getElementById('h_period')){
		document.getElementById('s_period').appendChild(h_period);
	//なかったら削除
	}else if(!check_flg && document.getElementById('h_period')){
		period_box = document.getElementById('s_period');
		period_box.removeChild(period_box.firstChild);
	}
}

//職種
function searchCategory(){
	h_category = document.createElement('input');
	h_category.type = 'hidden';
	h_category.name = 'category';
	h_category.id = 'h_category';

	check_flg = 0;

	for(i=1;i<=6;i++){
		if(document.getElementById('category' + i).checked == true){
			if(!h_category.value){
				h_category.value = i;
			}else{
				h_category.value += "_" + i;
			}
			//チェックがあったらフラグを立てる
			check_flg = 1;
		}
	}

	//フラグがたってて、hiddenがある場合
	if(check_flg && document.getElementById('h_category')){
		category_box = document.getElementById('s_category');
		category_box.removeChild(category_box.firstChild);
		document.getElementById('s_category').appendChild(h_category);
	//フラグがたってて、hiddenがない場合
	}else if(check_flg && !document.getElementById('h_category')){
		document.getElementById('s_category').appendChild(h_category);
	//なかったら削除
	}else if(!check_flg && document.getElementById('h_category')){
		category_box = document.getElementById('s_category');
		category_box.removeChild(category_box.firstChild);
	}
}

//職種
function searchFeature(){
	h_feature = document.createElement('input');
	h_feature.type = 'hidden';
	h_feature.name = 'feature';
	h_feature.id = 'h_feature';

	check_flg = 0;

	for(i=1;i<=21;i++){
		if(document.getElementById('feature' + i).checked == true){
			if(!h_feature.value){
				h_feature.value = i;
			}else{
				h_feature.value += "_" + i;
			}
			//チェックがあったらフラグを立てる
			check_flg = 1;
		}
	}

	//フラグがたってて、hiddenがある場合
	if(check_flg && document.getElementById('h_feature')){
		feature_box = document.getElementById('s_feature');
		feature_box.removeChild(feature_box.firstChild);
		document.getElementById('s_feature').appendChild(h_feature);
	//フラグがたってて、hiddenがない場合
	}else if(check_flg && !document.getElementById('h_feature')){
		document.getElementById('s_feature').appendChild(h_feature);
	//なかったら削除
	}else if(!check_flg && document.getElementById('h_feature')){
		feature_box = document.getElementById('s_feature');
		feature_box.removeChild(feature_box.firstChild);
	}
}

//時給
function searchPay(){
	pay = document.getElementById('pay_num').value;

	h_pay = document.createElement('input');
	h_pay.type = 'hidden';
	h_pay.name = 'pay';
	h_pay.id = 'h_pay';
	h_pay.value = pay;

	//フラグがたってて、hiddenがある場合
	if(pay && document.getElementById('h_pay')){
		pay_box = document.getElementById('s_pay');
		pay_box.removeChild(pay_box.firstChild);
		document.getElementById('s_pay').appendChild(h_pay);
	//フラグがたってて、hiddenがない場合
	}else if(pay && !document.getElementById('h_pay')){
		document.getElementById('s_pay').appendChild(h_pay);
	//なかったら削除
	}else if(!pay && document.getElementById('h_pay')){
		pay_box = document.getElementById('s_pay');
		pay_box.removeChild(pay_box.firstChild);
	}
	
}


//結果一覧の検索ボタンクリック（全チェック）
function searchCheck(){
	searchPeriod();
	searchCategory();
	searchFeature();
	searchPay();
	
	document.search.submit();
}

//結果一覧の検索ボタンクリック（全チェック）ヘッダー
function searchCheckHeader(){
	searchPeriod();
//	searchCategory();
//	searchFeature();
	searchPay();
	
	document.search.submit();
}
//結果一覧の検索ボタンクリック（全チェック）フッター
function searchCheckFooter(){
	searchPeriod();
//	searchCategory();
//	searchFeature();
	searchPay();
	
	document.search2.submit();
}


//トップの検索ボタンクリック（全チェック）
function searchCheckTop(){
	searchPeriod();
	searchCategory();
	
	document.search.submit();
}


//------------------------------------------------------------------
//企業対応履歴用
function CompaniesCreateTbl4(oj){
	// 新しいテーブルを追加
	var stf4 = document.getElementById(oj);
	var stf4inr = stf4.innerHTML;
	var form = stf4.getElementsByTagName('form')[0];
	var tbl = form.getElementsByTagName('table')[0];
	var tblinr = tbl.innerHTML;
	var num = form.getElementsByTagName('table')[0].getAttribute('name');
	num = Number(num)+1;

	tblinr = tblinr.replace(/(histories)[0-9]+/mgi,"$1"+num);
	tblinr = tblinr.replace(/(<textarea.*>).*?(<\/textarea>)/gi,"$1$2");
//	tbl.innerHTML = tblinr;

	var i;
	var j;
	for(i = 0;i < tbl.rows.length;i++){
		for(j = 0;j < tbl.rows[i].cells.length;j++){
			if(i == 0 && j == 0){
				var temp = tbl.rows[0].cells[0].getElementsByTagName('input');
				if(temp[4].getAttribute('type') == "hidden" && temp[4].getAttribute('name') == "hid"){
					temp[4].setAttribute("value","");
				}
			}
			if(i == 0 && j == 2){
				var temp = tbl.rows[0].cells[2].getElementsByTagName('input');
				temp[0].setAttribute("value","");
				temp[1].setAttribute("value","");
				temp[2].setAttribute("value","");
			}
			if(i == 1 && j == 1){
				var temp = tbl.rows[1].cells[1].getElementsByTagName('input');
				temp[0].setAttribute("value","");
			}
			tbl.rows[0].cells[i].innerHTML = tbl.rows[0].cells[i].innerHTML.replace(/(<input\b[^>]*id=")(.*?)(".+>.*[\n][\r]*.+\2)(.+)/gi,"$1$2"+num+"$3"+num+"$4");
			tbl.rows[0].cells[i].innerHTML = tbl.rows[0].cells[i].innerHTML.replace(/(histories)[0-9]+/gi,"$1"+num);
			tbl.rows[i].cells[j].innerHTML = tbl.rows[i].cells[j].innerHTML.replace(/(<textarea[^>]*>)[^<]*?(<\/textarea>)/gi,"$1$2");
		}
	}
	tblinr = tbl.innerHTML;

	tbl_fr = '<table width="100%" border="0" cellspacing="0" cellpadding="0" name="'+num+'">\n';
	tbl_bk = '</table>\n';
	tblinr = tbl_fr+tblinr+tbl_bk;

	form_fr = '<form method="post" action="/company/applicationtest/save/update" name="histories'+num+'" >';
	form_bk = "</form>";


	stf4.innerHTML = form_fr + tblinr + form_bk + stf4inr;
}


function freeSearchSubmit(){
	document.freeSearch.submit();
}
