/**
 * Created by IOAN on 10/23/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
    $('#jobs_search_frm').on('submit', function(e){
        e.preventDefault();

        var form_data = $('#jobs_search_frm').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',
            async: false,
            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);

                }

            }
        });



    });

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

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

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

                }

            }
        });



    });


});

