<% # encoding: utf-8 %>

	
        <div class="subnav">
					
			<%= form_for('member_select_search', :remote => true, :html => { :id => 'member_select_search', :class => 'member_select_search'}, :url => admin_member_select_member_select_search_path('member_select_search')  ) do |f| %>
					
            <div id="accordion">
                <ul class="nav nav-pills filter">
				
					<% @member_selects.each do |member_select| %>
						 
						<li class="accordion-group">
							<div class="accordion-heading">
								<a href="#<%= member_select.key -%>" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle"><%= member_select.title -%> <b class="web-symbol"></b></a>
							</div>
						</li>   
						
					<% end -%>	
					
                </ul>
                <div class="accordion-group filters">
					
					<% @member_selects.each do |member_select| %>
					
                    <div class="accordion-body collapse form-horizontal" id="<%= member_select.key -%>">
                        <div class="accordion-inner">
                            <div class="control-group">
                                <label class="control-label" for="">類別</label>
                                <div class="controls">
									
									<% member_select.sub_roles.each do |sub_role| %>
									
                                    <label class="checkbox inline">
                                        <input type="checkbox" name="member_selects[sub_role][]" value="<%= sub_role.id -%>"> <%= sub_role.title -%>
                                    </label>
									<% end %>
									
                                    <label class="checkbox inline">
                                            <a class="select-all" href="#"><i class="icon-ok"></i></a>　<a class="cancel-all" href="#"><i class="icon-remove"></i></a>
                                    </label>
                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label" for="">狀態</label>
                                <div class="controls">
									
									<% member_select.statuses.each do |status| %>
									
                                    <label class="checkbox inline">
                                        <input type="checkbox" name="member_selects[status][]" value="<%= status.id -%>"> <%= status.title -%>
                                    </label>
									
									<% end %>
									
                                    <label class="checkbox inline">
                                            <a class="select-all" href="#"><i class="icon-ok"></i></a>　<a class="cancel-all" href="#"><i class="icon-remove"></i></a>
                                    </label>
                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label">關鍵字搜尋</label>
                                <div class="controls">
                                    <input type="text" data-provide="typeahead" data-items="4" name="member_selects[keyword][<%= member_select.id -%>][]">
                                </div>
                            </div>
                        </div>
                        <div class="filter-clear">
                            <a href="#" class="btn btn-success btn-small"><i class="icon-plus"></i> Add</a>
                            <a data-toggle="modal" href="#search-results" class="btn btn-primary btn-small" data-remote="true" onclick="$('#member_select_search').submit();"><i class="icon-search"></i> Search</a>
                        </div>
                    </div>
					
					<% end %>
					
                </div>
            </div>
			
			<% end %>
			
        </div>
		
		
		<% #results %>
	
		<div id="member_select_result_add">
			
		
			<div class="clear" id="users_checkbox_ary">
				
		<div class="checkblock">
			<div class="checkbox clear checked">
				<div class="check-icon"></div>
				<div class="member-avatar">
					<img alt="Person" class="member-img" src="images/menber-pic.png">
				</div>
				<label class="member-name" for="lab-user-4f45f3b9e9d02c5db900006d">儒淵 傅</label>
				<input checked="checked" class="check" type="checkbox" value="true">
			</div>
		</div>
			</div>
			
			<div class="form-actions form-fixed pagination-right">
				<input class="btn btn-primary" name="commit" type="submit" value="Update">
			</div>
			
			
		</div>
		
		<% #results %>
		
    </div>
	
	
	
	<% #search %>
	
	<div id="member_select_result">
		<div id="search-results" class="search-results modal hide fade" tabindex="1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			<%#= render :partial => "member_select_search" %>
		</div>
	</div>
	
	
<% content_for :page_specific_javascript do %>
	 
	<%= stylesheet_link_tag "inc/permission-checkbox" %>
	<%= javascript_include_tag "inc/permission-checkbox" %>
	
	<script type="text/javascript">
	
		$("#more").click(function() {
			$("#member_select_search").submit();
		}

		$(document).ready(function(){
			$('.select-all').click(function() {
				$(this).each(function() {
					$(this).parents('label').prevAll('label').find('input').attr({checked:'checked'})
				})
			});
			$('.cancel-all').click(function() {
				$(this).each(function() {
					$(this).parents('label').prevAll('label').find('input').removeAttr('checked')
				})
			});
		});
		
	</script>

<% end %>	
	
	