//-----------------------------------------------------------------------------------------

function FuncoesPadrao(){BoxOrcamentoOnload(); formOnload(); ProdutosOnload();}

//function FuncoesOrcamento(){formOnload(); OrcamentoOnload(); ProdutosOnload(); LiberaFinalizacao('SIM');}
function FuncoesOrcamento(){formOnload(); OrcamentoOnload(); ProdutosOnload();}

function FuncoesCadastro(){Onload_cad(); formOnload();}

function FuncoesContato(){Onload_ct(); formOnload();}

function FuncoesInstitucional(){formOnload();}

function FuncoesBanners(){formOnload();}

function FuncoesLogotipos(){formOnload(); LogotiposOnload();}

function FuncoesLogotiposADM(){formOnload(); LogotiposOnloadADM();}

//function Onload_ct(){popDeptos(); popEstados('Estado'); popVisita('Visita');}
function Onload_ct(){ popEstados('Estado'); popVisita('Visita');}

function Onload_cad(){popEstados('Estado'); popSexo('Sexo');}


//-----------------------------------------------------------------------------------------
// funcao para remover os espacos em branco
function Trim(str){return str.replace(/^\s+|\s+$/g,"");}

//-----------------------------------------------------------------------------------------

function OrcamentoOnload() {var url="PRO_Orcamento_Itens.asp?ID="+Math.random(); xmlHttp_orcload=PegaXmlHttpObjeto02(stCh_OrcamentoOnload); xmlHttp_orcload.open("GET", url , true); xmlHttp_orcload.send(null)}

function stCh_OrcamentoOnload(){ 
if (xmlHttp_orcload.readyState==4 || xmlHttp_orcload.readyState=="complete") 
 {var rsp_orcamento=xmlHttp_orcload.responseText; document.getElementById('td_orcamento').innerHTML=rsp_orcamento;}
}

//-----------------------------------------------------------------------------------------

function popEstados(oeid){var e='AC,AL,AM,AP,BA,CE,DF,ES,GO,MA,MG,MS,MT,PA,PB,PE,PI,PR,RJ,RN,RO,RR,RS,SC,SE,SP,TO'; s=e.split(","); for (x=0;x<27;x++) { document.getElementById(oeid).options[x+1] = new Option(s[x],s[x]);}}

//-----------------------------------------------------------------------------------------

function popSexo(oeid1){var e1='M,F'; s1=e1.split(","); for (x1=0;x1<2;x1++) { document.getElementById(oeid1).options[x1+1] = new Option(s1[x1],s1[x1]);}}

//-----------------------------------------------------------------------------------------

function popVisita(oeid2){var e2='Sim,Não'; s2=e2.split(","); for (x2=0;x2<2;x2++) { document.getElementById(oeid2).options[x2+1] = new Option(s2[x2],s2[x2]);}}

//-----------------------------------------------------------------------------------------

function popDeptos(){var url="PRO_ajx.asp?ID="+Math.random()+"&O=POPDPTO"; xmlHttp_Depto=GetXmlHttpObject(stChged_popdpto); xmlHttp_Depto.open("GET", url , true); xmlHttp_Depto.send(null)}

//-----------------------------------------------------------------------------------------

function stChged_popdpto(){if (xmlHttp_Depto.readyState==4 || xmlHttp_Depto.readyState=="complete"){var rsp_depto=xmlHttp_Depto.responseText; if(rsp_depto != '-'){var b=0; splitString=rsp_depto.split("#@#"); document.getElementById('Depto').options[0]=new Option('',''); var b=1; for(a=0;a<=(splitString.length-1);a+=2){document.getElementById('Depto').options[b]=new Option(splitString[a+1],splitString[a]); b+=1}}}}

//-----------------------------------------------------------------------------------------

//function apenasnumericos(caracter){if(document.all) {var tecla = event.keyCode;} else {if(document.layers) {var tecla = caracter.which;}}if(tecla > 47 && tecla < 58) {return true;} else {if (tecla != 8) {return false;} else {return true;}}}

function apenasnumericos(caracter) {
var nTecla;
nTecla = (caracter.which) ? caracter.which : caracter.keyCode;
if(nTecla > 47 && nTecla < 58) {return true;}
else {
	if (nTecla == 8 || nTecla == 9 || nTecla == 11) // 8=backspace, 9=HTABs e 11=VTAB
		return true;
	else
		return false;
	}
}

//-----------------------------------------------------------------------------------------

function validaContato() { var cad_ok=true; if ((document.getElementById('Email').value.indexOf("@")==-1) || (document.getElementById('Email').value.indexOf(".")==-1)) {cad_ok=false; marcaV('s_Email')} else {marcaP('s_Email')} 
if (document.getElementById('Nome').value.length<3) {cad_ok=false; marcaV('s_Nome');} else {marcaP('s_Nome')} 
if (document.getElementById('CodTelefone').value.length!=2 || document.getElementById('NumTelefone').value.length<5) {cad_ok=false; marcaV('s_Telefone')} else {marcaP('s_Telefone')} 
//if (document.getElementById('Estado').value.length!=2) {cad_ok=false; marcaV('s_Estado');} else {marcaP('s_Estado')} 
//if (document.getElementById('Pais').value.length<3) {cad_ok=false; marcaV('s_Pais');} else {marcaP('s_Pais')} 
if (document.getElementById('Empresa').value.length<3) {cad_ok=false; marcaV('s_Empresa');} else {marcaP('s_Empresa')} 
//if (document.getElementById('Cidade').value.length<3) {cad_ok=false; marcaV('s_Cidade');} else {marcaP('s_Cidade')} 
if (document.getElementById('Comentario').value.length<10) {cad_ok=false; marcaV('s_Comentario');} else {marcaP('s_Comentario')} 
//if (document.getElementById('Depto').value.length<3) {cad_ok=false; marcaV('s_Depto');} else {marcaP('s_Depto')}
return cad_ok;
}

//-----------------------------------------------------------------------------------------

function VerLogin(){var url="PRO_ajx.asp?ID="+Math.random()+"&O=VERLOG&LO="+document.getElementById('Login').value; xmlHttp_login=GetXmlHttpObject(st_VerLogin); xmlHttp_login.open("GET", url , true); xmlHttp_login.send(null)}

function st_VerLogin(){if(xmlHttp_login.readyState==4 || xmlHttp_login.readyState=="complete"){rsp=xmlHttp_login.responseText; if (rsp=='EX') { alert('Este login já existe em nosso sistema, favor digitar outro!'); marcaV('s_Login'); document.getElementById('Login').value=''; document.getElementById('Login').focus()} }}

//-----------------------------------------------------------------------------------------

function VerEmail(){var url="PRO_ajx.asp?ID="+Math.random()+"&O=VEREML&EM="+document.getElementById('Email').value; xmlHttp_Email=GetXmlHttpObject(st_VerEmail); xmlHttp_Email.open("GET", url , true); xmlHttp_Email.send(null)}

function st_VerEmail(){if(xmlHttp_Email.readyState==4 || xmlHttp_Email.readyState=="complete"){rsp_email=xmlHttp_Email.responseText; if (rsp_email=='EX') { alert('Este email já está cadastrado!\n\n1 - Se você esqueceu sua senha, clique na opção "Esqueci a senha" para que possamos reenviá-la;\n2 - Se você deseja continuar o cadastro, por favor digite outro email;'); marcaV('s_Email'); document.getElementById('Email').value=''; document.getElementById('Email').focus()} }}

//-----------------------------------------------------------------------------------------

function verificaCNPJ(CNPJparaVerificar){if(CNPJparaVerificar==0){return(0);}else{g=CNPJparaVerificar.length-2;if(RealTestaCNPJ(CNPJparaVerificar,g)==1){g=CNPJparaVerificar.length-1;if(RealTestaCNPJ(CNPJparaVerificar,g) == 1){	return(1);}else{return(0);}}else{return(0)}}}

function RealTestaCNPJ(CNPJ,g){var VerCNPJ=0;var ind=2;var tam;for(f=g;f>0;f--){VerCNPJ+=parseInt(CNPJ.charAt(f-1))*ind;if(ind>8){ind=2;}else{ind++;}}VerCNPJ%=11;if(VerCNPJ==0||VerCNPJ==1){VerCNPJ=0;}else{VerCNPJ=11-VerCNPJ;}if(VerCNPJ!=parseInt(CNPJ.charAt(g))){return(0);}else{return(1);}}

//-----------------------------------------------------------------------------------------

function validaData(str) { 

	dia = (str.substring(0,2)); 
    mes = (str.substring(3,5)); 
	ano = (str.substring(6,10)); 

	cons = true; 

	// verifica se foram digitados números
	if (isNaN(dia) || isNaN(mes) || isNaN(ano)){
		alert("Preencha a data somente com números."); 
		str = "";
		str.focus(); 
		return false;
	}

    // verifica o dia valido para cada mes 
    if ((dia < 01)||(dia < 01 || dia > 30) && 
		(mes == 04 || mes == 06 || 
		 mes == 09 || mes == 11 ) || 
		 dia > 31) { 
    	cons = false; 
	} 

	// verifica se o mes e valido 
	if (mes < 01 || mes > 12 ) { 
		cons = false; 
	} 

	// verifica se e ano bissexto 
	if (mes == 2 && ( dia < 01 || dia > 29 || 
	   ( dia > 28 && 
	   (parseInt(ano / 4) != ano / 4)))) { 
		cons = false; 
	} 
    
	if (cons == false) {return false;}

}

//-----------------------------------------------------------------------------------------

// colocar no evento onKeyUp passando o objeto como parametro
function FormataData(val)
{
   	var pass = val.value;
	var expr = /[0123456789]/;
		
	for(i=0; i<pass.length; i++){
		// charAt -> retorna o caractere posicionado no índice especificado
		var lchar = val.value.charAt(i);
		var nchar = val.value.charAt(i+1);
	
		if(i==0){
		   // search -> retorna um valor inteiro, indicando a posição do inicio da primeira
		   // ocorrência de expReg dentro de instStr. Se nenhuma ocorrencia for encontrada o método retornara -1
		   // instStr.search(expReg);
		   if ((lchar.search(expr) != 0) || (lchar>3)){
			  val.value = "";
		   }
		   
		}else if(i==1){
			   
			   if(lchar.search(expr) != 0){
				  // substring(indice1,indice2)
				  // indice1, indice2 -> será usado para delimitar a string
				  var tst1 = val.value.substring(0,(i));
				  val.value = tst1;				
 				  continue;			
			   }
			   
			   if ((nchar != '/') && (nchar != '')){
				 	var tst1 = val.value.substring(0, (i)+1);
				
					if(nchar.search(expr) != 0) 
						var tst2 = val.value.substring(i+2, pass.length);
					else
						var tst2 = val.value.substring(i+1, pass.length);
	
					val.value = tst1 + '/' + tst2;
			   }

		 }else if(i==4){
			
				if(lchar.search(expr) != 0){
					var tst1 = val.value.substring(0, (i));
					val.value = tst1;
					continue;			
				}
		
				if	((nchar != '/') && (nchar != '')){
					var tst1 = val.value.substring(0, (i)+1);

					if(nchar.search(expr) != 0) 
						var tst2 = val.value.substring(i+2, pass.length);
					else
						var tst2 = val.value.substring(i+1, pass.length);
	
					val.value = tst1 + '/' + tst2;
				}
   		  }
		
		  if(i>=6){
			  if(lchar.search(expr) != 0) {
					var tst1 = val.value.substring(0, (i));
					val.value = tst1;			
			  }
		  }
	 }
	
     if(pass.length>10)
		val.value = val.value.substring(0, 10);
	 	return true;
}

