// セレクト項目初期化

function setSelectOptions(elm, vals, def) {
	elm.clear;
	elm.options.length = 0;
	i = 0;
	for (var optIdx in vals) {
		elm.options.length = i+1;
		elm.options[i].value = optIdx;
		elm.options[i].text  = vals[optIdx];
		if (optIdx == def) {
			elm.options[i].selected  = true;
		}
		i++;
	}
}

function syncWithSex(fm, sex) {
///fm.intro.value = arrIntro[sex];
	for (var profNo in arrProf) {
		profID = 'PROF' + profNo;
		setSelectOptions(document.all[profID],arrProf[profNo][sex],1);
	}
	if (bbs == 'on'){
		setSelectOptions(document.all['bbscat'],arrCat[sex],1);
		if (ftelBlank == true && sex == 2) {
			fm.tel.disabled = true;
			fm.tel.style.backgroundColor = '#cccccc';
			fm.tel.value = '記入不要';
		} else {
			fm.tel.disabled = false;
			fm.tel.style.backgroundColor = '#ffffff';
			fm.tel.value = '';
		}
	}
}

function syncWithArea2(fm, pref, city) {
	fm.area2.value = pref;
	fm.area3.value = city;
	setSelectOptions(document.all['area2'], arrArea2, pref);
	setSelectOptions(document.all['area3'], arrArea3[pref], city);
}

// 文字列のバイトサイズチェック

function jstrlen(str) {
	var len = 0;
	str = escape(str);
	for (i = 0; i < str.length; i++, len++) {
		if (str.charAt(i) == "%") {
			if (str.charAt(++i) == "u") {
				i += 3;
				len++;
			}
			i++;
		}
	}
	return len;
}



function initForm() {
	if (prof == 'on'){
		syncWithSex(document.applyForm, sexDefault);
	}
}
function initDom() {
	if (domain == 'on'){
	setSelectOptions(document.applyForm.domain, arrDomain, 0);
	}
}

function initArea() {
	if (area == 'on'){
	syncWithArea2(document.applyForm, 13, 0);	//都道府県(デフォルト東京)の詳細地区表示
	}
}

