<% if @fenceagent %>
<div id="resource_agent_<%=@fenceagent.name%>">
  <form method=POST action="/update_fence_device">
    <table style="clear:left; float:left; margin-top: 25px;">
      <% 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>
	  <td class="reg">
	    &nbsp;<%= name %>
	  </td>
	  <td>
	    <input style="margin-right: 50px;" type="text" name="<%= @cur_resource && @cur_resource.options[name] ? "_res_paramne_" : "_res_paramempty_"%><%=name%>" value="<%=@cur_resource.options[name] if (@existing_resource and @cur_resource and @cur_resource.options)%>" size="35" class="text_field">
	  </td>
	</tr>
      <% } %>
      <tr>
	<td class="reg" onclick="show_hide_constraints(this)">
	  <span class="rightarrow sprites"></span><span class="downarrow sprites" style="display: none;"></span></td>
	<td class="reg">
	  Optional Arguments
	</td>
      </tr>
      <% @fenceagent.optional_options.each { |name, desc|  %>
	<tr style="display: none;">
	  <td class="reg">
	    &nbsp;<%= name %>
	  </td>
	  <td>
	    <input style="margin-right: 50px;" type="text" name="<%= @cur_resource && @cur_resource.options[name] ? "_res_paramne_" : "_res_paramempty_"%><%=name%>" value="<%=@cur_resource.options[name] if @existing_resource and @cur_resource and @cur_resource.options%>" 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 %>
