function janela(url){
	window.location = url;
}

function janelaNova(url, altura, largura, sc){
	var definicao = "location=no, menubar=no, resizable=no, status=yes, toolbar=no, width="+largura+"px, height="+altura+"px, scrollbars="+sc;
	var jan = window.open(url, "", definicao);

	//posiciona a janela no centro da tela
	var X = (screen.availWidth / 2) - (largura / 2);
	var Y = (screen.availHeight / 2) - (altura / 2);

	jan.moveTo(X,Y);
	jan.focus();
}

function janelaNova02(url){
	jan = window.open(url);
	jan.moveTo(0,0);
	jan.focus();
}

function janelaModal(url, altura, largura, sc, argumentos){
	//cria uma janela modal dialog
	var definicao = "dialogHeight="+altura+"px; dialogWidth="+largura+"px; center=yes; status=no; scroll="+sc+";";
	var retorno = window.showModalDialog(url, argumentos, definicao);
	return retorno;
}

function fechaJanela(){
	document.onkeydown = function(){
		if(codigoCaractere02(event.keyCode) == "ESC"){
			//fecha a janela ativa
			window.close();
		}
	}
}

function selecionaTodos(nome, campo, estilo01, estilo02, nomeTabela){
	sel = document.getElementById(nome);
	obj = document.getElementsByName(campo);
	tam = obj.length;
	if(sel.status == true){
		//se o usuário selecionar o objeto "nome", seleciona todos os checkbox da página
		for(var i=0;i<tam;i++){
			obj[i].status = true;
			if(nomeTabela){
				//muda o estilo da linha
				mudaEstiloLinha(campo, i, estilo01, estilo02, nomeTabela);
			}
		}
	}else{
		//se o usuário deselecionar o objeto "nome", deseleciona todos os checkbox da página
		for(var i=0;i<tam;i++){
			obj[i].status = false;
			if(nomeTabela){
				//muda o estilo da linha
				mudaEstiloLinha(campo, i, estilo01, estilo02, nomeTabela);
			}
		}
	}
}

function selecionaTodasTabelas(nome, campo, estilo01, estilo02, nomeTabela){
	var sel = document.getElementById(nome);
	var obj = document.getElementsByName(campo);
	tam = obj.length;
	if(sel.status == true){
		//se o usuário selecionar o objeto "nome", seleciona todos os checkbox da página
		for(var i=0;i<tam;i++){
			obj[i].status = true;
			if(nomeTabela){
				//muda o estilo das tabela
				mudaEstiloTabela(campo, i, estilo01, estilo02, nomeTabela);
			}
		}
	}else{
		//se o usuário deselecionar o objeto "nome", deseleciona todos os checkbox da página
		for(var i=0;i<tam;i++){
			obj[i].status = false;
			if(nomeTabela){
				//muda o estilo das tabela
				mudaEstiloTabela(campo, i, estilo01, estilo02, nomeTabela);
			}
		}
	}
}

function selecionaLinha(nome, indice, estilo01, estilo02, nomeTabela){
	var checkBox = document.getElementsByName(nome);
	var tabela = document.getElementById(nomeTabela);
	var linha = tabela.getElementsByTagName("tr");
	if(checkBox[indice].status == true){
		checkBox[indice].status = false;
	}else{
		checkBox[indice].status = true;
	}
	mudaEstiloLinha(nome, indice, estilo01, estilo02, nomeTabela);
}

function selecionaLinha02(nome, indice, estilo01, estilo02, nomeTabela){
	//define o comboBox sempre como true
	var checkBox = document.getElementsByName(nome);
	var tabela = document.getElementById(nomeTabela);
	var linha = tabela.getElementsByTagName("tr");
	if(checkBox[indice].status == false){
		checkBox[indice].status = true;
		mudaEstiloLinha(nome, indice, estilo01, estilo02, nomeTabela);
	}
}

function selecionaTabela(nome, indice, estilo01, estilo02, nomeTabela){
	var checkBox = document.getElementsByName(nome);
	var tabela = document.getElementById(nomeTabela);
	if(checkBox[indice].status == false){
		checkBox[indice].status = true;
		mudaEstiloTabela(nome, indice, estilo01, estilo02, nomeTabela);
	}else{
		checkBox[indice].status = false;
		mudaEstiloTabela(nome, indice, estilo01, estilo02, nomeTabela);
	}
}

