function CreateList1(rslt, rsltresult, vtype, vcurrent){
	if(rsltresult == null)return false;
	var xmlhttp = createXmlHttp();
	if(xmlhttp == null){alert('XMLHttpRequest非対応のブラウザです。'); return false;}

	var ooptions = rsltresult.options;
	var slist;
	var svalue;
	var idx;

	rsltresult.value = '';
	if(rslt.value.length == 0){ooptions.length = 1; return false;}

	xmlhttp.onreadystatechange = handleHttpEvent;
	function handleHttpEvent(){
		if(xmlhttp.readyState == 4){
			if(xmlhttp.status == 200){
				if(get_response_text(xmlhttp).length > 0){
					slist = get_response_text(xmlhttp).split(';');
					ooptions.length = slist.length + 1;
					for(idx = 0; slist[idx] != null; idx++){
						svalue = slist[idx].split(',');
						ooptions[idx + 1].value = svalue[0];
						ooptions[idx + 1].innerHTML = svalue[1];
						if(vcurrent == svalue[0]){
							ooptions[idx + 1].selected = true;
						}

					}
				}
			} else {
				window.alert('通信エラーが発生しました。');
			}
		}
	}
	// HTTPリクエスト実行
	xmlhttp.open('GET', '/echo/' + vtype + '.asp?v1=' + rslt.value, true);
	xmlhttp.send(null);
}
function CreateList2(rslt1, rslt2, rsltresult, vtype, vcurrent){
	if(rsltresult == null)return false;
	var xmlhttp = createXmlHttp();
	if(xmlhttp == null){alert('XMLHttpRequest非対応のブラウザです。'); return false;}

	var ooptions = rsltresult.options;
	var slist;
	var svalue;
	var idx;

	rsltresult.value = '';
	if(rslt1.value.length == 0 || rslt2.value.length == 0){ooptions.length = 1; return false;}

	xmlhttp.onreadystatechange = handleHttpEvent;
	function handleHttpEvent(){
		if(xmlhttp.readyState == 4){
			if(xmlhttp.status == 200){
				if(get_response_text(xmlhttp).length > 0){
					slist = get_response_text(xmlhttp).split(';');
					ooptions.length = slist.length + 1;
					for(idx = 0; slist[idx] != null; idx++){
						svalue = slist[idx].split(',');
						ooptions[idx + 1].value = svalue[0];
						ooptions[idx + 1].innerHTML = svalue[1];
						if(vcurrent == svalue[0]){
							ooptions[idx + 1].selected = true;
						}

					}
				}
			} else {
				window.alert('通信エラーが発生しました。');
			}
		}
	}
	// HTTPリクエスト実行
	xmlhttp.open('GET', '/echo/' + vtype + '.asp?v1=' + rslt1.value + '&v2=' + rslt2.value, true);
	xmlhttp.send(null);
}

function ListClear(){
	for(var idx = 0; idx < arguments.length; idx++) {
		arguments[idx].options.length=1;
		arguments[idx][0].selected = true;
	}
}

function GetStation(vprefecturecode, vrailwaylinecode, vcurrentcode, rselect){
	if(rselect == null)return false;
	var railwaylinelist;
	var railwayline;
	var xmlhttp = createXmlHttp();
	if(xmlhttp == null){
		window.alert('XMLHttpRequest非対応のブラウザです。');
	}
	var ooptions = rselect.options;
	rselect.value = '';
	if(vprefecturecode.length == 0 || vrailwaylinecode.length == 0){ooptions.length = 1; return false;}

	xmlhttp.onreadystatechange = handleHttpEvent;
	function handleHttpEvent(){
		if(xmlhttp.readyState == 4){
			if(xmlhttp.status == 200){
				if(get_response_text(xmlhttp).length > 0){
					railwaylinelist = get_response_text(xmlhttp).split(';');
					ooptions.length = railwaylinelist.length + 1;
					for(idx = 0; railwaylinelist[idx] != null; idx++){
						railwayline = railwaylinelist[idx].split(',');
						ooptions[idx + 1].value = railwayline[0];
						ooptions[idx + 1].innerHTML = railwayline[1];
						if(vcurrentcode == railwayline[0]){
							ooptions[idx + 1].selected = true;
						}
					}
				}
			} else {
				window.alert('通信エラーが発生しました。');
			}
		}
	}
	// HTTPリクエスト実行
	xmlhttp.open('GET', '/echo/station.asp?pc=' + vprefecturecode + '&rc=' + vrailwaylinecode, true);
	xmlhttp.send(null);
}

