var dialogId;
var listId;
var inputText;

//declaring the constructor
function ChooserDialog(dialogId, listId, inputText)
{
    this.dialogId  = dialogId;
    this.listId    = listId;
    this.inputText = inputText;

    $(document).ready(function () {
        $('ul#'+listId+' li').quicksearch({
            position: 'before',
            attached: 'ul#'+listId,
            inputText: inputText,
            fixWidths: '40',
            delay: 100 
        });
    });
    $(document).ready(function(){
        $("#"+dialogId).dialog({
            modal: true,
            autoOpen: false,
            resizable: false,
            width: 500,
            maxHeight: 350
        });
    });    
}

// instance methods
ChooserDialog.prototype = {
    // shows dialog
    showDialog: function ()
    {
        $("#"+this.dialogId).dialog('open');
        return false;
    },

    // processes user selection
    selectionMade: function (id, value)
    {
        document.getElementById(id).value = value;
        $("#"+this.dialogId).dialog('close');
//        $("#"+this.dialogId).hide("puff", {}, 1000);

        return false;
    }
};