function selecionaTabela02(nome, indice, estilo01, estilo02, nomeTabela){
	//define o comboBox sempre como true
	var checkBox = document.getElementsByName(nome);
	var tabela = document.getElementById(nomeTabela);
	checkBox[indice].status = true;
	mudaEstiloTabela(nome, indice, estilo01, estilo02, nomeTabela);
}

function verificaBusca(){
	d = document.busca;
	escolha = document.getElementsByName("escolha");
	ordem = document.getElementsByName("ordem");
	if((d.produto.value == "") && (d.descricao.value == "") && (d.preco.value == "")){
		alert("Informe pelo menos um dos campos para efetuar a busca");
		d.produto.focus();
		return false;
	}
	indice = 0;
	for(var i=0;i<escolha.length;i++){
		if(escolha[i].status == true)
			indice++;
	}
	if(indice > 1){
		alert("Escolha apenas uma opção, preço ou produto");
		return false;
	}
	indice = 0;
	for(var i=0;i<ordem.length;i++){
		if(ordem[i].status == true)
			indice++;
	}
	if(indice > 1){
		alert("Escolha apenas uma opção de ordem, menor ou maior");
		return false;
	}
	return true;
}

function reduzFoto(foto, largura, altura){
	//reduz ou aumenta proporcionalmente a foto principal
	var f = document.getElementsByName(foto);
	var porcentagem = new Number();

	var tam = f.length;

	//reduz ou aumenta a foto
	for(var i=0;i<tam;i++){
		if(f[i].width < f[i].height){
			porcentagem = (largura * 100) / f[i].width;
		}else{
			porcentagem = (altura * 100) / f[i].height;
		}
		novaLargura = (f[i].width * porcentagem) / 100;
		novaAltura = (f[i].height * porcentagem) / 100;

		f[i].width = novaLargura;
		f[i].height = novaAltura;
	}
}

function verificaResolucao(obj){
	//função para verificar a resolução da tela do usuário e com isso posicionar o site no centro ou no canto esquerdo
	var largura = screen.availWidth - 10;
	var altura = screen.availHeight - 100;
	//div responsável pelo posicionamento do site na tela
	var div = document.getElementById(obj);
	//tabela principal do site
	var tabela = div.firstChild;
	var meioTela = new Number();
	var pos = new String();

	div.style.position = "absolute";

	if(largura >= tabela.width){
		//calcula o centro da tela horizontalmente
		meioTela = ~(tabela.width / 2);

		//posiciona a divisão no centro horizontal da tela
		div.style.left = "50%";
		div.style.marginLeft = String(meioTela + "px");
	}
	if(altura >= tabela.height){
		//calcula o centro da tela verticalmente
		meioTela = ~(tabela.height / 2);

		div.style.top = "50%";
		div.style.marginTop = String(meioTela + "px");
	}else{
		div.style.top = 0;
	}
}

function centroTopo(obj){
	//função para colocar o site no topo e no centro da tela
	var largura = screen.availWidth - 10;
	//div responsável pelo posicionamento do site na tela
	var div = document.getElementById(obj);
	//tabela principal do site
	var tabela = div.firstChild;
	var meioTela = new Number();
	var pos = new String();

	div.style.position = "absolute";

	if(largura >= tabela.width){
		//calcula o centro da tela horizontalmente
		meioTela = ~(tabela.width / 2);

		//posiciona a divisão no centro horizontal da tela
		div.style.left = "50%";
		div.style.marginLeft = String(meioTela + "px");
	}
	div.style.top = 0;
}

function ajustaPosicao(obj, topo, margemEsquerda, esquerda){
	//função que ajusta a posição do obj de acordo com as margens especificadas
	//div responsável pelo posicionamento do site na tela
	var div = document.getElementById(obj);
	div.style.position = "absolute";
	div.style.marginLeft = margemEsquerda;
	div.style.left = esquerda;
	div.style.top = topo;
}

function mudaEstilo(estilo, indice, nomeTabela){
	var tabela = document.getElementById(nomeTabela);
	var colunas = tabela.getElementsByTagName("td");
	colunas[indice].className = estilo;
}

