//<!--
			var timerID = null;
			var timerRunning = false;

			function CriaArray (n) {
				this.length = n
				return;
			}

			function stopclock () {
				if(timerRunning) {
					clearTimeout(timerID);
					timerRunning = false;
				}
				return;
			}

			function time() {
				var now = new Date();
				var hours = now.getHours();

				var NomeDia = new CriaArray(7);
				NomeDia[0] = "Domingo";
				NomeDia[1] = "Segunda-feira";
				NomeDia[2] = "Ter&ccedil;a-feira";
				NomeDia[3] = "Quarta-feira";
				NomeDia[4] = "Quinta-feira";
				NomeDia[5] = "Sexta-feira";
				NomeDia[6] = "S&aacute;bado";

				var NomeMes = new CriaArray(12);
				NomeMes[0] = "Janeiro";
				NomeMes[1] = "Fevereiro";
				NomeMes[2] = "Mar&ccedil;o";
				NomeMes[3] = "Abril";
				NomeMes[4] = "Maio";
				NomeMes[5] = "Junho";
				NomeMes[6] = "Julho";
				NomeMes[7] = "Agosto";
				NomeMes[8] = "Setembro";
				NomeMes[9] = "Outubro";
				NomeMes[10] = "Novembro";
				NomeMes[11] = "Dezembro";

				var hoje = new Date();
				var dia = hoje.getDate();
				var dias = hoje.getDay();
				var mes = hoje.getMonth();
				var ano = hoje.getFullYear();
				if (dia < 10) {
					dia = "0" + dia;
				}
				if (ano < 2000) {
					ano = "19" + ano;
				}

				var hours = ((now.getHours() < 10) ? "0" : "") + now.getHours();
				var minutes = ((now.getMinutes() < 10) ? ":0" : ":") + now.getMinutes();
				var seconds = ((now.getSeconds() < 10) ? ":0" : ":") + now.getSeconds();
				var Time=(hours + minutes + seconds );
				document.getElementById('relogio').innerHTML = NomeDia[dias] + " , " + dia + " de " + NomeMes[mes] + " de " + ano + "&nbsp;&nbsp;-&nbsp;&nbsp;" + Time;
				timerID = setTimeout("time()",1000);
				timerRunning = true;
				return;
			}

			function clearStatus() {
				if(timerRunning) {
					clearTimeout(timerID);
					timerRunning = false;
					document.getElementById('relogio').innerHTML="";
				}
				return;
			}

			function startclock() {
				stopclock();
				time();
				return;
			}

			function trim(wcampo) {
				wcampo.replace(" ","");
				return wcampo;
			}

			function validacpf(wcampo){
				var i;

				if (wcampo.length < 11) {
					return false;
				}
				else {
					var c = wcampo.substr(0,9);
					var dv = wcampo.substr(9,2);
					var d1 = 0;

					for (i = 0; i < 9; i++){
						d1 += c.charAt(i)*(10-i);
					}

					d1 = 11 - (d1 % 11);

					if (d1 > 9) d1 = 0;

					var d2 = d1;
					d1 *= 2;

					for (i = 0; i < 9; i++){
						d1 += c.charAt(i)*(11-i);
					}

					d1 = 11 - (d1 % 11);

					if (d1 > 9) d1 = 0;

					d2 = (10 * d2) + d1;

					if (d2 == dv) {
						return true;
					}
					else {
						return false;
					}
				}
			}

			function removeAcentos($campo){

				var $comAcentos = "áéíóúàèìòùâêîôûäëïöüãõñ@#$%^&*():;°ºª+=~`´_ ç";
				var $semAcentos = "aeiouaeiouaeiouaeiouaon___________________--c";
				var $retorno = "";

				$tempstring = $campo.value.toLowerCase();

				for(i=0; i<$comAcentos.length; i++){
					for(j=0; j<$tempstring.length; j++){
						$retorno = $tempstring.replace($comAcentos.substr(i,1), $semAcentos.substr(i,1));
						$retorno = $retorno.replace("_","").replace('--', '-');
						$tempstring = $retorno;
					}
				}
				$campo.value = $tempstring;
				return $tempstring;
			}

