<div class="contextual">
<%= link_to_function(l(:button_add), "$('new-watcher-form').toggle();") if User.current.allowed_to?("add_#{watched.class.name.underscore}_watchers".to_sym, @project) %>
</div>

<h3><%= l(:label_issue_watchers) %> (<%= watched.watcher_users.size %>)</h3>

<% if User.current.allowed_to?("add_#{watched.class.name.underscore}_watchers".to_sym, @project) %>
	<% remote_form_for(:watcher, @watcher, 
                	   :url => {:controller => 'watchers',
              	              :action => 'new',
            	                :object_type => watched.class.name.underscore,
         	                    :object_id => watched},
       	             :method => :post,
      	             :html => {:id => 'new-watcher-form', :style => 'display:none;'}) do |f| %>
    <% users = Principal.active.find(:all, :limit => 25) - watched.watcher_users %>
		<p><%= label_tag "user_search", l(:label_user_search) %><%= text_field_tag 'user_search', nil, :style => "width:98%;" %></p>
		<%= observe_field(:user_search,
                 :frequency => 0.5,
                 :update => :users,
                 :url => auto_complete_users_path(:remove_watchers => watched.id, :klass => watched.class, :include_groups => true),
                 :with => 'q')
                  %>
		
		<div id="users">
			<%= principals_check_box_tags 'user_ids[]', users %>
		</div>

		<p><%= submit_tag l(:button_add) %>
		<%= toggle_link l(:button_cancel), 'new-watcher-form'%></p>
	<% end %>
<% end %>

<%= watchers_list(watched) %>