function mudaEstiloLinha(nome, indice, estilo01, estilo02, nomeTabela){
	if(nome)
		var checkBox = document.getElementsByName(nome);
	var tabela = document.getElementById(nomeTabela);
	var linha = tabela.getElementsByTagName("tr");

	if(checkBox){
		if(event.type == "mouseover"){
			//verifca se o check está marcado
			if(checkBox[indice].status == false){
				//então muda o estilo da linha
				linha[indice].className = estilo02;
			}
		}else if(event.type == "mouseout"){
			//verifica o status do check
			if(checkBox[indice].status == false){
				linha[indice].className = estilo01;
			}
		}else if(event.type == "click"){
			//verifica o status do check
			if(checkBox[indice].status == true)
				linha[indice].className = estilo02;
			else
				linha[indice].className = estilo01;
		}
	}else{
		if(event.type == "mouseout")
			linha[indice].className = estilo01;
		else
			linha[indice].className = estilo02;
	}
}

function mudaEstiloLinha02(nome, indice, indiceTabela, estilo01, estilo02, nomeTabela){
	//muda o estilo da linha, quando existem várias tabelas com o mesmo nome
	if(nome)
		var checkBox = document.getElementsByName(nome);
	var tabela = document.getElementsByName(nomeTabela);
	var linha = tabela[indiceTabela].getElementsByTagName("tr");

	if(checkBox){
		if(event.type == "mouseover"){
			//verifca se o check está marcado
			if(checkBox[indice].status == false){
				//então muda o estilo da linha
				linha[indice].className = estilo02;
			}
		}else if(event.type == "mouseout"){
			//verifica o status do check
			if(checkBox[indice].status == false){
				linha[indice].className = estilo01;
			}
		}else if(event.type == "click"){
			//verifica o status do check
			if(checkBox[indice].status == true)
				linha[indice].className = estilo02;
			else
				linha[indice].className = estilo01;
		}
	}else{
		if(event.type == "mouseout")
			linha[indice].className = estilo01;
		else
			linha[indice].className = estilo02;
	}
}

function mudaEstiloLinha03(nome, indice, estilo01, estilo02, nomeTabela){
	if(nome)
		var checkBox = document.getElementsByName(nome);
	var tabela = document.getElementById(nomeTabela);
	var linha = tabela.getElementsByTagName("tr");

	if(checkBox){
		//verifica o status do check
		if(checkBox[indice].status == true)
			linha[indice].className = estilo02;
		else
			linha[indice].className = estilo01;
	}
}

function mudaEstiloTabela(nome, indice, estilo01, estilo02, nomeTabela){
	//muda o estilo da linha, quando existem várias tabelas com o mesmo nome
	if(nome)
		var checkBox = document.getElementsByName(nome);
	var tabela = document.getElementsByName(nomeTabela);

	if(checkBox){
		if(event.type == "mouseover"){
			//verifca se o check está marcado
			if(checkBox[indice].status == false){
				//então muda o estilo da linha
				tabela[indice].className = estilo02;
			}
		}else if(event.type == "mouseout"){
			//verifica o status do check
			if(checkBox[indice].status == false){
				tabela[indice].className = estilo01;
			}
		}else if(event.type == "click"){
			//verifica o status do check
			if(checkBox[indice].status == true)
				tabela[indice].className = estilo02;
			else
				tabela[indice].className = estilo01;
		}
	}else{
		if(event.type == "mouseout")
			tabela[indice].className = estilo01;
		else
			tabela[indice].className = estilo02;
	}
}

