<%
 import java.util.Calendar;
 import java.text.SimpleDateFormat;
 import org.exoplatform.ecm.utils.text.Text;
 private String getTimestampName() {
  Calendar now = Calendar.getInstance();
  SimpleDateFormat formatter = new SimpleDateFormat("yyyy.MM.dd '-' hh'h'mm'm'ss");
  return formatter.format(now.getTime());
 }
 String timestampName = Text.convertJcrChars(getTimestampName());
 def name = _ctx.appRes("Contact.dialog.label.Name");
 def email = _ctx.appRes("Contact.dialog.label.Email");
 def phone = _ctx.appRes("Contact.dialog.label.Phone");
 def message = _ctx.appRes("Contact.dialog.label.Message");
 def isFCCPortlet = false;
 if(uiform.getParent().getId().equals("UIFCCPortlet")) {
   isFCCPortlet = true;
   uiform.setId("FCC_Contact");
 }
%>

<div class="grid_6">
  <div id="contact-form" class="contact-form">

<% uiform.begin() %>
<%/* start render action*/%>
		<% if (!isFCCPortlet) {
			 uiform.processRenderAction()
		   }
		%>

		<%/* end render action*/%>

    <div class="box-module">
      <div class="control-group" style="display:none;">
        <label class="control-label"><%=_ctx.appRes("FormGenerator.dialog.label.Date")%></label>
        <div class="controls">
          $timestampName
          <div style="display:none;">
            <%
             String[] fieldName = ["jcrPath=/node", "mixintype=mix:i18n", "editable=if-null", "validate=empty", timestampName] ;
             uicomponent.addTextField("name", fieldName) ;
            %>
          </div>
        </div>
      </div>
    </div>
      <label class="name">
      <%
      String[] fullName = ["jcrPath=/node/exo:name", "defaultValues=", "validate=empty,name", ""];
      uicomponent.addTextField("fullName", fullName);
     %>

    </label>
    <label class="email">
    <%
    String[] emailAddr = ["jcrPath=/node/exo:email", "defaultValues=", "validate=empty,email", ""];
    uicomponent.addTextField("emailContact", emailAddr);
   %>
  </label>
  <label class="phone">
  <%
  String[] phoneNumber = ["jcrPath=/node/exo:phone", "defaultValues=", ""];
  uicomponent.addTextField("phoneNumber", phoneNumber);
 %>
</label>
<label class="message">
<%
String[] messages = ["jcrPath=/node/exo:message", "defaultValues=", "validate=empty",""];
uicomponent.addTextAreaField("messages", messages);
%>
</label>
    <%
     if(isFCCPortlet) {
     %>
     <div >
     <%
       for(action in uicomponent.getActions()) {
         String actionLabel = _ctx.appRes(uicomponent.getName() + ".action." + action);
         if(actionLabel.equals("Submit")) actionLabel = "SEND";
         String link = uicomponent.event(action);                  %>
            <button type="button" href="javascript:void(0);" onclick="$link" class="btn">$actionLabel</button>
    <%
       }
       %>
         </div>
       <%
     }
    %>
<% uiform.end() %>
  </div>
</div>
<script type="text/javascript">
  document.getElementById("fullName").setAttribute("placeholder", "$name");
  document.getElementById("emailContact").setAttribute("placeholder", "$email");
  document.getElementById("phoneNumber").setAttribute("placeholder", "$phone");
  document.getElementById("messages").setAttribute("placeholder", "$message");
</script>
