/*********************************************************************************/
/*
/* Auction On-Line 2.0
/* Desenvolvedor: Wilson da Silva Cabrera
/* Atualização..: 24/10/2008 às 11:16hs
/* Todos os direitos reservados
*/

/*********************************************************************************/
/*
/* Funções comuns a várias áreas do sistema
*/

function getXmlHttpRequest() {

	if ( window.XMLHttpRequest ){

		return new XMLHttpRequest();

	} else if ( window.ActiveXObject ){

		return new ActiveXObject( "Microsoft.XMLHTTP" );

	}

}

function sonumeros( evt, cobj ){

	var tecla;

	if ( evt.which ){
		tecla = evt.which;
	} else {
		tecla = evt.keyCode;
	}

	if ( tecla == 13 ) {
		if ( cobj != '' ) { document.getElementById( cobj ).focus(); }
	}

	if ( tecla > 47 && tecla < 58 ){
		return true;
	} else {
		if ( tecla == 8 || ( tecla >= 35 && tecla <= 40 ) || tecla == 46 || tecla == 9 ) return true;
		return false;
	}

}

function sointeiros( evt, cobj ){

	var tecla;

	if ( evt.which ){
		tecla = evt.which;
	} else {
		tecla = evt.keyCode;
	}

	if ( tecla == 13 ) {
		if ( cobj != '' ) { document.getElementById( cobj ).focus(); }
	}

	if ( tecla > 47 && tecla < 58 ){
		return true;
	} else {
		if ( tecla == 8 || ( tecla >= 35 && tecla <= 40 ) || tecla == 9 ) return true;
		return false;
	}

}

function entertab( evt, cobj ){

	var tecla;

	if ( evt.which ){
		tecla = evt.which;
	} else {
		tecla = evt.keyCode;
	}

	if ( tecla == 13 && cobj ){ document.getElementById( cobj ).focus(); }

	return true;

}

/*********************************************************************************/
/*
/* Função para tratamento do cadastro de pessoa física
*/

