var specialistReferralTracker = {
    settings: {
        company_autocompleteUrl: '',
        patient_autocompleteUrl: '',
        chartType_autocompleteUrl: '',
        health_facility_autocomplete_url: '',
        service_autocomplete_url: ''
    },
    init: function() {
        this.bindAutoComplete();

        jQ('#companies').bind('change', function () {
            var val = jQ(this).val();
            jQ('#form-company-id').val(val);
        });

        jQ('#branches').bind('change', function () {
            var val = jQ(this).val();
            jQ('#form-branch-id').val(val);
        });

        jQ('#servicing-branches').bind('change', function () {
            var val = jQ(this).val();
            jQ('#form-servicing-branch-id').val(val);
        });

        jQ('#services').bind('change', function () {
            var val = jQ(this).val();
            jQ('#form-service-id').val(val);
        });

    },
    bindAutoComplete: function() {
        global.autocomplete.bind(specialistReferralTracker.settings.patient_autocompleteUrl, '#form-patient-fullName', '#form-patient-id');
        global.autocomplete.bind(specialistReferralTracker.settings.specialist_autocompleteUrl, '#form-specialist-fullName', '#form-specialist-id');
        global.autocomplete.bind(specialistReferralTracker.settings.company_autocompleteUrl, '#form-company-desc', '#form-company-id');
        global.autocomplete.bind(specialistReferralTracker.settings.health_facility_autocomplete_url, '#form-branch', '#form-branch-id');
        global.autocomplete.bind(specialistReferralTracker.settings.service_autocomplete_url, '#form-service', '#form-service-id');

    }
};