<%@ page errorPage="errorPage.jsp" language="java" session="true" contentType="text/html;charset=ISO-8859-2" %>
<%@ page pageEncoding="UTF-8"%>
<%@ page import="com.etixpert.evolution.gui.servlets.*"%>
<%@ page import="java.util.*"%>
<%@ include file="header.jsp" %>
<%@ include file="check.jsp" %>
<%!
public String getCountryPostCodeOptions(HttpSession session) throws Exception{
	StringBuffer sb = new StringBuffer("");
	Country[] countries = FormHelperC.getCountries();

	for (int i = 0; i < countries.length; i++) {
		String selected="";
		if (getVal("country_post_code", session).equals(countries[i].country_post_code)) selected=" selected";
		sb.append("<option"+selected+" value=\""+ countries[i].country_post_code + "\">"+countries[i].country_post_code+"</option>");
	}
	return sb.toString();
}

public String getVal(String name, HttpSession session) {
	Map m = (Map)session.getAttribute("interessent_detail_address.jsp");
	if (m == null) return "";
	String[] vals = (String[])m.get(name);
	if (vals != null && vals.length>0 && vals[0] != null) return vals[0];
	return "";
}
public String getRadioChecked(String name,String value, HttpSession session) {
	Map m = (Map)session.getAttribute("interessent_detail_address.jsp");
	if (m == null) {
		if (value.equals("1")) return " checked";
		else return "";
	}
	String[] vals = (String[])m.get(name);
	if (vals != null && vals.length>0 && vals[0] != null)
		if (value.equals(vals[0]))
			return " checked";
	if (vals==null || vals.length==0) if (value.equals("1")) return " checked";
	return "";
}
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
<link href="main.css" rel="stylesheet" type="text/css">
<SCRIPT LANGUAGE="JavaScript">
<!-- JavaScript code hiding
	function changeSel(which){
		window = open("leftMenu.jsp?sel="+which, "_self", "");
	}

	function simpleLink(origLink) {
		parent.mainFrame.location = origLink;
	}


	function link(origLink){
		if (top.mainFrame.document.forms.length == 0) {
			simpleLink(origLink);
			return;
		}
		else {
			if (top.mainFrame.document.forms[0].saveState == null) {
				simpleLink(origLink);
				return;
			}
			top.mainFrame.document.forms[0].saveState.value = top.mainFrame.self.location.pathname;
			top.mainFrame.document.forms[0].link.value = origLink;
			top.mainFrame.document.forms[0].submit();
		}
	}
// -->
</SCRIPT>
</head>
<%
	boolean admin = false;
	boolean distributor = false;
	boolean customer = false;
	if	(session.getAttribute("admin")!=null) admin = true;
	if	(session.getAttribute("customer")!=null) customer = true;
		if	(session.getAttribute("distributor")!=null) distributor = true;
%>
<body bgcolor="#e6eee6">
<div width="800" height="30" align="left" class="menu"><%=FormHelperC.generateInteressentDataHeaderString(pageContext)%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="menu" href="process/interessent_selection.jsp">Anderen Interessent auswählen</a></div>
<table border="1" id="userTable" class="menu">
<jsp:include page="MenuHelper.jsp">
	<jsp:param name="self_id" value="2720"/>
	<jsp:param name="parent_id" value="2700"/>	
</jsp:include>
</table>

