Zapatec.AlertWindow = function(message, config) {
	config.showMaxButton = false;
	config.showMinButton = false;
	config.canResize = false;
	config.showStatus = false;
	var win = this.win = new Zapatec.Window(config);
	win.create(config.left || "center", config.top || "center", config.width || win.config.minWidth, config.height || win.config.minHeight);
	if (config.title) {
		win.setTitle(config.title);
	}
	this.win.contentArea.className = 'zpWinAlertContent';
	this.win.contentArea.style.overflow = "visible";
	this.win.contentArea.style.height = "auto";		
	this.messageArea = document.createElement("div");
	this.messageArea.className = "zpWinAlertMessage";
	this.messageArea.innerHTML = message;
	this.win.contentArea.appendChild(this.messageArea);
	this.okButton = document.createElement("button");
	this.okButton.innerHTML = "Ok";
	this.okButton.className = "zpWinAlertButton";
	Zapatec.Utils.addEvent(this.okButton, "click", function (ev) {
		win.close();
	});
	this.win.contentArea.appendChild(this.okButton);
	win.show();
}

Zapatec.ConfirmWindow = function(message, config) {
	var confirmW = this;
	this.result = false;
	this.onConfirm = null;
	config.showMinButton = false;
	config.showMaxButton = false;
	config.showStatus = false;
	config.canResize = false;
	var win = this.win = new Zapatec.Window(config);
	win.create(config.left || "center", config.top || "center", config.width || win.config.minWidth, config.height || win.config.minHeight);
	if (config.title) {
		win.setTitle(config.title);
	}
	this.win.contentArea.className = 'zpWinConfirmContent';
	this.win.contentArea.style.overflow = "visible";
	this.win.contentArea.style.height = "auto";		
	this.messageArea = document.createElement("div");
	this.messageArea.className = "zpWinConfirmMessage";
	this.messageArea.innerHTML = message;
	this.win.contentArea.appendChild(this.messageArea);
	this.okButton = document.createElement("button");
	this.okButton.innerHTML = "Ok";
	this.okButton.className = "zpWinOkButton";
	Zapatec.Utils.addEvent(this.okButton, "click", function () {
		confirmW.result = true; 
		win.hide(); 
		if (confirmW.onConfirm) {
			confirmW.onConfirm(confirmW.result);
		}
	});
	this.win.contentArea.appendChild(this.okButton);
	this.cancelButton = document.createElement("button");
	this.cancelButton.innerHTML = "Cancel";
	this.cancelButton.className = "zpWinCancelButton";
	Zapatec.Utils.addEvent(this.cancelButton, "click", function () {
		confirmW.result = false; 
		win.hide(); 
		if (confirmW.onConfirm) {
			confirmW.onConfirm(confirmW.result);
		}
	});
	this.win.contentArea.appendChild(this.cancelButton);
	win.closeButton.customMouseUp = function () {
		confirmW.result = false; 
		win.hide(); 
		if (confirmW.onConfirm) {
			confirmW.onConfirm(confirmW.result);
		}
	};	
}

Zapatec.ConfirmWindow.prototype.getResponse = function (action) {
	this.onConfirm = action;
	this.win.show();
}

Zapatec.DialogWindow = function(message, config) {
	dialogW = this;
	this.result = null;
	this.onConfirm = null;
	config.showMinButton = false;
	config.showMaxButton = false;
	if (!config.closeAction) {
		config.showCloseButton = false;
	}
	config.showStatus = false;
	config.canResize = false;
	config.showResize = false;
	win = this.win = new Zapatec.Window(config);
	win.create(config.left || "center", config.top || "center", config.width || win.config.minWidth, config.height || win.config.minHeight);
	if (config.title) {
		win.setTitle(config.title);
	}
	this.win.contentArea.className = 'zpWinDialogContent';
	this.win.contentArea.style.overflow = "visible";
	this.win.contentArea.style.height = "auto";
	this.win.contentArea.style.width = (config.width) ? (config.width + "px") : "auto";
	this.messageArea = document.createElement("div");
	this.messageArea.className = "zpWinDialogMessage";
	this.messageArea.innerHTML = message;
	this.win.contentArea.appendChild(this.messageArea);
	this.buttons = [];
	for(var i in config.buttons) {
		button = document.createElement("button");
		button.innerHTML = config.buttons[i];
		button.className = "zpWinDialogButton";
		Zapatec.Utils.addEvent(button, "click", function (ev) {
			ev = ev || window.event; 
			target = Zapatec.Utils.getTargetElement(ev);
			dialogW.result = target.innerHTML;
			win.hide(); 
			if (dialogW.onConfirm) {
				dialogW.onConfirm(dialogW.result);
			}
		});
		this.win.contentArea.appendChild(button);
		this.buttons.push(button);
	}
	if (config.closeAction) {
		win.closeButton.customMouseUp = config.closeAction;
	}
}

Zapatec.DialogWindow.prototype.getResponse = function (action) {
	this.onConfirm = action;
	this.win.show();
}

