<% if @fenceagent %>
<div id="resource_agent_<%=@fenceagent.name%>">
  <form method=POST action="/update_fence_device">
    <table style="clear:left; float:left; margin-top: 25px;">
      <tr>
        <td><div class="bold">Description:</div></td>
        <td><span class="reg" style="float:left;"><%=h(@fenceagent.short_desc)%>&nbsp;</span>&nbsp;<span title="<%=nl2br(h(@fenceagent.long_desc))%>" onclick="$(this).closest('table').find('.long_desc_div').toggle();" class="infoicon sprites" style="margin-top:2px;"></span></td>
      </tr>
      <tr>
        <td></td>
        <td><div class="long_desc_div reg" style="display:none; font-size:12px; max-width:350px;"><%= nl2br(h(@fenceagent.long_desc))%></div></td>
      </tr>
      <% if @new_fenceagent %>
	<tr>
	  <td class="reg">
	    Fence Instance Name
	  </td>
	  <td>
	    <input style="margin-right: 50px;" type="text" name="name" size="35" class="text_field">
	  </td>
	</tr>
      <% end %>

      <% if @existing_resource %>
	<input type="hidden" name="resource_id" value="<%=@cur_resource.id%>">
      <% end %>

      <input type="hidden" name="resource_type" value="<%=@fenceagent.name%>">
      <% @fenceagent.required_options.each { |name, desc|  %>
	<tr title="<%=h(desc[1])%>">
	  <td class="reg">
	    &nbsp;<%= name %>
	  </td>
	  <td>
	    <input placeholder="<%=desc[0]%>" style="margin-right: 50px;" type="text" name="<%= @cur_resource && @cur_resource.instance_attr[name] ? "_res_paramne_" : "_res_paramempty_"%><%=name%>" value="<%=h(@cur_resource.instance_attr[name].value) if (@existing_resource and @cur_resource and @cur_resource.instance_attr[name])%>" size="35" class="text_field">
	  </td>
	</tr>
      <% } %>
      <tr>
	<td id="<%= @new_fenceagent ? "optional_fenceargs_new" : "optional_fenceargs_existing" %>" class="reg" onclick="show_hide_constraints(this)" colspan=2>
	  <span class="rightarrow sprites"></span><span class="downarrow sprites" style="display: none;"></span>
	  <div class="bold">Optional Arguments:</div>
	</td>
      </tr>
      <% @fenceagent.optional_options.each { |name, desc|  %>
	<tr style="display: none;">
	  <td class="reg">
	    &nbsp;<%= name %>
	  </td>
	  <td>
            <input placeholder="<%=desc[0]%>" style="margin-right: 50px;" type="text" name="<%= @cur_resource && @cur_resource.instance_attr[name] ? "_res_paramne_" : "_res_paramempty_"%><%=name%>" value="<%=h(@cur_resource.instance_attr[name].value) if @existing_resource and @cur_resource and @cur_resource.instance_attr[name]%>" size="35" class="text_field">
	  </td>
	</tr>
      <% } %>
      <tr class="stop">
    <td id="<%= @new_fenceagent ? "advanced_fenceargs_new" : "advanced_fenceargs_existing" %>" class="reg" onclick="show_hide_constraints(this)" colspan=2>
      <span class="rightarrow sprites"></span><span class="downarrow sprites" style="display: none;"></span>
      <div class="bold">Advanced Arguments:</div>
    </td>
      </tr>
      <% @fenceagent.advanced_options.each { |name, desc|  %>
    <tr style="display: none;">
      <td class="reg">
        &nbsp;<%= name %>
      </td>
      <td>
            <input placeholder="<%=desc[0]%>" style="margin-right: 50px;" type="text" name="<%= @cur_resource && @cur_resource.instance_attr[name] ? "_res_paramne_" : "_res_paramempty_"%><%=name%>" value="<%=h(@cur_resource.instance_attr[name].value) if @existing_resource and @cur_resource and @cur_resource.instance_attr[name]%>" size="35" class="text_field">
      </td>
    </tr>
      <% } %>
      <tr class="stop"><td class="center" style="padding-top:20px;" colspan=2>
	  <input type=submit class="text_field apply_changes" onclick="$(this).hide();create_resource($(this).parents('form'),<%=@existing_resource ? 'true':'false'%>,true); return false;" value="<%= @existing_resource ? "Apply Changes" : "Create Fence Instance" %>">
	</td>
      </tr>
    </table>
  </form>
</div>
<% end %>
