<table bgcolor="#ffffff" cellpadding="5">
      #if ($msg)
      <tr>
        <td colspan="2">
          <table bgcolor="#ffffff">
            <tr>
              <td>
                $msg
              </td>
            </tr>
          </table>
        </td>
      </tr>
      #end
</table>

      #if ($mode == "delete")
      <form name="SecurityForm" method="post" action="$jslink.getPaneByName("SecurityBrowser").setAction("portlets.SecurityUpdateAction")">
      <table>
      	<tr>
      		<td colspan="2">$l10n.SECURITY_FORM_ARE_YOU_SURE_YOU_WAN_VM</td>
      	</tr>
        <tr>
            #formReadOnlyCell ("Name" "security_name" $!entry.Name)
        </tr>
      </table>
      <table border="0"  cellspacing="0" cellpadding="5" width="30%">
      <tr>
        <td>
          <input type="submit" name="eventSubmit_doDelete" value="$l10n.SECURITY_FORM_DELETE_SECURITY_ENTR_VM"/>
        </td>
      </tr>
      </table>
      </form>
      #elseif($mode == "insert")
      <form name="SecurityForm" method="post" action="$jslink.getPaneByName("SecurityForm").setAction("portlets.SecurityUpdateAction")">
      
      <table>
	<input type="hidden" name="mode" value="update"/>
        <tr>
          <td bgcolor="$!{skin.TitleBackgroundColor}">
            <b><font face="$ui.sansSerifFonts">$l10n.SECURITY_FORM_NAME_VM</font></b>
          </td>
          <td bgcolor="$!{skin.TitleBackgroundColor}">
            <font face="$ui.sansSerifFonts">
              <input type="text" size="30" name="security_name" value="$!data.user.getTemp("security_name")"/>
            </font>
          </td>
        </tr>
        <tr>
          <td bgcolor="$!{skin.TitleBackgroundColor}">
            <b><font face="$ui.sansSerifFonts">$l10n.SECURITY_FORM_TITLE_VM</font></b>
          </td>
          <td bgcolor="$!{skin.TitleBackgroundColor}">
            <font face="$ui.sansSerifFonts">
              <input type="text" size="50" name="title" value="$!data.user.getTemp("title")">
            </font>
          </td>
        </tr>
        <!--Consider making text area-->
        <tr>
	  <td bgcolor="$!{skin.TitleBackgroundColor}">
	    <b><font face="$ui.sansSerifFonts">$l10n.SECURITY_FORM_DESCRIPTION_VM</font></b>
	  </td>
	  <td bgcolor="$!{skin.TitleBackgroundColor}">
	    <font face="$ui.sansSerifFonts">
	      <textarea rows="10" cols="50" size="50" name="description">$!data.user.getTemp("description")</textarea>
	    </font>
	  </td>
	</tr>
      </table>
      <table border="0"  cellspacing="0" cellpadding="5" width="30%">
      <tr>
        <td>
          <input type="submit" name="eventSubmit_doInsert" value="$l10n.SECURITY_FORM_INSERT_SECURITY_VM"/>
        </td>
      </tr>
      </table>
      </form>
      #elseif($mode == "update")
	      <form name="SecurityForm" method="post" action="$jslink.getPaneByName("SecurityForm").setAction("portlets.SecurityUpdateAction")">
	      
	      <table>
		<input type="hidden" name="mode" value="update"/>
	        <tr>
	          #formReadOnlyCell ("Name" "security_name" $!entry.Name)
	        </tr>
	        <tr>
	          <td bgcolor="$!{skin.TitleBackgroundColor}">
	            <b><font face="$ui.sansSerifFonts">$l10n.SECURITY_FORM_TITLE_VM</font></b>
	          </td>
	          <td bgcolor="$!{skin.TitleBackgroundColor}">
	            <font face="$ui.sansSerifFonts">
	              <input type="text" size="50" name="title" value="$!entry.title">
	            </font>
	          </td>
	        </tr>
	        <!--Consider making text area-->
	        <tr>
		  <td bgcolor="$!{skin.TitleBackgroundColor}">
		    <b><font face="$ui.sansSerifFonts">$l10n.SECURITY_FORM_DESCRIPTION_VM</font></b>
		  </td>
		  <td bgcolor="$!{skin.TitleBackgroundColor}">
		    <font face="$ui.sansSerifFonts">
		      <textarea rows="10" cols="50" size="50" name="description">$!entry.description</textarea>
		    </font>
		  </td>
		</tr>
	      </table>
	      <table border="0"  cellspacing="0" cellpadding="5" width="30%">
	      <tr>
	        <td>
	          <input type="submit" name="eventSubmit_doUpdate" value="$l10n.SECURITY_FORM_UPDATE_SECURITY_VM"/>
	        </td>
	      </tr>
	      </table>
	      </form>
      
      	      <form method="post" action="$jslink.getPaneByName("SecurityForm").setAction("portlets.SecurityUpdateAction")">
      		<input type="hidden" name="mode" value="update"/>
      		<input type="hidden" name="security_name" value="$!entry.name"/>
	      <table border="1">
	        ##<th>&nbsp;</th>
	      	##<th>Action</th>
	      	##<th>Allows</th>
	      #foreach($securityAccess in $entry.getAccesses())
	      	<tr>
	      	  <td><input type="checkbox" name="access_index" value="$!velocityCount"/></td>
	      	  <td>
	      	    $securityAccess.action
	      	  </td>
	      	  
	      	  #set($allowList = $securityAccess.getOwnerAllows())
	      	  #if($allowList.size() == 0)
	      	  	#set($allowList = $securityAccess.getAllows())
	      	  #end

	      	  #if($allowList.size() == 1)
	      	  	#set($allow = $allowList.get(0))
	      	  #end
	      	  <td>
	      	  	#if($allow)
	      	  	<table>
	      	  		<tr>
	      	  			<td>#if($allow.user)User #elseif($allow.role)Role #else Owner #end</td>
	      	  			<td>#if($allow.user)$allow.user #elseif($allow.role)$allow.role #else &nbsp; #end</td>
	      	  		<tr>
	      	  	</table>
	      	  	#else
