
function Splash (oinit)
{
	var self = {
				contenedor: null,
				_dim: { docAncho: 0, docAlto: 0, winAncho: 0, winAlto: 0, scrollTop: 0, scrollLeft: 0},
				_init: {
						alpha:          0.8,
						cerrarOnClick:  true,
						cerrarOnEscape: true,
						color:          '#fff',
						data:           {},
						index:          1,
						plantilla:      '',
						x:              0,
						y:              0,
						zIndex:         1000,
						onload:         null,
						onclose:        null
				},
				_velo: null,

				_dimensiones: function () {
						var doc = $ (document);
						var win = $ (window);

						if ($.browser.msie) 
						{	var dHeight = doc.height();
							var wHeight = win.height();
							this._dim = { docAncho:    window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth, 
								            docAlto:     dHeight - wHeight < 20 ? wHeight : dHeight,
							            	winAncho: win.width (),
							            	winAlto: win.height (),
							            	scrollLeft: win.scrollLeft (), 
							            	scrollTop: win.scrollTop ()}; 
						} else
						{	this._dim = { docAncho: doc.width (),
								            docAlto: doc.height(), 
							  	          winAncho: win.width (),
							    	        winAlto: win.height (),
							      	      scrollLeft: win.scrollLeft (), 
							        	    scrollTop: win.scrollTop ()}; 
						}
				},

				close: function () {
						if (this._velo) 
						{	$(document).unbind ('keydown.velo');
							this._velo.unbind ('click.velo');
							$(window).unbind ('resize.velo');  
							this.contenedor.fadeOut ('fast', function() { self.contenedor.remove (); self.contenedor = null; });				
							this._velo.fadeOut ('fast', function() { self._velo.remove (); self._velo = null; });				
						}
						return this; 
				},

				load: function (oinit) {	
						if (typeof oinit == 'undefined') oinit = {};
						$.extend (this._init, oinit);
						this._velo = $ ('<div/>');
						$ ('body').append (this._velo);
						this._dimensiones ();
						this._velo.css ({ position: 'absolute',
									top: 0,
									left: 0,
									width: this._dim.docAncho,
									height: this._dim.docAlto,
									display: 'none',
									opacity: 0,
									backgroundColor: this._init.color,
									zIndex: this._init.zIndex});
						if (this._init.cerrarOnEscape) $(document).bind('keydown.velo', { velo: this },
								                                               function (event) { if (event.keyCode == 27) event.data.velo.close (event); });
						if (this._init.cerrarOnClick)this._velo.bind ('click.velo', { velo: this }, 
													                                   function(event) { event.data.velo.close (event); });					
						$(window).bind('resize.velo', { velo: this }, function (event) { event.data.velo._resize(); });
						this._velo.css ({display: 'block'}).fadeTo ('slow', this._init.alpha, 
																												function() {	
																														self._resize (); 
																														self._velo.append (self._init.contenedor);
																												});
						this._contenido ();																																	
						return this;				
				},

				_resize: function () {
						if (this._velo) 
						{	this._dimensiones ();				
							this._velo.css ( {width: this._dim.docAncho, height: this._dim.docAlto});
							// QUIZAS CENTRAR EL CONTENEDOR							
						}				
				},
				
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
				
				_contenido: function () {
						this.contenedor = $ ('<div/>');
						this.contenedor.css ({ width:     0, 
							                      height:   0, 
							                      position: 'absolute', 
																		left:     this._init.x, 
							                      top:      this._init.y,
							                      zIndex:   this._init.zIndex + 1});
						$ ('body').append (this.contenedor);
//						this.post ({plantilla: this._init.plantilla});
						this.post ($.extend (this._init.data, {plantilla: this._init.plantilla}));
				},
				
				append: function (contenido) {
						$ ('#idCerrar', contenido).click (function () { self.close ()});
						this.contenedor.append (contenido);
						var w = contenido.outerWidth (true), h = contenido.outerHeight (true);
						this.contenedor.animate ({ width:  w,
							                         height: h,
							                         top:    (this._dim.winAlto - h) / 2 + this._dim.scrollTop,
							                         left:   (this._dim.winAncho - w) / 2 + this._dim.scrollLeft}, 'slow');
				},
				
				post: function (data) {
					$.post (data.plantilla.substr (data.plantilla.length - 4) == '.php' ? data.plantilla : '/lib/jquery/plantilla.php', data, 
									function (data) { self.append ($ ('<div/>').html (data)); });
				}
	};

	self.load (oinit);
	return self;
}