function verificaCadastroFisica(){

	if ( document.getElementById( "txtcpf" ).value.length < 11 ){
		window.alert( "Você precisa informar um CPF." );
		document.getElementById( "txtcpf" ).focus();
		return false;
	}

	if ( document.getElementById( "txtrg" ).value == "" ){
		window.alert( "Você precisa informar um RG." );
		document.getElementById( "txtrg" ).focus();
		return false;
	}

	if ( document.getElementById( "txtnome" ).value == "" ){
		window.alert( "Você precisa informar um NOME." );
		document.getElementById( "txtnome" ).focus();
		return false;
	}

	if ( document.getElementById( "txtcep1" ).value.length < 5 || document.getElementById( "txtcep2" ).value.length < 3 ){
		window.alert( "Você precisa informar um CEP." );
		document.getElementById( "txtcep1" ).focus();
		return false;
	}

	if ( document.getElementById( "txtendereco" ).value == "" ){
		window.alert( "Você precisa informar um ENDEREÇO." );
		document.getElementById( "txtendereco" ).focus();
		return false;
	}

	if ( document.getElementById( "txtnumero" ).value == "" ){
		window.alert( "Você precisa informar um NÚMERO." );
		document.getElementById( "txtnumero" ).focus();
		return false;
	}

	if ( document.getElementById( "txtbairro" ).value == "" ){
		window.alert( "Você precisa informar um BAIRRO." );
		document.getElementById( "txtbairro" ).focus();
		return false;
	}

	if ( document.getElementById( "txtcidade" ).value == "" ){
		window.alert( "Você precisa informar uma CIDADE." );
		document.getElementById( "txtcidade" ).focus();
		return false;
	}

	if ( document.getElementById( "txtddd1" ).value.length < 2 || document.getElementById( "txttelefone1" ).value.length < 8 ){
		window.alert( "Você precisa informar um TELEFONE FIXO com seu respectivo código de área." );
		document.getElementById( "txtddd1" ).focus();
		return false;
	}

	if ( document.getElementById( "txtemail" ).value == "" ){
		window.alert( "Você precisa informar um E-MAIL." );
		document.getElementById( "txtemail" ).focus();
		return false;
	}

	if ( document.getElementById( "txtdia" ).value.length < 2 || document.getElementById( "txtmes" ).value.length < 2 || document.getElementById( "txtano" ).value.length < 4 ){
		window.alert( "Você precisa informar uma DATA DE NASCIMENTO válida." );
		document.getElementById( "txtdia" ).focus();
		return false;
	}

	if ( document.getElementById( "txtapelido" ).value == "" ){
		window.alert( "Você precisa informar um LOGIN." );
		document.getElementById( "txtapelido" ).focus();
		return false;
	}

	processando( true );

	var xmlhttp = getXmlHttpRequest();

	var cdados = "txtcpf=" + document.getElementById( "txtcpf" ).value;
	cdados += "&txtrg=" + document.getElementById( "txtrg" ).value;
	cdados += "&txtnome=" + document.getElementById( "txtnome" ).value;
	cdados += "&txtcep1=" + document.getElementById( "txtcep1" ).value;
	cdados += "&txtcep2=" + document.getElementById( "txtcep2" ).value;
	cdados += "&txtendereco=" + document.getElementById( "txtendereco" ).value;
	cdados += "&txtnumero=" + document.getElementById( "txtnumero" ).value;
	cdados += "&txtcomplemento=" + document.getElementById( "txtcomplemento" ).value;
	cdados += "&txtbairro=" + document.getElementById( "txtbairro" ).value;
	cdados += "&txtcidade=" + document.getElementById( "txtcidade" ).value;
	cdados += "&cbbuf=" + document.getElementById( "cbbuf" ).options[document.getElementById( "cbbuf" ).selectedIndex].value;
	cdados += "&txtddd1=" + document.getElementById( "txtddd1" ).value;
	cdados += "&txttelefone1=" + document.getElementById( "txttelefone1" ).value;
	cdados += "&txtddd2=" + document.getElementById( "txtddd2" ).value;
	cdados += "&txttelefone2=" + document.getElementById( "txttelefone2" ).value;
	cdados += "&txtdddfax=" + document.getElementById( "txtdddfax" ).value;
	cdados += "&txtfax=" + document.getElementById( "txtfax" ).value;
	cdados += "&txtemail=" + document.getElementById( "txtemail" ).value;
	cdados += "&txtempresa=" + document.getElementById( "txtempresa" ).value;
	cdados += "&txtfuncao=" + document.getElementById( "txtfuncao" ).value;
	cdados += "&txtinteresse=" + document.getElementById( "txtinteresse" ).value;
	cdados += "&txtconhecimento=" + document.getElementById( "txtconhecimento" ).value;
	cdados += "&txtdia=" + document.getElementById( "txtdia" ).value;
	cdados += "&txtmes=" + document.getElementById( "txtmes" ).value;
	cdados += "&txtano=" + document.getElementById( "txtano" ).value;
	cdados += "&cbbestadocivil=" + document.getElementById( "cbbestadocivil" ).options[document.getElementById( "cbbestadocivil" ).selectedIndex].value;
	cdados += "&cbbsexo=" + document.getElementById( "cbbsexo" ).options[document.getElementById( "cbbsexo" ).selectedIndex].value;
	cdados += "&txtlogin=" + document.getElementById( "txtapelido" ).value;

	alert(cdados);

	xmlhttp.open( "POST", "proc-cadastrofisica.php?" + cdados, true );

	xmlhttp.setRequestHeader( "Cache-Control", "no-store, no-cache, must-revalidate" );
	xmlhttp.setRequestHeader( "Cache-Control", "post-check=0, pre-check=0" );
	xmlhttp.setRequestHeader( "Pragma", "no-cache" );
	xmlhttp.setRequestHeader( "Content-Type", "text/xml" );
	xmlhttp.setRequestHeader( "encoding", "ISO-8859-1" );
	xmlhttp.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" );
	xmlhttp.setRequestHeader( "Content-length", cdados.length );

	xmlhttp.onreadystatechange = function(){

		if ( xmlhttp.readyState == 4 ){

			if ( xmlhttp.status == 200 ){

				var i         = 0;
				var clances   = "";
				var resultado = xmlhttp.responseXML;

				var alerta = resultado.getElementsByTagName( "alerta" );

				if ( alerta[0].childNodes[0].data !== "OK" ){

					processando( false );

					window.alert( alerta[0].childNodes[0].data );

					if ( alerta[0].getAttribute( "campo" ) !== "" ){

						document.getElementById( alerta[0].getAttribute( "campo" ) ).focus();

					}

					return false;

				}

				document.location.href = "sucesso-cadastro.php";

				processando( false );

			} else {

				processando( false );

				window.alert( "Ocorreu um erro no momento da pesquisa solicitada!" );

			}

		}

	}

	xmlhttp.send( null );

}

/*********************************************************************************/
/*
/* Função para tratamento do cadastro de pessoa jurídica
*/