function montaBotoes(cod, paginas, nomes, altura, largura, divisao, adicionaisValores, adicionaisNomes){
	//função que monta os botões nos detalhes de um item selecionado
	//adicionaisValores: são valores que devem ser passados pelo método GET (caso necessário)
	//adicionaisNomes: são os nomes atribuídos aos valores que serão passados pelo método GET

	var div = document.getElementById(divisao);
	var tabela = div.children(0);
	var coluna = tabela.children(0).children(1).children(0);
	var tamanho = coluna.children.length;
	if(tamanho > 0){
		for(var i=0;i<tamanho;i++){
			//remove os botões
			var elemento = coluna.children(0);
			coluna.removeChild(elemento);
		}
	}

	var acentos = Array("á", "é", "í", "ó", "ú", "Á", "É", "Í", "Ó", "Ú", "ã", "õ", "Ã", "Õ", "à", "è", "ì", "ò", "ù", "À", "È", "Ì", "Ò", "Ù", "â", "ê", "î", "ô", "û", "Â", "Ê", "Î", "Ô", "Û", "ä", "ë", "ï", "ö", "ü", "Ä", "Ë", "Ï", "Ö", "Ü", "ç", "Ç");
	var substitui = Array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U", "a", "o", "A", "O", "a", "e", "i", "o", "u", "A", "E", "I", "O", "U", "a", "e", "i", "o", "u", "A", "E", "I", "O", "U", "a", "e", "i", "o", "u", "A", "E", "I", "O", "U", "c", "C");

	//cria os botões
	for(var i=0;i<paginas.length;i++){
		//verifica o tamanho da janela nova para impressão de dados (largura e altura)
		var linkagem = new String();
		var rolagem = "no";
		var nome = nomes[i].toLowerCase();
		if(nome.indexOf("imprimir") != -1){
			alturaAux = screen.availHeight;
			larguraAux = screen.availWidth;
			linkagem = "admImpressao.php";
			rolagem = "yes";
		}else if(nome.indexOf("cópia") != -1){
			alturaAux = screen.availHeight;
			larguraAux = screen.availWidth;
			linkagem = "admImpressao.php";
			rolagem = "yes";
		}else if(nome == "fotos" || nome.indexOf("adicionar") != -1){
			alturaAux = altura;
			larguraAux = largura;
			rolagem = "yes";
			linkagem = "admJanelaNova.php";
		}else if(nome == "gerar senha atendimento"){
			alturaAux = screen.availHeight;
			larguraAux = screen.availWidth;
			linkagem = "admImpressao.php";
			rolagem = "yes";
		}else if(nome == "abrir" || nome == "descontos"){
			alturaAux = altura;
			larguraAux = largura;
			linkagem = "adm.php";
		}else if(nome.indexOf("vistorias") != -1){
			alturaAux = altura;
			larguraAux = largura;
			linkagem = "adm.php";
		}else{
			alturaAux = altura;
			larguraAux = largura;
			linkagem = "admJanelaNova.php";
			rolagem = "yes";
		}

		var nomeAux = nomes[i].toLowerCase();
		nomeAux = nomeAux.replace(" ", "");
		for(var j=0;j<acentos.length;j++){
			nomeAux = nomeAux.replace(acentos[j], substitui[j]);
		}

		var classe = "admBotao";
		if(nomes[i].length > 12)
			classe = "admBotao02";

		//verifica a url de destino (linkagem)
		linkagem += "?cod="+ cod +"&pag="+ paginas[i];
		if(adicionaisValores){
			linkagem += "&";
			for(var a=0;a<adicionaisValores.length;a++){
				if(a==(adicionaisValores.length - 1))
					linkagem += adicionaisNomes[a] + "=" + adicionaisValores[a];
				else
					linkagem += adicionaisNomes[a] + "=" + adicionaisValores[a] + "&";
			}
		}

		if(nomes[i] == "Fechar"){
			var texto = "<input type=\"button\" name=\""+ nomeAux +"\" id=\""+ nomeAux +"\" value=\""+ nomes[i] +"\" class=\""+ classe +"\" />";
		}else if(nomes[i] == "Abrir" || nomes[i] == "Descontos"){
			var texto = "<input type=\"button\" name=\""+ nomeAux +"\" id=\""+ nomeAux +"\" value=\""+ nomes[i] +"\" class=\""+ classe +"\" onclick=\"janela('"+ linkagem +"')\" />";
		}else if(nomes[i] == "Alterar Senha"){
			var texto = "<input type=\"button\" name=\""+ nomeAux +"\" id=\""+ nomeAux +"\" value=\""+ nomes[i] +"\" class=\""+ classe +"\" onclick=\"mostraFormularioAlterarSenha('"+cod+"')\" />";
		}else if(nome.indexOf("vistorias") != -1){
			var texto = "<input type=\"button\" name=\""+ nomeAux +"\" id=\""+ nomeAux +"\" value=\""+ nomes[i] +"\" class=\""+ classe +"\" onclick=\"janela('"+ linkagem +"')\" />";
		}else{
			var texto = "<input type=\"button\" name=\""+ nomeAux +"\" id=\""+ nomeAux +"\" value=\""+ nomes[i] +"\" class=\""+ classe +"\" onclick=\"janelaNova('"+ linkagem +"', '"+ alturaAux +"', '"+ larguraAux +"', '"+ rolagem +"')\" />";
		}

		var botao = document.createElement(texto);
		coluna.appendChild(botao);
	}

	//scroll(0,0);
	expandeDivisao(divisao, null, null);
}