//			usar esta função com onblur="javascript:removeAcentos(this)" no campo desejado
			function remover(wcampo){
				removeAcentos(wcampo);
				return;
			}

			function clearCampo( campo, event ){
 				campo.value = "";
				return true;
			}
			
			function mostrar() {
				x=document.getElementById("pop");
				x.className="mostra";
				return;
			}

			function ocultar() {
				x=document.getElementById("pop");
				x.className="oculta";
				return;
			}
			
			function xeqTamCEP( campo, event ){
 				if( campo.value.length != 9 ){
					alert("CEP inválido");
					return false;
				}
				else {
 					return true;
				}
			}
			
			function validaTeclaCEP(campo, event){
				var BACKSPACE = 8;
				var TABHOR = 9;
				var key;
				var tecla;
				CheckTAB=true;

				if(navigator.appName.indexOf("Netscape")!= -1){
					tecla= event.which;
				}else{
					tecla= event.keyCode;
				}
				key = String.fromCharCode(tecla);

				if (tecla == 13){
					return false;
				}
				else if ((tecla == BACKSPACE) || (tecla == TABHOR)) {
					return true;
				}
				else {
					if (campo.value.length == 5) {
						campo.value += "-";
						return (sonumeros(key));
					}
					else {
						return (sonumeros(key));
					}
				}
			}
			
			function validavalores(campo, event){
				var BACKSPACE = 8;
				var key;
				var tecla;
				CheckTAB=true;

				if(navigator.appName.indexOf("Netscape")!= -1) {
					tecla= event.which;
				}
				else {
					tecla= event.keyCode;
				}
 
				key = String.fromCharCode( tecla );

				if (tecla == 13){
					return false;
				}
				else if (tecla == BACKSPACE) {
					return true;
				}
				else {
					return (sovalores(key));
				}
			}
			
			function sovalores(caractere){
				var strValidos = "0123456789,";

 				if (strValidos.indexOf(caractere) == -1) {
					return false;
				}
				else {
 					return true;
				}
			}
			
			function sonumeros(caractere){
				var strValidos = "0123456789";

 				if (strValidos.indexOf(caractere) == -1) {
					return false;
				}
				else {
 					return true;
				}
			}
			
			function pesquisa() {
				document.getElementById('argumento').focus();
				var n_tip = 9, n_cat = 9, n_cam = 9, s_arg = 9;
				n_tip = document.getElementById('tipo').value;
				n_cat = document.getElementById('categoria').value;
				n_cam = document.getElementById('selecao').value;
				s_arg = document.getElementById('argumento').value;
				if ((n_tip <= 1) && (n_cat == 0) && (s_arg.length < 1)) {
					alert("Esta seleção resultaria na exibição de praticamente todo o nosso acervo!\n\n\t\tPor favor selecione um critério menos abrangente!");
					return false;
				}
				else {
					location.href = "pesquisa.asp?tp="+n_tip+"&ct="+n_cat+"&cp="+n_cam+"&ar="+s_arg+"";
				}
				return true;
			}
			
			function cancela() {
				document.getElementById('acao').value = "";
				document.getElementById('acao1').value = "";
				document.getElementById('acao2').value = "";
				return true;
			}
			
			function reserva() {
				document.getElementById('argumento').focus();
				var n_tip = 9, n_cat = 9, n_cam = 9, s_arg = 9, s_ref, s_tit, s_edi, s_aut, s_anoed, s_cat, s_pes, s_val;
				n_tip = document.getElementById('tipo').value;
				n_cat = document.getElementById('categoria').value;
				n_cam = document.getElementById('selecao').value;
				s_arg = document.getElementById('argumento').value;
				s_ref = document.getElementById('refer').value;
				s_tit = document.getElementById('titulo').value;
				s_aut = document.getElementById('autor').value;
				s_edi = document.getElementById('editora').value;
				s_ano = document.getElementById('ano').value;
				s_cat = document.getElementById('categr').value;
				s_pes = document.getElementById('peso').value;
				s_val = document.getElementById('valor').value;
				location.href = "reservar.asp?tp="+n_tip+"&ct="+n_cat+"&cp="+n_cam+"&ar="+s_arg+"&rf="+s_ref+"&ti="+s_tit+"&au="+s_aut+"&ed="+s_edi+"&an="+s_ano+"&cg="+s_cat+"&ps="+s_pes+"&vl="+s_val;
				return true;
			}
			
			function recuperacli() {
				var s_ref, s_tit, s_aut, s_edi, s_ano, s_cat, s_pes, s_val, s_ema;
				s_ref = document.getElementById('refer').value;
				s_tit = document.getElementById('titulo').value;
				s_aut = document.getElementById('autor').value;
				s_edi = document.getElementById('edito').value;
				s_ano = document.getElementById('ano').value;
				s_cat = document.getElementById('categr').value;
				s_pes = document.getElementById('peso').value;
				s_val = document.getElementById('valor').value;
				s_ema = document.getElementById('email').value;
				location.href = "reservar.asp?rf="+s_ref+"&ti="+s_tit+"&au="+s_aut+"&ed="+s_edi+"&an="+s_ano+"&cg="+s_cat+"&ps="+s_pes+"&vl="+s_val+"&em="+s_ema;
				return true;
			}
			
			function comentario() {
				var w_campo = document.getElementById('nome').value;
				w_campo = w_campo.split(" ");
				if (w_campo.length < 2) {
					alert("Nome inválido ou incompleto");
					document.getElementById('nome').focus();
					return false;
				}
				var w_campo = document.getElementById('email').value;
				w_campo = w_campo.split("@");
				if (w_campo.length < 2) {
					document.getElementById('email').focus();
					alert("E-mail inválido ou incompleto");
					return false;
				}
				var w_campo = document.getElementById('email').value;
				w_campo = w_campo.split(".");
				if (w_campo.length < 2) {
					document.getElementById('email').focus();
					alert("E-mail inválido ou incompleto");
					return false;
				}
				var w_campo = document.getElementById('cep').value;
				if (w_campo.length < 9) {
					document.getElementById('cep').focus();
					alert("CEP inválido ou incompleto");
					return false;
				}
//				var w_campo = document.getElementById('avalia').value;
//				if (w_campo.length < 1) {
//					document.getElementById('avalia').focus();
//					alert("Por favor faça sua avaliação dos nossos serviços");
//					return false;
//				}
				return true;
			}
			
			function xeqpedido() {
				var w_campo = document.getElementById('refer').value;
				if (w_campo.length < 1) {
					alert("Nenhuma obra foi selecionada. Volte à pesquisa e selecione a obra desejada");
					document.getElementById('nome').focus();
					return false;
				}
				var w_campo = document.getElementById('nome').value;
				w_campo = w_campo.split(" ");
				if (w_campo.length < 2) {
					alert("Nome inválido ou incompleto");
					document.getElementById('nome').focus();
					return false;
				}
				var w_campo = document.getElementById('email').value;
				w_campo = w_campo.split("@");
				if (w_campo.length < 2) {
					document.getElementById('email').focus();
					alert("E-mail inválido ou incompleto");
					return false;
				}
				var w_campo = document.getElementById('email').value;
				w_campo = w_campo.split(".");
				if (w_campo.length < 2) {
					document.getElementById('email').focus();
					alert("E-mail inválido ou incompleto");
					return false;
				}
				var w_campo = document.getElementById('cep').value;
				if (w_campo.length < 9) {
					document.getElementById('cep').focus();
					alert("CEP inválido ou incompleto");
					return false;
				}
				var w_campo = document.getElementById('ender').value;
				w_campo = w_campo.split(" ");
				if (w_campo.length < 2) {
					document.getElementById('ender').focus();
					alert("Endereço inválido ou incompleto");
					return false;
				}
				var w_campo = document.getElementById('complemento').value;
				if (w_campo.length < 1) {
					document.getElementById('complemento').focus();
					alert("Preencha o complemento com o número, apartamento, etc.");
					return false;
				}
				var w_campo = document.getElementById('bairro').value;
				if (w_campo.length < 1) {
					document.getElementById('bairro').focus();
					alert("Bairro inválido ou incompleto");
					return false;
				}
				var w_campo = document.getElementById('cidade').value;
				if (w_campo.length < 1) {
					document.getElementById('cidade').focus();
					alert("Cidade inválida ou incompleta");
					return false;
				}
				var w_campo = document.getElementById('envio').value;
				if (w_campo.valueOf() == 0) {
					document.getElementById('envio').focus();
					alert("Forma de envio da encomenda inválida");
					return false;
				}
				wresp = confirm("Pronto!\nVocê está efetuando a reserva (sem compromisso) do título abaixo com as seguintes características:\n\nTítulo...:\t "+document.getElementById('titulo').value+"\nAutor...:\t"+document.getElementById('autor').value+"\nValor....:\tR$ "+document.getElementById('valor').value+"\nEntrega:\t"+document.getElementById('envio').value+"\nUF......:\t "+document.getElementById('uf').value+"\nCidade.:\t"+document.getElementById('cidade').value+"\n\nDeseja continuar ?");
				if (wresp) {
					return true;
				}
				else {
					return false;
				}
			}

			function preparacao() {
				var w_codtip = document.getElementById('newcodi').value;
				var w_destip = document.getElementById('newtipo').value;
				var w_codsta = document.getElementById('newstat').value;
				var w_confir = "confirma";
				location.href = "cadtipos.asp?regi="+w_codtip+"&cont="+w_destip+"&acao="+w_confir;
				return true;
			}
			
			function validarusrpas() {
				var w_usr = document.getElementById('user').value;
				var w_pas = document.getElementById('senha').value;
				if ((w_usr == "") || (w_usr.search("'") != -1) || (w_usr.search("-") != -1) || (w_usr.search(" or ") != -1)) {
					alert("Usuário/Senha incorretos");
					return false;
				}
				if ((w_pas == "") || (w_pas.search("'") != -1) || (w_pas.search("-") != -1) || (w_pas.search(" or ") != -1)) {
					alert("Usuário/Senha incorretos");
					return false;
				}
				return true;
			}
			
