{% extends "polemictweet_base.html" %}
{% load i18n %}
{% load thumbnail %}

	{% block js_import %}
		<script type="text/javascript" src="{{STATIC_URL}}js/tiny_mce/tiny_mce.js"></script>
		<script type="text/javascript" src="{{STATIC_URL}}js/jquery.min.js"></script>
		<script type="text/javascript" src="{{STATIC_URL}}js/jquery.qtip.min.js"></script>
		<script type="text/javascript" src="{{STATIC_URL}}js/jquery.formset.js"></script>
		<script type="text/javascript" src="{{STATIC_URL}}js/create_group.js"></script>
	{% endblock %}
	{% block js_declaration %}
		
	<script type="text/javascript">
	
	var $j = jQuery.noConflict(); 

	// the function stopRKey prevents from the validation of the form if the user tape enter button while entering a field 
	function stopRKey(evt) {
	      var evt = (evt) ? evt : ((event) ? event : null);
	      var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
	      if ((evt.keyCode == 13) && (node.type=="text"))  {return false;}
	    }
	
	tinyMCE.init({
	    mode: "textareas",
	    theme: "advanced",
        plugins : "autolink,lists,spellchecker,layer,table,save,advhr,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras",
	
     	theme_advanced_buttons1 : "save,newdocument,bold,italic,underline,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,formatselect,fontselect,fontsizeselect",
        theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,search,replace,bullist,numlist,outdent,indent,blockquote,undo,redo,link,unlink,anchor,cleanup,help,code,insertdate,inserttime,preview,forecolor,backcolor",
        theme_advanced_buttons3 : "tablecontrols,hr,removeformat,visualaid,sub,sup,charmap,emotions,iespell,advhr,ltr,rtl,fullscreen",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_statusbar_location : "bottom",
        theme_advanced_resizing : true,
	});
	
	$j(document).ready(function(){
		init_events()
    });

	document.onkeypress = stopRKey;
	
	</script>	
	{% endblock %}

	{% block content %}
	{{ event_form.errors }}
    
	<div id="add_event" class="span-18 last">
	{% if group_slug %}
		<div class="projectsgroupstitle">{% trans "Modify this group" %}</div>
	{% else %}
		<div class="projectsgroupstitle">{% trans "Create group" %}</div>
	{% endif %}
    
	<form action="{{ create_group_action }}" enctype="multipart/form-data" id="my_form" method="POST" enctype="multipart/form-data" >
	
        <div id="groupformhidden">
		{% csrf_token %}
            <input type="hidden" name="form_status" value="{{form_status}}" id="group_form_status" />
            {% for hidden in form.hidden_fields %}
                {{ hidden }}
            {% endfor %}
        </div>

        <div id="groupformfields" class="span-18 last">
            	<div>{{ group_form.title.errors }}{{ group_form.title.label_tag }}{{group_form.title}}</div>
            	<a id="displayTranslateTitle" class="translateTitle">
					<span class="title">{% trans "Add translations" %}</span>
				</a>
                <div id="translate_title">
                {% for language_code in translation_languages %}
                    <div>
                        <label for="id_title_{{language_code}}">group.title_{{language_code}}</label>
                        <input type = "text" name = "title_{{language_code}}" id="id_title_{{language_code}}" ></input>
                    </div>
                {% endfor %}
                </div>
                <div>{{ group_form.description.errors }}{{ group_form.description.label_tag }}{{group_form.description}}</div>
                <a id="displayTranslateDescription" class="translateDescription">
					<span class="title">{% trans "Add translations" %}</span>
				</a>
                <div id="translate_description">
                {% for language_code in translation_languages %}
                    <div>
                        <label for="id_description_{{language_code}}">group.description_{{language_code}}</label>
                        <textarea name = "description_{{language_code}}" id="id_description_{{language_code}}" ></textarea>
                    </div>
                {% endfor %}
                </div>
           
                <div>
				{% trans "choose an group image" %}
				</div>
				
				<table id="choosegrouppicturecontainer" >
					<!-- <tr>
					    <td class="leftcolumn">
					        {% trans "Current group picture" %}
					    </td>
					</tr> -->
				    <tr>
				        <td class="leftcolumn">
				            {% trans "Upload a new picture" %}<br/> (JPG, PNG, &lt;&nbsp;1&nbsp;Mo)
				        </td>
				        <td>
				        	<div>{{ group_form.image.errors }}{{group_form.image.label_tag}}{{group_form.image}}</div>
				        </td>
				    </tr>
				</table>
				<div>{{ group_form.events.errors }}{{ group_form.events.label_tag }}{{group_form.events}}</div>

				
        </div>
            
        <div id="submitgroup" class="span-18 last">
            <div id="submitgroup-buttons" class="span-8 last">
                <button type="submit" value="close" name="submit_button" id="submit_button_close">{% trans 'close_cancel' %}</button>
                <button type="submit" value="write" name="submit_button" id="submit_button_write">{% trans "write" %}</button>
            </div>
        </div>
	
	</form>
	</div>

{% endblock %}