//-----------------------------------------------------------------------------------------

function validaCADUSR() { 
var cad_ok=true; 
if ((document.getElementById('Email').value.indexOf("@")==-1) || (document.getElementById('Email').value.indexOf(".")==-1) || document.getElementById('Email').value.length<6) {cad_ok=false; marcaV('s_Email')} else {marcaP('s_Email')} 
if (document.getElementById('Nome').value.length<4) {cad_ok=false; marcaV('s_Nome');} else {marcaP('s_Nome')} 
//if (document.getElementById('SobreNome').value.length<3) {cad_ok=false; marcaV('s_SobreNome');} else {marcaP('s_SobreNome')} 

if (document.getElementById('DataDeNascimento').value!='') {
	if (validaData(document.getElementById('DataDeNascimento').value)==false) {cad_ok=false; marcaV('s_DataDeNascimento');} else {marcaP('s_DataDeNascimento')}
}

var numeroCNPJ = document.getElementById('CNPJ1').value+document.getElementById('CNPJ2').value+document.getElementById('CNPJ3').value+document.getElementById('CNPJ4').value+document.getElementById('CNPJ5').value

var numeroCNPJ_Limpo = Trim(numeroCNPJ)

if (numeroCNPJ_Limpo!='') 
{
	if (!verificaCNPJ(numeroCNPJ)) 
		{cad_ok=false; marcaV('s_CNPJ');} 
	else 
		{marcaP('s_CNPJ')}
}
else
{marcaP('s_CNPJ')}

//if ((!verificaCNPJ(numeroCNPJ)) || (numeroCNPJ=='')) {cad_ok=false; marcaV('s_CNPJ');} else {marcaP('s_CNPJ')}

if (document.getElementById('CodTelefoneEmpresa').value.length!=2 || document.getElementById('NumTelefoneEmpresa').value.length<5) {cad_ok=false; marcaV('s_TelefoneEmpresa')} else {marcaP('s_TelefoneEmpresa')} 

if (document.getElementById('Empresa').value.length<5) {cad_ok=false; marcaV('s_Empresa');} else {marcaP('s_Empresa')}

if (document.getElementById('Login').value.length<6) {cad_ok=false; marcaV('s_Login');} else {marcaP('s_Login')}

//se a verificação da senha nao bater - TEM QUE SER PRIMEIRO
if (document.getElementById('Senha').value != document.getElementById('SenhaRepetida').value) {cad_ok=false; marcaV('s_Senha'); marcaV('s_SenhaRepetida'); document.getElementById('Senha').value=''; document.getElementById('SenhaRepetida').value=''} else {marcaP('s_Senha'); marcaP('s_SenhaRepetida')} 

//se um deles forem menores ou maiores que o permitido
if (document.getElementById('Senha').value.length<6 || document.getElementById('SenhaRepetida').value.length<6) {cad_ok=false; marcaV('s_Senha'); marcaV('s_SenhaRepetida'); document.getElementById('Senha').value=''; document.getElementById('SenhaRepetida').value=''} else {marcaP('s_Senha'); marcaP('s_SenhaRepetida')}

return cad_ok;
}

//-----------------------------------------------------------------------------------------

function marcaV(idcmp) {document.getElementById(idcmp).style.color='#FF0000'} 
function marcaP(idcmp) {document.getElementById(idcmp).style.color='#000000'}

//-----------------------------------------------------------------------------------------

function gravaContato(){if (validaContato()){var url="PRO_ajx.asp?ID="+Math.random()+"&O=GRVCTO&NO="+document.getElementById('Nome').value+"&VI="+document.getElementById('Visita').value+"&EP="+document.getElementById('Empresa').value+"&TC="+document.getElementById('CodTelefone').value+"&TN="+document.getElementById('NumTelefone').value+"&EM="+document.getElementById('Email').value+"&BA="+document.getElementById('Bairro').value+"&CI="+document.getElementById('Cidade').value+"&ED="+document.getElementById('Endereco').value+"&ES="+document.getElementById('Estado').value+"&CO="+document.getElementById('Comentario').value; xmlHttp_Contato=GetXmlHttpObject(stCh_gravaContato); xmlHttp_Contato.open("GET", url , true); xmlHttp_Contato.send(null)} else {alert('O formulário não foi enviado!\n\nAs informações destacadas em vermelho estão incorretas ou incompletas.')}}

function stCh_gravaContato() {if (xmlHttp_Contato.readyState==4 || xmlHttp_Contato.readyState=="complete") {rsp_contato=xmlHttp_Contato.responseText; document.getElementById('tdcto').innerHTML=rsp_contato}}

//-----------------------------------------------------------------------------------------

function CadastraUsuario(){if (validaCADUSR()){var url="PRO_ajx.asp?ID="+Math.random()+"&O=CADUSR&C_Nome="+document.getElementById('Nome').value+"&C_SobreNome="+document.getElementById('SobreNome').value+"&C_Email="+document.getElementById('Email').value+"&C_Sexo="+document.getElementById('Sexo').value+"&C_DataDeNascimento="+document.getElementById('DataDeNascimento').value+"&C_Departamento="+document.getElementById('Departamento').value+"&C_Cargo="+document.getElementById('Cargo').value+"&C_Empresa="+document.getElementById('Empresa').value+"&C_CNPJ="+document.getElementById('CNPJ1').value+document.getElementById('CNPJ2').value+document.getElementById('CNPJ3').value+document.getElementById('CNPJ4').value+document.getElementById('CNPJ5').value+"&C_Endereco="+document.getElementById('Endereco').value+"&C_Bairro="+document.getElementById('Bairro').value+"&C_Cidade="+document.getElementById('Cidade').value+"&C_Estado="+document.getElementById('Estado').value+"&C_CEP="+document.getElementById('CEP').value+"&C_CodTelefoneEmpresa="+document.getElementById('CodTelefoneEmpresa').value+"&C_NumTelefoneEmpresa="+document.getElementById('NumTelefoneEmpresa').value+"&C_CodFax="+document.getElementById('CodFax').value+"&C_NumFax="+document.getElementById('NumFax').value+"&C_Atividade="+document.getElementById('Atividade').value+"&C_WebSite="+document.getElementById('WebSite').value+"&C_Login="+document.getElementById('Login').value+"&C_Senha="+document.getElementById('Senha').value+"&C_SenhaRepetida="+document.getElementById('SenhaRepetida').value+"&C_Boletim="+document.getElementById('Boletim').checked; xmlHttp_Usuario=GetXmlHttpObject(stCh_CadastraUsuario); xmlHttp_Usuario.open("GET", url , true); xmlHttp_Usuario.send(null)} else {alert('O cadastro não foi gravado!\n\nAs informações destacadas em vermelho estão incorretas ou incompletas.')}}

function stCh_CadastraUsuario() {if (xmlHttp_Usuario.readyState==4 || xmlHttp_Usuario.readyState=="complete") {rsp_usuario=xmlHttp_Usuario.responseText; document.getElementById('tdcto').innerHTML=rsp_usuario}}

//-----------------------------------------------------------------------------------------


function GetXmlHttpObject(handler) { 
	var objXmlHttp=null
	if (navigator.userAgent.indexOf("Opera")>=0) {
		alert("Esta funcionalidade não funciona no Opera") 
		return 
	}
	if (navigator.userAgent.indexOf("MSIE")>=0) { 
		var strName="Msxml2.XMLHTTP"
		if (navigator.appVersion.indexOf("MSIE 5.5")>=0) {
			strName="Microsoft.XMLHTTP"
			} 
		try { 
			objXmlHttp=new ActiveXObject(strName)
			objXmlHttp.onreadystatechange=handler 
			return objXmlHttp
			} 
		catch(e) { 
			alert("ERRO: Script para ActiveX deve estar desabilitado") 
			return 
			} 
	} 
	if (navigator.userAgent.indexOf("Mozilla")>=0) {
		objXmlHttp=new XMLHttpRequest()
		objXmlHttp.onload=handler
		objXmlHttp.onerror=handler 
		return objXmlHttp
	}
} 



/*   
function GetXmlHttpObject()
   {
   var xmlHttp=null;
   try {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
   catch (e) {
    //Internet Explorer
    try {
     xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
     }
    catch (e) {
     xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
     }
    }
   return xmlHttp;
   }  
*/
   
//-----------------------------------------------------------------------------------------

function desconvertUtf(strconverted)
{
	if (strconverted.length>0)
	{
	var strdesconverted = '';var tabcon = '&Agrave;,&Aacute;,&Acirc;,&Atilde;,&Auml;,&Aring;,&AElig;,&Ccedil;,&Egrave;,&Eacute;,&Ecirc;,&Euml;,&Igrave;,&Iacute;,&Icirc;,&Iuml;,&ETH;,&Ntilde;,&Ograve;,&Oacute;,&Ocirc;,&Otilde;,&Ouml;,&times;,&Oslash;,&Ugrave;,&Uacute;,&Ucirc;,&Uuml;,&Yacute;,&THORN;,&szlig;,&agrave;,&aacute;,&acirc;,&atilde;,&auml;,&aring;,&aelig;,&ccedil;,&egrave;,&eacute;,&ecirc;,&euml;,&igrave;,&iacute;,&icirc;,&iuml;,&eth;,&ntilde;,&ograve;,&oacute;,&ocirc;,&otilde;,&ouml;,&divide;,&oslash;,&ugrave;,&uacute;,&ucirc;,&uuml;,&yacute;,&thorn;,&yuml;';
	var splitabcon=tabcon.split(",");strdesconverted = strconverted;
	for (z=0;z<=63;z++){var regEx = new RegExp (splitabcon[z], 'g');strdesconverted=strdesconverted.replace(regEx,String.fromCharCode(z+192));}
	return strdesconverted;
	}else{return ''}
}

//-----------------------------------------------------------------------------------------
// bloco que busca os itens do orcamento temporario

function BoxOrcamentoOnload(){ShowItens()}

function PegaXmlHttpObjeto02(handler)
{ 
var objXmlHttp=null

if (navigator.userAgent.indexOf("Opera")>=0)
{
alert("Esta funcionalidade não funciona no Opera") 
return 
}
if (navigator.userAgent.indexOf("MSIE")>=0)
{ 
var strName="Msxml2.XMLHTTP"
if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
{
strName="Microsoft.XMLHTTP"
} 
try
{ 
objXmlHttp=new ActiveXObject(strName)
objXmlHttp.onreadystatechange=handler 
return objXmlHttp
} 
catch(e)
{ 
alert("ERRO: Script para ActiveX deve estar desabilitado") 
return 
} 
} 
if (navigator.userAgent.indexOf("Mozilla")>=0)
{
objXmlHttp=new XMLHttpRequest()
objXmlHttp.onload=handler
objXmlHttp.onerror=handler 
return objXmlHttp
}
}

