﻿//---------------------------------------------------------
//  検索ボックスGET化
//---------------------------------------------------------

//----------------------------------
// 上部
//----------------------------------

//勤務期間
function searchPeriodTop(){
	h_period_top = document.createElement('input');
	h_period_top.type = 'hidden';
	h_period_top.name = 'period';
	h_period_top.id = 'h_period_top';

	check_flg = 0;

	for(i=1;i<=2;i++){
		if(document.getElementById('period_t' + i).checked == true){
			if(!h_period_top.value){
				h_period_top.value = i;
			}else{
				h_period_top.value += "_" + i;
			}
			//チェックがあったらフラグを立てる
			check_flg = 1;
		}
	}

	//フラグがたってて、hiddenがある場合
	if(check_flg && document.getElementById('h_period_top')){
		period_box = document.getElementById('s_period_t');
		period_box.removeChild(period_box.firstChild);
		document.getElementById('s_period_t').appendChild(h_period_top);
	//フラグがたってて、hiddenがない場合
	}else if(check_flg && !document.getElementById('h_period')){
		document.getElementById('s_period_t').appendChild(h_period_top);
	//なかったら削除
	}else if(!check_flg && document.getElementById('h_period_top')){
		period_box = document.getElementById('s_period_t');
		period_box.removeChild(period_box.firstChild);
	}
}

//職種
function searchCategoryTop(){
	h_category_top = document.createElement('input');
	h_category_top.type = 'hidden';
	h_category_top.name = 'category';
	h_category_top.id = 'h_category_top';

	check_flg = 0;

	for(i=1;i<=6;i++){
		if(document.getElementById('category_t' + i).checked == true){
			if(!h_category_top.value){
				h_category_top.value = i;
			}else{
				h_category_top.value += "_" + i;
			}
			//チェックがあったらフラグを立てる
			check_flg = 1;
		}
	}

	//フラグがたってて、hiddenがある場合
	if(check_flg && document.getElementById('h_category_top')){
		category_box = document.getElementById('s_category_t');
		category_box.removeChild(category_box.firstChild);
		document.getElementById('s_category_t').appendChild(h_category_top);
	//フラグがたってて、hiddenがない場合
	}else if(check_flg && !document.getElementById('h_category_top')){
		document.getElementById('s_category_t').appendChild(h_category_top);
	//なかったら削除
	}else if(!check_flg && document.getElementById('h_category_top')){
		category_box = document.getElementById('s_category_t');
		category_box.removeChild(category_box.firstChild);
	}
}

//こだわりポイント
function searchFeatureTop(){
	h_feature_top = document.createElement('input');
	h_feature_top.type = 'hidden';
	h_feature_top.name = 'feature';
	h_feature_top.id = 'h_feature_top';

	check_flg = 0;

	for(i=1;i<=21;i++){
		if(document.getElementById('feature_t' + i).checked == true){
			if(!h_feature_top.value){
				h_feature_top.value = i;
			}else{
				h_feature_top.value += "_" + i;
			}
			//チェックがあったらフラグを立てる
			check_flg = 1;
		}
	}

	//フラグがたってて、hiddenがある場合
	if(check_flg && document.getElementById('h_feature_top')){
		feature_box = document.getElementById('s_feature_t');
		feature_box.removeChild(feature_box.firstChild);
		document.getElementById('s_feature_t').appendChild(h_feature_top);
	//フラグがたってて、hiddenがない場合
	}else if(check_flg && !document.getElementById('h_feature')){
		document.getElementById('s_feature_t').appendChild(h_feature_top);
	//なかったら削除
	}else if(!check_flg && document.getElementById('h_feature_top')){
		feature_box = document.getElementById('s_feature_t');
		feature_box.removeChild(feature_box.firstChild);
	}
}

//時給
function searchPayTop(){
	pay = document.getElementById('pay_num_t').value;

	h_pay_top = document.createElement('input');
	h_pay_top.type = 'hidden';
	h_pay_top.name = 'pay';
	h_pay_top.id = 'h_pay_top';
	h_pay_top.value = pay;

	//フラグがたってて、hiddenがある場合
	if(pay && document.getElementById('h_pay_top')){
		pay_box = document.getElementById('s_pay_t');
		pay_box.removeChild(pay_box.firstChild);
		document.getElementById('s_pay_t').appendChild(h_pay_top);
	//フラグがたってて、hiddenがない場合
	}else if(pay && !document.getElementById('h_pay_top')){
		document.getElementById('s_pay_t').appendChild(h_pay_top);
	//なかったら削除
	}else if(!pay && document.getElementById('h_pay_top')){
		pay_box = document.getElementById('s_pay_t');
		pay_box.removeChild(pay_box.firstChild);
	}
}

//----------------------------------
// 下部
//----------------------------------

