{% 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/add_content.js"></script>
	{% endblock %}
	{% block js_declaration %}
		<script type="text/javascript">
		
		// the function stopRKey prevents from the validation of the form if the user tape enter button while entering a field 
		var $j = jQuery.noConflict(); 
		init_prefix = '{{ add_content_form_set.prefix }}';
		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;}
		    }
		
		document.onkeypress = stopRKey;

		$j(function() {
		    $j('.addcontentform').formset({
		      prefix: '{{ add_content_form_set.prefix }}'
		    });
	  	})
	  	
	  	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()
		    });
	  	
		</script>
		
		</script>
	{% endblock %}	
	{% block content %}
	{{ event_form.errors }}
    
	<div id="add_content_event" class="span-18 last">
		<div class="projectseventstitle">{% trans "Add contents to an event" %}</div>
    
	<form action="{{ add_content_event_action }}" enctype="multipart/form-data" id="my_form" method="POST" enctype="multipart/form-data" >
	       {% csrf_token %} 
	                
	       {% for add_content_form in add_content_form_set.forms %}
	       <div class="addcontentform">
		        <div id="addcontentformhidden">
		            <input type="hidden" name="form_status" value="{{form_status}}" id="content_form_status" />
		            {% for hidden in add_content_form.hidden_fields %}
		                {{ hidden }}
		            {% endfor %}
		        </div>
	        <div id="addcontentformfields" class="span-18 last">
	             	<div>{{ add_content_form.display.errors }}{{ add_content_form.display.label_tag }}{{add_content_form.display}}</div>
	                <a id="displayTranslateDisplay" name ="displayTranslateDisplay" class="translateDisplay">
						<span class="title">{% trans "Add translations" %}</span>
					</a>
                	<div name="translate_display">
		                {% for language_code in translation_languages %}
	                   	<div>
	                       	<label for="id_display_{{language_code}}">event.display_{{language_code}}</label>
	                       	<input name = "display_{{language_code}}" id="id_display_{{language_code}}" type="text"></input>
	                   	</div>
	              		{% endfor %}
              		</div>	 
	                <div>{{ add_content_form.program.errors }}{{ add_content_form.program.label_tag }}{{add_content_form.program}}</div>
	               	
	               	<a id="displayTranslateProgram" name ="displayTranslateProgram" class="translateProgram">
						<span class="title">{% trans "Add translations" %}</span>
					</a>
					
	               	<div name="translate_program">
	               	{% for language_code in translation_languages %}
	                <div> 
                       	<label for="id_program_{{language_code}}">event.program_{{language_code}}</label>
                       	<textarea name = "program_{{language_code}}" id="id_program_{{language_code}}" ></textarea>
                    </div>
                   	{% endfor %}
                   	</div>
                   	
	                <div>{{ add_content_form.url.errors }}{{ add_content_form.url.label_tag }}{{add_content_form.url}}</div>    
		        </div>
	        </div>
	        {% endfor %} 
	        {{ add_content_form_set.management_form }}
    	        
        <div id="submitevent" class="span-18 last">
            <div id="submitevent-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 %}