function ShowItens() {var url="PRO_Box_Orcamento_Itens.asp?ID="+Math.random(); xmlHttp_orc=PegaXmlHttpObjeto02(stCh_ShowItens); xmlHttp_orc.open("GET", url , true); xmlHttp_orc.send(null)}

function stCh_ShowItens(){ 
if (xmlHttp_orc.readyState==4 || xmlHttp_orc.readyState=="complete") 
 {var rsp_itens=xmlHttp_orc.responseText; document.getElementById('td_or').innerHTML=rsp_itens;}
}

// ----- FUNCAO PARA RECONHECER O ENTER NO CAMPO DE quantidade de produto ----- //

function Exec_ADDPROD(e,xcodigoprod){ //e is event object passed from function invocation
	var characterCode //literal character code will be stored in this variable
	//alert('CHEGOU!')
	if(e && e.which){ //if which property of event object is supported (NN4)
		e = e
		characterCode = e.which //character code is contained in NN4's which property
	}
	else{
		e = event
		characterCode = e.keyCode //character code is contained in IE's keyCode property
	}

	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
		AdicionaItem(xcodigoprod)
		return false 
	}
	else{
		return true 
	}
}

//-----------------------------------------------------------------------------------------

function AdicionaItem(Item_UKEY){ 
	var F_ORC_NID_Quantidade 	= document.getElementById('F_ORC_NID_Quantidade_'+Item_UKEY).value;
	var F_ORC_PRD_Codigo			= document.getElementById('F_ORC_PRD_Codigo_'+Item_UKEY).value;
	var url_item						="PRO_ajx.asp?ID="+Math.random()+"&O=ADDPRD&QT="+F_ORC_NID_Quantidade+"&CD="+F_ORC_PRD_Codigo+"&UK="+Item_UKEY; 
	
	xmlHttp_Adiciona=GetXmlHttpObject(st_AdicionaItem);
	xmlHttp_Adiciona.open("GET", url_item , false);  //ESTA FALSE PARA FUNCIONAR NO FIREFOX!!!
	xmlHttp_Adiciona.send(null)
}

function st_AdicionaItem()
{ 
	if(xmlHttp_Adiciona.readyState==4 || xmlHttp_Adiciona.readyState=="complete") {	
			
		var rsp_Add					= xmlHttp_Adiciona.responseText; 
		var rsp_AdicionaItem			= rsp_Add.split(",");

		if (rsp_AdicionaItem[0]=='EX_VZ') {
			alert('Por favor, digite a quantidade desejada para orçamento.\nA quantidade mínima para este item é de '+rsp_AdicionaItem[1]+' unidades!'); 
			document.getElementById('F_ORC_NID_Quantidade_'+rsp_AdicionaItem[2]).value=''; 
			document.getElementById('F_ORC_NID_Quantidade_'+rsp_AdicionaItem[2]).focus();}
		else {
			if (rsp_AdicionaItem[0]=='EX_QT') {
			alert('A quantidade mínima para este item é de '+rsp_AdicionaItem[1]+' unidades!'); document.getElementById('F_ORC_NID_Quantidade_'+rsp_AdicionaItem[2]).value=''; document.getElementById('F_ORC_NID_Quantidade_'+rsp_AdicionaItem[2]).focus();} 
			else {
				if (rsp_AdicionaItem[0]=='EX_DP') {
					alert('Você já adicionou no orçamento este item com essa quantidade.\nVocê pode solicitar o orçamento do mesmo item com até três quantidades (diferentes).'); 
					document.getElementById('F_ORC_NID_Quantidade_'+rsp_AdicionaItem[2]).value=''; 
					document.getElementById('F_ORC_NID_Quantidade_'+rsp_AdicionaItem[2]).focus();} 
				else {
					if (rsp_AdicionaItem[0]=='EX_MX') {
						alert('Você já adicionou no orçamento o limite de\ntrês quantidades diferentes para esse item.'); 
						document.getElementById('F_ORC_NID_Quantidade_'+rsp_AdicionaItem[2]).value='';
						document.getElementById('F_ORC_NID_Quantidade_'+rsp_AdicionaItem[2]).focus();}
					else {
						if (rsp_AdicionaItem[0]=='OK') {
							alert('Produto adicionado ao orçamento com sucesso!'); document.getElementById('F_ORC_NID_Quantidade_'+rsp_AdicionaItem[2]).value=''; 
							document.getElementById('F_ORC_NID_Quantidade_'+rsp_AdicionaItem[2]).focus(); 
							BoxOrcamentoOnload();}
					}
				}
			}
		}	
	}
}

//-----------------------------------------------------------------------------------------

function LiberaAtualizacao(orc_ukey,prd_ukey,v_resposta) { if(v_resposta == 'SIM')	
	{
	var rsp_atualizacao = "<input name=AlteraItem_"+orc_ukey+" id=AlteraItem_"+orc_ukey+" type=image onClick=javascript:AlteraItem('"+prd_ukey+"','"+orc_ukey+"') src=Images/bt_box_atualizar.gif alt='Clique para atualizar o item do orçamento' align=middle width=17 height=17 border=0>";  // "<img src=Images/bt_box_atualizar.gif width=17 height=17 border=0>"
	LiberaFinalizacao('NAO')
	} 
	else 
	{
	var rsp_atualizacao="<img src=Images/bt_box_atualizar_off.gif width=17 height=17 border=0>";
	LiberaFinalizacao('SIM')
	} 
	document.getElementById('s_AtualizarPrd_'+orc_ukey).innerHTML=rsp_atualizacao; 
}

//-----------------------------------------------------------------------------------------

function LiberaFinalizacao(lf_resposta) {
	var resposta_fin = lf_resposta;
	//alert('Resposta: '+resposta_fin)
	alert('Antes de finalizar seu orçamento, verifique se todos os produtos estão com as especificações corretas.')
	var url_orc = "PRO_ajx.asp?ID="+Math.random()+"&O=LIBFIM&LF="+resposta_fin; 
	xmlHttp_fim = GetXmlHttpObject(stCh_LiberaFinalizacao); 
	xmlHttp_fim.open("GET", url_orc , true); 
	xmlHttp_fim.send(null);
}

function stCh_LiberaFinalizacao(){ 
if (xmlHttp_fim.readyState==4 || xmlHttp_fim.readyState=="complete") 
 {
	 var rsp_finalizacao = xmlHttp_fim.responseText; 
	 document.getElementById('s_FinalizarOrc').innerHTML = rsp_finalizacao;}
}

//-----------------------------------------------------------------------------------------

function LiberaFinalizacao2(lf_resposta2) {
	var resposta_fin2 = lf_resposta2;
	alert('Obrigado por retornar!');
	//alert('Antes de finalizar, verifique se todos os produtos estão com as especificações corretas.')
	var url_orc2 = "PRO_ajx.asp?ID="+Math.random()+"&O=LIBFIM&LF="+resposta_fin2; 
	xmlHttp_fim2 = GetXmlHttpObject(stCh_LiberaFinalizacao2); 
	xmlHttp_fim2.open("GET", url_orc2 , true); 
	xmlHttp_fim2.send(null);
}

function stCh_LiberaFinalizacao2(){ 
if (xmlHttp_fim2.readyState==4 || xmlHttp_fim2.readyState=="complete") 
 {
	 var rsp_finalizacao2 = xmlHttp_fim2.responseText; 
	 document.getElementById('s_FinalizarOrc').innerHTML = rsp_finalizacao2;}
}
//-----------------------------------------------------------------------------------------

function FinalizaOrcamento() {
	if (confirm("Todas as informações estão corretas?")) {
		var url="PRO_ajx.asp?ID="+Math.random()+"&O=FIMORC"; 
		xmlHttp_fimorc=PegaXmlHttpObjeto02(stCh_FinalizaOrcamento); 
		xmlHttp_fimorc.open("GET", url , false); 
		xmlHttp_fimorc.send(null)
	}
}

function stCh_FinalizaOrcamento(){ 
if (xmlHttp_fimorc.readyState==4 || xmlHttp_fimorc.readyState=="complete") 
 {
	 
	 //alert("Chegou! "+xmlHttp_fimorc.responseText);
	 
	 var rsp_fimorc					= xmlHttp_fimorc.responseText; 
	 var rsp_retornofim				= rsp_fimorc.split("#@#");
	 // trazer no response.write o Ok e a página de agradecimento...
	 if (rsp_retornofim[0]=='OK')
	 {
	 //alert("Finalizacao em desenvolvimento!\n\nGravar o orcamento no bco de dados\nEnviar o email para a promoline\nEnviar o email para o usuário\nLimpar o bco de dados temporario");
	 document.getElementById('td_orcamento').innerHTML=rsp_retornofim[1];}
	 }
}


//-----------------------------------------------------------------------------------------

function AlteraItem(Prod_UKEY, Orc_UKEY){ 
	var F_ORC_NID_Quantidade 	= document.getElementById('F_ORC_NID_Quantidade_'+Orc_UKEY).value;
	var F_ORC_NID_Gravacoes	 	= document.getElementById('F_ORC_NID_Gravacoes_'+Orc_UKEY).value;
	var F_ORC_NID_Modelo		 	= document.getElementById('F_ORC_NID_Modelo_'+Orc_UKEY).value;

	var url_item="PRO_ajx.asp?ID="+Math.random()+"&O=ATTPRD&QT="+F_ORC_NID_Quantidade+"&QG="+F_ORC_NID_Gravacoes+"&QM="+F_ORC_NID_Modelo+"&UP="+Prod_UKEY+"&UK="+Orc_UKEY; 
	xmlHttp_Altera=GetXmlHttpObject(st_AlteraItem);
	xmlHttp_Altera.open("GET", url_item , true); 
	xmlHttp_Altera.send(null)
}

function st_AlteraItem()
{ 
	if(xmlHttp_Altera.readyState==4 || xmlHttp_Altera.readyState=="complete") 
	{	
		var rsp_Att						= xmlHttp_Altera.responseText; 
		var rsp_AlteraItem				= rsp_Att.split(",");

		if (rsp_AlteraItem[0]=='EX_VZ')
		{alert('Por favor, digite a quantidade desejada para orçamento.\nA quantidade mínima para este item é de '+rsp_AlteraItem[1]+' unidades!'); document.getElementById('F_ORC_NID_Quantidade_'+rsp_AlteraItem[2]).value=''; document.getElementById('F_ORC_NID_Quantidade_'+rsp_AlteraItem[2]).focus();}
		else
		{
			if (rsp_AlteraItem[0]=='EX_QT') 
			{alert('A quantidade mínima para este item é de '+rsp_AlteraItem[1]+' unidades!'); document.getElementById('F_ORC_NID_Quantidade_'+rsp_AlteraItem[2]).value=''; document.getElementById('F_ORC_NID_Quantidade_'+rsp_AlteraItem[2]).focus();} 
			else 
			{
				if (rsp_AlteraItem[0]=='EX_DP') 
				{
					alert('Você já adicionou no orçamento este item com essa quantidade.'); document.getElementById('F_ORC_NID_Quantidade_'+rsp_AlteraItem[2]).value=''; document.getElementById('F_ORC_NID_Quantidade_'+rsp_AlteraItem[2]).focus();
				} 
				else
				{
					if (rsp_AlteraItem[0]=='OK') 
					{
						alert('Produto alterado com sucesso!');
						LiberaAtualizacao(rsp_AlteraItem[2],'','NAO');
					}
				}
			}
		}
			
	}
}

