/**
 * Created by IOAN on 10/22/2015.
 */
$(document).ready(function(){

    $('.load-disabled').each(function(){
        //console.log('load-disabled should enable');
        $(this).prop('disabled', false);
        $('.fa', $(this)).removeClass('fa-spin');
    });

    // Search Jobs
    $('#search_form').on('submit', function(e){
        e.preventDefault();

        var form_data = $('#search_form').serializeObject();

        form_data['csurl'] = encodeURIComponent(full_uri + "amodules/events_ext/ajax/search_events.php");
        form_data['baseurl'] = baseurl;
        //console.log(form_data);
        $.ajax({
            url: baseurl + '/proxy.php',
            data: form_data,
            type: 'post',
            dataType: 'json',
            cache: false,
            success: function(r) {
                if(r.result == 1) {
                    if(r.hasOwnProperty('flashm')) {
                        $.post(baseurl + '/flashm.php', {'flashm': r.flashm});
                    }
                    window.redirectLink = r.link;
                    window.setTimeout(function(){
                        var rlink = window.redirectLink;
                        delete(window.redirectLink);
                        document.location.href = rlink;
                    }, 200);

                }

            }
        });



    });

    $('.trigger-collapse').on('click', function(e){
        var $clickable = $('.clickable > i', $(this));
        if($clickable.hasClass('glyphicon-chevron-down')){
            $clickable.removeClass('glyphicon-chevron-down').addClass('glyphicon-chevron-up');
        }
        else {
            $clickable.removeClass('glyphicon-chevron-up').addClass('glyphicon-chevron-down');
        }
    });


});