IDIVDIALOG = 1;
function Dialog(dialogDiv){
    var a = $('<div id="dialog_'+IDIVDIALOG+'" title="Basic dialog" style="display:none"></div>');
    $('body').append(a);
    $('#dialog_' + IDIVDIALOG).each(function(){
        $(this).append('<p></p>');
    })

    this.dialog = $('#dialog_' + IDIVDIALOG);
    IDIVDIALOG++;
}
Dialog.prototype.Show = function(message, title, showOkButtons, showCloseButton){
    this.dialog.attr('title', title);
    this.dialog.find('p').each(function(){
        $(this).html(message);
    });

   this.dialog.dialog({
        height: 140,
        modal: true,
        closeOnEscape: showCloseButton,
        open: function(event, ui) {
            if(!showCloseButton)
                $(".ui-dialog-titlebar-close").hide();
        }

    });
    	
    if(showOkButtons == true){
        this.showOkButton(showOkButtons);
    }
};


Dialog.prototype.setMessage = function(message){
    this.dialog.find('p').each(function(){
        $(this).html(message);
    });
};

Dialog.prototype.showOkButton = function(value){
    var me = this;
    if(value){
        this.dialog.dialog( "option", "buttons", {
            "Ok": function(){
                me.dialog.trigger('onOkPressed');
                $(this).dialog("close");
            }
        });
    }else{
        this.dialog.dialog({"buttons" : [] });
    }
};


Dialog.prototype.OnOkPressed = function(callback){
    this.dialog.bind('onOkPressed', callback);
};

