/* ${__APPLICATION_VERSION__} */
	
eds.webapp.layout.Layer = function(layerName) {

	this.layer = layerName;

	if (typeof layerName == "string") {
		this.layer = document.getElementById(layerName);
	}                      

	var that = this;

	var is_ie = ( /msie/i.test(navigator.userAgent) &&
		!/opera/i.test(navigator.userAgent) );

	this.show = function(layerToCoverUp) {
	
		var container = document.getElementById(layerToCoverUp);

		var pos = new eds.webapp.layout.Position(container);
	
		this.showByCoord(container.offsetWidth, container.offsetHeight, pos.findPosY(), pos.findPosX());
	}
	
	this.showByOffset = function(referenceLayer, width, height, top, left) {

		var container = document.getElementById(referenceLayer);
		var pos = new eds.webapp.layout.Position(container);
	
		var newWidth = container.offsetWidth + width;
		var newHeight = container.offsetHeight + height;
		var newTop = pos.findPosY() + top;
		var newLeft = pos.findPosX() + left;
	
		this.showByCoord(newWidth, newHeight, newTop, newLeft);
	}
	
	this.showByCoord = function(width, height, top, left) {
	
		if ( ! width ) {
			width = 0;
		}
	
		this.layer.style.width = width + 'px';
	
		if ( ! height ) {
			height = 0;
		}
	
		this.layer.style.height= height + 'px';
	
		if ( ! top) {
			top = 0;
		}
	
		this.layer.style.top = top + 'px';
	
		if ( ! left ) {
			left = 0;
		}
	
		this.layer.style.left = left + 'px';
	
		/* ie */
		this.layer.style.display = '';
		/* firefox */
		this.layer.style.visibility = 'visible';
	}
	
	this.hide = function() {
	
		/* ie */
		this.layer.style.display = 'none';
		/* firefox */
		this.layer.style.visibility = 'hidden';
		this.layer.style.width = 0;
		this.layer.style.height = 0;
	}

	function _contains(f) {

		while (true) {

			if ( !f ) {
				return false;
			}

			if ( f.id ) {
				if ( f.id == that.layer.id ) {
					return true;
				}
			}

			f = f.parentNode;
		}

		return false;

	}

	this.contains = function(containedId) {
		var f = is_ie ? window.event.srcElement : containedId.target;
		return _contains(f);
	}
}