//-------------------------------------------------------------------------cadastro de usuários
			function manutusuario(w_cpcod, w_cpdes, w_cpsta, w_cpact) {
				document.getElementById('newcod').value = w_cpcod;
				document.getElementById('newdes').value = w_cpdes;
				document.getElementById('newsta').value = w_cpsta;
				document.getElementById('newact').value = w_cpact;
				mostrar();
				return true;
			}
			
//-------------------------------------------------------------------------cadastro de tipos
			function manuttipo(w_cpcod, w_cpdes, w_cpsta, w_cpact) {
				document.getElementById('newcod').value = w_cpcod;
				document.getElementById('newdes').value = w_cpdes;
				document.getElementById('newsta').value = w_cpsta;
				document.getElementById('newact').value = w_cpact;
				mostrar();
				return true;
			}
			
//-------------------------------------------------------------------------cadastro de categorias
			function novacategoria(w_cpcod, w_cpdes, w_cpsta, w_cpact) {
				document.getElementById('newcod').value = w_cpcod;
				document.getElementById('newdes').value = w_cpdes;
				document.getElementById('newsta').value = w_cpsta;
				document.getElementById('newact').value = w_cpact;
				mostrar();
				return true;
			}
			
			function manutcategoria(w_cpcod, w_cpdes, w_cpsta, w_cpact) {
				document.getElementById('newcod').value = w_cpcod;
				document.getElementById('newdes').value = w_cpdes;
				document.getElementById('newsta').value = w_cpsta;
				document.getElementById('newact').value = w_cpact;
				mostrar();
				return true;
			}
			