function GetRailwayLine(vprefecturecode, vcurrentcode, rselect){
	if(rselect == null)return false;
	var railwaylinelist;
	var railwayline;
	var xmlhttp = createXmlHttp();
	if(xmlhttp == null){
		window.alert('XMLHttpRequest非対応のブラウザです。');
	}
	var ooptions = rselect.options;
	rselect.value = '';
	if(vprefecturecode.length == 0){ooptions.length = 1; return false;}

	xmlhttp.onreadystatechange = handleHttpEvent;
	function handleHttpEvent(){
		if(xmlhttp.readyState == 4){
			if(xmlhttp.status == 200){
				if(get_response_text(xmlhttp).length > 0){
					railwaylinelist = get_response_text(xmlhttp).split(';');
					ooptions.length = railwaylinelist.length + 1;
					for(idx = 0; railwaylinelist[idx] != null; idx++){
						railwayline = railwaylinelist[idx].split(',');
						ooptions[idx + 1].value = railwayline[0];
						ooptions[idx + 1].innerHTML = railwayline[1];
						if(vcurrentcode == railwayline[0]){
							ooptions[idx + 1].selected = true;
						}
					}
				}
			} else {
				window.alert('通信エラーが発生しました。');
			}
		}
	}
	// HTTPリクエスト実行
	xmlhttp.open('GET', '/echo/railwayline.asp?pc=' + vprefecturecode, true);
	xmlhttp.send(null);
}

