/*
---
description:     MooDialog

authors:
  - Arian Stolwijk

license:
  - MIT-style license

requires:
  core/1.2.4:   '*'

provides:
  - [MooDialog.Confirm,Element.confirmLinkClick,Element.confirmFormSubmit]
...
*/

MooDialog.Confirm3 = new Class({	
	
	Extends: MooDialog,	
  
	options: {
		okText: 'Ok',
		cancelText: 'Cancel',
		focus: true
	},

	initialize: function(msg,fn,fn1,fn2,options){
		this.parent(options);
		
		fn = fn ? fn : $empty;
		fn1 = fn1 ? fn1 : $empty;
		fn2 = fn2 ? fn2 : $empty;
		
		var cancelButton = new Element('input',{
			type: 'button',
			events: {
				click: function(){
					fn1();
					this.close();
				}.bind(this)
			},
			value: this.options.cancelText
		});
		
		$(cancelButton).addClass('button');
		
		this.setContent(
			new Element('div')
				.adopt(
					new Element('p',{
						'class': 'MooDialogConfirm',
						text: msg
					})
				).adopt(
					new Element('div',{
						'class': 'buttons'
					}).adopt(cancelButton).adopt(
						new Element('input',{
							'class': 'button',
							type: 'button',
							events: {
								click: function(){
									fn();
									this.close();
								}.bind(this)
							},
							value: this.options.okText
						}),
						
						
						new Element('input',{
							'class': 'button',
							type: 'button',
							events: {
								click: function(){
									fn2();
									this.close();
								}.bind(this)
							},
							value: this.options.cancelText2
						})
					)
				)
		).open();
		
		if(this.options.focus){
			this.addEvent('show',function(){
				cancelButton.focus();
			});
		}
	}
});

