<% @pageName = @myView == "resource" ? "Resource" : "Fence Device" %>
<tr id="<%=@myView%>_title_row" {{bindAttr style="Pcs.<%=@myView%>_page"}}><td id="page_header" colspan=3>
<%= @myView == "resource" ? "RESOURCES" : "FENCE DEVICES" %>
    </td>
  </tr>
  <tr id="<%=@myView%>_header_row" {{bindAttr style="Pcs.<%=@myView%>_page"}}>
    <td id="remove_add" class="borderbottom">
      <div class="x sprites"><a href="#" class="x sprites"></a></div><div class=link">&nbsp;
	<% if @myView == "resource" %>
	  <a href="#" onclick='verify_remove("resource");return false;'>
	<% else %>
	  <a href="#" onclick='verify_remove("stonith");return false;'>
	<% end %>
      Remove</a>&nbsp;&nbsp;&nbsp;&nbsp;</div>
  <div class="plus sprites"></div><div class="link">&nbsp;
    <% if @myView == "resource" %>
      <a href="#" onclick="$('#add_resource').dialog({title: 'Add Resource', modal:true, width: 'auto'});return false;">
    <% else %>
      <a href="#" onclick="$('#add_stonith').dialog({title: 'Add Fence Device', modal:true, width: 'auto'});return false;">
    <% end %>
  Add</a>&nbsp;&nbsp;&nbsp;&nbsp;</div>
    <% if @myView == "resource" %>
      <div class="plus sprites"></div><div class="link">&nbsp;<a href="#" onclick="create_group();return false;">Create Group</a></div>
    <% end %>
    </td>
    <td class="borderbottom">&nbsp;</td>
    <td id="tab_name" width="125">
      <div style="float: left">&nbsp;Edit <%= @pageName%>&nbsp;</div><div class="check sprites"></div>
    </td>
  </tr>
  <tr id="<%=@myView%>_list_row" {{bindAttr style="Pcs.<%=@myView%>_page"}}>
    <td id="<%=@myView%>_list" class="node_list">
      <%= erb :_resource_list %>
    </td>
	<td id="node_info" colspan=2>
	  <div id="<%=@myView%>_info_div" style="opacity: 0;">
	  <div id="test">
	    <div id="node_info_header">
	      <div id="<%=@myView%>_info_header_title" class="node_info_header_title" >Edit <%= @pageName %>&nbsp;</div>
	      <div id="node_info_header_title_name">
		{{Pcs.resourcesController.cur_resource.name}}
	      </div>
	      <div>
{{#if Pcs.resourcesController.cur_resource.group}}
 &nbsp;({{Pcs.resourcesController.cur_resource.group}})
{{/if}}
	      </div>
	    </div>

	    <div id="node_sub_info">
	      <table>
		<tr>
		  <td><input disabled style="margin-right: 50px;" type="text" {{bindAttr value="Pcs.resourcesController.cur_resource.name"}} size="35" class="text_field"></td>
		  <td><div style="margin-right: 8px;" class="check sprites"></div></td>
		  <td>
		  {{#if Pcs.resourcesController.cur_resource.failed}}
		    <div id="res_status" class="status-offline">Failed</div>
                  {{else}}
		  {{#if Pcs.resourcesController.cur_resource.active}}
		    <div id="res_status" class="status">Running
		      {{#if Pcs.resourcesController.cur_resource.disabled}}
		        (Disabled)
		      {{/if}}
		    </div>
		  {{else}}
		    <div id="res_status" class="status-offline">
		      Inactive
		      {{#if Pcs.resourcesController.cur_resource.disabled}}
		        (Disabled)
		      {{/if}}
		     </div>
		  {{/if}}
		  {{/if}}
		  </td>
		</tr>
	      </table>
	    </div>

	    <div id="node_options_buttons">
	      <% if @myView == "resource" %>
		<div class="checkdark sprites" style="float: left"></div>
		<div id="resource_start_link" class="link">Enable</div>
		<div class="cancel sprites" style="float: left"></div>
		<div id="resource_stop_link" class="link">Disable</div>
		<div class="restart sprites" style="float: left"></div>
		<div id="resource_cleanup_link" class="link">Cleanup</div>
		<div class="xdark sprites" style="float: left"></div>
		<div id="resource_delete_link" class="link">Remove</div>
	      <% else %>
		<div class="xdark sprites" style="float: left"></div>
		<div id="stonith_delete_link" class="link">Remove</div>
		<div class="restart sprites" style="float: left"></div>
		<div id="stonith_cleanup_link" class="link">Cleanup</div>
	      <% end %>
	      <!--
	      <div class="move sprites" style="float: left"></div>
	      <div id="resource_move_link" class="link">Move</div>
	      <div class="history sprites" style="float: left"></div>
	      <div id="resource_history_link" class="link">History</div>
	      -->
	    </div>

	    <div id="node_details">
	      <table style="margin-bottom:25px;"><tr>
		  <td nowrap><div class="bold">Current Location:</div></td>
		  <td><div id="cur_res_loc" class="reg">
			{{Pcs.resourcesController.cur_resource.nodes}}
		  </div> </td>
		</tr>
	      </table>
	      <% if @myView == "resource" %>
	      <table style="clear:left;float:left">
		<tr><td style="display: block;" onclick="show_hide_constraints(this)" class="datatable_header hover-pointer">Resource Location Preferences ({{Pcs.resourcesController.cur_resource.location_constraints.length}}{{#unless Pcs.resourcesController.cur_resource.location_constraints.length}}0{{/unless}})<span style="" class="downarrow sprites"></span><span style="display: none;" class="rightarrow sprites"></span></td></tr>
		<tr><td>
		    <div id="locationdep">
		      <table class="datatable">
			<tr><th>Node</th><th>Score</th><th>Remove</th></tr>
			{{#each Pcs.resourcesController.cur_resource.location_constraints}}
			<tr>
			  <td>{{node}}</td>
			  <td>{{score}}</td>
			  <td {{bindAttr constraint_id="id"}} style="text-align:center">
			    {{#unless temp}}
				<a onclick="remove_constraint($(this).parent().attr('constraint_id'));return false;" href="#" class="remove">X</a>
			    {{/unless}}
			  </td>
			</tr>
		        {{/each}}
                        {{#unless Pcs.resourcesController.cur_resource.location_constraints}}
			<tr><td style="color: gray;">NONE</td><td></td><td></td></tr>
		        {{/unless}}
			<tr id="new_res_loc">
			  <td><input type="text" name="node_id"></td>
			  <td><input type="text" name="score" size="5"></td>
			  <td><button type="button" onclick="add_constraint('#new_res_loc','loc');" name="add">Add</button></td>
			</tr>
		      </table>
		    </div>
		  </td>
		</tr>
	      </table>
	      <table style="clear:left;float:left;">
		<tr><td style="display: block;" onclick="show_hide_constraints(this)" class="datatable_header hover-pointer">Resource Ordering Preferences ({{Pcs.resourcesController.cur_resource.ordering_constraints.length}}{{#unless Pcs.resourcesController.cur_resource.ordering_constraints.length}}0{{/unless}})<span style="" class="downarrow sprites"></span><span style="display: none;" class="rightarrow sprites"></span></td></tr>
		<tr><td>
		    <div id="locationdep">
		      <table class="datatable">
			<tr><th>Resource</th><th>Before/After</th><th>Score</th><th>Remove</th></tr>
		        {{#each Pcs.resourcesController.cur_resource.ordering_constraints}}	
			  <tr><td>{{other_rsc}}</td>
			    {{#if before}}
			    <td>Starts before {{then}}</td>
			    {{else}}
			    <td>Starts after {{first}}</td>
			    {{/if}}

			    <td>{{score}}</td>
			    <td {{bindAttr constraint_id="id"}} style="text-align:center">
				  <a onclick="remove_constraint($(this).parent().attr('constraint_id'));return false;" href="#" class="remove">X</a>
			    </td>
			  </tr>
 			{{/each}}
			{{#unless Pcs.resourcesController.cur_resource.ordering_constraints}}
			  <tr><td style="color: gray;">NONE</td><td></td><td></td><td></td></tr>
			{{/unless}}
			<tr id="new_res_orc">
			  <td><input type="text" name="target_res_id"></td>
			  <td><select name="order"><option value="after">After<option value="before">Before</select></td>
			  <td><input type="text" name="score" size="5"></td>
			  <td><button type="button" onclick="add_constraint('#new_res_orc','ord');" name="add">Add</button></td>
			</tr>
		      </table>
		    </div>
		  </td>
		</tr>
	      </table>
	      <table style="clear:left;float:left">
		<tr><td onclick="show_hide_constraints(this)" class="datatable_header hover-pointer">Resource Colocation Preferences ({{Pcs.resourcesController.cur_resource.colocation_constraints.length}}{{#unless Pcs.resourcesController.cur_resource.colocation_constraints.length}}0{{/unless}})<span style="" class="downarrow sprites"></span><span style="display: none;" class="rightarrow sprites"></span></td></tr>
		<tr><td>
		    <div id="locationdep">
		      <table class="datatable">
			<tr><th>Resource</th><th>Together/Apart</th><th>Score</th><th>Remove</th></tr>
			{{#each Pcs.resourcesController.cur_resource.colocation_constraints}}
			  <tr><td>{{other_rsc}}</td>
			    <td>{{together}}</td>
			    <td>{{score}}</td>
			    <td {{bindAttr constraint_id="id"}} style="text-align:center">
				  <a onclick="remove_constraint($(this).parent().attr('constraint_id'));return false;" href="#" class="remove">X</a>
			    </td>
			  </tr>
                        {{/each}}
 			{{#unless Pcs.resourcesController.cur_resource.colocation_constraints}}
			  <tr><td style="color: gray;">NONE</td><td></td><td></td><td></td></tr>
 			{{/unless}}
			<tr id="new_res_col">
			  <td><input type="text" name="target_res_id"></td>
			  <td><select name="colocate"><option value="together">Together<option value="apart">Apart</select></td>
			  <td><input type="text" name="score" size="5"></td>
			  <td><button type="button" onclick="add_constraint('#new_res_col','col');" name="add">Add</button></td>
			</tr>

		      </table>
		    </div>
		  </td>
		</tr>
	      </table>
	    </div>
	  <% end %>

	    <table style="clear:left;float:left;margin-top:25px;">
	      <% if @myView == "resource" and false %>
	      <tr>
		<td class="bold">Class:</td>
		<td class="reg">
		{{Pcs.resourcesController.cur_resource.res_class}}
		</td>
		<td style="padding-left:10px;" class="bold">Provider:</td>
		<td class="reg">
		{{Pcs.resourcesController.cur_resource.res_provider}}
		</td>
	      </tr>
	      <% end %>
	      <tr>
		<td class="bold">Type:</td>
		<td class="reg">
		{{Pcs.resourcesController.cur_resource.agentname}}
		</td>
	      </tr>
	    </table>

	    <% if @myView == "resource" %>
	      <div style="clear:left;" id="resource_agent_form"></div>
	    <% else %>
	      <div style="clear:left;" id="stonith_agent_form"></div>
	    <% end %>
	    {{#if Pcs.resourcesController.no_resources}}
	      <span id="node_info_header"><span id="node_info_header_title">No resources have been configured</span></span>
	     {{/if}}
	    </div>
	  </td>
	</tr>
    <% if @myView == "resource" %>
      </div>
    </table>
    <div id="add_resource" style="display: none;">
      <table id="resource_selector" style="clear:left;float:left;margin-top:25px;">
	<tr>
	  <td class="bold">Class/Provider</td>
	  <td>
	    <%
	      class_providers = []
	      @resource_agents.keys.each {|k|
		class_providers << k[0,k.rindex(':')]
	      }
	      class_providers.uniq!
	      class_providers.sort!
	    %>
	    <select id="resource_class_provider_selector">
	      <% class_providers.each {|cp| %>
		<option <%= "selected" if cp == "ocf:heartbeat" %> value="<%=cp%>"><%=cp%></option>
	      <% } %>
	    </select>
	  </td>
	</tr>
	<tr>
	  <td class="bold">Type</td>
	  <td>
	    <select id="all_ra_types" style="display:none;">
	      <% @resource_agents.keys.sort_by{|a|a.downcase}.each { |key| %>
		<option width=250px  value="<%=key%>"><%=key[(key.rindex(':')+1)..-1]%></option>
	      <% } %>
	    </select>
	    <select id="add_ra_type" onchange="load_resource_form($('#new_resource_agent'), this.value);">
	      <% @resource_agents.keys.sort_by{|a|a.downcase}.each { |key| %>
		<option width=250px <%= key == "ocf::heartbeat:IPaddr2" ? "selected" : "" %> value="<%=key%>"><%=key%></option>
	      <% } %>
	    </select>
	  </td>
	</tr>
      </table>
      <div id="new_resource_agent">
      </div>
    </div>
    <div id="add_stonith" style="display: none;">
      <table id="stonith_selector" style="clear:left;float:left;margin-top:25px;">
	<tr>
	  <td class="bold">Type</td>
	  <td>
	    <select id="add_stonith_type" onchange="load_resource_form($('#new_stonith_agent'),this.value,true);">
	      <% @stonith_agents.keys.sort_by{|a|a.downcase}.each { |name| %>
		<option width=250px <%= @stonith_agents[name]["type"] == "fence_apc" ? "selected" : "" %> value="<%=@stonith_agents[name]["type"]%>"><%=@stonith_agents[name]["type"]%></option>
	    <% } %>
	    </select>
	  </td>
	</tr>
      </table>
      <div id="new_stonith_agent">
      </div>
    </div>
    <div id="add_group" style="display: none;">
      <form method=POST onkeypress="if (event.keyCode == 13) {$(this).parent().parent().find('.ui-dialog-buttonpane button:eq(1)').trigger('click');return false;} " action="/resource_group_add">
	<p style="font-size:12px;">Group Name:</p><input name="resource_group" type=text>
	<input id="resources_to_add_to_group"  type=hidden name="resources" value="">
      </form>
    </div>
    <div id="verify_remove" style="display: none;">
      <p style="font-size:12px;">Are you sure you want to remove the following resource(s)?</p>
      <span id="resource_to_remove"></span>
    </div>
    <% end %>
