<%@ page contentType="text/html; charset=Shift_JIS" %>
<%@ page pageEncoding="Windows-31J"%>
<%@ page import="java.util.Locale" %>
<%@ page import="jp.co.orangesoft.xgate.addressbook.AddressBookEntry" %>
<%@ page import="jp.co.orangesoft.xgate.util.MobilePhoneAccessKey" %>
<%@ taglib prefix="c" uri="/WEB-INF/tlds/c.tld" %>

<jsp:useBean id="htmltool" class="jp.co.orangesoft.xgate.util.HtmlTool"/>

<%
	// アドレス帳の編集ページ
	
	String servlet = (String)request.getAttribute("servlet");
	String term = (String)request.getAttribute("term");
	Locale locale = (Locale)request.getAttribute("lang");
	String charset = "Windows-31J";
	int lang = locale.equals(Locale.JAPANESE) ? 0 : 1;

	// 文字テーブル
//	String[] title = {"本文を入力：", "Text:"};
//	String[] submit = {"登録", "OK"};
//	String[] back = {"戻る", "BACK"};

	AddressBookEntry entry = (AddressBookEntry)request.getAttribute("entry");

	String email = entry.getMailAddress();
	if(email == null) email = "";
	
	String nickname = entry.getNickName();
	if(nickname == null) nickname = "";
	
	String errmsg = (String)request.getAttribute("errmsg");
	if(errmsg == null) errmsg = "";
	if(errmsg.length() > 0) errmsg += "<br>";
	
	String entryID = (String)request.getAttribute("id");
	if(entryID == null) entryID = "";
	
	String acmd = (String)request.getAttribute("acmd");
	if(acmd == null) acmd = "";

	// etc
	MobilePhoneAccessKey accesskey = new MobilePhoneAccessKey();
%>

<%-- ==================================================================================== --%>
<c:choose>

<%-- ==================================================================================== --%>
<c:when test="${term == 'imode' || term == 'astel' || term == 'willcom'}">

<% response.setContentType("text/html;charset="+charset); %>

<html>
<body>
Register Address
<hr>
<form action="<%=servlet%>">
  <input type="hidden" name="cmd" value="CNA">
  <input type="hidden" name="action" value="commit">
  <input type="hidden" name="id" value="<%=htmltool.format(entryID)%>">
  <input type="hidden" name="acmd" value="<%=htmltool.format(acmd)%>">

  <font color="red"><%=htmltool.format(errmsg)%></font>

  PhoneNumber<br>
  <input type="text" size="20" name="mailaddress" maxlength="15" istyle="4" value="<%=htmltool.format(email)%>"><br>
  Nickname<br>
  <input type="text" size="20" name="nickname" maxlength="64" value="<%=htmltool.format(nickname)%>"><br>
<%--
  Address<br>
  <textarea name="address" cols="20" rows="3"></textarea><br>
  Phone number<br>
  <input type="text" size="20" name="phone" maxlength="64"><p>
--%>
  <center>
  <input type="submit" name="submit" value="OK"><br>

  </center>
</form>
</body>
</html>

</c:when>

<%-- ==================================================================================== --%>
<c:when test="${term == 'jphone' || term == 'jsky'}">
	
<% response.setContentType("text/html;charset="+charset); %>

<html>
<body>
Register Address
<hr>
<form action="<%=servlet%>">
  <input type="hidden" name="cmd" value="CNA">
  <input type="hidden" name="action" value="commit">
  <input type="hidden" name="id" value="<%=htmltool.format(entryID)%>">
  <input type="hidden" name="acmd" value="<%=htmltool.format(acmd)%>">

  <font color="red"><%=htmltool.format(errmsg)%></font>

  PhoneNumber<br>
  <input type="text" size="20" name="mailaddress" maxlength="15" mode="numeric" value="<%=htmltool.format(email)%>"><br>
  Nickname<br>
  <input type="text" size="20" name="nickname" maxlength="64" value="<%=htmltool.format(nickname)%>"><br>
<%--
  Address<br>
  <textarea name="address" cols="20" rows="3"></textarea><br>
  Phone number<br>
  <input type="text" size="20" name="phone" maxlength="64"><p>
--%>
  <center>
  <input type="submit" name="submit" value="OK"><br>
  </center>
</form>
</body>
</html>

</c:when>

<%-- ==================================================================================== --%>
<c:when test="${term == 'hdml'}">

<% response.setContentType("text/x-hdml;charset="+charset); %>

<HDML VERSION="3.0" TTL="1" public="true">

  <%-- メールアドレスの入力 --%>
  <ENTRY NAME="email" KEY="email" FORMAT="15N" DEFAULT="<%=htmltool.format(email)%>">
    <ACTION TYPE="ACCEPT" LABEL="Next" TASK="GOSUB" DEST="#nickname" VARS="email=$email">
    <%=htmltool.format(errmsg)%>
    PhoneNumber:
  </ENTRY>

  <%-- nicknameの入力(SMSはこれで終わり) --%>
  <ENTRY NAME="nickname" KEY="nickname" DEFAULT="<%=htmltool.format(nickname)%>">
    <ACTION TYPE="ACCEPT" LABEL="OK" TASK="GO" DEST="<%=servlet%>"
      METHOD="POST"
      POSTDATA="cmd=CNA&action=commit&id=<%=htmltool.format(entryID)%>&acmd=<%=htmltool.format(acmd)%>&nickname=$nickname&mailaddress=$email">
    <LINE>PhoneNumber:$email <br>
    Nickname:
  </ENTRY>

<%--
  <ENTRY NAME="adr" KEY="adr">
    <ACTION TYPE="ACCEPT" LABEL="Next" TASK="GOSUB" DEST="#phone" VARS="nickname=$nickname&adr=$adr">
    <LINE>E-mail:%%email%%<br>
    Nickname:$nickname<br>
    Address:
  </ENTRY>
  
  <ENTRY NAME="phone" KEY="phone">
    <ACTION TYPE="ACCEPT" LABEL="Enter" TASK="GO" DEST="%%servlet%%"
      METHOD="POST"
      POSTDATA="cmd=CNA&action=commit&id=%%id%%&acmd=%%acmd%%&nickname=$nickname&mailaddress=$email&address=$adr&phone=$phone">
    <LINE>E-mail:%%email%%<br>
    Nickname:$nickname<br>
    Address:$adr<br>
    Phone:
  </ENTRY>
--%>

</HDML>


</c:when>

<%-- ==================================================================================== --%>
<c:when test="${term == 'wml'}">
	<% response.setContentType("text/vnd.wap.wml;charset="+charset); %>

</c:when>

<%-- ==================================================================================== --%>
<c:when test="${term == 'wml_nokia'}">
	<% response.setContentType("text/vnd.wap.wml;charset="+charset); %>


</c:when>

<%-- ==================================================================================== --%>
<c:when test="${term == 'pc'}">
	<% response.setContentType("text/html;charset="+charset); %>

</c:when>

<%-- ==================================================================================== --%>
<c:when test="${term == 'palm'}">
	<% response.setContentType("text/html;charset="+charset); %>

</c:when>

<%-- ==================================================================================== --%>
<c:otherwise>
	
</c:otherwise>

<%-- ==================================================================================== --%>
</c:choose>

<!-- Copyright (c) 2000,2001 Orangesoft Inc. All Rights Reserved. -->