//-----------------------------------------------------------------------------------------

function ExcluiItem(Orc_UKEY){
	if (confirm("Tem certeza que deseja excluir este item do orçamento?")) {var url="PRO_ajx.asp?ID="+Math.random()+"&O=EXCPRD&UK="+Orc_UKEY; xmlHttp_ExcluiPrd=PegaXmlHttpObjeto(st_ExcluiItem); xmlHttp_ExcluiPrd.open("GET", url , true); xmlHttp_ExcluiPrd.send(null)}
	}
	
function st_ExcluiItem()
{ 
	if(xmlHttp_ExcluiPrd.readyState==4 || xmlHttp_ExcluiPrd.readyState=="complete") 
	{	
		var rsp_ExcluiPrd		= xmlHttp_ExcluiPrd.responseText; 
		if (rsp_ExcluiPrd == 'OK') 
		{
			alert("Produto excluido com sucesso!")
			FuncoesOrcamento(); LiberaFinalizacao('SIM'); // Recarrega os orçamentos 
		}
	}
}
	

//-----------------------------------------------------------------------------------------

function LoadCadastro(x_UkeuUsr){ 
	var url_item="PRO_ajx.asp?ID="+Math.random()+"&O=LD_CAD"+"&UK="+x_UkeuUsr; 
	xmlHttp_Carrega=GetXmlHttpObject(st_LoadCadastro);
	xmlHttp_Carrega.open("GET", url_item , true); 
	xmlHttp_Carrega.send(null)
}

function st_LoadCadastro()
{ 
	if(xmlHttp_Carrega.readyState==4 || xmlHttp_Carrega.readyState=="complete") 
	{	
		var rsp_Add						= xmlHttp_Carrega.responseText; 
		var rsp_AdicionaItem			= rsp_Add.split("#@#");

		if (rsp_AdicionaItem[0]=='OK')
		{
			document.getElementById('Nome').value=rsp_AdicionaItem[1];
			document.getElementById('SobreNome').value=rsp_AdicionaItem[2];
			document.getElementById('Email').value=rsp_AdicionaItem[3];

			var e_sx		= 'M,F'; 
			var s_sx		= e_sx.split(","); 
			var ind_sexo 	= 0
			
			for (x_sx=0;x_sx<2;x_sx++) 
			{ 
				document.getElementById('Sexo').options[x_sx+1] = new Option(s_sx[x_sx],s_sx[x_sx]);
				if (s_sx[x_sx] == rsp_AdicionaItem[4]) 
				{ ind_sexo = x_sx+1; }
			}			
			
			document.getElementById('Sexo').options[ind_sexo].selected = true;	
			document.getElementById('DataDeNascimento').value = rsp_AdicionaItem[5];	
			document.getElementById('Departamento').value=rsp_AdicionaItem[6];
			document.getElementById('Cargo').value=rsp_AdicionaItem[7];
			document.getElementById('Empresa').value=rsp_AdicionaItem[8];
			document.getElementById('CNPJ1').value=rsp_AdicionaItem[9].substring(0,2);
			document.getElementById('CNPJ2').value=rsp_AdicionaItem[9].substring(2,5);
			document.getElementById('CNPJ3').value=rsp_AdicionaItem[9].substring(5,8);
			document.getElementById('CNPJ4').value=rsp_AdicionaItem[9].substring(8,12);
			document.getElementById('CNPJ5').value=rsp_AdicionaItem[9].substring(12,14);
			document.getElementById('Endereco').value=rsp_AdicionaItem[10];
			document.getElementById('Bairro').value=rsp_AdicionaItem[11];
			document.getElementById('Cidade').value=rsp_AdicionaItem[12];

			var e_cad		= 'AC,AL,AM,AP,BA,CE,DF,ES,GO,MA,MG,MS,MT,PA,PB,PE,PI,PR,RJ,RN,RO,RR,RS,SC,SE,SP,TO'; 
			var s_cad		= e_cad.split(","); 
			var ind_estado 	= 0
			
			for (x_cad=0;x_cad<27;x_cad++) 
			{
				document.getElementById('Estado').options[x_cad+1] = new Option(s_cad[x_cad],s_cad[x_cad]);
				if (s_cad[x_cad] == rsp_AdicionaItem[13]) 
				{ ind_estado = x_cad+1; }
			}

			document.getElementById('Estado').options[ind_estado].selected = true;	
			document.getElementById('CEP').value=rsp_AdicionaItem[14];
			document.getElementById('CodTelefoneEmpresa').value=rsp_AdicionaItem[15];
			document.getElementById('NumTelefoneEmpresa').value=rsp_AdicionaItem[16];
			document.getElementById('CodFax').value=rsp_AdicionaItem[17];
			document.getElementById('NumFax').value=rsp_AdicionaItem[18];
			document.getElementById('Atividade').value=rsp_AdicionaItem[19];
			document.getElementById('WebSite').value=rsp_AdicionaItem[20];
			if (rsp_AdicionaItem[22] == 1){document.getElementById('Boletim').checked=true;}
			document.getElementById('Nome').focus();
		}
	}
}

//-----------------------------------------------------------------------------------------

function LoadAdmUsr(x_UkeyUsr){ 
	var url_item="PRO_ajx.asp?ID="+Math.random()+"&O=LD_USR"+"&UK="+x_UkeyUsr; 
	xmlHttp_LoadUSR=PegaXmlHttpObjeto02(st_LoadAdmUsr);
	xmlHttp_LoadUSR.open("GET", url_item , true); 
	xmlHttp_LoadUSR.send(null)
}

function st_LoadAdmUsr()
{ 
	if(xmlHttp_LoadUSR.readyState==4 || xmlHttp_LoadUSR.readyState=="complete") 
	{	
		var rsp_Add						= xmlHttp_LoadUSR.responseText; 
		//alert(rsp_Add);
		var rsp_AdicionaItem				= rsp_Add.split("#@#");
		if (rsp_AdicionaItem[0]=='OK')
		{
			document.getElementById('Nome').value=rsp_AdicionaItem[1];
			document.getElementById('SobreNome').value=rsp_AdicionaItem[2];
			document.getElementById('Email').value=rsp_AdicionaItem[3];

			var e_sx		= 'M,F'; 
			var s_sx		= e_sx.split(","); 
			var ind_sexo 	= 0
			
			for (x_sx=0;x_sx<2;x_sx++) 
			{ 
				document.getElementById('Sexo').options[x_sx+1] = new Option(s_sx[x_sx],s_sx[x_sx]);
				if (s_sx[x_sx] == rsp_AdicionaItem[4]) 
				{ ind_sexo = x_sx+1; }
			}			
			
			document.getElementById('Sexo').options[ind_sexo].selected = true;	
			document.getElementById('DataDeNascimento').value = rsp_AdicionaItem[5];	
			document.getElementById('Departamento').value=rsp_AdicionaItem[6];
			document.getElementById('Cargo').value=rsp_AdicionaItem[7];
			document.getElementById('Empresa').value=rsp_AdicionaItem[8];
			document.getElementById('CNPJ1').value=rsp_AdicionaItem[9].substring(0,2);
			document.getElementById('CNPJ2').value=rsp_AdicionaItem[9].substring(2,5);
			document.getElementById('CNPJ3').value=rsp_AdicionaItem[9].substring(5,8);
			document.getElementById('CNPJ4').value=rsp_AdicionaItem[9].substring(8,12);
			document.getElementById('CNPJ5').value=rsp_AdicionaItem[9].substring(12,14);
			document.getElementById('Endereco').value=rsp_AdicionaItem[10];
			document.getElementById('Bairro').value=rsp_AdicionaItem[11];
			document.getElementById('Cidade').value=rsp_AdicionaItem[12];

			var e_cad		= 'AC,AL,AM,AP,BA,CE,DF,ES,GO,MA,MG,MS,MT,PA,PB,PE,PI,PR,RJ,RN,RO,RR,RS,SC,SE,SP,TO'; 
			var s_cad		= e_cad.split(","); 
			var ind_estado 	= 0
			
			for (x_cad=0;x_cad<27;x_cad++) 
			{
				document.getElementById('Estado').options[x_cad+1] = new Option(s_cad[x_cad],s_cad[x_cad]);
				if (s_cad[x_cad] == rsp_AdicionaItem[13]) 
				{ ind_estado = x_cad+1; }
			}

			document.getElementById('Estado').options[ind_estado].selected = true;	
			document.getElementById('CEP').value=rsp_AdicionaItem[14];
			document.getElementById('CodTelefoneEmpresa').value=rsp_AdicionaItem[15];
			document.getElementById('NumTelefoneEmpresa').value=rsp_AdicionaItem[16];
			document.getElementById('CodFax').value=rsp_AdicionaItem[17];
			document.getElementById('NumFax').value=rsp_AdicionaItem[18];
			document.getElementById('Atividade').value=rsp_AdicionaItem[19];
			document.getElementById('WebSite').value=rsp_AdicionaItem[20];
			document.getElementById('USR_Ukey').value=rsp_AdicionaItem[23];
			document.getElementById('USR_EMP_Ukey').value=rsp_AdicionaItem[24];
			document.getElementById('Codigo_USR').value=rsp_AdicionaItem[25];
			document.getElementById('Codigo_EMP').value=rsp_AdicionaItem[26];
			if (rsp_AdicionaItem[27] == 1){document.getElementById('Acs_ADM').checked=true;}
			if (rsp_AdicionaItem[34] == 1){document.getElementById('Acs_GCO').checked=true;}
			if (rsp_AdicionaItem[35] == 1){document.getElementById('Acs_MKT').checked=true;}
			if (rsp_AdicionaItem[28] == 1){document.getElementById('Acs_DES').checked=true;}
			if (rsp_AdicionaItem[22] == 1){document.getElementById('Boletim').checked=true;}		
			
			document.getElementById('USR_DataCadastro').value=rsp_AdicionaItem[29];
			document.getElementById('USR_DataAtCadastro').value=rsp_AdicionaItem[30];
			document.getElementById('USR_PrimeiroAcesso').value=rsp_AdicionaItem[31];
			document.getElementById('USR_DataUltAce').value=rsp_AdicionaItem[32];
			document.getElementById('USR_NumAcessos').value=rsp_AdicionaItem[33];
	
			document.getElementById('Nome').focus();
		}
		else
		{alert("Ocorreu um erro no banco de dados.\nPor favor, contate o administrador.")
		}
	}
}

