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['h1101'] = '池袋・上野エリア';

ITEMS['h1102'] = '新宿・中野エリア';

ITEMS['h1103'] = '市ヶ谷・赤坂エリア';

ITEMS['h1104'] = '御茶ノ水・錦糸町エリア';

ITEMS['h1105'] = '大手町・日本橋エリア';

ITEMS['h1106'] = '渋谷・六本木エリア';

ITEMS['h1107'] = '銀座・豊洲エリア';

ITEMS['h1108'] = '品川・新橋エリア';

ITEMS['h1109'] = '23区以外';

ITEMS['h1201'] = '横浜・川崎エリア';

ITEMS['h1202'] = '横浜市・川崎市以外';

ITEMS['h1301'] = '千葉';

ITEMS['h1401'] = '埼玉';

ITEMS['h1501'] = '茨城';

ITEMS['h1601'] = '群馬';

ITEMS['h1701'] = '栃木';

ITEMS['h2101'] = '愛知';

ITEMS['h2201'] = '岐阜';

ITEMS['h2301'] = '三重';

ITEMS['h2401'] = '静岡';

ITEMS['h3101'] = '大阪市北区・中央区';

ITEMS['h3102'] = 'その他大阪市';

ITEMS['h3103'] = '大阪市外';

ITEMS['h3201'] = '滋賀';

ITEMS['h3301'] = '京都';

ITEMS['h3401'] = '兵庫';

ITEMS['h3501'] = '奈良';

ITEMS['h3601'] = '和歌山';

ITEMS['h4101'] = '福岡';

ITEMS['h4201'] = '佐賀';

ITEMS['e1101'] = '池袋・上野エリア';

ITEMS['e1102'] = '新宿・中野エリア';

ITEMS['e1103'] = '市ヶ谷・赤坂エリア';

ITEMS['e1104'] = '御茶ノ水・錦糸町エリア';

ITEMS['e1105'] = '大手町・日本橋エリア';

ITEMS['e1106'] = '渋谷・六本木エリア';

ITEMS['e1107'] = '銀座・豊洲エリア';

ITEMS['e1108'] = '品川・新橋エリア';

ITEMS['e1109'] = '23区以外';

ITEMS['e1201'] = '横浜・川崎エリア';

ITEMS['e1202'] = '横浜市・川崎市以外';

ITEMS['e1301'] = '千葉';

ITEMS['e1401'] = '埼玉';

ITEMS['e1501'] = '茨城';

ITEMS['e2101'] = '愛知';

ITEMS['e2201'] = '岐阜';

ITEMS['e2301'] = '三重';

ITEMS['e3101'] = '大阪市北区・中央区';

ITEMS['e3102'] = 'その他大阪市';

ITEMS['e3103'] = '大阪市外';

ITEMS['e3201'] = '滋賀';

ITEMS['e3301'] = '京都';

ITEMS['e3401'] = '兵庫';

ITEMS['e3501'] = '奈良';

ITEMS['e3601'] = '和歌山';

ITEMS['e4101'] = '福岡';

ITEMS['e4201'] = '佐賀';

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['t21'] = '岐阜';

ITEMS['t22'] = '静岡';

ITEMS['t23'] = '愛知';

ITEMS['t24'] = '三重';

ITEMS['t25'] = '滋賀';

ITEMS['t26'] = '京都';

ITEMS['t27'] = '大阪';

ITEMS['t28'] = '兵庫';

ITEMS['t29'] = '奈良';

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['s101'] = '法人営業';

ITEMS['s102'] = 'リテール営業';

ITEMS['s103'] = 'MR';

ITEMS['s104'] = '海外営業ほか';

ITEMS['s201'] = 'マーケ';

ITEMS['s202'] = '経理';

ITEMS['s203'] = '人事';

ITEMS['s204'] = '法務';

ITEMS['s205'] = '物流';

ITEMS['s206'] = '営業企画';

ITEMS['s207'] = '一般事務ほか';

ITEMS['s301'] = 'SE';

ITEMS['s302'] = 'プログラマ';

ITEMS['s303'] = 'ITコンサルタント';

ITEMS['s304'] = '社内情シスほか';

ITEMS['s401'] = 'コンサルタント';

ITEMS['s402'] = '金融関係職種';

ITEMS['s403'] = '不動産関連職種ほか';

ITEMS['s501'] = '回路設計';

ITEMS['s502'] = '機械設計';

ITEMS['s503'] = '生産技術';

ITEMS['s504'] = '金型設計';

ITEMS['s505'] = '生産管理ほか';

ITEMS['s601'] = 'Webプロデューサー';

ITEMS['s602'] = 'デザイナー';

ITEMS['s603'] = 'ファッション関連職種ほか';

ITEMS['s701'] = '臨床開発';

ITEMS['s702'] = '薬剤師';

ITEMS['s703'] = '研究開発';

ITEMS['s704'] = '食品生産開発ほか';

ITEMS['s801'] = 'スーパーバイザー';

ITEMS['s802'] = '店長';

ITEMS['s803'] = '販売スタッフ';

ITEMS['s804'] = '調理スタッフほか';

ITEMS['s901'] = '設計';

ITEMS['s902'] = '測量';

ITEMS['s903'] = '積算';

ITEMS['s904'] = '施工管理ほか';

ITEMS['s1001'] = '教師';

ITEMS['s1002'] = '講師';

ITEMS['s1003'] = '公務員';

ITEMS['s1004'] = 'その他';

ITEMS['g1'] = 'ソフトウェア・情報処理';

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'] = '放送・広告・印刷・出版';

ITEMS['g16'] = '人材ビジネス';

ITEMS['g17'] = 'コールセンター';

ITEMS['g18'] = '医療・福祉・介護・教育';

ITEMS['g19'] = 'コンサルタント・シンクタンク';

ITEMS['g20'] = '金融（銀行・保険・証券）';

ITEMS['g21'] = '金融（その他）';

ITEMS['g22'] = '不動産';

ITEMS['g23'] = '建築・土木';

ITEMS['g24'] = '電気・ガス・水道';

ITEMS['g25'] = '団体・連合会・官公庁';

ITEMS['g26'] = 'その他の業種';


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();
}