function GetPrefecture(vareacode, vprefecturecode, vbranchcode, vcurrentcode, rselect){
	if(rselect == null)return false;
	var prefecturelist;
	var prefecture;
	var xmlhttp = createXmlHttp();
	if(xmlhttp == null){
		window.alert('XMLHttpRequest非対応のブラウザです。');
	}
	var ooptions = rselect.options;
	rselect.value = '';
	if(vareacode.length == 0){ooptions.length = 1; return false;}

	xmlhttp.onreadystatechange = handleHttpEvent;
	function handleHttpEvent(){
		if(xmlhttp.readyState == 4){
			if(xmlhttp.status == 200){
				if(get_response_text(xmlhttp).length > 0){
					prefecturelist = get_response_text(xmlhttp).split(';');
					ooptions.length = prefecturelist.length + 1;
					for(idx = 0; prefecturelist[idx] != null; idx++){
						prefecture = prefecturelist[idx].split(',');
						ooptions[idx + 1].value = prefecture[0];
						ooptions[idx + 1].innerHTML = prefecture[1];
						if(vcurrentcode == prefecture[0]){
							ooptions[idx + 1].selected = true;
						}
					}
				}
			} else {
				window.alert('通信エラーが発生しました。');
			}
		}
	}
	// HTTPリクエスト実行
	xmlhttp.open('GET', '/echo/prefecture.asp?ac=' + vareacode + '&pc=' + vprefecturecode + '&bc' + vbranchcode, true);
	xmlhttp.send(null);
}
function GetJobType(vbigclasscode, vcurrentcode, rselect){
	if(rselect == null)return false;
	var jobtypelist;
	var jobtype;
	var xmlhttp = createXmlHttp();
	if(xmlhttp == null){
		window.alert('XMLHttpRequest非対応のブラウザです。');
	}
	var ooptions = rselect.options;
	rselect.value = '';
	if(vbigclasscode.length == 0){ooptions.length = 1; return false;}

	xmlhttp.onreadystatechange = handleHttpEvent;
	function handleHttpEvent(){
		if(xmlhttp.readyState == 4){
			if(xmlhttp.status == 200){
				if(get_response_text(xmlhttp).length > 0){
					jobtypelist = get_response_text(xmlhttp).split(';');
					ooptions.length = jobtypelist.length + 1;
					for(idx = 0; jobtypelist[idx] != null; idx++){
						jobtype = jobtypelist[idx].split(',');
						ooptions[idx + 1].value = jobtype[0];
						ooptions[idx + 1].innerHTML = jobtype[1];
						if(vcurrentcode == jobtype[0]){
							ooptions[idx + 1].selected = true;
						}
					}
				}
			} else {
				window.alert('通信エラーが発生しました。');
			}
		}
	}
	// HTTPリクエスト実行
	xmlhttp.open('GET', '/echo/jobtype.asp?b=' + vbigclasscode, true);
	xmlhttp.send(null);
}
function GetAddressToCompanyReg(vu, vl){
	var aad;
	var xmlhttp = createXmlHttp();
	if(xmlhttp == null){
		window.alert('XMLHttpRequest非対応のブラウザです。');
	}
	xmlhttp.onreadystatechange = handleHttpEvent;
	function handleHttpEvent(){
		if(xmlhttp.readyState == 4){
			if(xmlhttp.status == 200){
				if(get_response_text(xmlhttp).length > 0){
					aad = get_response_text(xmlhttp).split(';');
					document.forms.frmReg1.CONF_PrefectureCode.value = aad[1];
					document.forms.frmReg1.CONF_City_K.value = aad[4];
					document.forms.frmReg1.CONF_City_F.value = aad[5];
					document.forms.frmReg1.CONF_Town.value = aad[6];
					document.getElementById('errblock').style.display = 'none';
				}else{
					document.forms.frmReg1.CONF_PrefectureCode.value = '';
					document.forms.frmReg1.CONF_City_K.value = '';
					document.forms.frmReg1.CONF_City_F.value = '';
					document.forms.frmReg1.CONF_Town.value = '';
					document.getElementById('errblock').style.display = 'block';
				}
			} else {
				window.alert('通信エラーが発生しました。');
			}
		}
	}
	// HTTPリクエスト実行
	xmlhttp.open('GET', '/echo/address.asp?u=' + vu + '&l=' + vl, true);
	xmlhttp.send(null);
}
function GetAddressToInputBox(vu, vl){
	var aad;
	var xmlhttp = createXmlHttp();
	if(xmlhttp == null){
		window.alert('XMLHttpRequest非対応のブラウザです。');
	}
	xmlhttp.onreadystatechange = handleHttpEvent;
	function handleHttpEvent(){
		if(xmlhttp.readyState == 4){
			if(xmlhttp.status == 200){
				if(get_response_text(xmlhttp).length > 0){
					aad = get_response_text(xmlhttp).split(';');
					document.forms.frmEdit.CONF_PrefectureCode.value = aad[1];
					document.forms.frmEdit.CONF_City.value = aad[4];
					document.forms.frmEdit.CONF_City_F.value = aad[5];
					document.forms.frmEdit.CONF_Town.value = aad[6];
					document.forms.frmEdit.CONF_Town_F.value = aad[7];
				}else{
					document.forms.frmEdit.CONF_PrefectureCode.value = '';
					document.forms.frmEdit.CONF_City.value = '';
					document.forms.frmEdit.CONF_City_F.value = '';
					document.forms.frmEdit.CONF_Town.value = '';
					document.forms.frmEdit.CONF_Town_F.value = '';
				}
			} else {
				window.alert('通信エラーが発生しました。');
			}
		}
	}
	// HTTPリクエスト実行
	xmlhttp.open('GET', '../echo/address.asp?u=' + vu + '&l=' + vl, true);
	xmlhttp.send(null);
}
function GetAddress(vu, vl){
	document.getElementById('idshowaddress').style.color = '';
	document.getElementById('idshowaddress').innerHTML = '';
	document.forms.frmGoReg1.CONF_Post.value = '';
	document.forms.frmGoReg1.CONF_PrefectureCode.value = '';
	document.forms.frmGoReg1.CONF_PrefectureName.value = '';
	document.forms.frmGoReg1.CONF_City.value = '';
	document.forms.frmGoReg1.CONF_City_F.value = '';
	document.forms.frmGoReg1.CONF_Town.value = '';
	document.forms.frmGoReg1.CONF_Town_F.value = '';

	var aad;
	// XMLHttpRequestオブジェクト作成
	var xmlhttp = createXmlHttp();
	if(xmlhttp == null){
		window.alert('XMLHttpRequest非対応のブラウザです。');
	}
	// レスポンスデータ処理方法の設定
	xmlhttp.onreadystatechange = handleHttpEvent;
	// レスポンスデータ処理用のコールバック関数を定義

	function handleHttpEvent(){
		if(xmlhttp.readyState == 4){
			if(xmlhttp.status == 200){
				if(get_response_text(xmlhttp).indexOf(';') >= 0){
					aad = get_response_text(xmlhttp).split(';');
					document.getElementById('idshowaddress').innerHTML = aad[2] + aad[4] + aad[6];
					document.forms.frmGoReg1.CONF_Post.value = aad[0];
					document.forms.frmGoReg1.CONF_PrefectureCode.value = aad[1];
					document.forms.frmGoReg1.CONF_PrefectureName.value = aad[2];
					document.forms.frmGoReg1.CONF_City.value = aad[4];
					document.forms.frmGoReg1.CONF_City_F.value = aad[5];
					document.forms.frmGoReg1.CONF_Town.value = aad[6];
					document.forms.frmGoReg1.CONF_Town_F.value = aad[7];
					if(!(document.forms.frmGoReg1.CONF_Post_U.value.length > 2 && document.forms.frmGoReg1.CONF_Post_L.value.length > 3)){
						document.getElementById('post').className = 'need';
						document.getElementById('count').innerHTML=needcount();
					}else{
						document.getElementById('post').className = 'sumi';
						document.getElementById('count').innerHTML=needcount();
					}
				}else{
					if(!(document.forms.frmGoReg1.CONF_Post_U.value.length == 0 && document.forms.frmGoReg1.CONF_Post_L.value.length == 0)){
						document.getElementById('idshowaddress').innerHTML = '郵便番号が間違っています。再入力願います。';
					}
					document.getElementById('post').className = 'need';
					document.getElementById('count').innerHTML=needcount();
				}
			} else {
				window.alert('通信エラーが発生しました。');
			}
		}
	}
	// HTTPリクエスト実行
	xmlhttp.open('GET', '/echo/address.asp?u=' + vu + '&l=' + vl, true);
	xmlhttp.send(null);
}

function createXmlHttp(){
	if(window.XMLHttpRequest){
		// Mozilla, Firefox, Safari, IE7
		return new XMLHttpRequest();
	}else if(window.ActiveXObject){
		// IE5, IE6
		try{
			return new ActiveXObject('Msxml2.XMLHTTP');// MSXML3
		}catch(e){
			return new ActiveXObject('Microsoft.XMLHTTP');// MSXML2まで
		}
	}else{
		return null;
	}
}

function get_response_text(req){
	var text = req.responseText;
	return decodeURIComponent(text);
/*
	if(navigator.appVersion.indexOf('KHTML') > -1) {
		var esc = escape(text);

		if(esc.indexOf('%u') < 0 && esc.indexOf('%') > -1){
			text = decodeURIComponent(esc);
		}
		text = '';
	}
	return text;
*/
}