function mostraFormularioAlterarSenha(cod){
	var div = document.getElementById("divisaoAlterarSenha");
	var conteudo = div.children(0).children(0);
	div.style.visibility = "visible";
	if(div.style.marginLeft == ""){
		div.style.marginLeft = div.style.marginLeft - (conteudo.width / 2);
		div.style.top = ((screen.availHeight / 2) - (conteudo.height / 2)) - 20;
	}

	//cria a trava da divisão
	var novaDiv = document.createElement("div");
	var tabela = document.createElement("table");
	var tBody = document.createElement("tbody");
	var linha = document.createElement("tr");
	var coluna = document.createElement("td");
	linha.appendChild(coluna);
	tBody.appendChild(linha);
	tabela.appendChild(tBody);
	novaDiv.appendChild(tabela);

	var altura = screen.availHeight - 100;
	var largura = screen.availWidth - 50;

	novaDiv.id = "travaAlterarSenha";
	novaDiv.style.position = "absolute";
	novaDiv.style.left = "0px";
	novaDiv.style.top = "0px";
	novaDiv.style.zIndex = 3004;
	tabela.width = largura + "px";
	tabela.height = altura + "px";
	tabela.border = 0;

	document.getElementById("principal").appendChild(novaDiv);

	document.getElementById("cod").value = cod;
	document.getElementById("senhaNova").focus();

	document.getElementById("cancelar").onclick = function(){
		document.getElementById("principal").removeChild(novaDiv);
		div.style.visibility = "hidden";
	}
}

function expandeDivisao(nome, altura, largura){
	//função para colocar a divisão de nome no meio e criar uma trava
	var div = document.getElementById(nome);
	var maxLimitTop = (this.maxLimitTop == null)?(document.documentElement.scrollHeight - document.documentElement.clientHeight):this.maxLimitTop;
	var top = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0; 

	div.style.marginTop = "21%";
	div.style.left = "25%";
	div.style.top = top +"px"; 

	//cria a trava da divisão
	var novaDiv = document.createElement("div");
	var tabela = document.createElement("table");
	var tBody = document.createElement("tbody");
	var linha = document.createElement("tr");
	var coluna = document.createElement("td");
	linha.appendChild(coluna);
	tBody.appendChild(linha);
	tabela.appendChild(tBody);
	novaDiv.appendChild(tabela);

	if(!altura)
		altura = document.getElementById("principal").scrollHeight;
	if(!largura)
		largura = document.getElementById("principal").scrollWidth;
	novaDiv.id = "trava";
	novaDiv.style.position = "absolute";
	novaDiv.style.left = "0px";
	novaDiv.style.top = "0px";
	novaDiv.style.zIndex = 1;
	tabela.width = largura + "px";
	tabela.height = altura + "px";
	tabela.border = 0;

	document.getElementById("principal").appendChild(novaDiv);

	document.getElementById("fechar").onclick = function(){
		fechaDivisao02(nome);
	}
}

function expandeDivisao02(nome){
	//função coloca a divisão no centro, mas não cria uma trava, nem necessita do botão fechar
	var elemento = document.getElementById(nome);
	var i = new Number();
	while(i < 20){
		var conteudo = elemento.children(0).children(i);
		var testando = conteudo.getElementsByTagName("tr");
		if(testando.length > 0){
			elemento.style.position = "absolute";
			elemento.style.marginLeft = elemento.style.marginLeft - (conteudo.width / 2);
			//elemento.style.marginTop = conteudo.height;
			elemento.style.top = ((screen.availHeight / 2) - (conteudo.height / 2)) - 20;
		}
		i++;
	}
}

function fechaDivisao(nome){
	document.onkeydown = function(){
		if(codigoCaractere02(event.keyCode) == "ESC"){
			//fecha a divisão
			fechaDivisao02(nome);
		}
	}
}

function fechaDivisao02(nome){
	var div = document.getElementById(nome);
	if(div.style.display == 'block'){
		var trava = document.getElementById("trava");
		document.getElementById("principal").removeChild(trava);
		div.style.display = 'none';
	}
}

function formataTexto(string){
	//quando um texto é passado por xml para javascript, ela não retorna com linhas novas [ENTER]
	//esta função transforma as linhas novas textuais [\r\n] em linhas novas HTML [<br>]
	var substituto = new String();
	for(var i=0;i<string.length;i++){
		if(string.substr(i,4) == "\r\n\r\n"){
			substituto = substituto + "<br />";
		}else if(string.substr(i,2) == "\r\n"){
			substituto = substituto + "<br>";
		}else if(string.substr(i,1) == "\n"){
			substituto = substituto + "<br>";
		}else{
			substituto = substituto + string.substr(i,1);
		}
	}
	return substituto;
}

