


function OverlayObject(container){

	DisplayObject.call(this);
	
	this.zIndex = 100;
	this.containerObj = null;
	this.opacity = 80;
	this.color = "#000";
	this.removeOnClick = true;
	
	this.onRemoveFunction = null;

	if(container != null){
		this.containerObj = container;
	}
	
	this.OverlayObject = function(){
	
		this.createDOMElement("div","DTDOverlay");
		this.setStyle("position","absolute");

	}
	
	this.displayContent = function(){
		
		this.setStyle("top", "0");
		this.setStyle("left", "0");
		this.setStyle("z-index", this.zIndex);
		this.setStyle("width", "100%");
		this.setStyle("height", "100%");
		this.setStyle("display", 'block');
		this.setStyle("background-color", this.color);
		this.setOpacity(this.opacity);

		
		if(this.containerObj == null){// container is body, create full size with click off function
			this.containerObj = document.getElementsByTagName("body").item(0);
			this.addOnClickRemove();
			var pageSizes = this.getPageSizeObject();
			this.setStyle("height",pageSizes.pageHeight+"px");
		}else{
			this.setStyle("width",this.containerObj.clientWidth+"px");
			this.setStyle("height",this.containerObj.clientHeight+"px");
		}
		
		if(this.containerObj.firstChild != null){
			this.containerObj.insertBefore(this.domElement, this.containerObj.firstChild);
		}else{
			this.containerObj.appendChild(this.domElement);
		}
		
		
	}
	
	this.onUserClick = function(e){
		if(this.onRemoveFunction != null){
			
			this.onRemoveFunction(e);
			
		}else{
			if(this.removeOnClick){
				this.remove();
			}
		}
	}
	
	this.addOnClickRemove = function(){
		
		var thisObj = this;
		this.addEventListener("onclick", function(e){
			thisObj.onUserClick(e);
			return false;
		});
		
	}
	
	this.remove = function(){
		
		this.clearContents();
		
		this.containerObj.removeChild(this.domElement);
		
	}
	
	this.setContainer = function(container){
		this.containerObj = container;
	}

	this.OverlayObject();

}



OverlayObject.inherits(DisplayObject);