//-------------------------------------------------------------------------cadastro de categoriasev
			function novacategoriaev(w_cpcod, w_cpdes, w_cpsta, w_cpact) {
				document.getElementById('newcod').value = w_cpcod;
				document.getElementById('newdes').value = w_cpdes;
				document.getElementById('newsta').value = w_cpsta;
				document.getElementById('newact').value = w_cpact;
				mostrar();
				return true;
			}
			
			function manutcategoriaev(w_cpcod, w_cpdes, w_cpsta, w_cpact) {
				document.getElementById('newcod').value = w_cpcod;
				document.getElementById('newdes').value = w_cpdes;
				document.getElementById('newsta').value = w_cpsta;
				document.getElementById('newact').value = w_cpact;
				mostrar();
				return true;
			}
			
//-------------------------------------------------------------------------cadastro de editoras 
			function manuteditora(w_cpact) {
				if ((w_cpact == "A") || (w_cpact == "E")) {
					var w_combo = document.getElementById('editrf').value;
					if (w_combo == '') {
						alert("Escolha uma editora !");
						document.getElementById('argumento').focus();
						return false;
					}
					else {
						var w_separ = w_combo.split('§');
						document.getElementById('newcod').value = w_separ[0];
						document.getElementById('newdes').value = w_separ[2];
						if (w_separ[1] == "Ativa") {
							w_separ[1] = "A";
						}
						if (w_separ[1] == "Excluída") {
							w_separ[1] = "E";
						}
						document.getElementById('newsta').value = w_separ[1];
					}
				}
				document.getElementById('newact').value = w_cpact;
				mostrar();
				return true;
			}
			
