var LightBoxLite = {
	SetWindowBackground: function(sColor) {
		this._fullWindowBgColor = sColor;
	}, 
	
	SetLightOptions: function(nWidth, nHeight, sBgColor) {
		this._lightWindowWidth = nWidth;
		this._lightWindowHeight = nHeight;
		this._lightWindowBgColor = sBgColor;
	}, 
	
	SetClosingElement: function(sElementId) {
		this._AddClosingElement(sElementId);
	}, 
	
	ShowInnerElement: function(oElement) {
	    this._innerElement = oElement;
	    this._CreateFullWindow();
	    this._CreateLightWindow();
	    this._fullWindow.style.display = "";
	    this._innerElement.style.display = "";
	    document.body.onclick = this._BodyClick;
	    
	    this._FocusFirstText(this._innerElement);
	}, 
	
	Close: function() {
		if (this._fullWindow)
			this._fullWindow.style.display = "none";
		
		if (this._innerElement)
			this._innerElement.style.display = "none";
	}, 
	
	Reload: function(sElementToFocus) {
		LightBoxLite.Close();
		LightBoxLite.ShowInnerElement(LightBoxLite._innerElement);
		if (typeof sElementToFocus != "undefined") {
			_ge(sElementToFocus).focus();
		}
	}, 
	
	FindNodeDeep: function(oParent, oNode) {
		if (oParent == oNode)
			return true;
		for (var i=0; i<oParent.childNodes.length; i++) {
			var bFound = LightBoxLite.FindNodeDeep(oParent.childNodes[i], oNode);
			if (bFound)
				return true;
		}
		return false;
	}, 
	
	ChangeIdDeep: function(oParent, sToAppend) {
		if ((typeof oParent.id != "undefined") && (oParent.id.length > 0))
			oParent.id = sToAppend + oParent.id;
		
		for (var i=0; i<oParent.childNodes.length; i++)
			LightBoxLite.ChangeIdDeep(oParent.childNodes[i], sToAppend);
	}, 
	
	_CreateFullWindow: function() {
		var oDiv;
		if (!this._fullWindow) {
			oDiv = document.createElement("div");
			oDiv.id = "LightBoxLiteFullWindow";
			oDiv.style.position = "absolute";
			oDiv.style.top = "0px";
			oDiv.style.left = "0px";
			oDiv.style.backgroundColor = this._fullWindowBgColor;
			oDiv.style.filter = "alpha(opacity=75)";
			oDiv.style.opacity = "0.75";
			oDiv.style.display = "none";
			oDiv.style.zIndex = 3000;
			this._fullWindow = oDiv;
			document.body.appendChild(this._fullWindow);
		}
		oDiv = document.getElementById("LightBoxLiteFullWindow");
		oDiv.style.width = document.body.scrollWidth + "px";
		oDiv.style.height = document.body.scrollHeight + 250 + "px";
	}, 
	
	_CreateLightWindow: function() {
		if (this._innerElement) {
			var oDiv = this._innerElement;
			oDiv.style.position = "absolute";
			oDiv.style.width = this._lightWindowWidth + "px";
			oDiv.style.height = this._lightWindowHeight + "px";
			oDiv.style.padding = "10px";
			oDiv.style.textAlign = "left";
			oDiv.style.border = "1px solid #000";
			oDiv.style.backgroundColor = this._lightWindowBgColor;
			//oDiv.style.left = parseInt((document.body.clientWidth/2) - (this._lightWindowWidth/2) + document.body.scrollLeft) + "px";
			//oDiv.style.top = parseInt((document.body.clientHeight/2)-(this._lightWindowHeight/2) + document.body.scrollTop) + "px";
			oDiv.style.left = "123px";
			oDiv.style.top = "74px";
			//oDiv.style.marginLeft = (-1*parseInt(this._lightWindowWidth/2)) + "px";
			//oDiv.style.marginTop = (-1*parseInt(this._lightWindowHeight/2)) + "px";
			oDiv.style.filter = "alpha(opacity=100)";
			oDiv.style.opacity = "1.00";
			oDiv.style.display = "none";
			oDiv.style.zIndex = 5000;
		}
	}, 
	
	_AddClosingElement: function(sElementId) {
		this._closingElements[sElementId] = true;
	}, 
	
	_BodyClick: function(event) {
		if (typeof event == "undefined")
			event = window.event;
		
		var oSender = event.target || event.srcElement;
		if (oSender.id && oSender.id.length > 0 && LightBoxLite._closingElements[oSender.id]) {
			LightBoxLite.Close();
			return;
		}
		
		var sNodeName = oSender.nodeName.toLowerCase();
		if (sNodeName == "a" || sNodeName == "button" || (sNodeName == "input" && oSender.type == "button")) {
			//LightBoxLite.Reload();
			return;
		}
		
		if (LightBoxLite.FindNodeDeep(LightBoxLite._innerElement, oSender))
			return;
		
		LightBoxLite.Close();
	}, 
	
	_FocusFirstText: function(oParent) {
	    var arrInputs = oParent.getElementsByTagName("input");
	    for (var i=0; i<arrInputs.length; i++) {
			var oInput = arrInputs[i];
			if (oInput.type == "text") {
				try {
					oInput.focus();
				} catch (ex) {}
				break;
			}
	    }
	}, 
	
	_innerElement: 0, 
	_fullWindow: 0, 
	_lightWindow: 0, 
	_closingElements: new Array(), 
	_fullWindowBgColor: "#c0c0c0", 
	_lightWindowWidth: 500, 
	_lightWindowHeight: 250, 
	_lightWindowBgColor: "#ffffff"
}
