
 $.ui.dialog.prototype._createButtons = function(buttons) {
     
		var self = this,
			hasButtons = false,
			uiDialogButtonPane = $('<div></div>')
				.addClass(
					'ui-dialog-buttonpane ui-corner-bottom'
				);
		// if we already have a button pane, remove it
		this.uiDialog.find('.ui-dialog-buttonpane').remove();

		(typeof buttons == 'object' && buttons !== null &&
			$.each(buttons, function() {return !(hasButtons = true);}));
		if (hasButtons) {

			$.each(buttons, function(name, fn) {
                        var butonStyle ='ui-state-default';

                        if (typeof fn == 'object' && fn !== null ) {
                            var funct;
                            var display_name = name;
                            if ("name" in fn) {
                                display_name = fn.name;
                            }
                            $.each(fn, function(fun, type) {
                                if (fun == "onClickFunction") {
                                    funct = type;
                                }
                                if (fun == "type"){
                                    var div = '';
                                    if (type == "normal")
                                    {
                                        butonStyle = 'ui-state-normal';
                                        div = '<button class="dialogButtonNormal" type="button"> ' + display_name +'</button>';
                                    }
                                   
                                    if (type == "warning")
                                    {
                                        div = '<button class="dialogButtonWarning" type="button" > ' + display_name +'</button>';
                                        butonStyle = 'ui-state-warning';
                                        
                                    }
                                     if (type == "orange")
                                    {
                                        div = '<button class="dialogButtonOrange" type="button" > ' + display_name +'</button>';
                                        butonStyle = 'ui-state-orange';

                                    }
                                     if (type == "gray")
                                    {
                                        div = '<button class="dialogButtonGray" type="button" > ' + display_name +'</button>';
                                        butonStyle = 'ui-state-gray';

                                    }
                                    //$('<button type="button"></button>')
                                    $(div)
                                        .addClass(
                                                butonStyle +
                                                ' ui-corner-all'
                                        )
                                        .click(function() {funct.apply(self.element[0], arguments);})
                                        .hover(
                                                function() {
                                                    if (type == "normal") {
                                                        $(this).addClass('ui-state-hover-normal-extend');
                                                    } else if (type == "warning") {
                                                        $(this).addClass('ui-state-hover-warning-extend');
                                                    } else {
                                                        $(this).addClass('ui-state-hover-orange-extend');
                                                    }
                                                },
                                                function() {

                                                    if (type == "normal") {
                                                        $(this).removeClass('ui-state-hover-normal-extend');
                                                    } else if (type == "warning") {
                                                        $(this).removeClass('ui-state-hover-warning-extend');
                                                     } else {
                                                        $(this).removeClass('ui-state-hover-orange-extend');
                                                    }
                                                }
                                        )
                                        .focus(function() {
                                                //$(this).addClass('ui-state-focus');
                                        })
                                        .blur(function() {
                                               // $(this).removeClass('ui-state-focus');
                                        })
                                        .appendTo(uiDialogButtonPane);
                                }
                            });
                        } else {
                            $('<button type="button"></button>')
                            .addClass(
                                    'ui-state-default ' +
                                    'ui-corner-all'
                            )
                            .text(name)
                            .click(function() {fn.apply(self.element[0], arguments);})
                            .hover(
                                    function() {
                                            $(this).addClass('ui-state-hover');
                                    },
                                    function() {
                                            $(this).removeClass('ui-state-hover');
                                    }
                            )
                            .focus(function() {
                                   // $(this).addClass('ui-state-focus');
                            })
                            .blur(function() {
                                    //$(this).removeClass('ui-state-focus');
                            })
                            .appendTo(uiDialogButtonPane);
                        }

                      
			});
			uiDialogButtonPane.appendTo(this.uiDialog);
		}
	}


var open = $.ui.dialog.prototype.open;

$.ui.dialog.prototype.open = function() { 
    open.apply(this, arguments);
    
    dialogId = this.uiDialog.find('.ui-dialog-content').attr('id');
    $('#' + dialogId+'_warning').html('');
};



var _init = $.ui.dialog.prototype._init;

 $.ui.dialog.prototype._init = function() {
    
    _init.apply(this, arguments);
    if (!this.options.hideWarning)
    {
        this.uiDialogTitlebar.append('<div class="ajax-progress"></div>');
        dialogId = this.uiDialog.find('.ui-dialog-content').attr('id');
        this.uiDialog.find('.ui-dialog-content').html('<div class="dialog-warning"><span class="dialog-warning-label" id="'+dialogId+'_warning">Warning</span></div>' + this.uiDialog.find('.ui-dialog-content').html())  ;
    }
};


$.fn.showWarning = function(message) {
    $(this.selector + '_warning').removeClass('dialog-error-label');
    $(this.selector + '_warning').addClass('dialog-warning-label');
    $(this.selector + '_warning').show();
    $(this.selector + '_warning').html(message);
};

$.fn.showError = function(message) {
    
    $(this.selector + '_warning').removeClass('dialog-warning-label');
    $(this.selector + '_warning').addClass('dialog-error-label');
    $(this.selector + '_warning').show();
    $(this.selector + '_warning').html(message);
};


$.fn.clearWarning = function() {

    $(this.selector + '_warning').hide();
    $(this.selector + '_warning').html('');
};

