var referral = {
    settings: {
        company_autocompleteUrl: '',
        branch_autocompleteUrl: '',
        patient_autocompleteUrl: '',
        provider_autocompleteUrl: '',
        referring_physician_autocompleteUrl: '',
        referring_affiliate_autocompleteUrl: '',
        salesAgent_autocompleteUrl: '',
    },
    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);
        });
    },
    bindAutoComplete: function() {
        global.autocomplete.bind(referral.settings.company_autocompleteUrl, '#form-company-desc', '#form-company-id');
        global.autocomplete.bind(referral.settings.branch_autocompleteUrl, '#form-branch', '#form-branch-id');
        global.autocomplete.bind(referral.settings.patient_autocompleteUrl, '#form-patient-fullName', '#form-patient-id');
        global.autocomplete.bind(referral.settings.provider_autocompleteUrl, '#form-provider-fullName', '#form-provider-id');
        global.autocomplete.bind(referral.settings.referring_physician_autocompleteUrl, '#form-referring-physician', '#form-referring-physician-id');
        global.autocomplete.bind(referral.settings.referring_affiliate_autocompleteUrl, '#form-referring-affiliate', '#form-referring-affiliate-id');
        global.autocomplete.bind(referral.settings.salesAgent_autocompleteUrl, '#form-agent-fullName', '#form-agent-id');

    }
};