function verificaCadastroJuridica(){

	if ( document.getElementById( "txtcnpj" ).value.length < 14 ){
		window.alert( "Você precisa informar um CNPJ." );
		document.getElementById( "txtcnpj" ).focus();
		return false;
	}

	if ( document.getElementById( "txtie" ).value == "" ){
		window.alert( "Você precisa informar uma INSCRIÇÃO ESTADUAL." );
		document.getElementById( "txtie" ).focus();
		return false;
	}

	if ( document.getElementById( "txtrazaosocial" ).value == "" ){
		window.alert( "Você precisa informar uma RAZÃO SOCIAL." );
		document.getElementById( "txtrazaosocial" ).focus();
		return false;
	}

	if ( document.getElementById( "txtcep1" ).value.length < 5 || document.getElementById( "txtcep2" ).value.length < 3 ){
		window.alert( "Você precisa informar um CEP." );
		document.getElementById( "txtcep1" ).focus();
		return false;
	}

	if ( document.getElementById( "txtendereco" ).value == "" ){
		window.alert( "Você precisa informar um ENDEREÇO." );
		document.getElementById( "txtendereco" ).focus();
		return false;
	}

	if ( document.getElementById( "txtnumero" ).value == "" ){
		window.alert( "Você precisa informar um NÚMERO." );
		document.getElementById( "txtnumero" ).focus();
		return false;
	}

	if ( document.getElementById( "txtbairro" ).value == "" ){
		window.alert( "Você precisa informar um BAIRRO." );
		document.getElementById( "txtbairro" ).focus();
		return false;
	}

	if ( document.getElementById( "txtcidade" ).value == "" ){
		window.alert( "Você precisa informar uma CIDADE." );
		document.getElementById( "txtcidade" ).focus();
		return false;
	}

	if ( document.getElementById( "txtddd1" ).value.length < 2 || document.getElementById( "txttelefone1" ).value.length < 8 ){
		window.alert( "Você precisa informar um TELEFONE FIXO com seu respectivo código de área." );
		document.getElementById( "txtddd1" ).focus();
		return false;
	}

	if ( document.getElementById( "txtemail" ).value == "" ){
		window.alert( "Você precisa informar um E-MAIL." );
		document.getElementById( "txtemail" ).focus();
		return false;
	}

	if ( document.getElementById( "txtcpf" ).value.length < 11 ){
		window.alert( "Você precisa informar um CPF DE SÓCIO." );
		document.getElementById( "txtcpf" ).focus();
		return false;
	}

	if ( document.getElementById( "txtrg" ).value == "" ){
		window.alert( "Você precisa informar um RG DE SÓCIO." );
		document.getElementById( "txtrg" ).focus();
		return false;
	}

	if ( document.getElementById( "txtnome" ).value == "" ){
		window.alert( "Você precisa informar um NOME DE SÓCIO." );
		document.getElementById( "txtnome" ).focus();
		return false;
	}

	if ( document.getElementById( "txtapelido" ).value == "" ){
		window.alert( "Você precisa informar um LOGIN." );
		document.getElementById( "txtapelido" ).focus();
		return false;
	}

	processando( true );

	var xmlhttp = getXmlHttpRequest();

	var cdados = "txtcnpj=" + document.getElementById( "txtcnpj" ).value;
	cdados += "&txtie=" + document.getElementById( "txtie" ).value;
	cdados += "&txtim=" + document.getElementById( "txtim" ).value;
	cdados += "&txtrazaosocial=" + document.getElementById( "txtrazaosocial" ).value;
	cdados += "&txtnomefantasia=" + document.getElementById( "txtnomefantasia" ).value;
	cdados += "&txtcep1=" + document.getElementById( "txtcep1" ).value;
	cdados += "&txtcep2=" + document.getElementById( "txtcep2" ).value;
	cdados += "&txtendereco=" + document.getElementById( "txtendereco" ).value;
	cdados += "&txtnumero=" + document.getElementById( "txtnumero" ).value;
	cdados += "&txtcomplemento=" + document.getElementById( "txtcomplemento" ).value;
	cdados += "&txtbairro=" + document.getElementById( "txtbairro" ).value;
	cdados += "&txtcidade=" + document.getElementById( "txtcidade" ).value;
	cdados += "&cbbuf=" + document.getElementById( "cbbuf" ).options[document.getElementById( "cbbuf" ).selectedIndex].value;
	cdados += "&txtddd1=" + document.getElementById( "txtddd1" ).value;
	cdados += "&txttelefone1=" + document.getElementById( "txttelefone1" ).value;
	cdados += "&txtddd2=" + document.getElementById( "txtddd2" ).value;
	cdados += "&txttelefone2=" + document.getElementById( "txttelefone2" ).value;
	cdados += "&txtdddfax=" + document.getElementById( "txtdddfax" ).value;
	cdados += "&txtfax=" + document.getElementById( "txtfax" ).value;
	cdados += "&txtemail=" + document.getElementById( "txtemail" ).value;
	cdados += "&txtsite=" + document.getElementById( "txtsite" ).value;
	cdados += "&txtramo=" + document.getElementById( "txtramo" ).value;
	cdados += "&txtinteresse=" + document.getElementById( "txtinteresse" ).value;
	cdados += "&txtconhecimento=" + document.getElementById( "txtconhecimento" ).value;
	cdados += "&txtcpf=" + document.getElementById( "txtcpf" ).value;
	cdados += "&txtrg=" + document.getElementById( "txtrg" ).value;
	cdados += "&txtnome=" + document.getElementById( "txtnome" ).value;
	cdados += "&txtlogin=" + document.getElementById( "txtapelido" ).value;

	xmlhttp.open( "POST", "proc-cadastrojuridica.php?" + cdados, true );

	xmlhttp.setRequestHeader( "Cache-Control", "no-store, no-cache, must-revalidate" );
	xmlhttp.setRequestHeader( "Cache-Control", "post-check=0, pre-check=0" );
	xmlhttp.setRequestHeader( "Pragma", "no-cache" );
	xmlhttp.setRequestHeader( "Content-Type", "text/xml" );
	xmlhttp.setRequestHeader( "encoding", "ISO-8859-1" );
	xmlhttp.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" );
	xmlhttp.setRequestHeader( "Content-length", cdados.length );

	xmlhttp.onreadystatechange = function(){

		if ( xmlhttp.readyState == 4 ){

			if ( xmlhttp.status == 200 ){

				var i         = 0;
				var clances   = "";
				var resultado = xmlhttp.responseXML;

				var alerta = resultado.getElementsByTagName( "alerta" );

				if ( alerta[0].childNodes[0].data !== "OK" ){

					processando( false );

					window.alert( alerta[0].childNodes[0].data );

					if ( alerta[0].getAttribute( "campo" ) !== "" ){

						document.getElementById( alerta[0].getAttribute( "campo" ) ).focus();

					}

					return false;

				}

				document.location.href = "sucesso-cadastro.php";

				processando( false );

			} else {

				processando( false );

				window.alert( "Ocorreu um erro no momento da pesquisa solicitada!" );

			}

		}

	}

	xmlhttp.send( null );

}

