<!--#include virtual ="/common/lib/dbcon.asp"-->
<!--#include virtual ="/common/lib/func.asp"-->
<%
Dim v_addrstr, sql1, rs1
Dim seq, zipcode, sido, gugun , dong , ri, st_bunji, ed_bunji, addr_t1

v_addrstr = InputValue(request("p_addrstr"))
%>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<title>우편번호 검색</title>
<script type="text/javascript"  src="/common/js/01info.js"></script>
<script type="text/javascript">
<!--
function check() {

	if (document.forms[0].p_addrstr.value == "")
		alert("동 이름을 입력하세요.");
	else
		document.forms[0].submit();
}


function setf() {

	document.forms[0].p_addrstr.focus();
}


//우편값 넘기기..
function d_value(x,y,z){
	
	window.opener.document.getElementById("frm").m_zip1.value= x;
	window.opener.document.getElementById("frm").m_zip2.value= y;
	window.opener.document.getElementById("frm").m_addr1.value = z;

	self.close();
}
//-->
</script>
</head>
<body bgcolor="#ffffff" leftMargin="0" topMargin="0" marginheight="0" marginwidth="0" onload="javascript:setf();">
<FORM method="post" action="zipcode_search.php"> 

<table width="100%" height="100%" cellspacing="0" cellpadding="0">
<tr>
	<td height="4" bgcolor="013D64" colspan="2"><img src="imgs/popup_top_img.gif" width="32" height="4"></td>
</tr>
<tr height="40">
	<td class="pb2"><img src="imgs/tit_zip.gif" width="120" height="22"></td>
	<!-- Logo -->
	<td align="right" class="pt3 pr15">
		<%If popup_logo_image_url <> ""%>
			<!--<img src="<%=popup_logo_image_url%>" border="0">-->
		<%End if%>
	</td>
	<!-- //Logo -->
</tr>
<tr>
	<td height="1" bgcolor="E5E5E5" colspan="2"></td>
</tr>
<tr>
	<td height="100%" colspan="2" class="pt15 pb15 pr15 pl15" valign="top">
		<FORM method="post" action="zipcode_search.asp"> 
		<input type="hidden" name="mode" value="<%=mode%>">
		<table width="100%" cellspacing="5" cellpadding="0" bgcolor="E1E1E1" align="center">
			<tr>
				<td bgcolor="FFFFFF" style="padding:15 15 15 15;">
					<table width="100%" cellspacing="0" cellpadding="0">
						<tr>
							<td>
								<b>찾고자 하는 지역의 '동이름'을 입력해주세요.</b><br>
								<img width="0" height="3"><br>
								<font color="666666">예) 서울시 강남구 삼성1동이라면 '<font color="FF622C">삼성1</font>'만 입력하시면됩니다.</font>
							</td>
						</tr>
						<tr>
							<td height="10"></td>
						</tr>
						<tr>
							<td height="1" background="/img/s_line.gif"></td>
						</tr>
						<tr>
							<td height="10"></td>
						</tr>
						<tr style="padding-top:10;padding-bottom:4;" align="center">
							<td><b>&nbsp;이름 입력</b> <input type="text" name="p_addrstr" maxlength="30" size="20" class="ipche_input"> 동(읍/면)<img width="10" height="0"><a href="javascript:check();"><img src="imgs/zip_bt.gif" width="57" height="21" border="0" align="absmiddle"></a></td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
		<img width="0" height="4"><br>
		<table width="93%" cellspacing="0" cellpadding="0" align="center">
			<tr>
				<td bgcolor="FFFFFF" style="padding:15 15 0 15;">
					<%
						
						if v_addrstr <> "" then

							sql1 = "select * from zipcode where dong LIKE '%" & v_addrstr & "%'"
							Set rs1 = dbcon.execute( sql1 )

							If rs1.bof Or rs1.eof Then
%>
					<div align="center"><font color=#008E8B>등록된 데이터가 없습니다.</font></div>
<%
							Else
								Do Until rs1.eof
									seq      = rs1("SEQ")
									zipcode  = trim(rs1("ZIPCODE"))
									sido     = trim(rs1("SIDO"))
									gugun    = trim(rs1("GUGUN"))
									dong     = trim(rs1("DONG"))
									ri       = trim(rs1("RI"))
									st_bunji = trim(rs1("ST_BUNJI"))
									ed_bunji = trim(rs1("ED_BUNJI"))

									addr_t1  = sido & " " & gugun & " " & dong & " " & ri

									if st_bunji <> "" and ed_bunji <> "" then
										addr_t2 = st_bunji & " ~ " & ed_bunji & "동"
									else
										addr_t2 = ""
									End if

									addr_t = addr_t1 & addr_t2
%>
								<a href="javascript:d_value('<%=left(zipcode,3)%>','<%=right(zipcode,3)%>','<%=addr_t1%>')">[<%=substr($zipcode,0,3)?>-<?=substr($zipcode,4,3)?>]
								<?=$addr_t?></a><br><img width="0" height="6"><br>
<%

									rs1.movenext
								loop
							End if
							if ($mysql->RowCount() <= 0) { ?>
								<div align="center"><font color=#008E8B>등록된 데이터가 없습니다.</font></div>
								<?

							  } else {

									while($mysql->FetchInto(&$rs1)) {
										

										$seq      = $rs1[SEQ ];
										$zipcode  = trim($rs1[ZIPCODE]);
										$sido     = trim($rs1[SIDO]);
										$gugun    = trim($rs1[GUGUN]);
										$dong     = trim($rs1[DONG]);
										$ri       = trim($rs1[RI]);
										$st_bunji = trim($rs1[ST_BUNJI]);
										$ed_bunji = trim($rs1[ED_BUNJI]);
										

										$addr_t1  = $sido . " " . $gugun . " " . $dong . " " . $ri;
										 
										 if ($st_bunji != "" && $ed_bunji != "") {
										   $addr_t2 = $st_bunji ." ~ ". $ed_bunji . "동";
										 } else {
										   $addr_t2 = "";
										 }

										 $addr_t = $addr_t1 . $addr_t2;

									?>
								<a href="javascript:d_value('<?=substr($zipcode,0,3)?>','<?=substr($zipcode,4,3)?>','<?=$addr_t1?>')">[<?=substr($zipcode,0,3)?>-<?=substr($zipcode,4,3)?>]
								<?=$addr_t?></a><br><img width="0" height="6"><br>
									<? 
									}
							  }
						}
					?>
			</td>
		</tr>
		</table>
		</form>
	</td>
</tr>
<tr>
	<td height="1" bgcolor="E7E7E7" colspan="2"></td>
</tr>
<tr>
	<td height="25" bgcolor="F5F5F5" align="right" class="pr5" colspan="2"><a onclick="javascript:window.close();" class="curHand" onfocus="blur();"><img src="imgs/popup_close_bt.gif" width="35" height="19" border="0"></a></td>
</tr>
</table>

</body>
</html>
<?
$mysql->Disconnect();
?>