{% load i18n l10n %}

{% get_current_language as LANGUAGE_CODE %}

<div id="{{view_name}}_div_shortcuts_radio" class="shortcuts_container">
	{% for s in shortcuts %}
		{% if s.0 == shortcuts_select %}
			<input class="shortcuts_input" type="radio" id="{{view_name}}_date_radio{{forloop.counter}}" name="{{view_name}}_date_shortcut" value="{{ s.0 }}" checked="checked"/>
		{% else %}
			<input class="shortcuts_input" type="radio" id="{{view_name}}_date_radio{{forloop.counter}}" name="{{view_name}}_date_shortcut" value="{{ s.0 }}"/>
		{% endif %}
		<label class="shortcuts_label" id = "{{view_name}}_date_radio{{s.0}}" for="{{view_name}}_date_radio{{forloop.counter}}">{% trans s.1 %}</label>
	{% endfor %}
</div><!-- /Shortcuts -->



<script type="text/javascript" lang="text/javascript">
	// var view_name = String({{view_name}})
	window['{{view_name}}_selection_shortcuts']  = '{{shortcuts_select}}'
	// var {{view_name}}_shortcuts_select = ''
	// selection_shortcuts = '{{shortcuts_select}}'

	$("#{{view_name}}_div_shortcuts_radio label").removeClass('ui-state-active');
	$("#{{view_name}}_date_radio{{shortcuts_select}}").addClass('ui-state-active');	

	$('#'+'{{view_name}}'+'_div_shortcuts_radio').buttonset();

	$('#{{view_name}}_div_shortcuts_radio input').click(function(){
		window['{{view_name}}_selection_shortcuts']  =  $(this).val()
		// selection_shortcuts = $(this).val()
		// {{view_name}}_shortcuts_select = selection_shortcuts
		$("#{{view_name}}_datepicker_from_calldate").removeClass('ui-state-active');	
		$("#{{view_name}}_datepicker_to_calldate").removeClass('ui-state-active');	
		shortcutsDateFilter('{{view_name}}');
		{{view_name}}_callback('shortcuts');
	});


function shortcutsPrevious(param_filters)
{
	try
	{
		if (selection_shortcuts == '1h'||selection_shortcuts =='3h'||selection_shortcuts =='24h'||selection_shortcuts =='pweek'||selection_shortcuts =='pmonth')
			param_filters = param_filters + '&previous=1'
		else
			param_filters = param_filters + '&previous=-1'
	}
	catch(error)
	{
		param_filters = param_filters + '&previous=-1'
	}
	return param_filters
}

//ONLY USE SHORTCUTS WHITCH DATE  TODOMAS

//Shorcuts function TODOMAS
	// $('#tri_radio_column').click(function(){
	// 	{{view_name}}_callback('shortcuts',$(this).next().val());			
	// });
	
	// $('#{{view_name}}_div_shortcuts_radio label').click(function(){
	// 	console.log('entro shorcuts click binding');
	// 	{{view_name}}_callback('shortcuts',$(this).next().val());
	// 	// GB_callback('shortcuts');
	// });

</script>