//-----------------------------------------------------------------------------------------

function LoadAdmOrc(x_UkeyOrc){ 
	var url_orc="PRO_ajx.asp?ID="+Math.random()+"&O=LD_ORC"+"&UK="+x_UkeyOrc; 
	xmlHttp_LoadORC=GetXmlHttpObject(st_LoadAdmOrc);
	xmlHttp_LoadORC.open("GET", url_orc , true); 
	xmlHttp_LoadORC.send(null)
}

function st_LoadAdmOrc()
{ 
	if(xmlHttp_LoadORC.readyState==4 || xmlHttp_LoadORC.readyState=="complete") 
	{	
		var rsp_ORC						= xmlHttp_LoadORC.responseText; 
		var rsp_ExibeORC				= rsp_ORC.split("#@#");
		if (rsp_ExibeORC[0]=='OK')
		{
			document.getElementById('NDC_Codigo_1CRM').value=rsp_ExibeORC[1];
			//document.getElementById('NDC_Status').value=rsp_ExibeORC[2];
			document.getElementById('NDC_UKEY').value=rsp_ExibeORC[3];
			document.getElementById('NDC_DataAbertura').value=rsp_ExibeORC[4];
			document.getElementById('NDC_Contato').value=rsp_ExibeORC[5];
			document.getElementById('NDC_EMP_UKEY').value=rsp_ExibeORC[6];
			document.getElementById('USR_Codigo_1CRM').value=rsp_ExibeORC[7];
			document.getElementById('EMP_Codigo_1CRM').value=rsp_ExibeORC[8];

			var e_cad		= rsp_ExibeORC[9];
			// 'AC,AL,AM,AP,BA,CE,DF,ES,GO,MA,MG,MS,MT,PA,PB,PE,PI,PR,RJ,RN,RO,RR,RS,SC,SE,SP,TO'; 
			var e_val		= rsp_ExibeORC[10];
			//'1,2,3,4,5'; 
			var s_cad		= e_cad.split("#!#"); 
			var s_val		= e_val.split("#!#"); 
			var ind_status 	= 0

			for (x_cad=0;x_cad<=(s_cad.length-1);x_cad++) 
			{
				document.getElementById('NDC_Status').options[x_cad+1] = new Option(s_cad[x_cad],s_val[x_cad]);
				if (s_val[x_cad] == rsp_ExibeORC[2]) 
					{ ind_status = x_cad+1; }
			}
			document.getElementById('NDC_Status').options[ind_status].selected = true;	
			
			document.getElementById('NDC_Codigo_1CRM').focus();
		}
		else
		{//alert("Ocorreu um erro no banco de dados.\nPor favor, contate o administrador.")
		}
	}
}


//-----------------------------------------------------------------------------------------

function AtualizaUsuario(){if (validaATTUSR()){var url="PRO_ajx.asp?ID="+Math.random()+"&O=ATTUSR&C_Nome="+document.getElementById('Nome').value+"&C_SobreNome="+document.getElementById('SobreNome').value+"&C_Email="+document.getElementById('Email').value+"&C_Sexo="+document.getElementById('Sexo').value+"&C_DataDeNascimento="+document.getElementById('DataDeNascimento').value+"&C_Departamento="+document.getElementById('Departamento').value+"&C_Cargo="+document.getElementById('Cargo').value+"&C_Empresa="+document.getElementById('Empresa').value+"&C_CNPJ="+document.getElementById('CNPJ1').value+document.getElementById('CNPJ2').value+document.getElementById('CNPJ3').value+document.getElementById('CNPJ4').value+document.getElementById('CNPJ5').value+"&C_Endereco="+document.getElementById('Endereco').value+"&C_Bairro="+document.getElementById('Bairro').value+"&C_Cidade="+document.getElementById('Cidade').value+"&C_Estado="+document.getElementById('Estado').value+"&C_CEP="+document.getElementById('CEP').value+"&C_CodTelefoneEmpresa="+document.getElementById('CodTelefoneEmpresa').value+"&C_NumTelefoneEmpresa="+document.getElementById('NumTelefoneEmpresa').value+"&C_CodFax="+document.getElementById('CodFax').value+"&C_NumFax="+document.getElementById('NumFax').value+"&C_Atividade="+document.getElementById('Atividade').value+"&C_WebSite="+document.getElementById('WebSite').value+"&C_Boletim="+document.getElementById('Boletim').checked; xmlHttp_Usuario=GetXmlHttpObject(stCh_CadastraUsuario); xmlHttp_Usuario.open("GET", url , true); xmlHttp_Usuario.send(null)} else {alert('O cadastro não foi gravado!\n\nAs informações destacadas em vermelho estão incorretas ou incompletas.')}}

function stCh_CadastraUsuario() {if (xmlHttp_Usuario.readyState==4 || xmlHttp_Usuario.readyState=="complete") {rsp_usuario=xmlHttp_Usuario.responseText; document.getElementById('tdattusr').innerHTML=rsp_usuario}}

function validaATTUSR() { 
var cad_ok=true; 
if ((document.getElementById('Email').value.indexOf("@")==-1) || (document.getElementById('Email').value.indexOf(".")==-1) || document.getElementById('Email').value.length<6) {cad_ok=false; marcaV('s_Email')} else {marcaP('s_Email')} 
if (document.getElementById('Nome').value.length<4) {cad_ok=false; marcaV('s_Nome');} else {marcaP('s_Nome')} 
//if (document.getElementById('SobreNome').value.length<3) {cad_ok=false; marcaV('s_SobreNome');} else {marcaP('s_SobreNome')} 

if (document.getElementById('DataDeNascimento').value!='') {
	if (validaData(document.getElementById('DataDeNascimento').value)==false) {cad_ok=false; marcaV('s_DataDeNascimento');} else {marcaP('s_DataDeNascimento')}
}

var numeroCNPJ = document.getElementById('CNPJ1').value+document.getElementById('CNPJ2').value+document.getElementById('CNPJ3').value+document.getElementById('CNPJ4').value+document.getElementById('CNPJ5').value

if ((!verificaCNPJ(numeroCNPJ)) || (numeroCNPJ=='')) {cad_ok=false; marcaV('s_CNPJ');} else {marcaP('s_CNPJ')}

if (document.getElementById('CodTelefoneEmpresa').value.length!=2 || document.getElementById('NumTelefoneEmpresa').value.length<5) {cad_ok=false; marcaV('s_TelefoneEmpresa')} else {marcaP('s_TelefoneEmpresa')} 
if (document.getElementById('Empresa').value.length<5) {cad_ok=false; marcaV('s_Empresa');} else {marcaP('s_Empresa')}

return cad_ok;
}

//-----------------------------------------------------------------------------------------

function ADM_Att_Usuario(){
	if (validaADMATTUSR()){
		var url="PRO_ajx.asp?ID="+Math.random()+"&O=ADMUSR&C_Nome="+document.getElementById('Nome').value+"&C_SobreNome="+document.getElementById('SobreNome').value+"&C_Email="+document.getElementById('Email').value+"&C_Sexo="+document.getElementById('Sexo').value+"&C_DataDeNascimento="+document.getElementById('DataDeNascimento').value+"&C_Departamento="+document.getElementById('Departamento').value+"&C_Cargo="+document.getElementById('Cargo').value+"&C_Empresa="+document.getElementById('Empresa').value+"&C_CNPJ="+document.getElementById('CNPJ1').value+document.getElementById('CNPJ2').value+document.getElementById('CNPJ3').value+document.getElementById('CNPJ4').value+document.getElementById('CNPJ5').value+"&C_Endereco="+document.getElementById('Endereco').value+"&C_Bairro="+document.getElementById('Bairro').value+"&C_Cidade="+document.getElementById('Cidade').value+"&C_Estado="+document.getElementById('Estado').value+"&C_CEP="+document.getElementById('CEP').value+"&C_CodTelefoneEmpresa="+document.getElementById('CodTelefoneEmpresa').value+"&C_NumTelefoneEmpresa="+document.getElementById('NumTelefoneEmpresa').value+"&C_CodFax="+document.getElementById('CodFax').value+"&C_NumFax="+document.getElementById('NumFax').value+"&C_Atividade="+document.getElementById('Atividade').value+"&C_WebSite="+document.getElementById('WebSite').value+"&C_Boletim="+document.getElementById('Boletim').checked+"&C_Codigo_USR="+document.getElementById('Codigo_USR').value+"&C_Codigo_EMP="+document.getElementById('Codigo_EMP').value+"&C_Acs_ADM="+document.getElementById('Acs_ADM').checked+"&C_Acs_MKT="+document.getElementById('Acs_MKT').checked+"&C_Acs_GCO="+document.getElementById('Acs_GCO').checked+"&C_Acs_DES="+document.getElementById('Acs_DES').checked+"&C_USR_Ukey="+document.getElementById('USR_Ukey').value+"&C_USR_EMP_Ukey="+document.getElementById('USR_EMP_Ukey').value;
		xmlHttp_Usuario=GetXmlHttpObject(stCh_ADM_Att_Usuario); 
		xmlHttp_Usuario.open("GET", url , true); 
		xmlHttp_Usuario.send(null);
	} 
	else {
		alert('O cadastro não foi gravado!\n\nAs informações destacadas em vermelho estão incorretas ou incompletas.')
	}
}

function stCh_ADM_Att_Usuario() {if (xmlHttp_Usuario.readyState==4 || xmlHttp_Usuario.readyState=="complete") {rsp_usuario=xmlHttp_Usuario.responseText; document.getElementById('tdattusr').innerHTML=rsp_usuario}}

function validaADMATTUSR() { 
var cad_ok=true; 
if ((document.getElementById('Email').value.indexOf("@")==-1) || (document.getElementById('Email').value.indexOf(".")==-1) || document.getElementById('Email').value.length<6) {cad_ok=false; marcaV('s_Email')} else {marcaP('s_Email')} 
if (document.getElementById('Nome').value.length<4) {cad_ok=false; marcaV('s_Nome');} else {marcaP('s_Nome')} 
//if (document.getElementById('SobreNome').value.length<3) {cad_ok=false; marcaV('s_SobreNome');} else {marcaP('s_SobreNome')} 

if (document.getElementById('DataDeNascimento').value!='') {
	if (validaData(document.getElementById('DataDeNascimento').value)==false) {cad_ok=false; marcaV('s_DataDeNascimento');} else {marcaP('s_DataDeNascimento')}
}

var numeroCNPJ = document.getElementById('CNPJ1').value+document.getElementById('CNPJ2').value+document.getElementById('CNPJ3').value+document.getElementById('CNPJ4').value+document.getElementById('CNPJ5').value

if ((!verificaCNPJ(numeroCNPJ)) || (numeroCNPJ=='')) {cad_ok=false; marcaV('s_CNPJ');} else {marcaP('s_CNPJ')}

if (document.getElementById('CodTelefoneEmpresa').value.length!=2 || document.getElementById('NumTelefoneEmpresa').value.length<5) {cad_ok=false; marcaV('s_TelefoneEmpresa')} else {marcaP('s_TelefoneEmpresa')} 
if (document.getElementById('Empresa').value.length<5) {cad_ok=false; marcaV('s_Empresa');} else {marcaP('s_Empresa')}

return cad_ok;
}

