var marketingEncounter = {
    settings: {
        patient_autocompleteUrl: '',
        company_autocompleteUrl: '',
        branch_autocompleteUrl: '',
        encounter_autocompleteUrl: '',
        marketingStaff_autocompleteUrl: '',
        accountUser_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('#encounterTypes').bind('change', function () {
            var val = jQ(this).val();
            jQ('#form-encounterType-id').val(val);
        });

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

        jQ('#referring-physician').bind('change', function () {
            var val = jQ(this).val();
            jQ('#form-referring-physician-id').val(val);
        });
    },
    bindAutoComplete: function() {
        global.autocomplete.bind(marketingEncounter.settings.patient_autocompleteUrl, '#form-patient', '#form-patient-id');
        global.autocomplete.bind(marketingEncounter.settings.company_autocompleteUrl, '#form-company-desc', '#form-company-id');
        global.autocomplete.bind(marketingEncounter.settings.branch_autocompleteUrl, '#form-branch', '#form-branch-id');
        global.autocomplete.bind(marketingEncounter.settings.encounter_autocompleteUrl, '#form-encounterType', '#form-encounterType-id');
    }
};