/**
* @package			modal.js
* @dependence		prototype.js - v1.5.1.1, dialog.js - v0.1, overlay.js - v0.1
* @version			0.1.2
* 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("modal.js requires the Prototype JavaScript framework >= 1.5.0");

var Modal = {};
Modal = {
	/**
	* @access public
	*/
	version: '0.1.2',

	/**
	* @access public
	*/
	files: ['overlay', 'dialog'],

	/**
	* @access public
	*/
	require: function(name) {
	    document.write('<script type="text/javascript" src="' + name + '.js"></script>');
	},

	/**
	* @access public
	*/
	load: function(){
		// Idea and part of core code from - script.aculo.us web site: http://script.aculo.us/
		$A(document.getElementsByTagName("script")).findAll( function(s) {
			return (s.src && s.src.match(/modal\.js(\?.*)?$/))
		}).each( function(s) {
			var path = s.src.replace(/modal\.js(\?.*)?$/,'');
			Modal.files.each(function(include){Modal.require(path+include)});
		});
	},

	/**
	* @access public
	*/
	show: function(element, options) {
		Overlay.show(options);
		Dialog.show(element,options);
	},

	/**
	* @access public
	*/
	hide: function(){
		Overlay.hide();
		Dialog.hide();
	}
}
Modal.load();
