	/**
	* @package			overlay.js
	* @dependence		prototype.js - v1.5.1.1
	* @version			0.1.1
	* browser test		FF 2.0.0.x / IE 6.0 and 7.0
	* @license			GNU GPL 2.0
	* @author 			Alvaro A. Lima Jr <alvarolimajr@gmail.com>
	* @copyright 		Alvaro Junior! <http://alvarojunior.net>
	*/
	if(typeof(Prototype) == 'undefined' || parseFloat(Prototype.Version) < 1.5)
		throw("dialog.js requires the Prototype JavaScript framework >= 1.5.0");

		if (!window.Dialog)
			var Dialog = {};
		/**
		* Usage :
		*  - Dialog.show(element,options);
		*  -- options = {scroll : true, zIndex: 999};
		*/
		Dialog.Methods = {
			/**
			* @access public
			*/
			version: '0.2.0',

			/**
			* Método construtor
			* @access private
			*/
			__init__: function(element,options){
				this._element = $(element);
				this._setOptions(options);
				this._center();
				Event.observe(window, 'resize', this._center.bindAsEventListener(this));
				Event.observe(window, 'scroll', this._center.bindAsEventListener(this));
			},

			/**
			* @access protected
			*/
			_setOptions: function(options) {
				this.options = {
					scroll: false,
					zIndex: 999
				};
				Object.extend(this.options, options || {});
			},

			_center: function() {
				if(!this._element._centered){
					this._element.setStyle({position: 'absolute', zIndex: this.options.zIndex });
					this._element._centered = true;
		        }
				var dims = Element.getDimensions(this._element);
				Position.prepare();
				var winWidth = self.innerWidth || document.documentElement.clientWidth || document.body.clientWidth || 0;
				var winHeight = self.innerHeight || document.documentElement.clientHeight || document.body.clientHeight || 0;
				var offLeft = (Position.deltaX + Math.floor((winWidth-dims.width)/2));
				var offTop = (Position.deltaY + Math.floor((winHeight-dims.height)/2));
				var t = ((offTop != null && offTop > 0) ? offTop : '0')	+ 'px';
				var l = ((offLeft != null && offLeft > 0) ? offLeft : '0') + 'px';
				this._element.setStyle({top :t , left: l});
			},

			show : function(element,options){
				this.__init__(element,options);
				this._element.show();
			},

			hide : function(){
				this._element.hide();
			}
		};
		Object.extend(Dialog, Dialog.Methods);