function splash_Engine() {

	this.layerNr = 0;
	this.opacity = 50;
	this.zIndex = 100;
	this.queue = new Object();

	this.pageWidth	= 0;
	this.pageHeight = 0;

};

splash_Engine.prototype = {

	newLayer: function(p, dim, windowName) {
		var w,h;
		var test1 = dim.scrollHeight;
		var test2 = dim.offsetHeight;

		w = dim.scrollWidth;
		h = dim.scrollHeight;


		// all but Explorer Mac
		if ( dim.offsetHeight > h )
		{
			w = dim.offsetWidth;
			h = dim.offsetHeight;
		}

		if ( window.innerHeight > h )
		{
			w = window.innerWidth;
			h = window.innerHeight;
		}

		if ( document.documentElement.clientHeight > h )
		{
			w = document.documentElement.clientWidth;
			h = document.documentElement.clientHeight;
		}

		var splash = document.createElement('div');
		splash.setAttribute('id', windowName + 'splash' + this.layerNr);

		this.getPageSize();

		splash.style.left = 0;
		splash.style.top = 0;

        if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.appVersion.indexOf("Win") != -1)) {
		    splash.style.width = w+'px';
        } else if ( navigator.userAgent.indexOf("Opera")>=0 ) {
		    splash.style.width = w+'px';
        } else {
		    splash.style.width = w+'px';
        }

        splash.style.height = this.pageHeight+'px';

		splash.style.visibility = 'visible';
		splash.style.position = 'absolute';
		splash.style.backgroundColor = '#000000';

		splash.style.zIndex = getZIndex();

		splash.style.opacity = (this.opacity / 100);
		splash.style.MozOpacity = (this.opacity / 100);
		splash.style.KhtmlOpacity = (this.opacity / 100);
		splash.style.filter = "alpha(opacity=" + this.opacity + ")";

		p.appendChild(splash);

		this.queue[windowName + 'splash' + this.layerNr] = splash;

//        splash.setAttribute('onClick', 'wPropertyDatapage.close(); enableSelect();');
//        splash.setAttribute('onkeypress', 'checkKeyCode(event.keyCode);');

        this.layerNr++;
	},

	getPageSize: function() {
		var xScroll, yScroll;

		if (window.innerHeight && window.scrollMaxY) {
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;

		} else if (document.body.scrollHeight > document.body.offsetHeight){
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;

		} else {
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;

		}

		var windowWidth, windowHeight;
		if (self.innerHeight) {
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;

		} else if (document.documentElement && document.documentElement.clientHeight) {
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;

		} else if (document.body) {
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}

		if (yScroll < windowHeight){
			this.pageHeight = windowHeight;
		} else {
			this.pageHeight = yScroll;
		}

		if (xScroll < windowWidth){
			this.pageWidth = windowWidth;
		} else {
			this.pageWidth = xScroll;
		}

	},

	remove: function(p, windowName) {
		if ( this.layerNr == 0 ) {
			return;
		}

		var splash = this.queue[windowName + 'splash' + (this.layerNr - 1) ];
		p.removeChild(splash);

		this.layerNr--;
	}

}

var splash = new splash_Engine();