/*********************************************************************************/
/*
/* Função para tratamento do formulário de contato
*/

function verificaContato(){

	if ( document.getElementById( "txtnome" ).value == "" ){
		window.alert( "Por favor, informe seu nome!" );
		document.getElementById( "txtnome" ).focus();
		return false;
	}

	if ( document.getElementById( "txtemail" ).value == "" ){
		window.alert( "Por favor, informe seu e-mail!" );
		document.getElementById( "txtemail" ).focus();
		return false;
	}

	if ( document.getElementById( "txtsolicitacao" ).value == "" ){
		window.alert( "Por favor, informe o porque de seu contato!" );
		document.getElementById( "txtsolicitacao" ).focus();
		return false;
	}

	processando( true );

	var xmlhttp = getXmlHttpRequest();

	var cdados = "txtnome=" + document.getElementById( "txtnome" ).value + "&txtemail=" + document.getElementById( "txtemail" ).value + "&txtsolicitacao=" + document.getElementById( "txtsolicitacao" ).value;

	cdados = converteHexa( cdados );

	xmlhttp.open( "POST", "./proc-contato.php?" + cdados, true );

	xmlhttp.setRequestHeader( "Cache-Control", "no-store, no-cache, must-revalidate" );
	xmlhttp.setRequestHeader( "Cache-Control", "post-check=0, pre-check=0" );
	xmlhttp.setRequestHeader( "Pragma", "no-cache" );
	xmlhttp.setRequestHeader( "Content-Type", "text/xml" );
	xmlhttp.setRequestHeader( "encoding", "ISO-8859-1" );
	xmlhttp.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" );
	xmlhttp.setRequestHeader( "Content-length", cdados.length );

	xmlhttp.onreadystatechange = function(){

		if ( xmlhttp.readyState == 4 ){

			if ( xmlhttp.status == 200 ){

				var i         = 0;
				var clances   = "";
				var resultado = xmlhttp.responseXML;

				var alerta = resultado.getElementsByTagName( "alerta" );

				if ( alerta[0].childNodes[0].data !== "OK" ){

					processando( false );

					window.alert( alerta[0].childNodes[0].data );

					if ( alerta[0].getAttribute( "campo" ) !== "" ){

						document.getElementById( alerta[0].getAttribute( "campo" ) ).focus();

					}

					return false;

				}

				document.location.href = "sucesso-contato.php";

				processando( false );

			} else {

				processando( false );

				window.alert( "Ocorreu um erro no momento da pesquisa solicitada!" );

			}

		}

	}

	xmlhttp.send( null );

}

