<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/displaytag-12.tld" prefix="display" %>
<%@ taglib uri="http://ajaxtags.org/tags/ajax" prefix="ajax" %>
<%@ page import="com.ampiere.util.AmpiereUtil" %>
<jsp:include page="/ampiere/jsp/common/includeYAHOOUI.jsp" flush="true" /> 
<html>
<head>
<title><bean:write name="searchInfoFormPostal" property="title"/></title>
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/ampiere/css/import.css" />
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/ampiere/css/window.css"/>
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/ampiere/css/displaytag.css" />
<script type="text/javascript" src="${pageContext.request.contextPath}/ampiere/ajax/js/prototype-1.4.0.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/ampiere/ajax/js/scriptaculous.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/ampiere/ajax/js/overlibmws.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/ampiere/ajax/js/ajaxtags-1.2-beta1.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/ampiere/js/window.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/ampiere/js/search.js"></script>
<style type="text/css">
<!--
    #displayTagOverflow {
	    width: 760px;
    }
-->
</style>
<script type="text/javascript">
/**
 * Update informations(do callout)
 */
function updatePostal() {
	if (! checkParent(window)) {
        window.close();
		return;
	}

    var radioObjects = window.document.getElementsByName("radioSelect");
    var targetObj = window.opener.top.document.getElementById("postalId");
	var locationOptionObj = window.opener.top.document.getElementById("locationOption");
    if (radioObjects != null && targetObj != null && locationOptionObj != null) {
        for (var i = 0; i < radioObjects.length; i++) {
            if (radioObjects[i] != null && radioObjects[i].checked) {
                targetObj.value = radioObjects[i].value;
				locationOptionObj.value = "change";
                targetObj.form.submit();
                window.close();
                window.opener.focus();
                return;
            }
        }
    }

    window.close();
	window.opener.focus();
}	//	updateInfo
</script>
<%!
String getColTitle(Object obj, int idx) {
	if (obj == null) { return "&nbsp;"; } else { String s = AmpiereUtil.sanitizing(((com.ampiere.search.ColBean)obj).getColTitle(idx)); if (s == null || "".equals(s) || " ".equals(s)) { return "&nbsp;"; } else { return s; } }
}
String getColData(Object obj, int idx) {
	if (obj == null) { return "&nbsp;"; } else { Object o = (((com.ampiere.search.ColBean)obj).getColData(idx)); if (o == null) { return "&nbsp;"; } else { String s = AmpiereUtil.sanitizing(o.toString()); if (s == null || "".equals(s) || " ".equals(s)) { return "&nbsp;"; } else { return s; } } }
}
%>
</head>

<body id="popup" <% if ("1".equals(request.getAttribute("doQuery"))) { %> onload="doQuery();" <% } %> onunload="closeMyChildren();">
	<table width="100%" >
	<tr>
	<td class="windowHeader">
<div id="header">
		<h1><bean:write name="searchInfoFormPostal" property="title"/></h1>
</div>
	</td>
    <td valign="top" width="18">
    <div id="progressMsg" style="padding-top:1px;display:none;"><img src="${pageContext.request.contextPath}/ampiere/images/Loading-0.gif" /></div>
    </td>
    </tr>
	</table>

<!-- header -->


<!-- body -->
<div id="body" >
<div class="search-box">

    <html:form styleId="infoLookupForm" style="margin:0;" target="_self" action="/ampiere/InfoPostalSearchAction.do" enctype="application/x-www-form-urlencoded" focus="value">
    	<html:hidden name="searchInfoFormPostal" property="windowNo"/>
    	<html:hidden name="searchInfoFormPostal" property="columnName"/>
    	<html:hidden name="searchInfoFormPostal" property="column_ID"/>
        <table class="popupInfoTable" cellspacing="5" cellpadding="0">
        <tr>
            <td class="lbl"><bean:write name="searchInfoFormPostal" property="valueLabel"/></td>
            <td><html:text name="searchInfoFormPostal" property="value" size="10" /></td>
            <td class="lbl"><bean:write name="searchInfoFormPostal" property="regionLabel"/></td>
            <td><html:text name="searchInfoFormPostal" property="region" size="16" /></td>
            <td class="lbl"><bean:write name="searchInfoFormPostal" property="cityLabel"/></td>
            <td><html:text name="searchInfoFormPostal" property="city" size="16" /></td>
            <td class="lbl"><bean:write name="searchInfoFormPostal" property="addressLabel"/></td>
            <td><html:text name="searchInfoFormPostal" property="address" size="30" /></td>
        </tr>
        <tr>
            <td colspan="8" class="button-box align-right" scope="row">
            <html:button property="search" onclick="doQuery();"><bean:write name="searchInfoFormPostal" property="searchBtnTitle"/></html:button>
            </td>
        </tr>
        </table>
    </html:form>

</div>

<!-- displayTagFrame -->

    <ajax:displayTag id="displayTagFrame" ajaxFlag="displayAjax">
      <display:table id="oneObject" name="searchResultPostal" class="displaytag" pagesize="10" scope="session"
        defaultsort="2" defaultorder="ascending" export="true" excludedParams="ajax" sort="list" cellpadding="0" cellspacing="0">
        <display:column title="<%=getColTitle(oneObject, 0)%>" media="html" class="align-center" sortable="false">
            <input type="radio" id="radioSelect" name="radioSelect" value="<bean:write name='oneObject' property='colId'/>" ondblclick="updatePostal();return false;"/>
        </display:column>
        <%-- Postal --%>
        <display:column title="<%="&nbsp;" + getColTitle(oneObject, 1) + "&nbsp;"%>" sortable="true" headerClass="sortable"><%=getColData(oneObject, 1)%></display:column>
        <%-- Country --%>
        <display:column title="<%="&nbsp;" + getColTitle(oneObject, 2) + "&nbsp;"%>" sortable="true" headerClass="sortable"><%=getColData(oneObject, 2)%></display:column>
        <%-- Region --%>
        <display:column title="<%=getColTitle(oneObject, 3)%>"><%=getColData(oneObject, 3)%></display:column>
        <%-- Address1 --%>
        <display:column title="<%=getColTitle(oneObject, 4)%>"><%=getColData(oneObject, 4)%></display:column>
        <%-- Region_Kana --%>
        <display:column title="<%=getColTitle(oneObject, 5)%>"><%=getColData(oneObject, 5)%></display:column>
        <%-- City_Kana --%>
        <display:column title="<%=getColTitle(oneObject, 6)%>"><%=getColData(oneObject, 6)%></display:column>
        <%-- Address_Kana --%>
        <display:column title="<%=getColTitle(oneObject, 7)%>"><%=getColData(oneObject, 7)%></display:column>
      </display:table>
    </ajax:displayTag>

<!-- body-footer -->
<div class="bottomMenuRight">
<table>
	<tr>
	<td>
	<font color="#EE0000"><i><bean:write name='searchInfoFormPostal' property='largeRecords'/></i></font>
	</td>
	<td class="lbl" style="padding-right:5px;">
	<input id="ok" type="image" src="${pageContext.request.contextPath}/ampiere/images/Ok32.png" onclick="updatePostal();" alt="<bean:write name='searchInfoFormPostal' property='submitBtnTitle'/>"/>
	<span>OK</span>	
	<input id="cancel" type="image" src="${pageContext.request.contextPath}/ampiere/images/Cancel32.png" onclick="window.close();return false;" alt="<bean:write name='searchInfoFormPostal' property='closeBtnTitle'/>"/>
    <span>キャンセル</span> 
	</td>
	</tr>
	</table>
</div>
<!-- /body-footer -->
</div>
<!-- /body -->
</body>
</html>