function populatePrograms() {
    $.getJSON('/_scripts/get_info.php?' + new Date().getTime(), {
        category: $('#phdsubjectfinder #category').val()
    }, function (data) {
        var select = $('#phdsubjectfinder #subject');
        var options = select.attr('options');
        $('option', select).remove();
        $('#phdsubjectfinder #subject').click(function () {});
        $.each(data, function (index, array) {
            options[options.length] = new Option(array['name'], array['url']);
        });
    });
}

function populatePrograms2() {
    $.getJSON('/_scripts/get_info.php?' + new Date().getTime(), {
        category: $('#phdsubjectfinder2 #category2').val()
    }, function (data) {
        var select = $('#phdsubjectfinder2 #subject');
        var options = select.attr('options');
        $('option', select).remove();
        $('#phdsubjectfinder2 #subject').click(function () {});
        $.each(data, function (index, array) {
            options[options.length] = new Option(array['name'], array['url']);
        });
    });
}

function populatePrograms3() {
    $.getJSON('/_scripts/get_info.php?' + new Date().getTime(), {
        school_name: $('#phdsubjectfinder3 #school_name').val(),
        category: $('#phdsubjectfinder3 #category3').val()
    }, function (data) {
        var select = $('#phdsubjectfinder3 #subject');
        var options = select.attr('options');
        $('option', select).remove();
        $('#phdsubjectfinder3 #subject').click(function () {});
        $.each(data, function (index, array) {
            options[options.length] = new Option(array['name'], array['url']);
        });
    });
}

function populatePrograms4() {
    $.getJSON('/_scripts/get_info.php?' + new Date().getTime(), {
        school_name: $('#phdsubjectfinder4 #school_name').val(),
        category: $('#phdsubjectfinder4 #category4').val()
    }, function (data) {
        var select = $('#phdsubjectfinder4 #subject');
        var options = select.attr('options');
        $('option', select).remove();
        $('#phdsubjectfinder4 #subject').click(function () {});
        $.each(data, function (index, array) {
            options[options.length] = new Option(array['name'], array['url']);
        });
    });
}

function populatePrograms5() {
    $.getJSON('/_scripts/get_info.php?' + new Date().getTime(), {
        school_name: $('#phdsubjectfinder5 #school_name').val(),
        category: $('#phdsubjectfinder5 #category5').val()
    }, function (data) {
        var select = $('#phdsubjectfinder5 #subject');
        var options = select.attr('options');
        $('option', select).remove();
        $('#phdsubjectfinder5 #subject').click(function () {});
        $.each(data, function (index, array) {
            options[options.length] = new Option(array['name'], array['url']);
        });
    });
}

function populatePrograms6() {
    $.getJSON('/_scripts/get_info.php?' + new Date().getTime(), {
        school_name: $('#phdsubjectfinder6 #school_name').val(),
        category: $('#phdsubjectfinder6 #category6').val()
    }, function (data) {
        var select = $('#phdsubjectfinder6 #subject');
        var options = select.attr('options');
        $('option', select).remove();
        $('#phdsubjectfinder6 #subject').click(function () {});
        $.each(data, function (index, array) {
            options[options.length] = new Option(array['name'], array['url']);
        });
    });
}

function populatePrograms7() {
    $.getJSON('/_scripts/get_info.php?' + new Date().getTime(), {
        school_name: $('#phdsubjectfinder7 #school_name').val(),
        category: $('#phdsubjectfinder7 #category7').val()
    }, function (data) {
        var select = $('#phdsubjectfinder7 #subject');
        var options = select.attr('options');
        $('option', select).remove();
        $('#phdsubjectfinder7 #subject').click(function () {});
        $.each(data, function (index, array) {
            options[options.length] = new Option(array['name'], array['url']);
        });
    });
}

function populatePrograms8() {
    $.getJSON('/_scripts/get_info.php?' + new Date().getTime(), {
        school_name: $('#phdsubjectfinder8 #school_name').val(),
        category: $('#phdsubjectfinder8 #category8').val()
    }, function (data) {
        var select = $('#phdsubjectfinder8 #subject');
        var options = select.attr('options');
        $('option', select).remove();
        $('#phdsubjectfinder4 #subject').click(function () {});
        $.each(data, function (index, array) {
            options[options.length] = new Option(array['name'], array['url']);
        });
    });
}