//-----------------------------------------------------------------------------------------

function ADM_Att_Orcamento(){
	if (validaADMATTORC()){
		var url="PRO_ajx01.asp?ID="+Math.random()+"&O=ADMATTORC&C_NDC_Codigo_1CRM="+document.getElementById('NDC_Codigo_1CRM').value+"&C_NDC_Status="+document.getElementById('NDC_Status').value+"&C_NDC_UKEY="+document.getElementById('NDC_UKEY').value;
		xmlHttp_AttORC=GetXmlHttpObject(stCh_ADM_Att_Orcamento); 
		xmlHttp_AttORC.open("GET", url , true); 
		xmlHttp_AttORC.send(null);
	} 
	else {
		alert('O cadastro não foi gravado!\n\nÉ necessário definir o status deste orçamento.');
		document.getElementById('NDC_Status').focus();
	}
}

function stCh_ADM_Att_Orcamento() {
	if (xmlHttp_AttORC.readyState==4 || xmlHttp_AttORC.readyState=="complete") {
		rsp_AttORC=xmlHttp_AttORC.responseText; 
		document.getElementById('tdattorc').innerHTML=rsp_AttORC;
		}
	}

function validaADMATTORC() { 
var cad_ok=true; 
if (document.getElementById('NDC_Status').value.length<4) {cad_ok=false; marcaV('s_NDC_Status');} else {marcaP('s_NDC_Status')} 
return cad_ok;
}


//-----------------------------------------------------------------------------------------

function TrocaSenha(){if (validaAttSenha()){var url="PRO_ajx.asp?ID="+Math.random()+"&O=ATTPSW&C_Senha="+document.getElementById('Senha').value; xmlHttp_Senha=GetXmlHttpObject(stCh_TrocaSenha); xmlHttp_Senha.open("GET", url , true); xmlHttp_Senha.send(null)} else {alert('O login deve ter no mínimo 6 caracteres\ne ambos os campos devem estar idênticos.')}}

function stCh_TrocaSenha() {if (xmlHttp_Senha.readyState==4 || xmlHttp_Senha.readyState=="complete") {rsp_senha=xmlHttp_Senha.responseText; document.getElementById('tdattusr').innerHTML=rsp_senha}}

function validaAttSenha() { 
var cad_ok=true; 

//se a verificação da senha nao bater - TEM QUE SER PRIMEIRO
if (document.getElementById('Senha').value != document.getElementById('SenhaRepetida').value) {cad_ok=false; marcaV('s_Senha'); marcaV('s_SenhaRepetida'); document.getElementById('Senha').value=''; document.getElementById('SenhaRepetida').value=''} else {marcaP('s_Senha'); marcaP('s_SenhaRepetida')} 

//se um deles forem menores ou maiores que o permitido
if (document.getElementById('Senha').value.length<6 || document.getElementById('SenhaRepetida').value.length<6) {cad_ok=false; marcaV('s_Senha'); marcaV('s_SenhaRepetida'); document.getElementById('Senha').value=''; document.getElementById('SenhaRepetida').value=''} else {marcaP('s_Senha'); marcaP('s_SenhaRepetida')}

return cad_ok;
}

//---------------------------------------------------------------------------------------/

function Ctr_Prd_Principal(variavel_Produto,operacao) {
	var url="PRO_ajx.asp?ID="+Math.random()+"&O=VERPRI&UK="+variavel_Produto+"&OP="+operacao; 
	xmlHttp_Uk_Produto=GetXmlHttpObject(stCh_Ctr_Prd_Principal); 
	xmlHttp_Uk_Produto.open("GET", url , true); 
	xmlHttp_Uk_Produto.send(null);
	//if (operacao=="OK") {DestaqueOK(variavel_Produto);} 
    //if (operacao=="EX") {DestaqueEX(variavel_Produto);}
	}

function stCh_Ctr_Prd_Principal(){ 
if (xmlHttp_Uk_Produto.readyState==4 || xmlHttp_Uk_Produto.readyState=="complete") 
 	 {
	 var rsp_Uk_Produto				= xmlHttp_Uk_Produto.responseText; 
	 var rsp_UkPrd					= rsp_Uk_Produto.split("#@#");
	 document.getElementById('s_principal_'+rsp_UkPrd[0]).innerHTML=rsp_UkPrd[1];
	 }
}

//---------------------------------------------------------------------------------------/

function Ctr_Prd_Secao(var_Produto,op) {
	var url="PRO_ajx.asp?ID="+Math.random()+"&O=VERSEC&UK="+var_Produto+"&OP="+op; 
	xmlHttp_Uk_Prd_Secao=GetXmlHttpObject(stCh_Ctr_Prd_Secao); 
	xmlHttp_Uk_Prd_Secao.open("GET", url , true); 
	xmlHttp_Uk_Prd_Secao.send(null);
	//if (op=="OK") {DestaqueOK(var_Produto);} 
    //if (op=="EX") {DestaqueEX(var_Produto);}
	}

function stCh_Ctr_Prd_Secao(){ 
if (xmlHttp_Uk_Prd_Secao.readyState==4 || xmlHttp_Uk_Prd_Secao.readyState=="complete") 
 	 {
	 var rsp_Uk_Prd_Secao			= xmlHttp_Uk_Prd_Secao.responseText; 
	 var rsp_UkPrd_Sec				= rsp_Uk_Prd_Secao.split("#@#");
	 document.getElementById('s_secao_'+rsp_UkPrd_Sec[0]).innerHTML=rsp_UkPrd_Sec[1];
	 }
}

//-----------------------------------------------------------------------------------

//function DestaqueOK(xUkeyOK){ document.getElementById('tabela_destaque_'+xUkeyOK).style.backgroundColor='#F3F3F3'; }
//function DestaqueEX(xUkeyEX){ document.getElementById('tabela_destaque_'+xUkeyEX).style.backgroundColor='#FFFFFF'; }

//-----------------------------------------------------------------------------------

function IndicarPrd(x_codigo){
	var url="PRO_ajx.asp?ID="+Math.random()+"&O=INDAMG&UK="+x_codigo;
	xmlHttp_Indique=GetXmlHttpObject(stCh_IndicarPrd); 
	xmlHttp_Indique.open("GET", url , true); 
	xmlHttp_Indique.send(null)
}

function stCh_IndicarPrd() {
	if (xmlHttp_Indique.readyState==4 || xmlHttp_Indique.readyState=="complete") {
		rsp_indique=xmlHttp_Indique.responseText; 
		bt_comente="<a href=javascript:ComentarPrd()><img src=Images/bt_comentario_on.gif width=125 height=15 border=0></a>"
		bt_indique="<img src=Images/bt_enviaramigo_off.gif width=125 height=15 border=0>"
		document.getElementById('s_prd_interacao').innerHTML=rsp_indique;
		document.getElementById('s_bt_comentario').innerHTML=bt_comente;
		document.getElementById('s_bt_indicacao').innerHTML=bt_indique;
		}
}

//-----------------------------------------------------------------------------------

function ComentarPrd(x_codigo){
	var url="PRO_ajx.asp?ID="+Math.random()+"&O=COMPRD&UK="+x_codigo; 
	xmlHttp_Comente=GetXmlHttpObject(stCh_ComentarPrd); 
	xmlHttp_Comente.open("GET", url , true); 
	xmlHttp_Comente.send(null)
}

function stCh_ComentarPrd() {
	if (xmlHttp_Comente.readyState==4 || xmlHttp_Comente.readyState=="complete") {
		rsp_comente=xmlHttp_Comente.responseText; 
		bt_comente="<img src=Images/bt_comentario_off.gif width=125 height=15 border=0>"
		bt_indique="<a href=javascript:IndicarPrd()><img src=Images/bt_enviaramigo_on.gif width=125 height=15 border=0></a>"
		document.getElementById('s_prd_interacao').innerHTML=rsp_comente;
		document.getElementById('s_bt_comentario').innerHTML=bt_comente;
		document.getElementById('s_bt_indicacao').innerHTML=bt_indique;
		}
}

//-----------------------------------------------------------------------------------

function ImprimirPrd(x_codigo){
	window.open('PRO_Produtos_Impressao.asp?ID='+Math.random()+'&UK='+x_codigo, 'Prd_Impressao', 'location=no, scrollbars=yes, resizable=yes, toolbar=no, width=500, height=500');
}

//-----------------------------------------------------------------------------------------

function EnviaComentario(uk_produto){if (ValidaComentario()){var url="PRO_ajx.asp?ID="+Math.random()+"&O=GRVCOM&UK="+uk_produto+"&NO="+document.getElementById('Nome').value+"&EP="+document.getElementById('Empresa').value+"&TC="+document.getElementById('CodTelefone').value+"&TN="+document.getElementById('NumTelefone').value+"&EM="+document.getElementById('Email').value+"&CO="+document.getElementById('Comentario').value; xmlHttp_Contato=GetXmlHttpObject(stCh_EnviaComentario); xmlHttp_Contato.open("GET", url , true); xmlHttp_Contato.send(null)} else {alert('O formulário não foi enviado!\n\nAs informações destacadas em vermelho estão incorretas ou incompletas.')}}

function stCh_EnviaComentario() {if (xmlHttp_Contato.readyState==4 || xmlHttp_Contato.readyState=="complete") {rsp_comentario=xmlHttp_Contato.responseText; document.getElementById('td_fr_comentario').innerHTML=rsp_comentario}}

function ValidaComentario() { 
var com_ok=true; 
if ((document.getElementById('Email').value.indexOf("@")==-1) || (document.getElementById('Email').value.indexOf(".")==-1)) {com_ok=false; marcaV('s_Email')} else {marcaP('s_Email')} 
if (document.getElementById('Nome').value.length<3) {com_ok=false; marcaV('s_Nome');} else {marcaP('s_Nome')} 
if (document.getElementById('CodTelefone').value.length!=2 || document.getElementById('NumTelefone').value.length<5) {com_ok=false; marcaV('s_Telefone')} else {marcaP('s_Telefone')} 
if (document.getElementById('Empresa').value.length<3) {com_ok=false; marcaV('s_Empresa');} else {marcaP('s_Empresa')} 
if (document.getElementById('Comentario').value.length<10) {com_ok=false; marcaV('s_Comentario');} else {marcaP('s_Comentario')} 
return com_ok;
}

//-----------------------------------------------------------------------------------------

function EnviaIndicacao(uk_produto){if (ValidaIndicacao()){var url="PRO_ajx.asp?ID="+Math.random()+"&O=GRVIND&UK="+uk_produto+"&NO="+document.getElementById('Nome').value+"&EM="+document.getElementById('Email').value+"&ND="+document.getElementById('NomeDest').value+"&ED="+document.getElementById('EmailDest').value+"&CO="+document.getElementById('Comentario').value; xmlHttp_Contato=GetXmlHttpObject(stCh_EnviaIndicacao); xmlHttp_Contato.open("GET", url , true); xmlHttp_Contato.send(null)} else {alert('O formulário não foi enviado!\n\nAs informações destacadas em vermelho estão incorretas ou incompletas.')}}