/*********************************************************************************/
/*
/* Função para tratamento do formulário de receba os catálogos
*/

function verificaRecebaOsCatalogos(){

	if ( document.getElementById( "txtnome" ).value == "" ){
		window.alert( "Você precisa informar uma NOME ou RAZÃO SOCIAL." );
		document.getElementById( "txtnome" ).focus();
		return false;
	}

	if ( document.getElementById( "txtendereco" ).value == "" ){
		window.alert( "Você precisa informar um ENDEREÇO." );
		document.getElementById( "txtendereco" ).focus();
		return false;
	}

	if ( document.getElementById( "txtnumero" ).value == "" ){
		window.alert( "Você precisa informar um NÚMERO." );
		document.getElementById( "txtnumero" ).focus();
		return false;
	}

	if ( document.getElementById( "txtbairro" ).value == "" ){
		window.alert( "Você precisa informar um BAIRRO." );
		document.getElementById( "txtbairro" ).focus();
		return false;
	}

	if ( document.getElementById( "txtcep1" ).value.length < 5 || document.getElementById( "txtcep2" ).value.length < 3 ){
		window.alert( "Você precisa informar um CEP." );
		document.getElementById( "txtcep1" ).focus();
		return false;
	}

	if ( document.getElementById( "txtcidade" ).value == "" ){
		window.alert( "Você precisa informar uma CIDADE." );
		document.getElementById( "txtcidade" ).focus();
		return false;
	}

	if ( document.getElementById( "txtemail" ).value == "" ){
		window.alert( "Você precisa informar um E-MAIL." );
		document.getElementById( "txtemail" ).focus();
		return false;
	}

	if ( document.getElementById( "cbbramo" ).value == "" ){
		window.alert( "Você precisa informar seu INTERESSE PRINCIPAL." );
		document.getElementById( "cbbramo" ).focus();
		return false;
	}

	processando( true );

	var xmlhttp = getXmlHttpRequest();

	var cdados = "txtnome=" + document.getElementById( "txtnome" ).value;
	cdados += "&txtendereco=" + document.getElementById( "txtendereco" ).value;
	cdados += "&txtnumero=" + document.getElementById( "txtnumero" ).value;
	cdados += "&txtcomplemento=" + document.getElementById( "txtcomplemento" ).value;
	cdados += "&txtbairro=" + document.getElementById( "txtbairro" ).value;
	cdados += "&txtcep1=" + document.getElementById( "txtcep1" ).value;
	cdados += "&txtcep2=" + document.getElementById( "txtcep2" ).value;
	cdados += "&txtcidade=" + document.getElementById( "txtcidade" ).value;
	cdados += "&cbbuf=" + document.getElementById( "cbbuf" ).options[document.getElementById( "cbbuf" ).selectedIndex].value;;
	cdados += "&cbbramo=" + document.getElementById( "cbbramo" ).options[document.getElementById( "cbbramo" ).selectedIndex].value;;
	cdados += "&txtemail=" + document.getElementById( "txtemail" ).value;

	aramos = document.getElementsByName( "checkbox[]" );

	for( i = 0; i < aramos.length; i++ ){

		if ( aramos[i].checked ){

			cdados += "&checkbox[]=" + aramos[i].value;

		}

	}

	xmlhttp.open( "POST", "proc-recebaoscatalogos.php?" + cdados, true );

	xmlhttp.setRequestHeader( "Cache-Control", "no-store, no-cache, must-revalidate" );
	xmlhttp.setRequestHeader( "Cache-Control", "post-check=0, pre-check=0" );
	xmlhttp.setRequestHeader( "Pragma", "no-cache" );
	xmlhttp.setRequestHeader( "Content-Type", "text/xml" );
	xmlhttp.setRequestHeader( "encoding", "ISO-8859-1" );
	xmlhttp.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" );
	xmlhttp.setRequestHeader( "Content-length", cdados.length );

	xmlhttp.onreadystatechange = function(){

		if ( xmlhttp.readyState == 4 ){

			if ( xmlhttp.status == 200 ){

				var i         = 0;
				var clances   = "";
				var resultado = xmlhttp.responseXML;

				var alerta = resultado.getElementsByTagName( "alerta" );

				if ( alerta[0].childNodes[0].data !== "OK" ){

					processando( false );

					window.alert( alerta[0].childNodes[0].data );

					if ( alerta[0].getAttribute( "campo" ) !== "" ){

						document.getElementById( alerta[0].getAttribute( "campo" ) ).focus();

					}

					return false;

				}

				document.location.href = "sucesso-recebaoscatalogos.php";

				processando( false );

			} else {

				processando( false );

				window.alert( "Ocorreu um erro no momento da pesquisa solicitada!" );

			}

		}

	}

	xmlhttp.send( null );

}

