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

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

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

        form_data['csurl'] = encodeURIComponent(full_uri + "amodules/jobs_ext/ajax/search_jobs.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);

                }

            }
        });
    });

    $('.toggle-categs').on('click', function(e){
        var $switch = $(this);
        var $parent = $switch.closest('ul');
        var op = $switch.data('show');

        if( op == "show") {
            $parent.find('li.extra').removeClass('hidden');
            $switch.removeClass('fa-chevron-down').addClass('fa-chevron-up').data('show', 'hide');
        }
        else {
            $parent.find('li.extra').addClass('hidden');
            $switch.removeClass('fa-chevron-up').addClass('fa-chevron-down').data('show', 'show');
        }

    });

});