function areaCodeInit(url,refButtonId,postalTextBoxId,prefTextBoxId,cityTextBoxId,city2TextBoxId){
	//見出し置換テーブル
	var captions={
		'都道府県 No.' : '都道府県' ,
		'市区町村 No.' : '市区町村' 
	};

	var prefSelectId='areCodePrefSelect'; //県セレクトボックスのID
	var citySelectId='areCodeCitySelect'; //市セレクトボックスのID

	//送信フォーム生成
	var s='';
	s += '<div style="display:none">';
//	s += '<div style="display:block">';
	s += '	<iframe name="areaCodeFrame" >';
	s += '	</iframe>';
	s += '	<form method="get" action="'+url+'" id="areaCodeForm" target="areaCodeFrame" >';
	s += '	 <input id="areaCodePref" name="pref" />';
	s += '	 <input id="areaCodeCity" name="city" />';
	s += '	 <input id="areaCodePostal" name="postal" />';
	s += '	 <input name="prefInput" value="'+prefSelectId+'" />';
	s += '	 <input name="cityInput" value="'+citySelectId+'" />';
	s += '	 <input name="prefIdInput" value="'+prefTextBoxId+'" />';
	s += '	 <input name="cityIdInput" value="'+cityTextBoxId+'" />';
	s += '	 <input name="city2Input" value="'+city2TextBoxId+'" />';
	s += '	 <input id="areaCodeCmd" name="cmd"/>';
	s += '	</form>';
	s += '</div>';
	document.write(s);
	
	//郵便番号
	var p=document.createElement('input');
	p.type='button';
	p.value='郵便番号で検索';
	p.id=refButtonId;
	with (document.getElementById(postalTextBoxId)) {
		parentNode.insertBefore(p, nextSibling);
	}
	p.onclick=function() {
		document.getElementById('areaCodePostal').value = document.getElementById(postalTextBoxId).value;
		document.getElementById('areaCodeCmd').value='postal';
		document.getElementById('areaCodeForm').submit();
		return false;
	}

	//県セレクトボックス
	var prefSelect=document.createElement('select');
	prefSelect.id=prefSelectId;
	with (document.getElementById(prefTextBoxId)) {
		parentNode.insertBefore(prefSelect, nextSibling);
		style.display='none';
	}
	prefSelect.onchange=function () {
		document.getElementById(cityTextBoxId).value='';
		document.getElementById(citySelectId).innerHTML='';
		document.getElementById('areaCodePref').value = prefSelect.value;
		document.getElementById(prefTextBoxId).value = prefSelect.value;
		document.getElementById('areaCodeCmd').value='pref';
		document.getElementById('areaCodeForm').submit();
	}
	//市セレクトボックス
	var citySelect=document.createElement('select');
	citySelect.id=citySelectId;
	with (document.getElementById(cityTextBoxId)) {
		parentNode.insertBefore(citySelect, nextSibling);
		style.display='none';
	}

	citySelect.onchange=function () {
		document.getElementById(cityTextBoxId).value = citySelect.value;
		document.getElementById('areaCodeCity').value = citySelect.value;
	}

	//初期化
	document.getElementById('areaCodePref').value=document.getElementById(prefTextBoxId).value;
	document.getElementById('areaCodeCity').value=document.getElementById(cityTextBoxId).value;
	document.getElementById('areaCodeCmd').value='init';
	document.getElementById('areaCodeForm').submit();

	//見出し置換
	var els=document.getElementsByTagName('span');
	for(var i=0;i<els.length;i++) {
		if(els[i].innerHTML in captions) {
			els[i].innerHTML = captions[els[i].innerHTML];
		}
	}
}

