function abrirChat(URL) {
	var width = 301;
	var height = 501;
	var left = 400;
	var top = 200;
	window.open(URL,'janela', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=no, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
}

// Funcoes Genericas de Validacao de Forms
function EnviaHttp(url){
	var url;
	window.location= 'fluxo/enviaHttps.asp?pagina='+url;
}
function LimparTipos(){	
	
	if (document.getElementById('PosHome')) { 
	  //existe 
//		document.getElementById("rdBuscarAutomovel").style.visibility = "hidden"; //tirar para busca por medida.
		document.getElementById("rdBuscarAutomovel").checked = true; //definir "" quando for efetuar busca por medida.
		document.getElementById("rdBuscarMedida").checked = "";
		
		document.getElementById("rdAutomovel_Automovel").checked = "";
		document.getElementById("rdAutomovel_Pickup").checked = "";


		if (document.getElementById("AutomoveisHome").style.display == 'none' || document.getElementById("AutomoveisHomeII").style.display == 'none'){
			document.getElementById("AutomoveisHome").style.display = 'block';
			document.getElementById("AutomoveisHomeII").style.display = 'block';
		}
		
	} 
	
	
}

function IsValidRequiredField(field, errField)
	{
		if (Limpa_String($$(field).value) == "")
		{
			$$(errField).style.display = 'block';
			return false;
		}
		else
		{
			$$(errField).style.display = 'none';
			return true;
		};
	}
function IsValidRequiredField2(field, errField)
	{
		if (Limpa_String($$(field).value) == "")
		{
			$$(errField).style.display = 'block';
			return false;
		}
		else
		{
			$$(errField).style.display = 'none';
			return true;
		};
	}
	
function IsValidVerificationEmail(field, errField){

	valor = $$(field).value;

	if (valor.indexOf('@')==-1 || valor.indexOf('.')==-1){
		
		$$(errField).style.display = 'block';
		return false;
			
		}else{
		
		$$(errField).style.display = 'none';			
		return true;
	
	}

}
function IsValidVerificationEmail2(field, errField){

	valor = $$(field).value;

	if (valor.indexOf('@')==-1 || valor.indexOf('.')==-1){
		
		$$(errField).style.display = 'block';
		return false;
			
		}else{
		
		$$(errField).style.display = 'none';			
		return true;
	
	}

}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function BloqueiaTeclaLogin(Campo) {
	var key_code = Campo.keyCode ? Campo.keyCode : Campo.which ? Campo.which : Campo.charCode;
	var numeros='&*%$()<>';
	if ((numeros.indexOf(String.fromCharCode(key_code))!=-1) && (key_code!=8 && key_code!=46) && key_code != 13 || (key_code==34 || key_code==39)) {
		return false;
	}
}
function SoNumeros(Campo) {
	var key_code = Campo.keyCode ? Campo.keyCode : Campo.which ? Campo.which : Campo.charCode;
	var numeros='0123456789';
	if ((numeros.indexOf(String.fromCharCode(key_code))==-1) && (key_code!=8 && key_code!=46) && (key_code != 13)){
		alert('¡Digite apenas números nesta área!')
		return false;
	}
}
function ValidaCPF(InString) {
      LenStr = InString.length;
		if ((LenStr < 8)||(LenStr > 11)) {
			alert("O CPF é inválido");
			return false};
      TempString="";
		if (LenStr < 11) {
	        for (Count=1; Count<=(11-LenStr); Count++) {
	                TempString = TempString + "0";
        	}
		}
		InString = TempString + InString;
		CicFrente = "" + InString.substring(0,9);
		CicDigito = "" + InString.substring(9,11);
		TempString = CicFrente;
		Fator=10;
		DigitoFinal = "";
		for (loop=0; loop<=1; loop++) {
			SomaDig=0;
			for (Count=0; Count<=TempString.length; Count++) {
					StrChar = TempString.substring(Count, Count+1);
					SomaDig = SomaDig + (StrChar * Fator);
					Fator--;
			}
			Resto = SomaDig % 11;
			if (Resto<=1)
				Digito = 0;
			else
				Digito = 11 - Resto;
			DigitoFinal = "" + DigitoFinal + Digito;
			TempString = CicFrente + "" + Digito;
			Fator=11;
			if (SomaDig==0) {
				DigitoFinal=01;
				CicDigito=02;
				}
		}
		if ((DigitoFinal!=CicDigito)||(InString=="11111111111")||(InString=="22222222222")||
		   (InString=="33333333333")||(InString=="44444444444")||(InString=="55555555555")||
		   (InString=="66666666666")||(InString=="77777777777")||(InString=="88888888888")||
		   (InString=="99999999999")||(InString=="01234567890")||(InString=="1234567890"))
			{
			alert("Informe um CPF válido");
        	return (false);
		}
		return true;
}

function IsValidCPF(InString) {
      LenStr = InString.length;
		if ((LenStr < 8)||(LenStr > 11)) {
			return false};
      TempString="";
		if (LenStr < 11) {
	        for (Count=1; Count<=(11-LenStr); Count++) {
	                TempString = TempString + "0";
        	}
		}
		InString = TempString + InString;
		CicFrente = "" + InString.substring(0,9);
		CicDigito = "" + InString.substring(9,11);
		TempString = CicFrente;
		Fator=10;
		DigitoFinal = "";
		for (loop=0; loop<=1; loop++) {
			SomaDig=0;
			for (Count=0; Count<=TempString.length; Count++) {
					StrChar = TempString.substring(Count, Count+1);
					SomaDig = SomaDig + (StrChar * Fator);
					Fator--;
			}
			Resto = SomaDig % 11;
			if (Resto<=1)
				Digito = 0;
			else
				Digito = 11 - Resto;
			DigitoFinal = "" + DigitoFinal + Digito;
			TempString = CicFrente + "" + Digito;
			Fator=11;
			if (SomaDig==0) {
				DigitoFinal=01;
				CicDigito=02;
				}
		}
		if ((DigitoFinal!=CicDigito)||(InString=="11111111111")||(InString=="22222222222")||
		   (InString=="33333333333")||(InString=="44444444444")||(InString=="55555555555")||
		   (InString=="66666666666")||(InString=="77777777777")||(InString=="88888888888")||
		   (InString=="99999999999")||(InString=="01234567890")||(InString=="1234567890"))
			{
				//alert("Informe um CPF válido");
				return (false);
			}
		return true;
}

function Limpa_String(texto) {
	while ((texto.indexOf('.') >= 0) || (texto.indexOf(',') >= 0) || (texto.indexOf('-') >=0) || (texto.indexOf('/') >= 0))
	{
		texto = texto.replace('-','');
		texto = texto.replace('.','');
		texto = texto.replace('/','');
		texto = texto.replace(',','');
	}
	return texto;
}
function checa_cpf(CPF, campo) {
	var mensagem = "Informe corretamente o número do CPF!"
	var msg = "";
	if (CPF != ""){
		if (CPF.length != 11 || CPF == "00000000000" || CPF == "11111111111" || CPF == "22222222222" ||	CPF == "33333333333" || CPF == "44444444444" || CPF == "55555555555" || CPF == "66666666666" || CPF == "77777777777" || CPF == "88888888888" || CPF == "99999999999"){
			msg = mensagem;
		}
		soma = 0;
		for (y=0; y < 9; y ++)
			soma += parseInt(CPF.charAt(y)) * (10 - y);
		resto = 11 - (soma % 11);
		if (resto == 10 || resto == 11)
			resto = 0;
		if (resto != parseInt(CPF.charAt(9)))
		  	msg = mensagem; 
		soma = 0;
		for (y = 0; y < 10; y ++)
		  	soma += parseInt(CPF.charAt(y)) * (11 - y);
		resto = 11 - (soma % 11);
		if (resto == 10 || resto == 11) 
			resto = 0;
		if (resto != parseInt(CPF.charAt(10)))
		  	msg = mensagem;
	}
	if(msg != "" && CPF != ""){
		CampoAlerta(campo, msg);
		return false;
	}
	else{
		AplicaMascara('CPF', campo);
		return true;
		
	}
}
/**
* Formata o Campo de acordo com a mascara informada.
* Ex de uso: onkeyup="AplicaMascara('HORA', this);".
* @author Igor Escobar (blog@igorescobar.com)
* @param Mascara String que possui o nome da mascara de formatação do campo.
* @param elemento Campo que será formatado de acordo com a mascara, voce pode informar o id direto ou o próprio elemento usando o this.
* @returns {void}
* @methods
   - DATA: 
   - HORA:
   - CEP:
   - CPF:
   - CNPJ
   - TEL
   - TELDDD
   - PLACA
*/
function AplicaMascara(Mascara, elemento){
    // Seta o elemento
    var elemento = (elemento.value) ? elemento : document.getElementById(elemento); 
    if(!elemento) return false;

    // DEFINE AS REGRAS DE FORMATAÇÃO DOS CAMPOS
    var Regexs = {
        CNPJ: 	/(([0-9]){2})(([0-9]){3})(([0-9]){3})(([0-9]){4})(([0-9]){2})/,
        CPF: 	/(([0-9]){3})(([0-9]){3})(([0-9]){3})(([0-9]){2})/,
        PLACA:  /(([A-Za-z]){3})(([0-9]){4})/,
        DATA: 	/(([0-9]){2})(([0-9]){2})(([0-9]){4})/,
        HORA: 	/(([0-9]){2})(([0-9]){2})(([0-9]){2})/,
        TELDDD: /(([0-9]){2})(([0-9]){4})(([0-9]){4})/,
        TEL: 	/(([0-9]){4})(([0-9]){4})/,
        CEP: 	/(([0-9]){5})(([0-9]){3})/
    }
    MyRegex = eval('Regexs.'+Mascara);
    
    // INSTANCIA A REGRA REGEX PARA FORMATACAO
    getRegexGroups = new RegExp(MyRegex);
    
    // INSTANCIA A REGRA QUE VERIFICA SE O CAMPO POSSUI SOMENTE NÚMEROS
    onlyNumbers = new RegExp(/^([0-9]+)$/);
    
    // ESTE É O CAMPO COM AS IMPURESAS (DIGITADO PELO USUÁRIO FINAL)
    var CampoSujo = elemento.value;
    
    // RETIRA OS EXCESSOS DOS CAMPOS PARA QUE POSSAMOS APLICAR A MASCARA EM UM CAMPO LIMPO
    var oValue = CampoSujo.replace(/([./;:,\-()]+)/g,"");
    
    // VERIFICA SE A REGRA QUE ELE SE ESCOLHEU SE APLICA AO TEXTO DIGITADO NO CAMPO 
  
    if(getRegexGroups.test(oValue) == true){
        //APLICA A REGRA NO CAMPO E FORMATA
        switch(Mascara){

            case 'CNPJ'	 : oNewCampo = oValue.replace(getRegexGroups,"$1.$3.$5/$7-$9"); break;          
            case 'CPF' 	 : oNewCampo = oValue.replace(getRegexGroups,"$1.$3.$5-$7"); break;
            case 'PLACA' : oNewCampo = oValue.replace(getRegexGroups,"$1-$3"); break;
 			case 'TEL'   : oNewCampo = oValue.replace(getRegexGroups,"$1-$3"); break;
            case 'TELDDD': oNewCampo = oValue.replace(getRegexGroups,"($1) $3-$5"); break;
            case 'DATA'  : oNewCampo = oValue.replace(getRegexGroups,"$1/$3/$5"); break;
            case 'HORA'  : oNewCampo = oValue.replace(getRegexGroups,"$1:$3:$5"); break;
			case 'CEP' 	 : oNewCampo = oValue.replace(getRegexGroups,"$1-$3"); break;
        }
        // Retorna o valor do elemento com seu novo valor
        elemento.value = oNewCampo; 
    } 
} 
function valida_cnpj(cnpj, campo){
    var numeros, digitos, soma, i, resultado, pos, tamanho, digitos_iguais, msg;
	msg = "CNPJ incorreto! Por favor, verifique os digitos!"
    digitos_iguais = 1;
	if(cnpj != ""){
	    if (cnpj.length < 14 && cnpj.length < 15){
			CampoAlerta(campo, msg);
	        return false;
		}
	    for (i = 0; i < cnpj.length - 1; i++)
	    	if (cnpj.charAt(i) != cnpj.charAt(i + 1)){
	        	digitos_iguais = 0;
	            break;
	        }
	    if(!digitos_iguais){
	    	tamanho = cnpj.length - 2
	        numeros = cnpj.substring(0,tamanho);
	        digitos = cnpj.substring(tamanho);
	        soma = 0;
	        pos = tamanho - 7;
	        for (i = tamanho; i >= 1; i--){
	        	soma += numeros.charAt(tamanho - i) * pos--;
	            if (pos < 2)
	            	pos = 9;
	        }
	        resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
	        if (resultado != digitos.charAt(0)){
	        	CampoAlerta(campo, msg);
				return false;
			}
	        tamanho = tamanho + 1;
	        numeros = cnpj.substring(0,tamanho);
	        soma = 0;
	        pos = tamanho - 7;
	        for (i = tamanho; i >= 1; i--){
	        	soma += numeros.charAt(tamanho - i) * pos--;
	        	if (pos < 2)
	       			pos = 9;
	       	}
	        resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
	        if (resultado != digitos.charAt(1)){
				CampoAlerta(campo, msg);
	        	return false;
			}
			else{
			 	AplicaMascara('CNPJ', campo);
	        	return true;
	        	
			}
	    }
	    else{
			CampoAlerta(campo, msg);
	        return false;
		}
	}else{
	 	
		CampoAlerta(campo, msg);
	        return false;
	}
}
function verifica_data(data, campo) {
	if (data != "") {
		dia = (data.substring(0,2));
		mes = (data.substring(3,5)); 
		ano = (data.substring(6,10)); 
		situacao = ""
		if (isNaN(dia)){
			situacao = "falsa";
		}
		if (isNaN(mes)){
			situacao = "falsa";
		}
		if (isNaN(ano)){
			situacao = "falsa";
		}
		if(dia == "" || dia == null || dia == " "){
			situacao = "falsa"; 
		}
		if(mes == "" || mes == null || mes == " "){
			situacao = "falsa"; 
		}
		if(ano == "" || ano == null || ano == " "){
			situacao = "falsa"; 
		}
		
		if ((dia < 01 || dia > 30) && (mes == 04 || mes == 06 || mes == 09 || mes == 11) || dia > 31) { 
			situacao = "falsa"; 
		};
		if (mes < 01 || mes > 12 ) { 
			situacao = "falsa"; 
		};
		if (mes == 2 && ( dia < 01 || dia > 29 || ( dia > 28 && (parseInt(ano / 4) != ano / 4)))) { 
			situacao = "falsa"; 
		} 
		
		if (situacao == "falsa") {
			mensagem = 'Fecha No válido'
			CampoAlerta(campo, mensagem);
			return false;
		}else{
			return true;
		}
	}else{
		return true;
	}
}

function IsValidDate(data) {
	var situacao = true;
	if (data != "") {
		dia = (data.substring(0,2));
		mes = (data.substring(3,5)); 
		ano = (data.substring(6,10)); 
		if (isNaN(dia)){
			situacao = false;
		}
		if (isNaN(mes)){
			situacao = false;
		}
		if (isNaN(ano)){
			situacao = false;
		}
		if(dia == "" || dia == null || dia == " "){
			situacao = false; 
		}
		if(mes == "" || mes == null || mes == " "){
			situacao = false; 
		}
		if(ano == "" || ano == null || ano == " "){
			situacao = false; 
		}
		
		if ((dia < 01 || dia > 30) && (mes == 04 || mes == 06 || mes == 09 || mes == 11) || dia > 31) { 
			situacao = false; 
		};
		if (mes < 01 || mes > 12 ) { 
			situacao = false; 
		};
		if (mes == 2 && ( dia < 01 || dia > 29 || ( dia > 28 && (parseInt(ano / 4) != ano / 4)))) { 
			situacao = false; 
		} 
	}
	else
		situacao = false;
		
	return situacao;
}

function checa_numerico(Str, campo) {
	var Str
	var mensagem = "Este campo só aceita números!"
	if (Str != "") {
	if (isNaN(Str)){
		msg = mensagem;
		CampoAlerta(campo, mensagem);
		return false;
	}else{
		return true
	}
	}else{
		return true;
	}
}
function chk_senha(Str, campo, campo2){
	var Campo_1 = Str
	var Campo_2 = campo2.value
	if (Campo_1 != Campo_2){
		mensagem = "Senha não confere!"
		CampoAlerta(campo, mensagem);
		return false;
	}else{
		return true;	
	}
}
function checa_email(valor, campo) {

	var mensagem = "Informe corretamente o email!"
	var msg = "";
	if (valor != ""){ 
		var email = valor.match(/(\w+)@(.+)\.(\w+)$/);
		if (email == null){
  			msg = mensagem;
  		}
	}
	if(msg != "" && valor != ""){
		CampoAlerta(campo, msg);
		return false;
	}
	else{
		return true;
	}
}
function Left(str, n){
	if (n <= 0)
		return "";
	else if (n > String(str).length)
		return str;
	else
		return String(str).substring(0,n);
}
function Right(str, n){
	if (n <= 0)
   		return "";
	else if (n > String(str).length)
   		return str;
	else {
   		var iLen = String(str).length;
   		return String(str).substring(iLen, iLen - n);
	}
}

function CampoAlerta(campo, msg){
	campo.className = 'Alerta'
	campo.select();
	campo.focus();
	alert(msg);
}

//A partir de um valor float ela retorna o valor formatado com separador de milhar e vírgula nos centavos.
//Tem que ser aplicado no ONBLUR do input.
function float2moeda(num, campo) {

   x = 0;
   num = num.replace(",",".");
   if(num<0) {

      num = Math.abs(num);
      x = 1;
   }
   if(isNaN(num)){
	   num = "0";
	   alert("Utilize apenas números separadores monetária (vírgulas e pontos)!");
		campo.className = 'Alerta'
		campo.select();
		campo.focus();
		campo.onkeypress = function(){
		campo.className = ''
		}

   }
      cents = Math.floor((num*100+0.5)%100);
   num = Math.floor((num*100+0.5)/100).toString();
   if(cents < 10) cents = "0" + cents;
      for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
         num = num.substring(0,num.length-(4*i+3))+'.'
               +num.substring(num.length-(4*i+3));
   ret = num + ',' + cents;
   if (x == 1) ret = ' - ' + ret;return ret;
}
/* FUNÇÃO VALIDA FORM DESENVOLVIDO POR RODRIGO CESAR
 Para utilizar este verificador lembre-se de chamar a função no evento onsubmit de seu formulário.
 Para validar um campo, basta inserir no atributo ID as três primeiras letras da validação no início do valor. Ex:
 	- Para validar um campo Email por exemplo, antes do atribuir um ID, utilize as letras "ema" (sem aspas).
 Para setar um campo como obrigatório existem duas opções:
 	- Você pode validar um campo e setá-lo como obrigatório. Para isso use no ID do campo a sintaxe: ema_ID_obr
 Para um melhor uso, lembre-se de criar o  style "Alerta" (sem aspas).
    -  Você pode validar se um campo já possui informação do registro atual cadastrada no banco de dados, ou seja, checar as informações dos campos. Para isso use no class o style "input_filtro_bd_valida" (sem aspas). Para um melhor uso, lembre-se de criar o style "AlertaValida" (sem aspas). Você pode usar esta função atraves de validaInfBD(tabela,campo,valor,acao).

 
 Abaixo as letras aceitas para validação:
 ema - Valida email
 cpf - Valida CPF 
 cnp - Valida CNPJ
 cpj - Valida CPF/CNPJ
 dat - Valida Data
 	* nos campos tipo data, usar a instrução: OnKeyUp="this.value=mascara_data(this.value)"
 num - Valida campo Numérico
 moe - Valida campo Moeda
 	*  nos campos do tipo Moeda, usar a instrução: onblur="this.value = float2moeda(this.value, this);"
 obr - Campo Obrigatório
 */
	
function verifica_form(form){
	var Acampo = new Array();
	var chkCampo, campo, chkCampoObr, Pass, chkCampoVal, nomeCampo;
	Pass = 0
	for (i = 0; i < form.length; i++) {
		if(form[i].id != null && form[i].id != " " && form[i].id != "" && form[i].disabled == ""){
			campo = form[i];
			chkCampo 	= Left(campo.id, 3);
			chkCampoObr	= Right(campo.id, 3);
			chkCampoVal = campo.className;
				
			chkCampo=chkCampo.toLowerCase();
			chkCampoObr	= chkCampoObr.toLowerCase();
			chkCampoVal = chkCampoVal.toLowerCase();
				
			nomeCampo=campo.id;
			nomeCampo=nomeCampo.replace("obr_","");
			nomeCampo=nomeCampo.replace("_obr","");
				
			//Valida CPF
			if (chkCampo == 'cpj'){
				campo.value = campo.value.replace(/([./;:,\-()]+)/g,"");
				if(campo.value.length <= 11){
					chkCampo = 'cpf';
					}
				else{
					chkCampo = 'cnp';
				}
					
			}
			if (chkCampo == 'cpf'){
				campo.value = campo.value.replace(/([./;:,\-()]+)/g,"");
				ValidaPass = checa_cpf(campo.value, campo);
				if(ValidaPass != true){Pass = Pass+1;};				
				if(chkCampoObr == 'obr'){
					if (campo.value == null || campo.value == "" || campo.value == " "){
						CampoAlerta(campo, "Preencha os campos obrigatórios.");
						Pass = Pass + 1;
					}
				}
			}
			//Valida CNPJ
			if (chkCampo == 'cnp'){
				campo.value = campo.value.replace(/([./;:,\-()]+)/g,"");	
				ValidaPass = valida_cnpj(campo.value, campo)
				if(ValidaPass != true){Pass = Pass+1;};
				if(chkCampoObr == 'obr'){
					if (campo.value == null || campo.value == "" || campo.value == " "){
						CampoAlerta(campo, "Preencha os campos obrigatórios.");
						Pass = Pass + 1;
					}
				}				
			}
			//Valida Data
			if (chkCampo == 'dat'){
				ValidaPass = verifica_data(campo.value, campo)
				if(ValidaPass != true){Pass = Pass+1;};
				if(chkCampoObr == 'obr'){
					if (campo.value == null || campo.value == "" || campo.value == " "){
						CampoAlerta(campo, "Preencha os campos obrigatórios.");
						Pass = Pass + 1;
					}
				}
			}
			//Valida Numerico
			if (chkCampo == 'num'){
				ValidaPass = checa_numerico(campo.value, campo);
				if(ValidaPass != true){Pass = Pass+1;};
				if(chkCampoObr == 'obr'){
					if (campo.value == null || campo.value == "" || campo.value == " "){
						CampoAlerta(campo, "Preencha os campos obrigatórios.");
						Pass = Pass + 1;
					}
				}
			}
				
			//Valida Senha
			if (chkCampo == 'sen'){
				ValidaPass = chk_senha(campo.value, campo, form[i+1]);
				if(ValidaPass != true){
					Pass = Pass+1;
				};	
				if(chkCampoObr == 'obr'){
					if (campo.value == null || campo.value == "" || campo.value == " "){
						CampoAlerta(campo, "Preencha os campos obrigatórios.");
						Pass = Pass + 1;
					}
				}					
			}
				
			//Valida Email
			if (chkCampo == 'ema'){
				ValidaPass = checa_email(campo.value, campo);
				if(form[i].name == "confereemail"){
					if(campo.value != form[i-1].value){
						CampoAlerta(campo, "E-mail não é o mesmo!");
						Pass = Pass + 1;							
					}
				}				
				if(ValidaPass != true){Pass = Pass+1;};
				if(chkCampoObr == 'obr'){
					if (campo.value == null || campo.value == "" || campo.value == " "){
						CampoAlerta(campo, "Preencha os campos obrigatórios.");
						Pass = Pass + 1;
					}
				}				
			}
			//Formata Moeda
			if (chkCampo == 'moe'){
				campo.value = float2moeda(campo.value, campo);
				if(chkCampoObr == 'obr'){
					if (campo.value == null || campo.value == "" || campo.value == " " || parseFloat(campo.value) <= 0){
						CampoAlerta(campo, "Preencha os campos obrigatórios.");
						Pass = Pass + 1;
					}
				}
			}
	
				
			//Valida Email
			if (chkCampo == 'obr'){
				if (campo.value == null || campo.value == "" || campo.value == " "){
					Pass = Pass + 1;
					if(campo.type == 'select-one'){
						alert("Selecione uma opção!");
						if (campo.className='input_filtro') {
							classNome='inputazul'
						}else if (campo.className='input_filtro_bd_valida') {
							classNome='inputazul_valida'
						}
						campo.className = 'Alerta';
						campo.onchange = function(){campo.className =classNome};
						Pass = Pass + 1;	
					}else{
						CampoAlerta(campo, "Preencha os campos obrigatórios.");
						Pass = Pass + 1;
					}
				}
			}
			if((Pass==0) && (campo.value != null || campo.value != "" || campo.value != " ") && (chkCampoVal == 'inputazul_valida' || chkCampoVal ==  'alertavalida')){
				ValidaPass=validaInfBD(document.getElementById('numTabela').value,nomeCampo,campo.value,document.getElementById('Acao').value);
				if(ValidaPass==1){
					Pass = Pass + 1;
					campo.className = 'AlertaValida';
					alert("¡A informação já esta registada na base de dados! Entra com uma nova.");
				}
			}
	/*
	*******************************************
			TESTA CAMPO TIPO RADIO
	*******************************************
	*/
			if (campo.type == "radio" && chkCampoObr == 'obr') {
				if (form[campo.name].length == null){
					if (form[campo.name].checked) {
					  ok = true;
					}else{
						ok = false;
						Pass = Pass + 1;
					}
				}else{
					for (x = 0; x < form[campo.name].length; x++) {
						ok = false;
						if (form[campo.name][x].checked) {
							ok = true;
							break;
						}
					}
				}
					
				if (ok == false) {
					Pass = Pass + 1;
					if (campo.disabled == "") {
						CampoAlerta(campo, "Selecione uma opção!");
					}
				}
			}
	
	
	/*
	**********************************
			FIM DO TESTA RADIO
	**********************************	
	*/
		}
		if (Pass > 0){
			i = form.length;
		}
			
	}
	
	//alert(Pass);
	if(Pass == 0){
	 	return true;
	}else{
		return false;
	}
	
}
function desabilita_cor(campo) {
	campo.className = 'textfield';
}
//apenas quando for campo para validação de banco de dados
function desabilita_cor_bd_valida(campo) {
	campo.className = 'inputazul_valida';
}
//validação de campos, ver se já existe cadastrado no banco de dados
function validaInfBD(tabela,campo,valor,acao){
	var campoCodAlt="";
	var valorCodAlt=""
	if (acao.toUpperCase()=='ALT'){
		campoCodAlt=document.getElementById('campoCodAlt').value;
		valorCodAlt=document.getElementById(campoCodAlt).value;
	}
	var msg = $.ajax({
		url: 'ChecarCampos.asp?tabela='+tabela+'&campo='+campo+'&valor='+valor+'&acao='+acao+'&campoCodAlt='+campoCodAlt+'&valorCodAlt='+valorCodAlt,
		async: false
	}).responseText;
	return msg;
	
}

function comboDinamico(nomeCombo,nomePagina){
	$('select[@name='+nomeCombo+']').html('<option value="">Cargando ::::</option>');
	$.post(nomePagina,
		//{ estado : valor },
		function(resposta){
			$('select[@name='+nomeCombo+']').html(resposta);
		}
	);
}
function Input_DadosInvalidos(o)
{
	o.className = 'Alerta';
	o.onkeypress = function()
	{
		desabilita_cor(this);
		this.onkeypress = null;
	};
}
function trim(str) { return str.replace(/^\s+|\s+$/g,""); }
function isValidMail(mail) { return mail.match(/(\w+)@(.+)\.(\w+)$/) != null; }
function Enum(num){

		var tecla = num.which;
		if (num.keyCode != 0)
			return true;

		if (tecla > 47 && tecla < 58)
			return true;
			else return false;
}