<form action="process/interessent_detail_address.jsp" method="post">
<input type="hidden" name="saveState"/>
<input type="hidden" name="pageAction"/>
<input type="hidden" name="link" value="process/interessent_detail_address.jsp"/>
<input type="hidden" name="row"/>
  <table width="800" border="0" cellpadding="0" cellspacing="0" id="userDetailsTable" class="normal">
    <!--DWLayoutTable-->
    <tr>
      <td width="202" height="30" valign="top" id="userTableContentTitles"><!--DWLayoutEmptyCell-->&nbsp;</td>
      <td width="40">&nbsp;</td>
      <td width="558" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
    </tr>
    <tr>
      <td height="30" valign="top" id="userTableContentTitles"><fmt:message key="ADDRESS_TYPE"/>:</td>
      <td>&nbsp;</td>
      <td valign="top" id="userTableContentFields"><input<%=getRadioChecked("address_type","1", session)%> name="address_type" type="radio" value="1" class="checkbox"/>
        <fmt:message key="TYPE_PRIVAT"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input<%=getRadioChecked("address_type","0", session)%> type="radio" name="address_type" value="0" class="checkbox"/>
        <fmt:message key="TYPE_FIRMA"/></td>
    </tr>
    <tr>
      <td height="30" valign="top" id="userTableContentTitles"><fmt:message key="COUNTRY_POST_CODE"/>:</td>
      <td>&nbsp;</td>
      <td valign="top" id="userTableContentFields"><select name="country_post_code"><%=getCountryPostCodeOptions(session)%>
        </select></td>
    </tr>
    <tr>
      <td height="30" valign="top" id="userTableContentTitles"><fmt:message key="PLZ"/>:</td>
      <td>&nbsp;</td>
      <td valign="top" id="userTableContentFields"><input maxlength="8" id="little" type="text" name="postcode" value="<%=getVal("postcode", session)%>"></td>
    </tr>
    <tr>
      <td height="30" valign="top" id="userTableContentTitles"><fmt:message key="CITY"/>:</td>
      <td>&nbsp;</td>
      <td valign="top" id="userTableContentFields"><input maxlength="50" id="comment" type="text" name="city" value="<%=getVal("city", session)%>"></td>
    </tr>
    <tr>
      <td height="30" valign="top" id="userTableContentTitles"><fmt:message key="STREET"/>:</td>
      <td>&nbsp;</td>
      <td valign="top" id="userTableContentFields"><input type="text" id="comment" maxlength="50" name="street" value="<%=getVal("street", session)%>"></td>
    </tr>
    <tr>
      <td height="30" valign="top" id="userTableContentTitles"><fmt:message key="SHIPPING_NAME"/>:</td>
      <td>&nbsp;</td>
      <td valign="top" id="userTableContentFields"><input type="text" id="comment" maxlength="50" name="delivery_name" value="<%=getVal("delivery_name", session)%>"></td>
    </tr>
    <tr>
      <td height="30" valign="top" id="userTableContentTitles"><fmt:message key="COMMENT"/>:</td>
      <td>&nbsp;</td>
      <td valign="top" id="userTableContentFields"><textarea rows="3" id="comment" name="comment"><%=getVal("comment", session)%></textarea></td>
    </tr>
    <tr>
      <td height="30" valign="top" id="userTableContentTitles">&nbsp;</td>
      <td>&nbsp;</td>
      <td valign="top" id="userTableContentFields"><a href="javascript:top.mainFrame.document.forms[0].pageAction.value = 'interessent_add_new_address'; link('process/interessent_detail_address.jsp');">
      <%=FormHelperC.underMod(session, "interessent_addresses")?"Modifikation übernehmen":"Hinzufügen"%>
      </a></td>
    </tr>
    <tr>
      <td height="43">&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </table>
<div class="sortable" id="1" style="margin-left: 10px;">
    <table width="800px" id="mainTable">
      <col width="40"><col width="40"><col width="60"><col width="60"><col width="60"><col width="170"><col width="70"><col width="120"><col width="180">
      <tr>
      <td id="accountTableHeaderContent"><fmt:message key="M"/></td>
      <td id="accountTableHeaderContent"><fmt:message key="L"/></td>
	  <td id="accountTableHeaderContent"><fmt:message key="RECH_ADR"/></td>
      <td id="accountTableHeaderContent"><fmt:message key="LIEF_ADR"/></td>
      <td id="accountTableHeaderContent"><fmt:message key="COUNTRY"/></td>
      <td id="accountTableHeaderContent"><fmt:message key="ADDRESS"/></td>
      <td id="accountTableHeaderContent"><fmt:message key="ART"/></td>
      <td id="accountTableHeaderContent"><fmt:message key="SHIPPING_NAME"/></td>
      <td id="accountTableHeaderContent"><fmt:message key="COMMENT"/></td>
</tr>
</table>
<DIV STYLE="overflow: auto; width: 820px; height: 200px;
            border-left: 0px gray solid; border-bottom: 0px gray solid;
            padding:0px; margin: 0px;">
      <table border="0" cellpadding="0" cellspacing="0" width="800px" class="sortable" id="mainTable">
      <col width="40"><col width="40"><col width="60"><col width="60"><col width="60"><col width="170"><col width="70"><col width="120"><col width="180">
 <%=com.etixpert.evolution.gui.servlets.FormHelperC.generateInteressentAddressTableRows(session, "interessent_addresses")%>
</table>
</DIV></DIV>
</form>
</body>
</html>
