_box = {
	_aviso : false,
	screenW : '',
	screenH : '',
	tbranca : false,
	_id : '',
	_campo: '',

	getScreen : function() {
		var corpo = document.getElementsByTagName("body")[0];
		this.screenW = corpo.clientWidth;
		this.screenH = corpo.clientHeight;
	},

	aviso : function(id, campo) {
		if(this._aviso == false) {
			_box.criar('Atenção', 'includes/buscaTextoLightbox.php?id='+id); _box.dimensionar('500','350');
			this._aviso = true;
			this._id = id;
			if(campo) {
				this._campo = campo;
			}
		}
	},
	dimensionar : function(largura, altura) {
		var div = document.getElementById("blackContent");
		var conteudo = document.getElementById("blackConteudo");
		this.getScreen();
		div.style.width = largura+'px';
		div.style.height = altura+'px';
		div.style.marginLeft = eval(-(parseInt(largura)/2))+"px";
		div.style.marginTop = eval(-(parseInt(altura)/2))+"px";
		conteudo.style.height = eval(div.clientHeight - 60) + "px";
	},

	criar : function(titulo, conteudo) {
		if(!document.getElementById("blackContent")) {
			if(document.getElementById("tBranca")) {
				document.getElementById("tBranca").style.display = "none";
				this.tbranca = true;
			}
			var body = document.getElementsByTagName("body")[0];
			var blackContent = document.createElement("div");
					blackContent.setAttribute("id", "blackContent");
			var div_titulo = document.createElement("div");
					div_titulo.setAttribute("id", "blackTitle");
					div_titulo.setAttribute("style", "overflow: hidden; ");
			var _titulo = "<span style='font-family: tahoma, verdana; font-size: 12px; font-weight: bold; float: left; color: #333;'>"+titulo+"</span><span style='float: right; display: block;'><a style='color: #00f; font-size: 12px;' href='#' onclick='_box.fechar();'>Fechar[<span style='color: #f00;'>x</span>]</a></span>"
			var filhos = body.childNodes;
					div_titulo.innerHTML = _titulo;
					blackContent.appendChild(div_titulo);
			var blackConteudo = document.createElement("div");
					blackConteudo.setAttribute("id", "blackConteudo");
					if(!conteudo) {
						blackConteudo.innerHTML = "carregando...";
					} else {
						blackConteudo.innerHTML = '<iframe src='+conteudo+' frameborder=no noresize=noresize width=100% height=100% framespacing=0></iframe>';
					}
					blackContent.appendChild(blackConteudo);
					body.insertBefore(blackContent, filhos[0]);
		}
	},

	remover : function(el) {
		el.parentNode.removeChild(el);
	},

	fechar : function() {
		if(document.getElementById("blackContent")) {
			bB = document.getElementById("blackContent");
			document.getElementById("tBranca").style.display = "block";
			this.remover(bB);
			if(this._campo != '') {
				this._campo.focus();
				this._campo = '';
			}
		}
	},

	rte : function(url) {
		document.getElementById("blackConteudo").innerHTML = '<iframe name=FrameRTE src='+url+' frameborder=no width=100% height=100%></iframe>'
	},

	carregar : function(url) {
		var ajax = criaXMLHttp();
		ajax.open("GET", url, true);
		ajax.onreadystatechange = function() {
			if(ajax.readyState == 4) {
				document.getElementById("blackConteudo").innerHTML = ajax.responseText;
			}
		}
		ajax.send(null);
	},

	limpar : function() {
		this._aviso = false;
		this.tbranca = false;
		this.screenW = '';
		this.screenH = '';
	}
}
