// JavaScript Document
function myAlert(txt, labelBotao) {

	tela = {
		moveTo : function(x,y) { window.scroll(x,y); },
		moveBy : function(x,y) { this.moveTo(this.sx()+x,this.sy()+y) },
		sx : function() { return (document.body) ? (document.body.scrollLeft) : (window.pageXOffset) },
		sy : function() { return (document.body) ? (document.body.scrollTop) : (window.pageYOffset) },
		dw : function() { return (document.body) ? (document.body.scrollWidth) : (document.width) },
		dh : function() { return (document.body) ? (document.body.scrollHeight) : (document.height) },
		ww : function() { return (document.body) ? (document.body.clientWidth) : (window.innerWidth) },
		wh : function() { return (document.body) ? (document.body.clientHeight) : (window.innerHeight) },
		sw : function() { return (screen.width) },
		sh : function() { return (screen.height) }
		};

	//iframe que vai bloquear a tela
	var iframe = document.createElement("iframe");
	iframe.style.position = "absolute";
	iframe.style.left = 0;
	iframe.style.top = 0;
	iframe.width = tela.ww();
	iframe.height = tela.dh();
	iframe.frameBorder = 0;
	iframe.className = "transparent";
	document.body.appendChild(iframe);
	
	//div que vai bloquear a tela
	var divTrava = document.createElement("div");
	divTrava.style.position = "absolute";
	divTrava.style.left = 0;
	divTrava.style.top = 0;
	divTrava.style.width = tela.ww();
	divTrava.style.height = tela.dh();
	divTrava.style.background = "#1b70e1";
	divTrava.className = "transparent";
	document.body.appendChild(divTrava);

	// cria imagem
	//var img = document.createElement("img");
	//img.src = "alerta.gif";

	// cria div
	div = document.createElement("div");
	div.style.position = "absolute";
	div.align = "center";
	div.className = "myAlertDiv";
	div.style.background = "#ffffff";

	// cria tabela
	var table = document.createElement("table");
	table.border		= 0;
	table.cellPading	= 0;
	table.cellSpacing	= 5;
	// cria linha
	row = table.insertRow(0);
	// cria coluna
	//col1 = row.insertCell(0);
	//col1.appendChild(img);
	col2 = row.insertCell(0);
	col2.className = "myAlertTd";
	col2.innerHTML = txt;

	div.appendChild(table);
	
	// cria  botao
	var botao = document.createElement("input");
	botao.type = "button";
	botao.onclick = function() {
		document.body.removeChild(divTrava);
		document.body.removeChild(iframe);
		document.body.removeChild(div);
	}
	if(!labelBotao) {
		botao.value = "OK";
	} else {
		botao.value = labelBotao;
	}
	botao.className = "myAlertBotao";
	div.appendChild(botao);
	
	document.body.appendChild(div);

	var left = (tela.ww() / 2) - (div.offsetWidth / 2);
	var top = ((tela.wh() / 2) + tela.sy()) - (div.offsetHeight / 2);

	div.style.left = left;
	div.style.top = top;
	botao.focus();
}
