function pulldownChanged(item) {
	var count = document.search.elements[item.name].length;
	for (i = 0; i < count; i++) {
		document.search.elements[item.name][i].value = item.value;
	}
}

function pulldownChanged2(item) {
	var count = document.search2.elements[item.name].length;
	for (i = 0; i < count; i++) {
		document.search2.elements[item.name][i].value = item.value;
	}
}

var ITEMS = new Array();

ITEMS['t01'] = '北海道';

ITEMS['t02'] = '青森';

ITEMS['t03'] = '岩手';

ITEMS['t04'] = '宮城';

ITEMS['t05'] = '秋田';

ITEMS['t06'] = '山形';

ITEMS['t07'] = '福島';

ITEMS['t13'] = '東京';

ITEMS['t14'] = '神奈川';

ITEMS['t11'] = '埼玉';

ITEMS['t12'] = '千葉';

ITEMS['t08'] = '茨城';

ITEMS['t09'] = '栃木';

ITEMS['t10'] = '群馬';

ITEMS['t19'] = '山梨';

ITEMS['t20'] = '長野';

ITEMS['t15'] = '新潟';

ITEMS['t16'] = '富山';

ITEMS['t17'] = '石川';

ITEMS['t18'] = '福井';

ITEMS['t23'] = '愛知';

ITEMS['t21'] = '岐阜';

ITEMS['t22'] = '静岡';

ITEMS['t24'] = '三重';

ITEMS['t27'] = '大阪';

ITEMS['t28'] = '兵庫';

ITEMS['t26'] = '京都';

ITEMS['t29'] = '奈良';

ITEMS['t25'] = '滋賀';

ITEMS['t30'] = '和歌山';

ITEMS['t31'] = '鳥取';

ITEMS['t32'] = '島根';

ITEMS['t33'] = '岡山';

ITEMS['t34'] = '広島';

ITEMS['t35'] = '山口';

ITEMS['t36'] = '徳島';

ITEMS['t37'] = '香川';

ITEMS['t38'] = '愛媛';

ITEMS['t39'] = '高知';

ITEMS['t40'] = '福岡';

ITEMS['t41'] = '佐賀';

ITEMS['t42'] = '長崎';

ITEMS['t43'] = '熊本';

ITEMS['t44'] = '大分';

ITEMS['t45'] = '宮崎';

ITEMS['t46'] = '鹿児島';

ITEMS['t47'] = '沖縄';

ITEMS['t48'] = '海外';

ITEMS['s101'] = '営業系エグゼクティブ';

ITEMS['s102'] = '管理系エグゼクティブ';

ITEMS['s201'] = '経理・財務';

ITEMS['s202'] = '総務・人事';

ITEMS['s203'] = '経営企画・事業企画';

ITEMS['s204'] = '商品企画・マーケティング';

ITEMS['s205'] = '広報・IR';

ITEMS['s206'] = '一般事務・営業事務';

ITEMS['s207'] = '貿易事務・国際事務';

ITEMS['s208'] = '秘書・アシスタント';

ITEMS['s209'] = 'コールセンター運営・管理（スーパーバイザー）';

ITEMS['s210'] = '法務・知的財産関連';

ITEMS['s211'] = '物流・購買';

ITEMS['s212'] = 'その他事務・管理系';

ITEMS['s301'] = 'ルートセールス';

ITEMS['s302'] = '管理職(営業責任者等)';

ITEMS['s303'] = '海外営業';

ITEMS['s304'] = '紹介カウンセラー・派遣コーディネーター';

ITEMS['s305'] = '営業（法人向け）';

ITEMS['s306'] = '営業（個人向け）';

ITEMS['s307'] = 'MR';

ITEMS['s308'] = '営業支援・プリセールス';

ITEMS['s309'] = 'その他営業系';

ITEMS['s401'] = '戦略系コンサルタント';

ITEMS['s402'] = '人事・組織系コンサルタント';

ITEMS['s403'] = '財務・会計系コンサルタント';

ITEMS['s501'] = '調査員・リサーチャー・アクチュアリー';

ITEMS['s502'] = '弁護士・弁理士・会計士・税理士';

ITEMS['s503'] = '薬剤師・医師・看護師・薬事申請';

ITEMS['s504'] = 'その他専門職系（金融・不動産以外）';

ITEMS['s601'] = 'アナリスト・ストラクチャード';

ITEMS['s602'] = 'バック・ミドルオフィス';

ITEMS['s603'] = 'アセットマネジメント・プロパティマネジメント・投資運用';

ITEMS['s604'] = 'その他専門職系（金融・不動産関連）';

ITEMS['s701'] = '店長・販売・SV・店舗管理';

ITEMS['s702'] = 'バイヤー・マーチャンダイザー';

ITEMS['s703'] = '店舗開発・FC開発';

ITEMS['s704'] = 'その他サービス系';

ITEMS['s801'] = 'プランナー・プロデューサー・ディレクター';

ITEMS['s802'] = 'デザイナー・オペレーター';

ITEMS['s803'] = 'その他クリエイティブ系';

ITEMS['s901'] = 'システムアナリスト・コンサルタント';