function populatePrograms9() {
    $.getJSON('/_scripts/get_info.php?' + new Date().getTime(), {
        school_name: $('#phdsubjectfinder9 #school_name').val(),
        category: $('#phdsubjectfinder9 #category9').val()
    }, function (data) {
        var select = $('#phdsubjectfinder9 #subject');
        var options = select.attr('options');
        $('option', select).remove();
        $('#phdsubjectfinder4 #subject').click(function () {});
        $.each(data, function (index, array) {
            options[options.length] = new Option(array['name'], array['url']);
        });
    });
}

function populatePrograms10() {
    $.getJSON('/_scripts/get_info.php?' + new Date().getTime(), {
        school_name: $('#phdsubjectfinder10 #school_name').val(),
        category: $('#phdsubjectfinder10 #category10').val()
    }, function (data) {
        var select = $('#phdsubjectfinder10 #subject');
        var options = select.attr('options');
        $('option', select).remove();
        $('#phdsubjectfinder4 #subject').click(function () {});
        $.each(data, function (index, array) {
            options[options.length] = new Option(array['name'], array['url']);
        });
    });
}

function populatePrograms11() {
    $.getJSON('/_scripts/get_info.php?' + new Date().getTime(), {
        school_name: $('#phdsubjectfinder11 #school_name').val(),
        category: $('#phdsubjectfinder11 #category11').val()
    }, function (data) {
        var select = $('#phdsubjectfinder11 #subject');
        var options = select.attr('options');
        $('option', select).remove();
        $('#phdsubjectfinder4 #subject').click(function () {});
        $.each(data, function (index, array) {
            options[options.length] = new Option(array['name'], array['url']);
        });
    });
}

function populatePrograms12() {
    $.getJSON('/_scripts/get_info.php?' + new Date().getTime(), {
        school_name: $('#phdsubjectfinder12 #school_name').val(),
        category: $('#phdsubjectfinder12 #category12').val()
    }, function (data) {
        var select = $('#phdsubjectfinder12 #subject');
        var options = select.attr('options');
        $('option', select).remove();
        $('#phdsubjectfinder4 #subject').click(function () {});
        $.each(data, function (index, array) {
            options[options.length] = new Option(array['name'], array['url']);
        });
    });
}

function populatePrograms13() {
    $.getJSON('/_scripts/get_info.php?' + new Date().getTime(), {
        school_name: $('#phdsubjectfinder13 #school_name').val(),
        category: $('#phdsubjectfinder13 #category13').val()
    }, function (data) {
        var select = $('#phdsubjectfinder13 #subject');
        var options = select.attr('options');
        $('option', select).remove();
        $('#phdsubjectfinder4 #subject').click(function () {});
        $.each(data, function (index, array) {
            options[options.length] = new Option(array['name'], array['url']);
        });
    });
}