//-------------------------------------------------------------------------cadastro de clientes
			function novocliente(w_cpact) {
				if (w_cpact == "P") {
					var w_combo = document.getElementById('clierf').value;
					if (w_combo == '') {
						alert("Escolha um cliente !");
						document.getElementById('argumento').focus();
						return false;
					}
					else {
						document.getElementById('newact').value = "P";
						document.getElementById('newcod').value = w_combo;
						return true;
					}
				}
				else {
					if (w_cpact == "M") {
						document.getElementById('novaact').value = w_cpact;
						return true;
					}
					else {
						document.getElementById('newact').value = w_cpact;
						mostrar();
						return true;
					}
				}
				return true;
			}
			
			function manutcliente(w_cpact) {
				if (w_cpact == "P") {
					var w_combo = document.getElementById('clierf').value;
					if (w_combo == '') {
						alert("Escolha um cliente !");
						document.getElementById('argumento').focus();
						return false;
					}
					else {
						document.getElementById('newact').value = "P";
						document.getElementById('newcod').value = w_combo;
						return true;
					}
				}
				else {
					if (w_cpact == "M") {
						document.getElementById('novaact').value = w_cpact;
						return true;
					}
					else {
						document.getElementById('newact').value = w_cpact;
						mostrar();
						return true;
					}
				}
				return true;
			}
			
//-------------------------------------------------------------------------cadastro de parametros
			function manutparametro(w_cpact) {
				document.getElementById('acao').value = w_cpact;
			}
			
//-------------------------------------------------------------------------arquivos
			function aguarde(w_campo) {
				if (w_campo == "bk") {
					x=document.getElementById("msg");
					x.className="oculta";
					document.getElementById('ger_bk').innerHTML = "Gerando Back-up. Aguarde...";
				}
				if (w_campo == "ev") {
					x=document.getElementById("msg");
					x.className="oculta";
					document.getElementById('ger_ev').innerHTML = "Gerando E.V. Aguarde...";
				}
				if (w_campo == "ev2") {
					x=document.getElementById("msg");
					x.className="oculta";
					document.getElementById('ger_ev2').innerHTML = "Gerando E.V.2 Aguarde...";
				}
				if (w_campo == "rv") {
					x=document.getElementById("msg");
					x.className="oculta";
					document.getElementById('ger_rv').innerHTML = "Gerando Relatório. Aguarde...";
				}
				return;
			}
			
