
// hideOnSubmit property defaulting to true
YAHOO.widget.Dialog.prototype.hideOnSubmit = true;

// add property "hideOnSubmit" to override hiding of dialog on submit
YAHOO.widget.Dialog.prototype.submit = function() {
	UNI.session.timer.start(); // restart session timout timer
	if (this.validate()) {
		this.beforeSubmitEvent.fire();
		this.doSubmit();
		this.submitEvent.fire();
		if(this.hideOnSubmit != false){ // don't close dialog unless specified
		   this.hide();
		}
		return true;
	} else {
		return false;
	}
};

// add support for images as buttons
YAHOO.widget.Dialog.prototype.configButtons = function(type, args, obj) {
	var buttons = args[0];
	if (buttons != "none") {
		this.buttonSpan = null;
		this.buttonSpan = document.createElement("SPAN");
		this.buttonSpan.className = "button-group";

		for (var b=0;b<buttons.length;b++) {
			var button = buttons[b];
            var htmlButton;
            if(button.image){
                htmlButton = document.createElement("input");
    			htmlButton.setAttribute("type", "image");
                htmlButton.setAttribute("src", button.image);
            }else{
    			htmlButton = document.createElement("BUTTON");
    			htmlButton.setAttribute("type", "button");
    
    			if (button.isDefault) {
    				htmlButton.className = "default";
    				this.defaultHtmlButton = htmlButton;
    			}
    
    			htmlButton.appendChild(document.createTextNode(button.text));
            }
			YAHOO.util.Event.addListener(htmlButton, "click", button.handler, this, true);
            
			this.buttonSpan.appendChild(htmlButton);		
			button.htmlButton = htmlButton;

			if (b === 0) {
				this.firstButton = button.htmlButton;
			}

			if (b == (buttons.length-1)) {
				this.lastButton = button.htmlButton;
			}

		}

		this.setFooter(this.buttonSpan);

		this.cfg.refireEvent("iframe");
		this.cfg.refireEvent("underlay");
	} else { // Do cleanup
		if (this.buttonSpan) {
			if (this.buttonSpan.parentNode) {
				this.buttonSpan.parentNode.removeChild(this.buttonSpan);
			}

			this.buttonSpan = null;
			this.firstButton = null;
			this.lastButton = null;
			this.defaultHtmlButton = null;
		}
	}
};

