var TgeUI = {
    init: function(){
        this.tabs();
    },
    tabs: function(){
        $('#tabbed').tabs({
        	select: function(event, ui)
        	{
        		window.location.replace($(ui.tab).attr('jumpTo'));
        		
        		return false;
        	
        	}
        }
        );
    }
}


$(function(){
    TgeUI.init();
    $(".btn_calendar").click(function(ev){
    		if($("#calendar").length  > 0)
    		{
    			$('#calendar').remove();
    			return;
    		}
    		
			var parent = $(this).parent();
			parent.append('<div id="calendar"><div></div></div>');
			
			var el = parent.children('input.datetime');
			var calendar = $('#calendar');
			var textInput = $(this).siblings("input[type='text']");
			var current_date = textInput.val();
			calendar.children('div').calendarLite({
				showYear: true,
				current_date:current_date,
				dateFormat: '{%yyyy}-{%mm}-{%dd}',
				months: ['Styczeń', 'Luty', 'Marzec', 'Kwiecień', 'Maj', 'Czerwiec', 'Lipiec', 'Sierpień', 'Wrzesień', 'Październik', 'Listopad', 'Grudzień'],
				days: ['Pn', 'Wt', 'Śr', 'Czw', 'Pt', 'Sb', 'Nd'],
				onSelect: function(date){
					textInput.val(date);
					calendar.remove();
					if (typeof calendarSelectAdditionalAction == 'function') {
					    // Dodatkowa akcja do wykonania po wybraniu daty
    					calendarSelectAdditionalAction(date);
    			    }
					return false;
				}
			});
	
	});
});