function populateOtherPrograms2() {
    $.getJSON('/_scripts/get_info.php?' + new Date().getTime(), {
        category: $('#otherprograms2 #category2a').val()
    }, function (data) {
        var select = $('#otherprograms2 #subject');
        var options = select.attr('options');
        $('option', select).remove();
        $('#otherprograms2 #subject').click(function () {});
        $.each(data, function (index, array) {
            options[options.length] = new Option(array['name'], array['url']);
        });
    });
}
$(document).ready(function () {
    $('#phdsubjectfinder #category').change(function () {
        populatePrograms();
    });
    $('#phdsubjectfinder select#subject').click(function () {
        if ($(this).val() == "") {
            $('#phdsubjectfinder .find_now').attr('disabled', true);
        } else {
            $('#phdsubjectfinder .find_now').attr('disabled', false);
        }
    });
    $('#phdsubjectfinder2 #category2').change(function () {
        populatePrograms2();
    });
    $('#phdsubjectfinder2 select#subject').click(function () {
        if ($(this).val() == "") {
            $('#phdsubjectfinder2 .find_now').attr('disabled', true);
        } else {
            $('#phdsubjectfinder2 .find_now').attr('disabled', false);
        }
    });
    $('#phdsubjectfinder3 #category3').change(function () {
        populatePrograms3();
    });
    $('#phdsubjectfinder3 select#subject').click(function () {
        if ($(this).val() == "") {
            $('#phdsubjectfinder3 .find_now').attr('disabled', true);
        } else {
            $('#phdsubjectfinder3 .find_now').attr('disabled', false);
        }
    });
    $('#phdsubjectfinder4 #category4').change(function () {
        populatePrograms4();
    });
    $('#phdsubjectfinder4 select#subject').click(function () {
        if ($(this).val() == "") {
            $('#phdsubjectfinder4 .find_now').attr('disabled', true);
        } else {
            $('#phdsubjectfinder4 .find_now').attr('disabled', false);
        }
    });
    $('#phdsubjectfinder5 #category5').change(function () {
        populatePrograms5();
    });
    $('#phdsubjectfinder5 select#subject').click(function () {
        if ($(this).val() == "") {
            $('#phdsubjectfinder5 .find_now').attr('disabled', true);
        } else {
            $('#phdsubjectfinder5 .find_now').attr('disabled', false);
        }
    });
    $('#phdsubjectfinder6 #category6').change(function () {
        populatePrograms6();
    });
    $('#phdsubjectfinder6 select#subject').click(function () {
        if ($(this).val() == "") {
            $('#phdsubjectfinder6 .find_now').attr('disabled', true);
        } else {
            $('#phdsubjectfinder6 .find_now').attr('disabled', false);
        }
    });
    $('#phdsubjectfinder7 #category7').change(function () {
        populatePrograms7();
    });
    $('#phdsubjectfinder7 select#subject').click(function () {
        if ($(this).val() == "") {
            $('#phdsubjectfinder7 .find_now').attr('disabled', true);
        } else {
            $('#phdsubjectfinder7 .find_now').attr('disabled', false);
        }
    });
    $('#phdsubjectfinder8 #category8').change(function () {
        populatePrograms8();
    });
    $('#phdsubjectfinder8 select#subject').click(function () {
        if ($(this).val() == "") {
            $('#phdsubjectfinder8 .find_now').attr('disabled', true);
        } else {
            $('#phdsubjectfinder8 .find_now').attr('disabled', false);
        }
    });
    $('#phdsubjectfinder9 #category9').change(function () {
        populatePrograms9();
    });
    $('#phdsubjectfinder9 select#subject').click(function () {
        if ($(this).val() == "") {
            $('#phdsubjectfinder9 .find_now').attr('disabled', true);
        } else {
            $('#phdsubjectfinder9 .find_now').attr('disabled', false);
        }
    });
    $('#phdsubjectfinder10 #category10').change(function () {
        populatePrograms10();
    });
    $('#phdsubjectfinder10 select#subject').click(function () {
        if ($(this).val() == "") {
            $('#phdsubjectfinder10 .find_now').attr('disabled', true);
        } else {
            $('#phdsubjectfinder10 .find_now').attr('disabled', false);
        }
    });
    $('#phdsubjectfinder11 #category11').change(function () {
        populatePrograms11();
    });
    $('#phdsubjectfinder11 select#subject').click(function () {
        if ($(this).val() == "") {
            $('#phdsubjectfinder11 .find_now').attr('disabled', true);
        } else {
            $('#phdsubjectfinder11 .find_now').attr('disabled', false);
        }
    });
    $('#phdsubjectfinder12 #category12').change(function () {
        populatePrograms12();
    });
    $('#phdsubjectfinder12 select#subject').click(function () {
        if ($(this).val() == "") {
            $('#phdsubjectfinder12 .find_now').attr('disabled', true);
        } else {
            $('#phdsubjectfinder12 .find_now').attr('disabled', false);
        }
    });
    $('#phdsubjectfinder13 #category13').change(function () {
        populatePrograms13();
    });
    $('#phdsubjectfinder13 select#subject').click(function () {
        if ($(this).val() == "") {
            $('#phdsubjectfinder13 .find_now').attr('disabled', true);
        } else {
            $('#phdsubjectfinder13 .find_now').attr('disabled', false);
        }
    });
    $('#otherprograms2 #category2a').change(function () {
        populateOtherPrograms2();
    });
    $('#otherprograms2 select#subject').click(function () {
        if ($(this).val() == "") {
            $('#otherprograms2 .find_now').attr('disabled', true);
        } else {
            $('#otherprograms2 .find_now').attr('disabled', false);
        }
    });
    var w = $(window);
    var k = $("#find_bar");
    var kt = k.offset().top;
    w.bind("scroll resize", function () {
        var wt = w.scrollTop();
        var d = wt - kt;
        if (d >= 15) {
            k.css({
                "position": "fixed",
                "top": "0px"
            });
        } else if (d < 15) {
            k.css({
                "position": "relative",
                "top": "0px"
            });
        }
    });
});
