var SplashScreen = new Class({
	Implements: [Options, Events],
	options: {
		overlayColor : '#000000',
		opacity : .5,
		fadeDuration : 2000,
		elementID  : 'ssoverlay',
		content : null
	},
	
	overlay : '',
	elementID : '',
	overlayMorph : $empty,
	

	initialize: function(options)
	{
		this.setOptions(options);
		this.overlay = new Element('div', {id : this.options.elementID});
		
//		this.sizeSplash();
		
		this.overlayMorph = new Fx.Morph($(this.overlay), {
												duration: this.options.fadeDuration
											 })
	},
	sizeSplash: function()
	{
		$(this.overlay).style.width = $(document.body).getSize().x + "px";
		$(this.overlay).style.height = $(document.body).getSize().y + "px";
		$(this.overlay).style.backgroundColor = this.options.overlayColor;
		$(this.overlay).set('opacity', this.options.opacity);
	},
	
	showSplash: function()
	{
		this.sizeSplash();
		
		$(document.body).grab(this.overlay);
	},
	revealSplash: function()
	{
		this.overlayMorph.set({'opacity':0});
		this.showSplash();
		this.overlayMorph.start({
							'opacity' : this.options.opacity
							}).chain(function(){ 
												}.bind(this));
	},
	hideSplash: function(delay)
	{
		setTimeout(function(){
//			overlayMorph = new Fx.Morph($(this.overlay), {
//													duration: this.options.fadeDuration
//												 });
			this.overlayMorph.start({
								'opacity' : 0
								}).chain(function(){ 
													$(this.overlay).destroy();
													}.bind(this));
							}.bind(this), delay);
	},
	addContent : function (domObjects)
	{
		$(this.overlay).grab(domObjects);
	}
});