ITEMS['s902'] = 'セールスエンジニア（ソフトウェア）';

ITEMS['s903'] = 'プロジェクトマネージャー';

ITEMS['s904'] = 'アプリケーション開発（オープン系）';

ITEMS['s905'] = 'アプリケーション開発（WEB・モバイル系）';

ITEMS['s906'] = 'アプリケーション開発（汎用系）';

ITEMS['s907'] = 'アプリケーション開発（制御・組み込み系）';

ITEMS['s908'] = 'ネットワークエンジニア（設計）';

ITEMS['s909'] = '社内SE・サポート・運用・保守・教育';

ITEMS['s910'] = '製品開発・研究';

ITEMS['s911'] = 'その他技術系（ソフトウェア）';

ITEMS['s1001'] = '設計・開発';

ITEMS['s1002'] = '生産技術・製造技術・エンジニアリング';

ITEMS['s1003'] = '生産管理・品質管理・品質保証';

ITEMS['s1004'] = 'セールスエンジニア(電気・電子・機械・自動車・化学・食品・医療)';

ITEMS['s1005'] = 'サポートエンジニア';

ITEMS['s1006'] = 'その他技術系(電気・電子・機械・自動車・化学・食品・医療)';

ITEMS['s1101'] = 'その他職種';

ITEMS['g1'] = 'IT・通信';

ITEMS['g2'] = 'メーカー';

ITEMS['g3'] = '商社';

ITEMS['g4'] = '流通・小売（ファッション・アパレル）';

ITEMS['g5'] = '流通・小売（その他）';

ITEMS['g6'] = 'フード・レストラン';

ITEMS['g7'] = 'レジャー・アミューズメント・ホテル';

ITEMS['g8'] = '放送・広告・印刷・出版';

ITEMS['g9'] = '人材ビジネス／コールセンター';

ITEMS['g10'] = '医療・福祉・介護・教育';

ITEMS['g11'] = 'コンサルタント・シンクタンク';

ITEMS['g12'] = '金融';

ITEMS['g13'] = '不動産・建築・土木';

ITEMS['g14'] = '団体・連合会・官公庁';

ITEMS['g15'] = 'その他業界';


function getCodes(itemName) {
	try {
		var codes = eval(document.search.elements[itemName].value);
		if (typeof(codes) == "object" && codes.constructor == Array) return codes;
	} catch (e) {
	}
	return new Array();
}

function getCodesText(itemName, type) {
	var codes = getCodes(itemName);
	var text = "";
	for (i = 0; i < codes.length; i++) {
		var code = codes[i];
		var key = type + code;
		if (!(key in ITEMS)) continue;
		if (text.length > 0) text += '、';
		text += ITEMS[key];
	}
	return text;
}

function getCodesJson(itemName, items, type) {
	var codes = getCodes(itemName);
	var json = '[';
	for (key in ITEMS) {
		if (key.charAt(0) != type) continue;
		var code = key.substring(1);
		
		var checked = null;
		for (i = 0; i < items.length; i++) {
			var item = items[i];
			if (item.value == code) { checked = item.checked; break; }
		}
		if (checked == null) {
			checked = false;
			for (i = 0; i < codes.length; i++) {
				if (codes[i] == code) { checked = true; break; }
			}
		}
		if (checked) {
			if (json.length > 1) json += ',';
			json += '\"' + code + '\"'
		}
	}
	json += ']';
	return json;
}

function checkPopupCodes(itemName, items) {
	var codes = getCodes(itemName);
	for (i = 0; i < items.length; i++) {
		var item = items[i];
		var code = item.value;
		for (j = 0; j < codes.length; j++) {
			if (codes[j] == code) { item.checked = true; break; }
		}
	}
}



function displayAreas(type) {
	var text = getCodesText('select-area', type);
	var p = document.getElementById('selected-areas');
	if (p) {
		if (p.hasChildNodes()) p.removeChild(p.firstChild);
		p.appendChild(document.createTextNode(text));
	}
}

function replaceAreas(type, items) {
	var json = getCodesJson('select-area', items, type);
	document.search.elements['select-area'].value = json;
	if (document.forms['search-area']) {
		document.forms['search-area'].elements['select-area'].value = json;
	}
	displayAreas(type);
}



function displayShokushu() {
	var text = getCodesText('sales', 's');
	var p = document.getElementById('selected-shokushu');
	if (p) {
		if (p.hasChildNodes()) p.removeChild(p.firstChild);
		p.appendChild(document.createTextNode(text));
	}
}

function replaceShokushu(items) {
	var json = getCodesJson('sales', items, 's');
	document.search.elements['sales'].value = json;
	displayShokushu();
}



function displayGyokai() {
	var text = getCodesText('industry', 'g');
	var p = document.getElementById('selected-gyokai');
	if (p) {
		if (p.hasChildNodes()) p.removeChild(p.firstChild);
		p.appendChild(document.createTextNode(text));
	}
}

function replaceGyokai(items) {
	var json = getCodesJson('industry', items, 'g');
	document.search.elements['industry'].value = json;
	displayGyokai();
}

