/*
LightWeightBox - Thom Shannon
http://www.ts0.com
V 1.0 2006
BSD License
*/

var LightWeightBoxOn=false;
var LightWeightBox = function(ele){
	this.ele = ele;
	this.backgroundColor = '#CCC';
	this.opacity = 0.5;
}
with (LightWeightBox){
	prototype.Render = function(){
		if (!LightWeightBoxOn){
			bgDiv = document.createElement('div');
			bgDiv.innerHTML = ''
			bgDiv.style.backgroundColor = this.backgroundColor;
			bgDiv.style.position='fixed';
			bgDiv.style.height='100%';
			bgDiv.style.width='100%';
			bgDiv.style.top=0;
			bgDiv.style.left='0';
			bgDiv.style.opacity=this.opacity;
			this.ele.style.position='fixed';
			this.bgDiv=bgDiv;
			document.body.appendChild(this.bgDiv);
			document.body.appendChild(this.ele);
			this.CheckSize();
			LightWeightBoxOn = true;
			var oSelf=this;
			this.sizeCheck = setInterval(function(){oSelf.CheckSize();},20);
		}
	}
	prototype.CheckSize = function(){
		if (this.ele.offsetHeight!=this.currentHeight) {
			this.offsetTop = (self.innerHeight/2)-(this.ele.offsetHeight/2);
			this.ele.style.top = this.offsetTop+'px';
			this.currentHeight=this.ele.offsetHeight;
		}
		if (this.ele.offsetWidth!=this.currentWidth) {
			this.offsetLeft = (self.innerWidth/2)-(this.ele.offsetWidth/2);
			this.ele.style.left = this.offsetLeft+'px';
			this.currentWidth=this.ele.offsetWidth;
		}
	}

	prototype.Close=function(oSelf){
		document.body.removeChild(oSelf.bgDiv);
		document.body.removeChild(oSelf.ele);
		LightWeightBoxOn = false;
	}
}