/*********************************************************************************/
/*
/* Função para tratamento do login ao sistema
*/

function verificaLogin(){

	if ( document.getElementById( "loginInput" ).value == "" ){
		window.alert( "Você precisa informar seu LOGIN." );
		document.getElementById( "loginInput" ).focus();
		return false;
	}

	if ( document.getElementById( "senhaInput" ).value == "" ){
		window.alert( "Você precisa informar sua SENHA." );
		document.getElementById( "senhaInput" ).focus();
		return false;
	}

	processando( true );

	var xmlhttp = getXmlHttpRequest();

	var cdados = "txtlogin=" + document.getElementById( "loginInput" ).value;
	cdados += "&txtsenha=" + document.getElementById( "senhaInput" ).value;

	xmlhttp.open( "POST", "proc-efetuarlogin.php?" + cdados, true );

	xmlhttp.setRequestHeader( "Cache-Control", "no-store, no-cache, must-revalidate" );
	xmlhttp.setRequestHeader( "Cache-Control", "post-check=0, pre-check=0" );
	xmlhttp.setRequestHeader( "Pragma", "no-cache" );
	xmlhttp.setRequestHeader( "Content-Type", "text/xml" );
	xmlhttp.setRequestHeader( "encoding", "ISO-8859-1" );
	xmlhttp.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" );
	xmlhttp.setRequestHeader( "Content-length", cdados.length );

	xmlhttp.onreadystatechange = function(){

		if ( xmlhttp.readyState == 4 ){

			if ( xmlhttp.status == 200 ){

				var i         = 0;
				var clances   = "";
				var resultado = xmlhttp.responseXML;

				var alerta = resultado.getElementsByTagName( "alerta" );

				if ( alerta[0].childNodes[0].data !== "OK" ){

					processando( false );

					window.alert( alerta[0].childNodes[0].data );

					if ( alerta[0].getAttribute( "campo" ) !== "" ){

						document.getElementById( alerta[0].getAttribute( "campo" ) ).focus();

					}

					return false;

				}

				document.location.href = "loginefetuado.php";

				processando( false );

			} else {

				processando( false );

				window.alert( "Ocorreu um erro no momento da pesquisa das informações!" );

			}

		}

	}

	xmlhttp.send( null );

}

/*********************************************************************************/
/*
/* Função para tratamento da rotina de solicitação de senha
*/

function verificaEsqueciaSenha(){

	if ( document.getElementById( "txtcpfcnpj" ).value == "" ){
		window.alert( "Você precisa informar seu CPF ou CNPJ." );
		document.getElementById( "txtcpfcnpj" ).focus();
		return false;
	}

	if ( document.getElementById( "txtemail" ).value == "" ){
		window.alert( "Você precisa informar o E-MAIL informado em seu cadastro." );
		document.getElementById( "txtemail" ).focus();
		return false;
	}

	processando( true );

	var xmlhttp = getXmlHttpRequest();

	var cdados = "txtcpfcnpj=" + document.getElementById( "txtcpfcnpj" ).value;
	cdados += "&txtemail=" + document.getElementById( "txtemail" ).value;

	xmlhttp.open( "POST", "proc-esqueciasenha.php?" + cdados, true );

	xmlhttp.setRequestHeader( "Cache-Control", "no-store, no-cache, must-revalidate" );
	xmlhttp.setRequestHeader( "Cache-Control", "post-check=0, pre-check=0" );
	xmlhttp.setRequestHeader( "Pragma", "no-cache" );
	xmlhttp.setRequestHeader( "Content-Type", "text/xml" );
	xmlhttp.setRequestHeader( "encoding", "ISO-8859-1" );
	xmlhttp.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" );
	xmlhttp.setRequestHeader( "Content-length", cdados.length );

	xmlhttp.onreadystatechange = function(){

		if ( xmlhttp.readyState == 4 ){

			if ( xmlhttp.status == 200 ){

				var i         = 0;
				var clances   = "";
				var resultado = xmlhttp.responseXML;

				var alerta = resultado.getElementsByTagName( "alerta" );

				if ( alerta[0].childNodes[0].data !== "OK" ){

					processando( false );

					window.alert( alerta[0].childNodes[0].data );

					if ( alerta[0].getAttribute( "campo" ) !== "" ){

						document.getElementById( alerta[0].getAttribute( "campo" ) ).focus();

					}

					return false;

				}

				document.location.href = "sucesso-esqueciasenha.php";

				processando( false );

			} else {

				processando( false );

				window.alert( "Ocorreu um erro no momento da pesquisa das informações!" );

			}

		}

	}

	xmlhttp.send( null );

}

