var index = -1;
var XML_ZIPCODE;
var queryStr; // »ç¿ëÀÚ°¡ ÀÔ·ÂÇÑ Å°¿öµå
var selectedQueryStr; // ¸¶¿ì½º·Î Å¬¸¯ÇÑ Å°¿öµå

function setListBox(e, str) {
	box = document.getElementById("list");
	text = document.frm1.query;
	list_div = box.contentWindow.document.getElementById("list_div");
	if(str) {
		if(!(e.keyCode == 38 || e.keyCode == 40)) {
			queryStr = text.value;
			index = -1;
			xmlhttp = XMLHTTP();
			with(xmlhttp) {
				open("POST", "../_include/search.php", false);
				setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				send("query=" + encodeURIComponent(str));
				//send("opt1=" + encodeURIComponent(str2));
				xml = responseXML;
			}
			XML_ZIPCODE = xml.getElementsByTagName("ZIPCODE");
			html = new String;
			for(i = 0; i < XML_ZIPCODE.length; i++) {
		// °Ë»ö °¹¼ö ¸¸Å­ Ãâ·Â µÇ´Â ºÎºÐ
				html += "<div id='no_" + i + "' style='width:100%; height:15px; cursor:pointer'";
				html += "onmouseover=\"if(parent.index>-1&&parent.index!=" + i + "){document.getElementById('no_' + parent.index).style.backgroundColor='';} parent.index=" + i + ";this.style.backgroundColor='#EEEEEE';parent.selectedQueryStr='" + XML_ZIPCODE.item(i).getAttribute('ADDR') + "';\" ";
				html += "onmouseout=\"parent.index=-1;this.style.backgroundColor=''\" "; 
				html += "onclick=\"parent.document.frm1.query.value='" + XML_ZIPCODE.item(i).getAttribute("ADDR") + "'\">";
				html += "<font color='#A4A4D2'></font> ";
				html += XML_ZIPCODE.item(i).getAttribute("ADDR").toUpperCase().replace(str.toUpperCase(), "<font color='red'>" + str.toUpperCase() + "</font>") + "</div>";
			}
			list_div.innerHTML = html;
			if(index == -1) box.style.display = "inline";
		}
		else {
			if(e.keyCode == 40 && index < XML_ZIPCODE.length - 1) {
				with(box.contentWindow.document) {
					if(index > -1) getElementById("no_" + index).style.backgroundColor = "";
					getElementById("no_" + ++index).style.backgroundColor = "#EEEEEE";
					text.value = XML_ZIPCODE.item(index).getAttribute("ADDR");
					body.scrollTop = Math.floor(index / 5) * 75;
				}
				box.style.display = "inline";
			}
			else if(e.keyCode == 38) {
				if(index > 0) {
					with(box.contentWindow.document) {
						getElementById("no_" + index).style.backgroundColor = "";
						getElementById("no_" + --index).style.backgroundColor = "#EEEEEE";
						text.value = XML_ZIPCODE.item(index).getAttribute("ADDR");
						body.scrollTop = Math.floor(index / 5) * 75;
					}
				}
				else {
					index = -1;
					box.style.display = "none";
					text.value = queryStr;
				}
			}
		}
	}
	else box.style.display = "none";
}

function removeListBox() {
	box = document.getElementById("list");
	box.style.display = "none";
}

function XMLHTTP() {
	try	{
		xmlhttp = new ActiveXObject("MSXML2.XMLHTTP");
	}
	catch(e) {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