function stCh_EnviaIndicacao() {if (xmlHttp_Contato.readyState==4 || xmlHttp_Contato.readyState=="complete") {rsp_indicacao=xmlHttp_Contato.responseText; document.getElementById('td_fr_indicacao').innerHTML=rsp_indicacao}}

function ValidaIndicacao() { 
var ind_ok=true; 
if ((document.getElementById('Email').value.indexOf("@")==-1) || (document.getElementById('Email').value.indexOf(".")==-1)) {ind_ok=false; marcaV('s_Email')} else {marcaP('s_Email')} 
if (document.getElementById('Nome').value.length<3) {ind_ok=false; marcaV('s_Nome');} else {marcaP('s_Nome')} 
if ((document.getElementById('EmailDest').value.indexOf("@")==-1) || (document.getElementById('EmailDest').value.indexOf(".")==-1)) {ind_ok=false; marcaV('s_EmailDest')} else {marcaP('s_EmailDest')} 
if (document.getElementById('NomeDest').value.length<3) {ind_ok=false; marcaV('s_NomeDest');} else {marcaP('s_NomeDest')}
return ind_ok;
}

//-----------------------------------------------------------------------------------------

function ExibirOrc(x_orcamento){
	var url="PRO_ajx01.asp?ID="+Math.random()+"&O=VERORC&UK="+x_orcamento;
	xmlHttp_Orcamento=GetXmlHttpObject(stCh_ExibirOrc); 
	xmlHttp_Orcamento.open("GET", url , true); 
	xmlHttp_Orcamento.send(null)
}

function stCh_ExibirOrc() {
	if (xmlHttp_Orcamento.readyState==4 || xmlHttp_Orcamento.readyState=="complete") {
		rsp_orcamento=xmlHttp_Orcamento.responseText; 
		//document.getElementById('td_meus_orcs').innerHTML=rsp_orcamento;
		window.location=rsp_orcamento;
		}
}

//-----------------------------------------------------------------------------------------

function ExibirAdmOrc(x_orcamento){
	var url="PRO_ajx01.asp?ID="+Math.random()+"&O=ADMORC&UK="+x_orcamento;
	xmlHttp_OrcDet=GetXmlHttpObject(stCh_ExibirAdmOrc); 
	xmlHttp_OrcDet.open("GET", url , true); 
	xmlHttp_OrcDet.send(null)
}

function stCh_ExibirAdmOrc() {
	if (xmlHttp_OrcDet.readyState==4 || xmlHttp_OrcDet.readyState=="complete") {
		rsp_OrcDet=xmlHttp_OrcDet.responseText; 
		window.location=rsp_OrcDet;
		}
}

//-----------------------------------------------------------------------------------------

function EnviaSenha(uk_produto){if (ValidaEmailSenha()){var url="PRO_ajx01.asp?ID="+Math.random()+"&O=ENVPAS&EM="+document.getElementById('EmailSenha').value; xmlHttp_Contato=GetXmlHttpObject(stCh_EnviaSenha); xmlHttp_Contato.open("GET", url , true); xmlHttp_Contato.send(null)} else {alert('O formulário não foi enviado!\n\nAs informações destacadas em vermelho estão incorretas ou incompletas.')}}

function stCh_EnviaSenha() {
	if (xmlHttp_Contato.readyState==4 || xmlHttp_Contato.readyState=="complete") {
		rsp_email_ok=xmlHttp_Contato.responseText; 
		if (rsp_email_ok=='EX') { alert('Email Inválido!\n\nO email digitado não consta em nossa base de dados.\nPor favor, digite o endereço novamente.'); marcaV('s_EmailSenha'); document.getElementById('EmailSenha').value=''; document.getElementById('EmailSenha').focus()}
		else
		{document.getElementById('td_esquece_senha').innerHTML=rsp_email_ok}
	}
}

function ValidaEmailSenha() { 
var ind_ok=true; 
if ((document.getElementById('EmailSenha').value.indexOf("@")==-1) || (document.getElementById('EmailSenha').value.indexOf(".")==-1)) {ind_ok=false; marcaV('s_EmailSenha')} else {marcaP('s_EmailSenha')} 
return ind_ok;
}

//-----------------------------------------------------------------------------------------

function ValidaAcesso(endereco){
	var url="PRO_ajx01.asp?ID="+Math.random()+"&O=VALACS&ED="+endereco; xmlHttp_Valida=GetXmlHttpObject(stCh_ValidaAcesso); xmlHttp_Valida.open("GET", url , true); xmlHttp_Valida.send(null)
}

function stCh_ValidaAcesso() {
	if (xmlHttp_Valida.readyState==4 || xmlHttp_Valida.readyState=="complete") {
		rsp_validacao=xmlHttp_Valida.responseText; 
		if (rsp_validacao=='EX') 
		{window.location="PRO_Restrito_Blocked.asp";}
	}
}

//-----------------------------------------------------------------------------------------

function ValidaAcessoADM(endereco){
	var url="PRO_ajx01.asp?ID="+Math.random()+"&O=VALACSADM&ED="+endereco; xmlHttp_ValidaADM=GetXmlHttpObject(stCh_ValidaAcessoADM); xmlHttp_ValidaADM.open("GET", url , true); xmlHttp_ValidaADM.send(null)
}

function stCh_ValidaAcessoADM() {
	if (xmlHttp_ValidaADM.readyState==4 || xmlHttp_ValidaADM.readyState=="complete") {
		rsp_validacaoADM=xmlHttp_ValidaADM.responseText; 
		if (rsp_validacaoADM=='EX') 
		{window.location="PRO_Restrito_Blocked.asp";}
	}
}

//-----------------------------------------------------------------------------------------

function ValidaAcessoGCO(endereco){
	var url="PRO_ajx01.asp?ID="+Math.random()+"&O=VALACSGCO&ED="+endereco; xmlHttp_ValidaGCO=GetXmlHttpObject(stCh_ValidaAcessoGCO); xmlHttp_ValidaGCO.open("GET", url , true); xmlHttp_ValidaGCO.send(null)
}

function stCh_ValidaAcessoGCO() {
	if (xmlHttp_ValidaGCO.readyState==4 || xmlHttp_ValidaGCO.readyState=="complete") {
		rsp_validacaoGCO=xmlHttp_ValidaGCO.responseText; 
		if (rsp_validacaoGCO=='EX') 
		{window.location="PRO_Restrito_Blocked.asp";}
	}
}

//-----------------------------------------------------------------------------------------

function ValidaAcessoMKT(endereco){
	var url="PRO_ajx01.asp?ID="+Math.random()+"&O=VALACSMKT&ED="+endereco; xmlHttp_ValidaMKT=GetXmlHttpObject(stCh_ValidaAcessoMKT); xmlHttp_ValidaMKT.open("GET", url , true); xmlHttp_ValidaMKT.send(null)
}

function stCh_ValidaAcessoMKT() {
	if (xmlHttp_ValidaMKT.readyState==4 || xmlHttp_ValidaMKT.readyState=="complete") {
		rsp_validacaoMKT=xmlHttp_ValidaMKT.responseText; 
		if (rsp_validacaoMKT=='EX') 
		{window.location="PRO_Restrito_Blocked.asp";}
	}
}


//-----------------------------------------------------------------------------------

// ----- FUNCAO PARA RECONHECER O ENTER NO CAMPO DE BUSCA ----- //

function Exec_Busca_Interna(e){ //e is event object passed from function invocation
	var characterCode //literal character code will be stored in this variable

	if(e && e.which){ //if which property of event object is supported (NN4)
		e = e
		characterCode = e.which //character code is contained in NN4's which property
	}
	else{
		e = event
		characterCode = e.keyCode //character code is contained in IE's keyCode property
	}

	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
		document.forms[0].submit() //submit the form
		return false 
	}
	else{
		return true 
	}
}

function Exec_Busca(e){ //e is event object passed from function invocation
	var characterCode //literal character code will be stored in this variable

	if(e && e.which){ //if which property of event object is supported (NN4)
		e = e
		characterCode = e.which //character code is contained in NN4's which property
	}
	else{
		e = event
		characterCode = e.keyCode //character code is contained in IE's keyCode property
	}

	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
		Pesquisar() //document.forms[0].submit() //submit the form
		return false 
	}
	else{
		return true 
	}
}

function Pesquisar()
{ 
	xmlHttp					=PegaXmlHttpObject();
	var url					="PRO_ajx01.asp?ID="+Math.random()+"&O=BUSCA&Search_Ex="+document.getElementById('search').value;
	xmlHttp.onreadystatechange	=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
    
	if (xmlHttp.readyState == 1) {
		document.getElementById("buscando").innerHTML="<img src='Images/bt_achando.gif'>";
		}
	
	//return url;
}

function stateChanged() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		//document.getElementById("header").innerHTML=xmlHttp.responseText;
		window.location=xmlHttp.responseText;
	}
}

function PegaXmlHttpObject()
{
	if (window.XMLHttpRequest) {   
		// Firefox, Opera 8.0+, Safari
		a=new XMLHttpRequest(); } 
	else {  
		// Internet Explorer
		try { a=new ActiveXObject("Msxml2.XMLHTTP"); }     
		catch(e) {  
			try { a=new ActiveXObject("Microsoft.XMLHTTP"); }     
			catch(e) { a=false; }  
			}  
		}   
	return a;
}

//-----------------------------------------------------------------------------------------

function LogotiposOnload() {
	var url="PRO_Restrito_Logotipos_Itens.asp?ID="+Math.random(); 
	xmlHttp_orcload=PegaXmlHttpObjeto02(stCh_LogotiposOnload); 
	xmlHttp_orcload.open("GET", url , true); 
	xmlHttp_orcload.send(null)
}

function stCh_LogotiposOnload(){ 
if (xmlHttp_orcload.readyState==4 || xmlHttp_orcload.readyState=="complete") 
 {
	 var rsp_orcamento=xmlHttp_orcload.responseText; 
 	document.getElementById('td_imagens').innerHTML=rsp_orcamento;}
}

//-----------------------------------------------------------------------------------------

function LogotiposOnloadADM() {
	var url="PRO_Restrito_Adm_Logotipos_Itens.asp?ID="+Math.random(); 
	xmlHttp_admimg=PegaXmlHttpObjeto02(stCh_LogotiposOnloadADM); 
	xmlHttp_admimg.open("GET", url , true); 
	xmlHttp_admimg.send(null)
}

function stCh_LogotiposOnloadADM(){ 
if (xmlHttp_admimg.readyState==4 || xmlHttp_admimg.readyState=="complete") 
 {
	 var rsp_admimg=xmlHttp_admimg.responseText; 
 	document.getElementById('td_adm_imagens').innerHTML=rsp_admimg;}
}

