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

	{% block js_import %}
		<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_live.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_live_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;}
		    }
		$j(function() {
			    $j('.addliveform').formset({
			      prefix: '{{ add_live_form_set.prefix }}'
			    });
			  })
		
		$j(document).ready(function(){
				init_events()
		    });
		
		document.onkeypress = stopRKey;

	 
		</script>

		
		</script>
	{% endblock %}	
	{% block content %}
	{{ event_form.errors }}
    
	<div id="add_live_event" class="span-18 last">
		<div class="projectseventstitle">{% trans "Add lives to an event" %}</div>
    
	<form action="{{ add_live_event_action }}" enctype="multipart/form-data" id="my_form" method="POST" enctype="multipart/form-data" >
	        {% csrf_token %}        
	        {% for add_live_form in add_live_form_set.forms %}
	        <div class="addliveform">
		        <div id="addliveformhidden">
		            <input type="hidden" name="form_status" value="{{form_status}}" id="live_form_status" />
		            {% for hidden in add_live_form.hidden_fields %}
		                {{ hidden }}
		            {% endfor %}
		        </div>
		        <div id="addliveformfields" class="span-18 last">
		        <div>{{ add_live_form.type.errors }}{{ add_live_form.type.label_tag }}{{add_live_form.type}}</div>	
		        
		            <div name="addlivestreamer" id="addlivestreamer" class="span-9 last">
		             	<div>{{ add_live_form.provider.errors }}{{ add_live_form.provider.label_tag }}{{add_live_form.provider}}</div>
		                <div>{{ add_live_form.streamer.errors }}{{ add_live_form.streamer.label_tag }}{{add_live_form.streamer}}</div>
		                <div>{{ add_live_form.file.errors }}{{ add_live_form.file.label_tag }}{{add_live_form.file}}</div>    
		        	</div>
		        	<div name="addliveembed" id = "addliveembed" class="span-9 last" >
		                <div>{{ add_live_form.embed.errors }}{{ add_live_form.embed.label_tag }}{{add_live_form.embed}}</div>
		            </div>
		        </div>
	        </div>
	        {% endfor %} 
	        {{ add_live_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 %}