function searchPeriodBtm(){
	h_period_btm = document.createElement('input');
	h_period_btm.type = 'hidden';
	h_period_btm.name = 'period';
	h_period_btm.id = 'h_period_btm';

	check_flg = 0;

	for(i=1;i<=2;i++){
		if(document.getElementById('period_b' + i).checked == true){
			if(!h_period_btm.value){
				h_period_btm.value = i;
			}else{
				h_period_btm.value += "_" + i;
			}
			//チェックがあったらフラグを立てる
			check_flg = 1;
		}
	}

	//フラグがたってて、hiddenがある場合
	if(check_flg && document.getElementById('h_period_btm')){
		period_box = document.getElementById('s_period_b');
		period_box.removeChild(period_box.firstChild);
		document.getElementById('s_period_b').appendChild(h_period_btm);
	//フラグがたってて、hiddenがない場合
	}else if(check_flg && !document.getElementById('h_period')){
		document.getElementById('s_period_b').appendChild(h_period_btm);
	//なかったら削除
	}else if(!check_flg && document.getElementById('h_period_btm')){
		period_box = document.getElementById('s_period_b');
		period_box.removeChild(period_box.firstChild);
	}
}

//職種
function searchCategoryBtm(){
	h_category_btm = document.createElement('input');
	h_category_btm.type = 'hidden';
	h_category_btm.name = 'category';
	h_category_btm.id = 'h_category_btm';

	check_flg = 0;

	for(i=1;i<=6;i++){
		if(document.getElementById('category_b' + i).checked == true){
			if(!h_category_btm.value){
				h_category_btm.value = i;
			}else{
				h_category_btm.value += "_" + i;
			}
			//チェックがあったらフラグを立てる
			check_flg = 1;
		}
	}

	//フラグがたってて、hiddenがある場合
	if(check_flg && document.getElementById('h_category_btm')){
		category_box = document.getElementById('s_category_b');
		category_box.removeChild(category_box.firstChild);
		document.getElementById('s_category_b').appendChild(h_category_btm);
	//フラグがたってて、hiddenがない場合
	}else if(check_flg && !document.getElementById('h_category_btm')){
		document.getElementById('s_category_b').appendChild(h_category_btm);
	//なかったら削除
	}else if(!check_flg && document.getElementById('h_category_btm')){
		category_box = document.getElementById('s_category_b');
		category_box.removeChild(category_box.firstChild);
	}
}

//こだわりポイント
function searchFeatureBtm(){
	h_feature_btm = document.createElement('input');
	h_feature_btm.type = 'hidden';
	h_feature_btm.name = 'feature';
	h_feature_btm.id = 'h_feature_btm';

	check_flg = 0;

	for(i=1;i<=21;i++){
		if(document.getElementById('feature_b' + i).checked == true){
			if(!h_feature_btm.value){
				h_feature_btm.value = i;
			}else{
				h_feature_btm.value += "_" + i;
			}
			//チェックがあったらフラグを立てる
			check_flg = 1;
		}
	}

	//フラグがたってて、hiddenがある場合
	if(check_flg && document.getElementById('h_feature_btm')){
		feature_box = document.getElementById('s_feature_b');
		feature_box.removeChild(feature_box.firstChild);
		document.getElementById('s_feature_b').appendChild(h_feature_btm);
	//フラグがたってて、hiddenがない場合
	}else if(check_flg && !document.getElementById('h_feature')){
		document.getElementById('s_feature_b').appendChild(h_feature_btm);
	//なかったら削除
	}else if(!check_flg && document.getElementById('h_feature_btm')){
		feature_box = document.getElementById('s_feature_b');
		feature_box.removeChild(feature_box.firstChild);
	}
}

//時給
function searchPayBtm(){
	pay = document.getElementById('pay_num_b').value;

	h_pay_btm = document.createElement('input');
	h_pay_btm.type = 'hidden';
	h_pay_btm.name = 'pay';
	h_pay_btm.id = 'h_pay_btm';
	h_pay_btm.value = pay;

	//フラグがたってて、hiddenがある場合
	if(pay && document.getElementById('h_pay_btm')){
		pay_box = document.getElementById('s_pay_b');
		pay_box.removeChild(pay_box.firstChild);
		document.getElementById('s_pay_b').appendChild(h_pay_btm);
	//フラグがたってて、hiddenがない場合
	}else if(pay && !document.getElementById('h_pay_btm')){
		document.getElementById('s_pay_b').appendChild(h_pay_btm);
	//なかったら削除
	}else if(!pay && document.getElementById('h_pay_btm')){
		pay_box = document.getElementById('s_pay_b');
		pay_box.removeChild(pay_box.firstChild);
	}
}

//結果一覧の検索ボタンクリック（全チェック）上部
function searchCheckHeader(){
	searchPeriodTop();
//	searchCategoryTop();
//	searchFeatureTop();
	searchPayTop();
	
	document.search_t.submit();
}

//結果一覧の検索ボタンクリック（全チェック）下部
function searchCheckFooter(){
	searchPeriodBtm();
//	searchCategoryBtm();
//	searchFeatureBtm();
	searchPayBtm();
	
	document.search_b.submit();
}