/*********************************************************************************/
/*
/* Função para tratamento do formulário de alteração de informações cadastrais
*/

function verificaMeuCadastro(){

	if ( document.getElementById( "txtcep1" ).value.length < 5 || document.getElementById( "txtcep2" ).value.length < 3 ){
		window.alert( "Você precisa informar um CEP." );
		document.getElementById( "txtcep1" ).focus();
		return false;
	}

	if ( document.getElementById( "txtendereco" ).value == "" ){
		window.alert( "Você precisa informar um ENDEREÇO." );
		document.getElementById( "txtendereco" ).focus();
		return false;
	}

	if ( document.getElementById( "txtnumero" ).value == "" ){
		window.alert( "Você precisa informar um NÚMERO." );
		document.getElementById( "txtnumero" ).focus();
		return false;
	}

	if ( document.getElementById( "txtbairro" ).value == "" ){
		window.alert( "Você precisa informar um BAIRRO." );
		document.getElementById( "txtbairro" ).focus();
		return false;
	}

	if ( document.getElementById( "txtcidade" ).value == "" ){
		window.alert( "Você precisa informar uma CIDADE." );
		document.getElementById( "txtcidade" ).focus();
		return false;
	}

	if ( document.getElementById( "txtuf" ).value.length < 2 ){
		window.alert( "Você precisa informar um ESTADO." );
		document.getElementById( "txtuf" ).focus();
		return false;
	}

	if ( document.getElementById( "txtddd1" ).value.length < 2 || document.getElementById( "txttelefone1" ).value.length < 8 ){
		window.alert( "Você precisa informar um TELEFONE FIXO com seu respectivo código de área." );
		document.getElementById( "txtddd1" ).focus();
		return false;
	}

	if ( document.getElementById( "txtemail" ).value == "" ){
		window.alert( "Você precisa informar um E-MAIL." );
		document.getElementById( "txtemail" ).focus();
		return false;
	}

	processando( true );

	var xmlhttp = getXmlHttpRequest();

	var cdados = "&txtcep1=" + document.getElementById( "txtcep1" ).value;
	cdados += "&txtcep2=" + document.getElementById( "txtcep2" ).value;
	cdados += "&txtendereco=" + document.getElementById( "txtendereco" ).value;
	cdados += "&txtnumero=" + document.getElementById( "txtnumero" ).value;
	cdados += "&txtcomplemento=" + document.getElementById( "txtcomplemento" ).value;
	cdados += "&txtbairro=" + document.getElementById( "txtbairro" ).value;
	cdados += "&txtcidade=" + document.getElementById( "txtcidade" ).value;
	cdados += "&txtuf=" + document.getElementById( "txtuf" ).value;
	cdados += "&txtddd1=" + document.getElementById( "txtddd1" ).value;
	cdados += "&txttelefone1=" + document.getElementById( "txttelefone1" ).value;
	cdados += "&txtddd2=" + document.getElementById( "txtddd2" ).value;
	cdados += "&txttelefone2=" + document.getElementById( "txttelefone2" ).value;
	cdados += "&txtdddfax=" + document.getElementById( "txtdddfax" ).value;
	cdados += "&txtfax=" + document.getElementById( "txtfax" ).value;
	cdados += "&txtemail=" + document.getElementById( "txtemail" ).value;

	xmlhttp.open( "POST", "proc-meucadastro.php?" + cdados, true );

	xmlhttp.setRequestHeader( "Cache-Control", "no-store, no-cache, must-revalidate" );
	xmlhttp.setRequestHeader( "Cache-Control", "post-check=0, pre-check=0" );
	xmlhttp.setRequestHeader( "Pragma", "no-cache" );
	xmlhttp.setRequestHeader( "Content-Type", "text/xml" );
	xmlhttp.setRequestHeader( "encoding", "ISO-8859-1" );
	xmlhttp.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" );
	xmlhttp.setRequestHeader( "Content-length", cdados.length );

	xmlhttp.onreadystatechange = function(){

		if ( xmlhttp.readyState == 4 ){

			if ( xmlhttp.status == 200 ){

				var i         = 0;
				var clances   = "";
				var resultado = xmlhttp.responseXML;

				var alerta = resultado.getElementsByTagName( "alerta" );

				if ( alerta[0].childNodes[0].data !== "OK" ){

					processando( false );

					window.alert( alerta[0].childNodes[0].data );

					if ( alerta[0].getAttribute( "campo" ) !== "" ){

						document.getElementById( alerta[0].getAttribute( "campo" ) ).focus();

					}

					return false;

				}

				document.location.href = "sucesso-meucadastro.php";

				processando( false );

			} else {

				processando( false );

				window.alert( "Ocorreu um erro no momento da pesquisa solicitada!" );

			}

		}

	}

	xmlhttp.send( null );

}