$l10n.SECURITY_FORM_NO_ALLOW_SET_VM
#end
	      	  </td>
	      	</tr>
	      #end
	      #if($entry.getAccesses().size() > 0)
	      <tr>
	        <td colspan="3"><input type="submit" name="eventSubmit_doRemoveaccess" value="$l10n.SECURITY_FORM_REMOVE_ACCESS_VM"/>
	      </tr>
	      #end
	      </table>
	      </form>
	      
	      <!--Add a new action entry-->
	      <script>
	      	
	      	var userSelect = new Array;
	      	var roleSelect = new Array;
	      	var populated = false;
	      	
	      	function populate()
	      	{	      	
		      	#foreach($user in $users)
		      	#set($myCount = $velocityCount - 1)
		      		var userOption$myCount = new Option;
		      		userOption${myCount}.value = "$user.userName";
		      		userOption${myCount}.text = "$user.userName";
		      		
		      		userSelect[$myCount] = userOption$myCount;		      		
		      	#end
		      	
		      	#foreach($role in $roles)
		      		#set($myCount = $velocityCount - 1)
		      		var roleOption$myCount = new Option;
		      		roleOption${myCount}.value = "$role.name";
		      		roleOption${myCount}.text = "$role.name";
		      		
		      		roleSelect[$myCount] = roleOption$myCount;
		      	#end
		      	
		      	populated = true;
		}
		
		
	      
	      	function changeList(selectAction)
	      	{
	      		if(!populated)
	      		{
	      			populate();
	      		}
	      		var val = selectAction.options[selectAction.selectedIndex].value;
	      		
	      		var newOpts = new Array;
	      		
	      		if(val == "user")
	      		{
	      			newOpts = userSelect;
	      		}
	      		else if(val == "role")
	      		{
	      			newOpts = roleSelect;
	      		}
	      		
	      		var select = document.NewSecurity.allow_value;
	      		
	      		for(var i=0; i<newOpts.length; i++)
	      		{
	      			select.options[i] = newOpts[i];
	      		}
	      		
	      		for(var j=newOpts.length; j<select.options.length; j++)
	      		{
	      			select.options[j] = new Option;
	      		}
	      	}
	      	
	      </script>
	      <form name="NewSecurity" method="post" action="$jslink.getPaneByName("SecurityForm").setAction("portlets.SecurityUpdateAction")">
	      <input type="hidden" name="mode" value="update"/>
	      <input type="hidden" name="security_name" value="$!entry.name"/>
	      <table>
	      	<tr>
	      	  <td>$l10n.SECURITY_FORM_ACTION_VM</td>
	      	  <td>
	      	  	<select name="access_action" >
	      	  		<option value="*">*</option>
	      	  		#foreach($permission in $permissions)
	      	  		<option value="$!permission.name" #if($data.user.getTemp("access_action") == $permission.name) selected="true" #end>$!permission.name</option>
	      	  		#end
	      	  	</select>
	      	  </td>
	      	</tr>
	      	<tr>
	      	  <td>$l10n.SECURITY_FORM_TYPE_VM</td>
	      	  <td>
	      	  	<select name="allow_type" onChange="changeList(this); return true;">
	      	  		<option value="owner">$l10n.SECURITY_FORM_OWNER_VM</option>
	      	  		<option value="user">$l10n.SECURITY_FORM_USER_VM</option>
	      	  		<option value="role">$l10n.SECURITY_FORM_ROLE_VM</option>
	      	  	</select>
	      	  </td>
	      	</tr>
	      	<tr>
	      	  <td>$l10n.SECURITY_FORM_VALUE_VM</td>
	      	  ##<td><input type="text" name="allow_value" value="$!data.parameters.getString("allow_value")"/></td>
	      	  
	      	  <td>
	      	  	<select name="allow_value">
	      	  	#*
	      	  	#foreach($user in $users)
	      	  		<option value="$user.name">$user.userName</option>
	      	  	#end
	      	  	*#
	      	  	</select>
	      	  </td>
	      	</tr>
	      	<tr>
	      	  <td><input type="submit" name="eventSubmit_doAddaccess" value="$l10n.SECURITY_FORM_ADD_SECURITY_ACCESS_VM"/>
	      	</tr>
	      </table>
	     </form>      
      #end
      
<table>
  <tr>
    <td>
  	<form name="BackToBrowserForm" method="post" action="$jslink.getPaneByName("SecurityBrowser").setAction("portlets.SecurityUpdateAction")">
  		<input type="submit" name="eventSubmit_doCancel" value="$l10n.SECURITY_FORM_BACK_TO_BROWSER_VM"/>
  	</form>
    </td>
  </tr>
</table>
