	var httpObj;

	if (!('outerHTML' in document.createElement('div'))) {
		HTMLElement.prototype.__defineGetter__('outerHTML', function() { return this.ownerDocument.createElement('div').appendChild(this.cloneNode(true)).parentNode.innerHTML })
	}

	function make_syasyu() {
		frm = document.frmSatei;
		if ((frm.maker.selectedIndex == 0) || (frm.haiki.selectedIndex == 0)) {
			len = frm.syasyu.options.length;
			for (i=len-1; i>=0; i--) {
				frm.syasyu.options[i] = null;
			}
			frm.syasyu.options[0] = new Option("お選びください","");
			restore_flg = false;
			return false;
		}
		
		maker = frm.maker.options[frm.maker.selectedIndex].value;
		haiki = frm.haiki.options[frm.haiki.selectedIndex].value;
		
		if (maker == "+") maker = "%2b";
		
		url = is_root() + "onlinesatei/p_get_syasyu.php";
		//alert(url);
		
		httpObj = createXMLHttpRequest(getSyasyuResponse);
		if (httpObj)
		{
			httpObj.open("GET", url + "?maker=" + maker + "&haiki=" + haiki + "&encode=" + get_encode(),true);
			httpObj.send(null);
		}		
	}

	function getSyasyuResponse() {
		//alert(httpObj.status);
		if ((httpObj.readyState == 4) && (httpObj.status == 200)) {
			makeSyasyuOption(httpObj.responseText);
		} else {

		}
	}
	
	function makeSyasyuOption(csvText) {

		frm = document.frmSatei;

		len = frm.syasyu.options.length;
		for (i=len-1; i>=0; i--) {
			frm.syasyu.options[i] = null;
		}

		lf = String.fromCharCode(10);
		lines = csvText.split(lf);
		frm.syasyu.options[0] = new Option("お選びください","");
		p = 1;
		for (i=0; i<lines.length; i++) {
			if (lines[i] != "") {
				cols = lines[i].split(",");
				frm.syasyu.options[p] = new Option(cols[0],lines[i]);
				p++;
			}
		}

		if (frm.hid_syasyu.value != "") {
			frm.syasyu.options[frm.hid_syasyu.value].selected = true;
			make_nensiki(frm.syasyu);
		}
	}
	
	function make_nensiki(obj) {
		makeNensikiOption(obj.value);
	}
	
	function makeNensikiOption(csvText) {

		if (csvText == "") return;
		
		frm = document.frmSatei;

		cols = csvText.split(",");
		frm.nensiki.value = "選択なし," + cols[1] + "," + cols[3] + "," + cols[4];

	}
	
	function check_on_satei() {
		frm = document.frmSatei;
		if (frm.maker.selectedIndex == 0) {
			alert("メーカーを選択して下さい。");
			return false;
		}
		if (frm.haiki.selectedIndex == 0) {
			alert("排気量を選択して下さい。");
			return false;
		}
		if (frm.syasyu.selectedIndex == 0) {
			alert("車種を選択して下さい。");
			return false;
		}
		
		frm.hid_syasyu.value = frm.syasyu.selectedIndex;
		
		return true;
	}

	function getWareki(y) {
		if (y > 1988) return "平成" + (y - 1988) + "年";	//　平成
		if (y > 1925) return "昭和" + (y - 1925) + "年";	//　昭和
		if (y > 1911) return "大正" + (y - 1911) + "年";	//　大正
		if (y > 1867) return "明治" + (y - 1867) + "年";	//　明治
		return "不明";
	}

	function is_root() {
		var scripts = document.getElementsByTagName( 'script' );  
		var ret = "";
		var p = 0;
		
		for ( var i=0; i<scripts.length; i++ ) {  
		    var s = scripts.item( i );
		    if( s.src.indexOf( "onlinesatei.js" ) != -1 ) {  
				p = s.outerHTML.indexOf( "../", 0 );
				if (p != -1) {
					while (s.outerHTML.indexOf( "../", p ) == p) {
						p = p + 3;
						ret = ret + "../";
					}
				}
				break;
		    }
		}
		return ret;
	}

	function get_encode() {
		if (document.all) {
			return (document.charset);
		} else {
			return (document.characterSet);
		}
	}