/*********************************************************************************/
/*
/* Função para tratamento da alteração de senha
*/

function verificaAlterarSenha(){

	if ( document.getElementById( "txtnovasenha" ).value == "" ){
		window.alert( "Você precisa informar sua NOVA SENHA." );
		document.getElementById( "txtnovasenha" ).focus();
		return false;
	}

	if ( document.getElementById( "txtconfirmacao" ).value == "" ){
		window.alert( "Você precisa confirmar sua NOVA SENHA." );
		document.getElementById( "txtconfirmacao" ).focus();
		return false;
	}

	if ( document.getElementById( "txtnovasenha" ).value != document.getElementById( "txtconfirmacao" ).value ) {
		window.alert( "As senhas informadas não coincidem!" );
		return false;
	}

	processando( true );

	var xmlhttp = getXmlHttpRequest();

	var cdados = "txtnovasenha=" + document.getElementById( "txtnovasenha" ).value;
	cdados += "&txtconfirmacao=" + document.getElementById( "txtconfirmacao" ).value;

	xmlhttp.open( "POST", "proc-alterarsenha.php?" + cdados, true );

	xmlhttp.setRequestHeader( "Cache-Control", "no-store, no-cache, must-revalidate" );
	xmlhttp.setRequestHeader( "Cache-Control", "post-check=0, pre-check=0" );
	xmlhttp.setRequestHeader( "Pragma", "no-cache" );
	xmlhttp.setRequestHeader( "Content-Type", "text/xml" );
	xmlhttp.setRequestHeader( "encoding", "ISO-8859-1" );
	xmlhttp.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" );
	xmlhttp.setRequestHeader( "Content-length", cdados.length );

	xmlhttp.onreadystatechange = function(){

		if ( xmlhttp.readyState == 4 ){

			if ( xmlhttp.status == 200 ){

				var i         = 0;
				var clances   = "";
				var resultado = xmlhttp.responseXML;

				var alerta = resultado.getElementsByTagName( "alerta" );

				if ( alerta[0].childNodes[0].data !== "OK" ){

					processando( false );

					window.alert( alerta[0].childNodes[0].data );

					if ( alerta[0].getAttribute( "campo" ) !== "" ){

						document.getElementById( alerta[0].getAttribute( "campo" ) ).focus();

					}

					return false;

				}

				document.location.href = "sucesso-alterarsenha.php";

				processando( false );

			} else {

				processando( false );

				window.alert( "Ocorreu um erro no momento da pesquisa das informações!" );

			}

		}

	}

	xmlhttp.send( null );

}

/*********************************************************************************/
/*
/* Funções para tratamento da pesquisa no site e detalhamento
*/

function verificaPesquisa(){

	if ( document.getElementById( "inputProduto" ).value.length < 3 ){
		window.alert( "É necessário informar uma palavra para efetuar a pesquisa!" );
		document.getElementById( "inputProduto" ).focus();
		return false;
	}

	processando( true );

	document.location.href = "pesquisar.php?txtpalavra=" + document.getElementById( "inputProduto" ).value;

	processando( false );

}

function detalharPesquisa( cleilao, clote ){

	window.open( "./pregao-lote.php?idleilao=" + cleilao + "&idlote=" + clote, "DETALHAMENTO", "left=20,top=10,height=500,width=760,statusbar=no,scrollbars=no" );

}

/*********************************************************************************/
/*
/* Funções para exibição e ocultaçao de mensagem de processamento
*/

function processando( l ){

	if ( l ){

		document.getElementById( "processando" ).style.top = document.body.scrollTop + 240;
		document.getElementById( "processando" ).style.visibility = "visible";

	} else {

		document.getElementById( "processando" ).style.visibility = "hidden";

	}
	
}

/*********************************************************************************/
/*
/* Funções para controle de paginação de resultados de pesquisa
*/

function paginar_pesquisa( ctexto, npagina ){

	processando( true );

	document.location.href="./pesquisar.php?txtpalavra=" + ctexto + "&pagina=" + npagina;

}

/*********************************************************************************/
/*
/* Funções para conversão de caracteres
*/

function converteHexa( cvalor ){

	var cretorno = "";

	if ( cvalor == "" ) return( "" );

	for( i = 0; i < cvalor.length; i++ ){

		if ( cvalor.charCodeAt( i ) > 122 ){

			cretorno += "%" + cvalor.charCodeAt( i ).toString( 16 ).toUpperCase();

		} else {

			cretorno += cvalor.charAt(i);

		}

	}

	return( cretorno );

}
