/**
 * SqueezeDialog - Expandable DialogBox
 *
 * Allows to open various content as dialog,
 * centered and animated box.
 *
 * Dependencies: MooTools 1.2
 *
 * Inspired by
 *  ... Harald Kirschner - The original SqueezeBox
 *
 * @version		1.0
 *
 * @license		MIT-style license
 * @author		Luis Merino <mail [at] luismerino.name>
 * @copyright	Author
 */

(function(){
	
var SqueezeDialog = {};

$mixin(SqueezeDialog, SqueezeBox);

$mixin(SqueezeDialog, {
	presets: {
		size: {x: 380, y: ''},
		sizeLoading: {x: 120, y: 60},
		handler: 'alert',
		closeBtn: false,
		overlayFx: {duration: 1},
		overlayOpacity: 0.5
	}
});

SqueezeDialog.handlers.extend({
	
	alert: function(){
		return new Element('div', {'class': 'dialog'}).adopt(
			new Element('p',{
				'class': 'title',
				text: this.url
			})
		).adopt(
			new Element('div',{
				'class': 'buttons'
			}).adopt(
				new Element('input',{
					type: 'button',
					events: {
						click: function(){
							this.close();
						}.bind(this)
					},
					value: Vadingo.translationManager._('Okay', 'application')
				})
			)
		);
	},
	
	confirm: function(){
		if ($type(this.url) != 'object') return false;
		var object = this.url;
		var fn = object.fn ? object.fn : $empty;
		var fn1 = object.fn1 ? object.fn1 : $empty;
		
		return new Element('div', {'class': 'dialog'}).adopt(
			new Element('p',{
				'class': 'title',
				text: object.msg
			})
		).adopt(
			new Element('div', {
				'class': 'buttons'
			}).adopt(
				new Element('input',{
					type: 'button',
					events: {
						click: function(){
							fn1();
							this.close();
						}.bind(this)
					},
					value: Vadingo.translationManager._('Cancel', 'application')
				})
			).adopt(
				new Element('input',{
					type: 'button',
					events: {
						click: function(){
							fn();
							this.close();
						}.bind(this)
					},
					value: Vadingo.translationManager._('Okay', 'application')
				})
			)
		);
	}
	
});

SqueezeDialog.parsers.extend({
	
	alert: function(){
		return true;
	},
	
	confirm: function(){
		return true;
	}
	
});

this.SqueezeDialog = SqueezeDialog;

})();