/**
 * Salary Checker Form Script
 * Loads list of job titles via ajax after selecting a category
 */

$(document).ready(function() {
                 
    $('#job_category_id').change(function() { 
        // Request List of Categories
        if ($(this).val() != '') {
            $('#job_title_id').load('/careers-advice/salary-options/?format=html&select=job_titles&job_category_id=' $(this).val(), 
                function(response, status, xhr) {
                    if (status == "error") {                    
                        var msg = "Sorry but there was an error: ";
                        alert(msg + xhr.status + " " + xhr.statusText);
                    }
                }
            
            );
            $('#job_title_id-label,#job_title_id-element').show();
        }
        else {
            $('#job_title_id-label,#job_title_id-element').hide();
        }
    });
    
    if ($('#job_title_id').val() == '') {
        $('#job_category_id').change();
    }      
        
});