//-------------------------------------------------------------------------cadastro de pedidos
			function pesqpedido() {
//				document.getElementById('argumento').focus();
				var w_tppd = document.getElementById('tipopd').value;
				var w_ainp = document.getElementById('ainp').value;
				var w_minp = document.getElementById('minp').value;
				var w_dinp = document.getElementById('dinp').value;
				var w_afip = document.getElementById('afip').value;
				var w_mfip = document.getElementById('mfip').value;
				var w_dfip = document.getElementById('dfip').value;
				if ((w_ainp != "AAAA") || (w_minp != "MM") || (w_dinp != "DD")) {
					if (w_ainp > w_afip) {
						alert("A data final (até) precisa ser maior que a data inicial (de)");
						return false;
					}
					if ((w_ainp == w_afip) && (w_minp > w_mfip)) {
						alert("A data final (até) precisa ser maior que a data inicial (de)");
						return false;
					}
					if ((w_ainp == w_afip) && (w_minp == w_mfip) && (w_dinp < w_dfip)) {
						alert("A data final (até) precisa ser maior que a data inicial (de)");
						return false;
					}
					var w_dtin = w_ainp+"/"+w_minp+"/"+w_dinp;
					var w_dtfi = w_afip+"/"+w_mfip+"/"+w_dfip;
				}
				document.getElementById('acao').value = "P"+w_tppd;
				return true;
			}
			
			function selecpedido(w_refer) {
				document.getElementById('acao1').value = "M"+w_refer;
				document.getElementById('tipopd3').value = document.getElementById('tipopd').value;
				return true;
			}
			
			function manutpedido(w_refer) {
				var werro = new CriaArray(2);
				var wind = 0;
				if (document.getElementById('vfrped').value == "") {
					werro[wind] = "Valor do Frete inválido\n";
					wind += 1;
				}
				else {
					for (i = 0; i < document.getElementById('vfrped').length; i++) {
						character = document.getElementById('vfrped').charAt(i);
						if ("0123456789,".indexOf(character) == -1) {
							werro[wind] = "Valor do Frete não numérico\n";
							wind += 1;
							break;
						}
					}
				}
				if (document.getElementById('vdeped').value == "") {
					werro[wind] = "Valor do Desconto inválido\n";
					wind += 1;
				}
				else {
					for (i = 0; i < document.getElementById('vdeped').length; i++) {
						character = document.getElementById('vdeped').charAt(i);
						if ("0123456789,".indexOf(character) == -1) {
							werro[wind] = "Valor do Desconto não numérico\n";
							wind += 1;
							break;
						}
					}
				}
				if (wind > 0) {
					var wmensagem = "Corrija as inconsistências encontradas:\n";
					var windm = 0;
					for(windm = 0; windm < wind; windm++) {
						wmensagem += (windm+1) + " - " + werro[windm];
					}
					alert(wmensagem);
					return false;
				}
				else {
					document.getElementById('acao2').value = "M"+w_refer;
					return true;
				}
			}
			
			function calcvltot() {
				var w_vl0 = 0.00, w_vl1 = 0.00, w_vl2 = 0.00, w_vl3 = 0.00, w_vltot = 0.00; w_pos = 0, w_campo = "";
				// pega o valor do produto
				w_campo = document.getElementById('vprped').value.replace(',','.');
				w_vl2 = parseFloat(w_campo);
				w_vl2 = Math.round(w_vl2 * 100) / 100;
				// pega o valor do frete
				w_campo = document.getElementById('vfrped').value.replace(',','.');
				if (isNaN(w_campo)) {
					alert("valor incorreto");
					document.getElementById('vfrped').value = '0,00';
					return false;
				}
				else {
					w_pos = w_campo.indexOf('.');
					switch (w_pos) {
						case -1:
							w_campo = w_campo.concat('.00');
							break;
						case 0:
							w_campo = '0' + w_campo;
							break;
						default:
							break;
					}
					w_pos = w_campo.indexOf('.');
					if ((w_campo.length - w_pos) < 3) {
						do {
							w_campo = w_campo.concat('0');
							w_pos = w_campo.indexOf('.');
						} while ((w_campo.length - w_pos) < 3);
					}
					if ((w_campo.length - w_pos) > 2) {
						w_campo = w_campo.substring(0,w_pos + 3);
					}
				}
				document.getElementById('vfrped').value = w_campo.replace('.',',');
				w_vl0 = parseFloat(w_campo);
				w_vl0 = Math.round(w_vl0 * 100) / 100;
				w_campo = document.getElementById('vdeped').value.replace(',','.');
				if (isNaN(w_campo)) {
					alert("valor incorreto");
					document.getElementById('vdeped').value = '0,00';
					return false;
				}
				else {
					w_pos = w_campo.indexOf('.');
					switch (w_pos) {
						case -1:
							w_campo = w_campo.concat('.00');
							break;
						case 0:
							w_campo = '0' + w_campo;
							break;
						default:
							break;
					}
					w_pos = w_campo.indexOf('.');
					if ((w_campo.length - w_pos) < 3) {
						do {
							w_campo = w_campo.concat('0');
							w_pos = w_campo.indexOf('.');
						} while ((w_campo.length - w_pos) < 3);
					}
					if ((w_campo.length - w_pos) > 2) {
						w_campo = w_campo.substring(0,w_pos + 3);
					}
				}
				document.getElementById('vdeped').value = w_campo.replace('.',',');
				w_vl1 = parseFloat(w_campo);
				w_vl1 = Math.round(w_vl1 * 100) / 100;
				w_vltot = w_vl2 + w_vl0 - w_vl1;
				w_campo = w_vltot.toString();
				w_pos = w_campo.indexOf('.');
				switch (w_pos) {
					case -1:
						w_campo = w_campo.concat('.00');
						break;
					case 0:
						w_campo = '0' + w_campo;
						break;
					default:
						break;
				}
				w_pos = w_campo.indexOf('.');
				if ((w_campo.length - w_pos) < 3) {
					do {
						w_campo = w_campo.concat('0');
						w_pos = w_campo.indexOf('.');
					} while ((w_campo.length - w_pos) < 3);
				}
				if ((w_campo.length - w_pos) > 2) {
					w_campo = w_campo.substring(0,w_pos + 3);
				}
				w_vltot = parseFloat(w_campo);
				w_vltot = Math.round(w_vltot * 100) / 100;
				document.getElementById('vtoped').value = w_campo.replace('.',',');
				return true;
			}
			