//-----------------------------------------------------------------------------------------

function ExcluirImg(IMG_UKEY){
	if (confirm("Tem certeza que deseja excluir este logotipo da lista?")) {var url="PRO_ajx01.asp?ID="+Math.random()+"&O=EXCIMG&UK="+IMG_UKEY; xmlHttp_ExcluiImg=PegaXmlHttpObjeto(st_ExcluirImg); xmlHttp_ExcluiImg.open("GET", url , true); xmlHttp_ExcluiImg.send(null)}
	}
	
function st_ExcluirImg()
{ 
	if(xmlHttp_ExcluiImg.readyState==4 || xmlHttp_ExcluiImg.readyState=="complete") 
	{	
		var rsp_ExcluiImg		= xmlHttp_ExcluiImg.responseText; 
		if (rsp_ExcluiImg == 'OK') 
		{
			alert("Logotipo excluido com sucesso!")
			FuncoesLogotipos();  // Recarrega os orçamentos 
		}
	}
}

//-----------------------------------------------------------------------------------------

function ExibirAdmImg(x_imagem){
	var url = "PRO_ajx01.asp?ID="+Math.random()+"&O=IMGDET&UK="+x_imagem;
	xmlHttp_ImgDet = GetXmlHttpObject(stCh_ExibirAdmImg); 
	xmlHttp_ImgDet.open("GET", url , true); 
	xmlHttp_ImgDet.send(null)
}

function stCh_ExibirAdmImg() {
	if (xmlHttp_ImgDet.readyState==4 || xmlHttp_ImgDet.readyState=="complete") {
		rsp_ImgDet = xmlHttp_ImgDet.responseText; 
		window.location = rsp_ImgDet;
		}
}

//-----------------------------------------------------------------------------------------

function ExibirAdmUsr(x_usuario){
	var url="PRO_ajx01.asp?ID="+Math.random()+"&O=VERUSR&UK="+x_usuario;
	xmlHttp_UsrDet=GetXmlHttpObject(stCh_ExibirAdmUsr); 
	xmlHttp_UsrDet.open("GET", url , true); 
	xmlHttp_UsrDet.send(null)
}

function stCh_ExibirAdmUsr() {
	if (xmlHttp_UsrDet.readyState==4 || xmlHttp_UsrDet.readyState=="complete") {
		rsp_UsrDet=xmlHttp_UsrDet.responseText; 
		window.location=rsp_UsrDet;
		}
}

//-----------------------------------------------------------------------------------------

function ExibirBnr(x_banner) {
	var url="PRO_Restrito_Adm_Banners_Detalhe.asp?ID="+Math.random()+"&UK="+x_banner; 
	xmlHttp_Banner=GetXmlHttpObject(stCh_ExibirBnr); 
	//LoadBanners(x_banner);
	xmlHttp_Banner.open("GET", url , true); 
	xmlHttp_Banner.send(null)}

function stCh_ExibirBnr(){ 
if (xmlHttp_Banner.readyState==4 || xmlHttp_Banner.readyState=="complete"){
	 var rsp_bannersload=xmlHttp_Banner.responseText; 
	 document.getElementById('td_adm_banners').innerHTML=rsp_bannersload;
	 }
}

//-----------------------------------------------------------------------------------------

function GravaBanner(){if (validaCADBNR()){
	alert("inicio: "+document.getElementById('DataInicio').value+" fim: "+document.getElementById('DataFim').value);
	var url="PRO_ajx01.asp?ID="+Math.random()+"&O=GRVBNR&C_Arquivo="+document.getElementById('Arquivo').value+"&C_Descricao="+document.getElementById('Descricao').value+"&C_Link="+document.getElementById('Link').value+"&C_DataInicio="+document.getElementById('DataInicio').value+"&C_DataFim="+document.getElementById('DataFim').value;
	xmlHttp_GravaBNR=PegaXmlHttpObjeto02(stCh_GravaBanner); 
	xmlHttp_GravaBNR.open("GET", url , true); 
	xmlHttp_GravaBNR.send(null);
	} 
	else {alert('O cadastro não foi gravado!\n\nAs informações destacadas em vermelho estão incorretas ou incompletas.')
	//alert("inicio: "+document.getElementById('DataInicio').value+" fim: "+document.getElementById('DataFim').value);
	}}

function stCh_GravaBanner() {
	if (xmlHttp_GravaBNR.readyState==4 || xmlHttp_GravaBNR.readyState=="complete") {
		var rsp_gravabnr		= xmlHttp_GravaBNR.responseText; 
		alert(rsp_gravabnr);
		if (rsp_gravabnr == 'OK') 
		{
			alert("Banner cadastrado com sucesso!");
			window.location="PRO_Restrito_Adm_Banners.asp" 
		}
		}
}

function validaCADBNR() { 
	var cad_ok=true; 
	if (document.getElementById('Arquivo').value.length<5) {cad_ok=false; marcaV('s_Arquivo');} else {marcaP('s_Arquivo')} 
	if (document.getElementById('Descricao').value.length<5) {cad_ok=false; marcaV('s_Descricao');} else {marcaP('s_Descricao')}
	//if (document.getElementById('DataInicio').value!='') {
		if (validaData(document.getElementById('DataInicio').value)==false) {cad_ok=false; marcaV('s_DataInicio');} else {marcaP('s_DataInicio')}
	//}
	//if (document.getElementById('DataFim').value!='') {
		if (validaData(document.getElementById('DataFim').value)==false) {cad_ok=false; marcaV('s_DataFim');} else {marcaP('s_DataFim')}
	//}
	return cad_ok;


}

//-----------------------------------------------------------------------------------------

function BannersOnload(x_pagina) {
	var url="PRO_Restrito_Adm_Banners_Itens.asp?ID="+Math.random()+"&PG_Atual="+x_pagina; 
	//xmlHttp_bnrload=PegaXmlHttpObjeto02(stCh_BannersOnload); 
	xmlHttp_bnrload=GetXmlHttpObject(stCh_BannersOnload); 
	xmlHttp_bnrload.open("GET", url , true); 
	xmlHttp_bnrload.send(null);
	}

function stCh_BannersOnload(){ 
if (xmlHttp_bnrload.readyState==4 || xmlHttp_bnrload.readyState=="complete") {
	var rsp_bannersload=xmlHttp_bnrload.responseText; 
	document.getElementById('td_adm_banners').innerHTML=rsp_bannersload;
	}
}


//-----------------------------------------------------------------------------------------

function LoadBanners(x_UkeyBNR){ 
	//alert("Entrou! "+x_UkeyBNR)
	var url_item="PRO_ajx01.asp?ID="+Math.random()+"&O=LD_BNR"+"&UK="+x_UkeyBNR; 
	xmlHttp_CarregaBNR=GetXmlHttpObject(st_LoadBanners);
	xmlHttp_CarregaBNR.open("GET", url_item , true); 
	xmlHttp_CarregaBNR.send(null)
}

function st_LoadBanners()
{ 
	if(xmlHttp_CarregaBNR.readyState==4 || xmlHttp_CarregaBNR.readyState=="complete") 
	{	
		var rsp_BNR					= xmlHttp_CarregaBNR.responseText; 
		var rsp_AdicionaBNR			= rsp_BNR.split("#@#");

		if (rsp_AdicionaBNR[0]=='OK')
		{
			//alert(rsp_AdicionaBNR[0]);
			document.getElementById('Arquivo').value=rsp_AdicionaBNR[1];
			document.getElementById('Descricao').value=rsp_AdicionaBNR[2];
			document.getElementById('Data').value=rsp_AdicionaBNR[3];
			if (rsp_AdicionaBNR[4] == 1){document.getElementById('Inativo').checked=true;}
			document.getElementById('BNR_UKEY').value=rsp_AdicionaBNR[5];
			document.getElementById('Arquivo').focus();
			//document.getElementById('Arquivo').value="Chegou"
		}
	}
}

//-----------------------------------------------------------------------------------------

function AtualizaBnr(){if (validaAtualizaBnr()){
	var url="PRO_ajx01.asp?ID="+Math.random()+"&O=ATTBNR&UK="+document.getElementById('BNR_UKEY').value+"&C_Arquivo="+document.getElementById('Arquivo').value+"&C_Descricao="+document.getElementById('Descricao').value+"&C_Link="+document.getElementById('Link').value+"&C_Inativo="+document.getElementById('Inativo').checked;
	xmlHttp_AttBNR=GetXmlHttpObject(st_AtualizaBanner);
	xmlHttp_AttBNR.open("GET", url , true); 
	xmlHttp_AttBNR.send(null)
	}
	else {alert('O cadastro não foi gravado!\n\nAs informações destacadas em vermelho estão incorretas ou incompletas.')}}
	
function st_AtualizaBanner(){ 
if (xmlHttp_AttBNR.readyState==4 || xmlHttp_AttBNR.readyState=="complete") {
	var rsp_retornobnr=xmlHttp_AttBNR.responseText; 
	document.getElementById('td_adm_banners').innerHTML=rsp_retornobnr;
	}
}

function validaAtualizaBnr() { 
var cad_ok=true; 
if (document.getElementById('Arquivo').value.length<5) {cad_ok=false; marcaV('s_Arquivo');} else {marcaP('s_Arquivo')} 
if (document.getElementById('Descricao').value.length<5) {cad_ok=false; marcaV('s_Descricao');} else {marcaP('s_Descricao')} 
return cad_ok;}

//-----------------------------------------------------------------------------------

function ExibeImg(x_produto){
	var url="PRO_ajx02.asp?ID="+Math.random()+"&O=EXBPHO&UK="+x_produto;
	xmlHttp_Foto=GetXmlHttpObject(stCh_ExibeImg); 
	xmlHttp_Foto.open("GET", url , true); 
	xmlHttp_Foto.send(null)
}

function stCh_ExibeImg() {
if (xmlHttp_Foto.readyState==4 || xmlHttp_Foto.readyState=="complete") {
	var rsp_foto=xmlHttp_Foto.responseText; 
	//alert(rsp_foto);
	document.getElementById('s_prd_photo').innerHTML=rsp_foto;
	}
}

//-----------------------------------------------------------------------------------

function grvcadNews(){var url="PRO_ajx01.asp?ID="+Math.random()+"&O=GCADN&NO="+document.getElementById('nome').value+"&EM="+document.getElementById('email').value; xmlHttp=GetXmlHttpObject(stCh_grcnw); xmlHttp.open("GET", url , true); xmlHttp.send(null)}

function stCh_grcnw(){if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){rsp=xmlHttp.responseText; if (rsp=='OK') {alert('Cadastro efetuado com sucesso!'); document.getElementById('nome').value=''; document.getElementById('email').value=''} else {alert('Este endereço de e-mail já está cadastrado!')} }}

function cadNews(){if (document.getElementById('email').value.indexOf("@")!=-1 && document.getElementById('email').value.indexOf(".")!=-1 && document.getElementById('nome').value.length>3) {grvcadNews()} else {alert('Para efetuar a cadastro de Newsletter é necessário inserir nome e email corretos!')}}


