$(document).ready(function(){
    $('#id_start_date').datepicker({
        dateFormat: 'mm/dd/y'
    });
    $('#id_end_date').datepicker({
        dateFormat: 'mm/dd/y'
    });
    $('#id_start_time').timepickr();
    $('#id_end_time').timepickr();
    $('#id_job_search_text').keypress(function(e){
        if (e.which == 13) {
            var queryValue = $('#id_job_search_text').val();
            $.get("/jobs/search", {
                query_value: queryValue
            }, function(data){
                $('#jobs_list').html(data);
            });
        }
    });
    $('#id_event_search_text').keypress(function(e){
        if (e.which == 13) {
            var queryValue = $('#id_event_search_text').val();
            $.get("/events/search", {
                query_value: queryValue
            }, function(data){
                $('#events_list').html(data);
            });
            events_list
        }
    });
    $('input:checkbox').change(function(){
        var checkbox_value = $(this).val();
        var checked = $(this).attr("checked");
        $("div." + checkbox_value).each(function(e){
            if(checked)
            { 
                $(this).show(); 
            }
            else
            {
                $(this).hide();
            }
        }
        );
        $("li." + checkbox_value).each(function(e){
            if(checked)
            { 
                $(this).show(); 
            }
            else
            {
                $(this).hide();
            }
        }
        );
    });
    $('#ajax_spinner').ajaxStart(function(){
        $(this).show();
    });
    $('#ajax_spinner').ajaxStop(function(){
        $(this).hide();
    });
    //  Tooltips
    $("#job_form :input").tooltip({
        // place tooltip on the right edge
    	position: "center right",
    	// a little tweaking of the position
    	offset: [-2, 10],
    	// use the built-in fadeIn/fadeOut effect
    	effect: "fade",
    	// custom opacity setting
    	opacity: 0.7
    })
})