//-------------------------------------------------------------------------cadastro de produtos
			function novoproduto() {
				var w_refer = 0;
				document.getElementById('acao').value = "M"+w_refer;
				return true;
			}
			
			function pesqproduto() {
				document.getElementById('argupq').focus();
				var n_tip = 9, n_cat = 9, n_cam = 9, s_arg = 9, i = 0, s_char = "", s_falso = "";
				n_tip = document.getElementById('tipopq').value;
				n_cat = document.getElementById('catepq').value;
				n_cam = document.getElementById('camppq').value;
				s_arg = document.getElementById('argupq').value;
				if ((n_tip <= 1) && (n_cat == 0) && (s_arg.length < 1)) {
					alert("Esta seleção resultaria na exibição de praticamente todo o acervo!\n\n\t\tPor favor selecione um critério menos abrangente!");
					return false;
				}
				if (n_cam == 4) {
					s_falso = "T";
					for (i = 0; i < s_arg.length; i++) {
						s_char = s_arg.charAt(i);
						if ("0123456789".indexOf(s_char) == -1) {
							s_falso = "F";
							break;
						}
					}
					if (s_falso == "F") {
						alert("Referência inválida!");
						return false;
					}
					if (parseInt(s_arg) > 0) {
						document.getElementById('acao').value = "M"+parseInt(s_arg);
						return true;
					}
				}
				if (n_cam == 5) {
					if ((s_arg.toUpperCase() == 'I') || (s_arg.toUpperCase() == 'E') || (s_arg.toUpperCase() == 'R') || (s_arg.toUpperCase() == 'INATIVO') || (s_arg.toUpperCase() == 'EXCLUIDO') || (s_arg.toUpperCase() == 'EXCLUÍDO') || (s_arg.toUpperCase() == 'RESERVADO')) {
						if ((s_arg.toUpperCase() == 'RESERVADO') || (s_arg.toUpperCase() == 'R')) {
							alert("Esta pesquisa pode demorar, pois serão listados muitos registros")
						}
						document.getElementById('acao').value = "P";
						return true;
					}
					else {
						alert("Os status disponíveis para pesquisa são: E ou I ou R correspondentes a Excluídos ou Inativos ou Reservados!");
						return false;
					}
				}
				document.getElementById('acao').value = "P";
				return true;
			}
			
			function selecproduto(w_refer) {
				document.getElementById('acao1').value = "M"+w_refer;
				document.getElementById('tipopd3').value = document.getElementById('tipopd').value;
				return true;
			}
			
			function salvaproduto(w_refer) {
				var werro = new CriaArray(9);
				var wind = 0;
				if (document.getElementById('tiporf').value == 0) {
					werro[wind] = "Selecione um Tipo de Produto\n";
					wind += 1;
				}
				if (document.getElementById('caterf').value == 0) {
					werro[wind] = "Selecione uma Categoria de Produto\n";
					wind += 1;
				}
				if (document.getElementById('editrf').value == 0) {
					werro[wind] = "Selecione uma Editora para o Produto\n";
					wind += 1;
				}
				if (document.getElementById('titulo').value == "") {
					werro[wind] = "Título do Produto inválido\n";
					wind += 1;
				}
				if (document.getElementById('autor').value == "") {
					werro[wind] = "Autor do Produto inválido\n";
					wind += 1;
				}
				if (document.getElementById('edicao').value == "") {
					werro[wind] = "Caso não tenha a informação da edição, preencha com 0 (zero)\n";
					wind += 1;
				}
				else {
					for (i = 0; i < document.getElementById('edicao').length; i++) {
						character = document.getElementById('edicao').charAt(i);
						if ("0123456789".indexOf(character) == -1) {
							werro[wind] = "Número da Edição não numérica\n";
							wind += 1;
							break;
						}
					}
				}
				if (document.getElementById('paginas').value == "") {
					werro[wind] = "Caso não tenha a informação de páginas, preencha com 0 (zero)\n";
					wind += 1;
				}
				else {
					for (i = 0; i < document.getElementById('paginas').length; i++) {
						character = document.getElementById('paginas').charAt(i);
						if ("0123456789".indexOf(character) == -1) {
							werro[wind] = "Quantidade de Páginas não numérica\n";
							wind += 1;
							break;
						}
					}
				}
				if (document.getElementById('peso').value == "") {
					werro[wind] = "Caso não tenha a informação de peso, preencha com 0 (zero)\n";
					wind += 1;
				}
				else {
					for (i = 0; i < document.getElementById('peso').length; i++) {
						character = document.getElementById('peso').charAt(i);
						if ("0123456789".indexOf(character) == -1) {
							werro[wind] = "Peso não numérico\n";
							wind += 1;
							break;
						}
					}
				}
				if (document.getElementById('valor').value == "") {
					werro[wind] = "Valor do Produto inválido\n";
					wind += 1;
				}
				else {
					for (i = 0; i < document.getElementById('valor').length; i++) {
						character = document.getElementById('valor').charAt(i);
						if ("0123456789,".indexOf(character) == -1) {
							werro[wind] = "Valor do Produto não numérico\n";
							wind += 1;
							break;
						}
					}
				}
				if (wind > 0) {
					var wmensagem = "Corrija as inconsistências encontradas:\n";
					var windm = 0;
					for(windm = 0; windm < wind; windm++) {
						wmensagem += (windm+1) + " - " + werro[windm];
					}
					alert(wmensagem);
					return false;
				}
				else {
					document.getElementById('acao2').value = "M"+w_refer;
					return true;
				}
			}
			
			function copiaproduto(w_refer) {
				document.getElementById('acao2').value = "C"+w_refer;
				return true;
			}
			
			function cancelaacaoproduto() {
				document.getElementById('acao').value = "";
				document.getElementById('acao1').value = "";
				document.getElementById('acao2').value = "";
				return true;
			}
			
			function addfavoritos() {
				var bookmarkurl="www.tracasetracos.com.br"
				var bookmarktitle="Sebo Traças e Traços"
				if (document.all) {
					window.external.AddFavorite(bookmarkurl,bookmarktitle)
				}
			}
//-->