
function acInit(control, update, url, options)
{
    var ac = new Ajax.Autocompleter(control, update, url, options);
    ac.options.onShow = function(element, update) {
        update.style.position = 'absolute';
        update.style.width = (element.offsetWidth-2) + 'px';
        Effect.Appear(update, {duration: 0.15});
    }
    if (ac.options.identifierField) {
        ac.options.afterUpdateElement = function(control, element) {
            var field = jQuery(this.options.identifierField);
            field.value = element.id;
        }.bind(ac);
    }
    if (ac.options.ccSelect) {
        ac.options.callback = function(control, params) {
            var ccSelect = $(this.options.ccSelect);
            return params + '&cc=' + encodeURIComponent(
                ccSelect.options[ccSelect.selectedIndex].value);
        }.bind(ac);
    }
    return ac;
}

