{% load i18n %}
	
<script type="text/javascript">
		
	$(document).ready(function() {
		var search_url = "{% url ldt.ldt_utils.views.share_filter filter='__FILTER__' use_groups='true' %}";
		var share_this = '{% trans "share this project" %}';
		var do_not_share = '{% trans "do not share" %}';
		var share_img = '{{LDT_MEDIA_PREFIX}}img/user_add.png';
		var do_not_share_img = '{{LDT_MEDIA_PREFIX}}img/user_delete.png';
		var state = 1;
			
		if ($("#add_contribution").size()) {
			var resize_elem = $("#add_contribution");	
		} else {
			var resize_elem = $("#add_content");
		}
		
		init_multi_select_events ($("#sharelist"), $("#selectedlist"), $("#read"), $("#write"), "#searchuserinput", search_url);

		$("#shareproject").click(function () {
			if (state == 1) {
				$("#sharecontainer").show();
				$("input[id=id_share]").val('True');
				var new_img = '<img class="shareicon" src=' + do_not_share_img + '>';
				$(this).html(new_img + do_not_share);
				state = 2;
			} else {
				$("#sharecontainer").hide();
				$("input[id=id_share]").val('False');
				var new_img = '<img class="shareicon" src=' + share_img + '>';
				$(this).html(new_img + share_this);
				state = 1;
			}
			
			resize_modal_window(resize_elem);
		});
		
	});
</script>


<div id="shareproject" class="clear">
<img class="shareicon" src="{{LDT_MEDIA_PREFIX}}img/user_add.png" />{% trans "share" %}
</div>

<input type="hidden" name="share" value="False" id="id_share"/>


<div id="sharecontainer" style="display:none;">

	<div id="permissioncontainer" class="append-bottom clear">
		<div id="elemslistcontainer" clas="span-9">
			<div id="elemslistheader">
				{% trans "User list" %}<br />
				<div class="searchfield span-4"><input type="text" name="search" id="searchuserinput" class="searchfieldinput searchfieldinputbase" value="{% trans 'search' %}"/><img id="projectsajaxloader" class="searchajaxloader" src="{{LDT_MEDIA_PREFIX}}/img/ajax-loader-16x16.gif" alt="loader"/><img id="projecsclear" class="searchclear" src="{{LDT_MEDIA_PREFIX}}img/clear-left.png"/></div>
			</div><br /><br />
			<select multiple="multiple" id="sharelist">
				{% include "ldt/ldt_utils/partial/sharewith.html" %}
			</select>
			<div id="elemslistfooter">
				<a href="#" id="selectall" title="{% trans "select all" %}">{% trans "select all" %}</a>
			</div>
		</div>
		
		<div id="selectors">
			<a href="#" id="selectelems"><img src="{{LDT_MEDIA_PREFIX}}img/to-right.gif" title="{% trans "select users" %}"></a><br />
			<a href="#" id="removeelems"><img src="{{LDT_MEDIA_PREFIX}}img/to-left.gif" title="{% trans "remove users" %}"></a>
		</div>
	
		<div id="selectedlistcontainer" class="span-9 last">
			<div id="selectedlistheader" >
				{% trans "Members list" %}
			</div>
			<select multiple="multiple" id="selectedlist" >
				{% for elem in member_list %}
					<option value="{{ elem.id }}-{{elem.type}}" {% if elem.change %}style="color: #2181B1;"{% endif %}>{{ elem.name }}</option>
				{% endfor %}
			</select>
			<div id="selectedlistfooter" class="span-6" >
				<a href="#" id="removeall" title="{% trans "remove all" %}">{% trans "remove all" %}</a>
				| <a href="#" id="chooseaux" title="{% trans "Decide whether a user user can change this group" %}">{% trans "can change" %}</a>
				| <a href="#" id="removeaux">{% trans "can not change" %}</a>
			</div>	
		</div>
		
		<div id="read">
		{% for elem in member_list %}
			<input type="hidden" value="{{ elem.id }}-{{ elem.type }}" name="read_list"/>
		{% endfor %}
		</div>
		
		<div id="write">
		{% for elem in admin_list %}
			<input type="hidden" value="{{ elem.id }}-{{ elem.type }}" name="write_list"/>
		{% endfor %}
		</div>
	</div> 

</div>
	