function mostraLegendaBotao(nome, bt){
	var div = document.getElementById("legendaBotoes");
	var botao = document.getElementById(bt);
	var esquerda = 0;
	var topo = 0;

	while(botao){
		esquerda += botao.offsetLeft;
		topo += botao.offsetTop;
		botao = botao.offsetParent;
	}
	if(navigator.userAgent.indexOf("Mac") != -1 && typeof document.body.leftMargin != "undefined"){
		esquerda += document.body.leftMargin;
		topo += document.body.topMargin;
	}

	div.style.visibility = "visible";
	div.style.top = topo + document.getElementById(bt).offsetHeight;
	div.style.left = esquerda;

	var conteudo = div.innerHTML;
	if(conteudo == ""){
		var texto = document.createTextNode(nome);
		div.appendChild(texto);
	}
}

function escondeLegendaBotao(){
	var div = document.getElementById("legendaBotoes");
	div.style.visibility = "hidden";
	div.innerHTML = "";
}

function atualizaPagina(){
	var url = String(window.location);
	var local = url.indexOf("adm.php");
	var novaUrl = url.substring(local, url.length);
	window.location = novaUrl;
}

function verificaSomenteNumeros(nome){
	var campo = document.getElementById(nome);
	if(campo){
		var digitado = event.keyCode;
		if(!codigoCaractere(digitado)){
			//verifica se o valor digitado é um backspace, delete, etc
			if(!codigoCaractere02(digitado)){
				//não faz nada
				event.returnValue = false;
			}
		}
	}else{
		event.returnValue = false;
	}
}

function controleImpressao(preVisualizar){
	if(preVisualizar == false){
		//remove as ferramentas da página de impressão
		var div = document.getElementById("principal");
		var elemento = div.children(0);
		div.removeChild(elemento);
	}
	impressao(preVisualizar);
}

function impressao(preVisualizar){
	var CorpoMensagem = document.body.innerHTML;
	var principal = document.getElementById("principal");
	document.body.innerHTML = principal.innerHTML;
	if( preVisualizar ){
		PreVisualizar();
	}else{
		window.print();
	}
	document.body.innerHTML = CorpoMensagem;
}

function PreVisualizar(){
	try{
		//Utilizando o componente WebBrowser1 registrado no MS Windows Server 2000/2003 ou XP/Vista
		var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>'; 
		document.body.insertAdjacentHTML('beforeEnd', WebBrowser); 
		WebBrowser1.ExecWB( 7, 1 ); 
		WebBrowser1.outerHTML = ""; 
	}catch(e){
		alert("Para visualizar a impressão você precisa habilitar o uso de controles ActiveX na página.");
		return;
	}
}

function bloquearBotao(){
	if(event.button==2||event.button==3){
		oncontextmenu='return false';
	}
}

//################# funções para mostrar o carregando na tela ##################
function criaCarregando(altura,largura){
	//pega a divisão para colocar o carregando
	var div = document.createElement("div");
	div.style.position = "absolute";
	div.style.left = "0px";
	div.style.top = "0px";
	div.id = "carregando";
	//div.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=50)";

	//cria a tabela que vai conter o carregando
	var tabela = document.createElement("table");
	var tBody = document.createElement("tbody");
	var linha = document.createElement("tr");
	var coluna = document.createElement("td");

	//cria o carregando
	var bgteste = new Flash("carregando.swf", "carregando", "155", "47");
	bgteste.addParameter("quality", "high");
	bgteste.addParameter("wmode", "transparent");
	bgteste.addParameter("showMenu", "true");

	//mostra o carregando
	if(altura && largura){
		tabela.width = largura;
		tabela.height = altura;
	}else{
		tabela.width = screen.availWidth;
		tabela.height = screen.availHeight;
	}
	tabela.border = 0;
	coluna.align = "center";
	coluna.valign = "middle";
	coluna.innerHTML = bgteste;
	linha.appendChild(coluna);
	tBody.appendChild(linha);
	tabela.appendChild(tBody);
	div.appendChild(tabela);
	document.body.appendChild(div);
}

function removeCarregando(){
	//remove a divisão com o carregando
	var div = document.getElementById("carregando");
	document.body.removeChild(div);
}
//##############################################################################