//=========================================================================================
// Identificação de browser
//=========================================================================================
var isNav4, isNav, isIE;

if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
  isNav = (navigator.appName=="Netscape") ? true : false;
  isIE = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;
}
if (navigator.appName=="Netscape") isNav4 = (parseInt(navigator.appVersion.charAt(0))==4);
//=========================================================================================
/************************************************************************/

function formatar_moeda(campo, separador_milhar, separador_decimal, tecla) {
	var sep = 0;
	var key = '';
	var i = j = 0;
	var len = len2 = 0;
	var strCheck = '0123456789';
	var aux = aux2 = '';
	var whichCode = (window.Event) ? tecla.which : tecla.keyCode;

	if (whichCode == 13) return true; // Tecla Enter
	if (whichCode == 8) return true; // Tecla Delete
	key = String.fromCharCode(whichCode); // Pegando o valor digitado
	if (strCheck.indexOf(key) == -1) return false; // Valor inválido (não inteiro)
	len = campo.value.length;
	for(i = 0; i < len; i++)
	if ((campo.value.charAt(i) != '0') && (campo.value.charAt(i) != separador_decimal)) break;
	aux = '';
	for(; i < len; i++)
	if (strCheck.indexOf(campo.value.charAt(i))!=-1) aux += campo.value.charAt(i);
	aux += key;
	len = aux.length;
	if (len == 0) campo.value = '';
	if (len == 1) campo.value = '0'+ separador_decimal + '0' + aux;
	if (len == 2) campo.value = '0'+ separador_decimal + aux;

	if (len > 2) {
		aux2 = '';

		for (j = 0, i = len - 3; i >= 0; i--) {
			if (j == 3) {
				aux2 += separador_milhar;
				j = 0;
			}
			aux2 += aux.charAt(i);
			j++;
		}

		campo.value = '';
		len2 = aux2.length;
		for (i = len2 - 1; i >= 0; i--)
		campo.value += aux2.charAt(i);
		campo.value += separador_decimal + aux.substr(len - 2, len);
	}

	return false;
}

function onlyDate(e, field) {
      var keyNumber = (isIE) ? event.keyCode : e.which;
      if (((keyNumber < 48) || (keyNumber > 57)) && (keyNumber!=13) && (keyNumber!="0") && (keyNumber!=8)) {
            if (isIE) event.keyCode=0;
            return false;
      }
      if ((keyNumber!=13) && (keyNumber!="0") && (keyNumber!=8) && (field.value.length == 2 || field.value.length == 5)) {
            field.value = field.value + '/';
      }
}

function validateClassificadoForm(doc) {
	var hasErrors = false;
	var category = doc.getElementById('categoryId');
	var title = doc.getElementById('title');
	var description = doc.getElementById('description');
	var telefone = doc.getElementById('telefone');
	var email = doc.getElementById('email');

	if (!hasErrors && category.value == '-1') {
		alert('Campo \'Categoria\' obrigatório.');
		hasErrors = true;
	}
		
	if (!hasErrors && title.value == '') {
		alert('Campo \'Titulo\' obrigatório.');
		hasErrors = true;
	}
	
	if (!hasErrors && description.value == '') {
		alert('Campo \'Descricao\' obrigatório.');
		hasErrors = true;
	}
	

/*	if (!hasErrors && telefone.value == '') {
		alert('Campo \'Telefone\' obrigatório.');
		hasErrors = true;
	}*/

	if (!hasErrors && email.value == '') {
		alert('Campo \'Email\' obrigatório.');
		hasErrors = true;
	} else if (!hasErrors) {
		hasErrors = !isValidEmail(email);
	}

	if (!hasErrors) {
		var form = doc.getElementById('frm');
		form.submit();
	}

}

/**************************************************************/

function validateCursoForm(doc) {
	var hasErrors = false;
	var nome = doc.getElementById('nome');
	var ministrante = doc.getElementById('ministrante');
	var assistentes = doc.getElementById('assistentes');
	var objetivos = doc.getElementById('objetivos');
	var publicoAlvo = doc.getElementById('publicoAlvo');
	var dataInicio = doc.getElementById('dataInicio');
	var dataTermino = doc.getElementById('dataTermino');
	var dias = doc.getElementById('dias');
	var nomeLocal = doc.getElementById('nomeLocal');
	var endereco = doc.getElementById('endereco');
	var bairro = doc.getElementById('bairro');
	var telefone = doc.getElementById('telefoneLocal');
	var dataInicioInscricao = doc.getElementById('dataInicioInscricao');
	var dataTerminoInscricao = doc.getElementById('dataTerminoInscricao');
	var telefoneInscricao = doc.getElementById('telefoneInscricao');
	var price = doc.getElementById('price');
	var priceDiscount = doc.getElementById('priceDiscount');
	var email = doc.getElementById('email');
	
	if (!hasErrors && nome.value == '') {
		alert('Campo \'Nome\' obrigatório.');
		hasErrors = true;
	}
	
	if (!hasErrors && ministrante.value == '') {
		alert('Campo \'Ministrante\' obrigatório.');
		hasErrors = true;
	}
	
/*	if (!hasErrors && assistentes.value == '') {
		alert('Campo \'Assistentes\' obrigatório.');
		hasErrors = true;
	}
*/
	
	if (!hasErrors && objetivos.value == '') {
		alert('Campo \'Objetivo do Curso/Oficina\' obrigatório.');
		hasErrors = true;
	}
	
	if (!hasErrors && publicoAlvo.value == '') {
		alert('Campo \'Publico Alvo\' obrigatório.');
		hasErrors = true;
	}
	
	if (!hasErrors && price.value == '') {
		alert('Campo \'Preco do curso\' obrigatório.');
		hasErrors = true;
	}
	
	if (!hasErrors && priceDiscount.value == '') {
		alert('Campo \'Preco do curso para associado\' obrigatório.');
		hasErrors = true;
	}
	
	if (!hasErrors && dataInicio.value == '') {
		alert('Campo \'Data de Inicio\' obrigatório.');
		hasErrors = true;
	} else if (!hasErrors) {
		hasErrors = !checkDate(dataInicio);
	}
	
	if (!hasErrors && dataTermino.value == '') {
		alert('Campo \'Data de Termino\' obrigatório.');
		hasErrors = true;
	} else if (!hasErrors) {
		hasErrors = !checkDate(dataTermino);
	}
	
	if (!hasErrors && dias.value == '') {
		alert('Campo \'Dias e Horarios\' obrigatório.');
		hasErrors = true;
	}
	
	if (!hasErrors && nomeLocal.value == '') {
		alert('Campo \'Nome do Local\' obrigatório.');
		hasErrors = true;
	}

	if (!hasErrors && endereco.value == '') {
		alert('Campo \'Endereco\' obrigatório.');
		hasErrors = true;
	}
	
	if (!hasErrors && telefone.value == '') {
		alert('Campo \'Telefone\' obrigatório.');
		hasErrors = true;
	}

	if (!hasErrors && dataInicioInscricao.value == '') {
		alert('Campo \'Data de Inicio da Inscricao\' obrigatório.');
		hasErrors = true;
	} else if (!hasErrors) {
		hasErrors = !checkDate(dataInicioInscricao);
	}
	
	if (!hasErrors && dataTerminoInscricao.value == '') {
		alert('Campo \'Data de Termino da Inscricao\' obrigatório.');
		hasErrors = true;
	} else if (!hasErrors) {
		hasErrors = !checkDate(dataTerminoInscricao);
	}
	
	if (!hasErrors && telefoneInscricao.value == '') {
		alert('Campo \'Telefone da Inscricao\' obrigatório.');
		hasErrors = true;
	}
	
	if (!hasErrors && email.value == '') {
		alert('Campo \'Email\' obrigatório.');
		hasErrors = true;
	} else if (!hasErrors) {
		hasErrors = !isValidEmail(email);
	}

	if (!hasErrors) {
		var form = doc.getElementById('frm');
		form.submit();
	}

}

/**************************************************************/

function validateConvenioForm(doc) {
//	var tipoConvenio1 = doc.getElementById('tipoConvenio1');
//	var tipoConvenio2 = doc.getElementById('tipoConvenio2');
	var nomeProduto = doc.getElementById('nomeProduto');
	var descricao = doc.getElementById('descricaoProduto');
	var valorProduto = doc.getElementById('valorProduto');
	var vantagensOferecidas = doc.getElementById('vantagensOferecidas');
	var nomeSolicitante = doc.getElementById('nomeSolicitante');
	var email = doc.getElementById('email');
	var dddTel = doc.getElementById('dddTel');
	var telefone = doc.getElementById('telefone');
	var dddCel = doc.getElementById('dddCel');
	var celular = doc.getElementById('celular');
	var hasErrors = false;
	
//	if (!hasErrors && (!tipoConvenio1.checked && !tipoConvenio2.checked)) {
//		alert('Campo \'Tipo de convênio\' obrigatório.');
//		hasErrors = true;
//	}
	
	if (!hasErrors && nomeProduto.value == '') {
		alert('Campo \'Produto/Serviço\' é obrigatório.');
		hasErrors = true;
	}
	
	if (!hasErrors && descricao.value == '') {
		alert('Campo \'Descricao do Produto/Servico\' é obrigatório.');
		hasErrors = true;
	}
	
	if (!hasErrors && valorProduto.value == '') {
		alert('Campo \'Valor do Produto\' é obrigatório.');
		hasErrors = true;
	}
	
	if (!hasErrors && vantagensOferecidas.value == '') {
		alert('Campo \'Vantagens Oferecidas\' é obrigatório.');
		hasErrors = true;
	}
	

/**
	if (!hasErrors && bairro.value == '') {
		alert('Campo \'Bairro\' obrigatório.');
		hasErrors = true;
	}
**/
	
	if (!hasErrors && nomeSolicitante.value == '') {
		alert('Campo \'Nome do Solicitante\' é obrigatório.');
		hasErrors = true;
	}
	
	if (!hasErrors && email.value == '') {
		alert('Campo \'Email\' é obrigatório.');
		hasErrors = true;
	} else if (!hasErrors) {
		hasErrors = !isValidEmail(email);
	}

	if (!hasErrors && dddTel.value == '') {
		if(dddCel.value == '' || celular.value == '') {
			alert('Campo \'DDD Telefone\' é obrigatório.');
			hasErrors = true;
		}
	}

	if (!hasErrors && telefone.value == '') {
		if(dddCel.value == '' || celular.value == '') {
			alert('Campo \'Telefone\' é obrigatório.');
			hasErrors = true;
		}
	}

	if (!hasErrors && dddCel.value == '') {
		if(dddTel.value == '' || telefone.value == '') {
			alert('Campo \'DDD Celular\' é obrigatório.');
			hasErrors = true;
		}
	}

	if (!hasErrors && celular.value == '') {
		if(dddTel.value == '' || telefone.value == '') {
			alert('Campo \'Celular\' é obrigatório.');
			hasErrors = true;
		}
	}

	if (!hasErrors) {
		var form = doc.getElementById('frm');
		form.submit();
	}

}

/**************************************************************/

function faturaFormBack(doc) {
	var form = doc.getElementById('frm');
	form.action = './mountFaturaBack.do';
	form.method = 'POST';
	form.submit();
}

/**************************************************************/

function validateFaturaForm(doc) {
	var dataSolicitacao = doc.getElementById('dataSolicitacao');
	var vencimento = doc.getElementById('vencimento');
	var dataEmissao = doc.getElementById('dataEmissao');
	var valor = doc.getElementById('valor');
	var empresa = doc.getElementById('empresa');
	var cnpj = doc.getElementById('cnpj');
	var ie = doc.getElementById('ie');
	var endereco = doc.getElementById('endereco');
	var cidade = doc.getElementById('cidade');
	var companyState = doc.getElementById('estado');
	var cep = doc.getElementById('cep');
	var telefone = doc.getElementById('telefone');
	var contato = doc.getElementById('contato');
	var servico = doc.getElementById('servico');
	var tipoJob1 = doc.getElementById('tipoJob1');
	var tipoJob2 = doc.getElementById('tipoJob2');
	var jobRealizado1 = doc.getElementById('jobRealizado1');
	var jobRealizado2 = doc.getElementById('jobRealizado2');
	var grupo = doc.getElementById('grupo');
	var cooperado = doc.getElementById('cooperado');
	var nomesCooperados = doc.getElementById('nomesCooperados');
	var entrega1 = doc.getElementById('entrega1');
	var entrega2 = doc.getElementById('entrega2');
	var entrega3 = doc.getElementById('entrega3');
	var ac= doc.getElementById('ac');
	var enderecoEntrega = doc.getElementById('enderecoEntrega');
	var cidadeEntrega = doc.getElementById('cidadeEntrega');
	var estadoEntrega = doc.getElementById('estadoEntrega');
	var cepEntrega = doc.getElementById('cepEntrega');
	var preenchido = doc.getElementById('preenchido');
//	var telContato = doc.getElementById('telContato');
	var email = doc.getElementById('email');
	var cobranca1 = doc.getElementById('cobranca1');
	var cobranca2 = doc.getElementById('cobranca2');
	var hasErrors = false;

	if (dataSolicitacao.value == '') {
	closeDivOpac();
		alert('Campo \'Data Solicitação\' obrigatório.');
		hasErrors = true;
	} else if (!hasErrors) {
		hasErrors = !checkDate(dataSolicitacao);
	}
	if (!hasErrors && vencimento.value == '') {
	closeDivOpac();
		alert('Campo \'Vencimento\' obrigatório.');
		hasErrors = true;
	} else if (!hasErrors) {
		hasErrors = !checkDate(vencimento);
	}
	if (!hasErrors && dataEmissao.value == '') {
	closeDivOpac();
		alert('Campo \'Data Emissão\' obrigatório.');
		hasErrors = true;
	} else if (!hasErrors) {
		hasErrors = !checkDate(dataEmissao);
	}
	if (!hasErrors && valor.value == '') {
	closeDivOpac();
		alert('Campo \'Valor\' obrigatório.');
		hasErrors = true;
	} else if(!hasErrors) {
		hasErrors = !isNumeric(valor);
		if (hasErrors) {
		closeDivOpac();
			alert('Campo \'Valor\' inválido.');
		}
	}

	if (!hasErrors && empresa.value == '') {
	closeDivOpac();
		alert('Campo \'Empresa (Tomador)\' obrigatório.');
		hasErrors = true;
	} 
	
	/**if (!hasErrors && cnpj.value == '') {
		alert('Campo \'CNPJ\' obrigatório.');
		hasErrors = true;
	} else if (!hasErrors) {
		hasErrors = !validarCNPJ(cnpj);
	}**/

//	} else if (ie.value == '') {
//		alert('Campo \'Inscrição Estadual\' obrigatório.');
//		hasErrors = true;
	if (!hasErrors && endereco.value == '') {
	closeDivOpac();
		alert('Campo \'Endereço\' obrigatório.');
		hasErrors = true;
	} else if (!hasErrors && cidade.value == '') {
	closeDivOpac();
		alert('Campo \'Cidade\' obrigatório.');
		hasErrors = true;
	} else if (!hasErrors && companyState.value == '-1') {
	closeDivOpac();
		alert('Campo \'Estado\' obrigatório.');
		hasErrors = true;
	} else if (!hasErrors && cep.value == '') {
	closeDivOpac();
		alert('Campo \'CEP\' obrigatório.');
		hasErrors = true;
	} else if (!hasErrors && telefone.value == '') {
	closeDivOpac();
		alert('Campo \'Telefone\' obrigatório.');
		hasErrors = true;
	} else if (!hasErrors && contato.value == '') {
	closeDivOpac();
		alert('Campo \'Contato\' obrigatório.');
		hasErrors = true;
	} else if (!hasErrors && servico.value == '') {
	closeDivOpac();
		alert('Campo \'Discriminação do Serviço\' obrigatório.');
		hasErrors = true;
	} else if (!hasErrors && (!tipoJob1.checked && !tipoJob2.checked)) {
	closeDivOpac();
		alert('Campo \'Tipo do Trabalho Realizado\' obrigatório.');
		hasErrors = true;
	} else if (!hasErrors && (!jobRealizado1.checked && !jobRealizado2.checked)) {
	closeDivOpac();
		alert('Campo \'Trabalho Realizado por\' obrigatório.');
		hasErrors = true;
	} else if (!hasErrors && (jobRealizado1.checked || jobRealizado2.checked)) {
		if (jobRealizado1.checked && grupo.value == '') {
		closeDivOpac();
			alert('Campo \'Nome do Grupo\' obrigatório.');
			hasErrors = true;
		} else if (jobRealizado2.checked && cooperado.value == '') {
		closeDivOpac();
			alert('Campo \'Nome do Cooperado\' obrigatório.');
			hasErrors = true;
		}
	}

	if (!hasErrors && (!entrega1.checked && !entrega2.checked && !entrega3.checked)) {
	closeDivOpac();
		alert('Campo \'Forma de Entrega\' obrigatório.');
		hasErrors = true;
	} else if (!hasErrors && (entrega2.checked || entrega3.checked)) {
		if (ac.value == '') {
		closeDivOpac();
			alert('Campo \'A/C\' obrigatório.');
			hasErrors = true;
		} else if (enderecoEntrega.value == '') {
		closeDivOpac();
			alert('Campo \'Endereço da Entrega\' obrigatório.');
			hasErrors = true;
		} else if (cidadeEntrega.value == '') {
		closeDivOpac();
			alert('Campo \'Cidade da Entrega\' obrigatório.');
			hasErrors = true;
		} else if (estadoEntrega.value == -1) {
		closeDivOpac();
			alert('Campo \'Estado da Entrega\' obrigatório.');
			hasErrors = true;
		} else if (cepEntrega.value == '') {
		closeDivOpac();
			alert('Campo \'CEP da Entrega\' obrigatório.');
			hasErrors = true;
		}
	}
	
	if (!hasErrors && preenchido.value == '') {
	closeDivOpac();
		alert('Campo \'Preenchido por\' obrigatório.');
		hasErrors = true;
/*	} else if (!hasErrors && telContato.value == '') {
		alert('Campo \'Telefone contato\' obrigatório.');
		hasErrors = true;
*/
	}
	if (!hasErrors && email.value == '') {
	closeDivOpac();
		alert('Campo \'Email\' obrigatório.');
		hasErrors = true;
	} else if (!hasErrors) {
		hasErrors = !isValidEmail(email);
	}

	if (!hasErrors && (!cobranca1.checked && !cobranca2.checked)) {
	closeDivOpac();
		alert('Campo \'Autorizo efetuar a cobrança 10 dias após o vencimento\' obrigatório.');
		hasErrors = true;
	}

	if (!hasErrors) {
		var form = doc.getElementById('frm');
		form.submit();
	}
}

/************************************************************************/

function checkDate(input){
	var validformat=/^\d{2}\/\d{2}\/\d{4}$/ //Basic check for format validity
	var returnval=false
	if (!validformat.test(input.value)){
		closeDivOpac();
		alert("Formato inválido da data. Por favor, tente novamente.")
	}else{ //Detailed check for valid date ranges
		var dayfield=input.value.split("/")[0]
		var monthfield=input.value.split("/")[1]
		var yearfield=input.value.split("/")[2]
		var dayobj = new Date(yearfield, monthfield-1, dayfield)
		if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield)){
			closeDivOpac();
			alert("Dia, mês ou ano inválido. Por favor tente novamente.")
		}else{
			returnval=true
		}
	}
	if (returnval==false) input.select()
		return returnval
}

/************************************************************************/

function isValidEmail(strEmail){
//  validRegExp = '^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$ /^[^@]+@[^@]+.[a-z]{2,}$/i';
   validRegExp = new RegExp(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/);
   // search email text for regular exp matches
/*    if (strEmail.value.search(validRegExp) == -1) 
   {
      alert('Email inválido, por favor digite um email válido.');
      return false;
    } 
*/
    if (!validRegExp.test(strEmail.value)) 
    {
      alert('Email inválido, por favor digite um email válido.');
      return false;
    } 
    return true; 
}

/************************************************************************/

function validateCPF(cpf, form)
{
	var isNumber = isNumeric(cpf);
	if (!isNumber) {
		alert('Favor digitar somente numeros');
		return false;
	}
	form.submit();
}

/************************************************************************/

function isNumeric(sText)
{
	if (sText.value.length == 0) {
		return false;
	}
	
	
	var ValidChars = "0123456789.,";
	var IsNumber=true;
	var Char;
	for (i = 0; i < sText.value.length; i++) 
	{ 
		Char = sText.value.charAt(i);
		if (ValidChars.indexOf(Char) == -1) 
		{
			return false;
		}
	}
	return true;
}

function justNumbers(sText)
{
	if (sText.length == 0) {
		return false;
	}
	
	
	var ValidChars = "0123456789.,";
	var IsNumber=true;
	var Char;
	for (i = 0; i < sText.length; i++) 
	{ 
		Char = sText.charAt(i);
		if (ValidChars.indexOf(Char) == -1) 
		{
			return false;
		}
	}
	return true;
}

/************************************************************************/

function validarCNPJ(cnpjObject) {
//	CNPJ = document.validacao.CNPJID.value;
	CNPJ = cnpjObject.value;
	erro = new String;
	if (CNPJ.length < 18) {
		erro += "É necessario preencher corretamente o número do CNPJ! \n\n";
	}
	if ((CNPJ.charAt(2) != ".") || (CNPJ.charAt(6) != ".") || (CNPJ.charAt(10) != "/") || (CNPJ.charAt(15) != "-")) {
		if (erro.length == 0) {
			erro += "É necessário preencher corretamente o número do CNPJ! \n\n";
		}
	}
	//substituir os caracteres que não são números
	if(document.layers && parseInt(navigator.appVersion) == 4) {
		x = CNPJ.substring(0,2);
		x += CNPJ.substring (3,6);
		x += CNPJ.substring (7,10);
		x += CNPJ.substring (11,15);
		x += CNPJ.substring (16,18);
		CNPJ = x;
	} else {
		CNPJ = CNPJ.replace (".","");
		CNPJ = CNPJ.replace (".","");
		CNPJ = CNPJ.replace ("-","");
		CNPJ = CNPJ.replace ("/","");
	}
	var nonNumbers = /\D/;
	if (nonNumbers.test(CNPJ)) erro += "A verificação de CNPJ suporta apenas números! \n\n";
	var a = [];
	var b = new Number;
	var c = [6,5,4,3,2,9,8,7,6,5,4,3,2];
	for (i=0; i<12; i++){
		a[i] = CNPJ.charAt(i);
		b += a[i] * c[i+1];
	}
	if ((x = b % 11) < 2) { a[12] = 0 } else { a[12] = 11-x }
	b = 0;
	for (y=0; y<13; y++) {
	       b += (a[y] * c[y]);
	}
	if ((x = b % 11) < 2) { a[13] = 0; } else { a[13] = 11-x; }
	if ((CNPJ.charAt(12) != a[12]) || (CNPJ.charAt(13) != a[13])){
	       erro +="Dígito verificador com problema!";
	}
	if (erro.length > 0){
	       alert(erro);
	       return false;
//	} else {
//	       alert("CNPJ valido!");
	}
	return true;
}


/************************************************************************/

function submitForm(doc, frmName, fieldName) {
	var form = doc.getElementById(frmName);
	var field = doc.getElementById(fieldName);
	var error = false;
	
	if (field.value=='') {
	  <!--  closeDivOpac();-->
		alert("Favor digitar uma palavra para realizar a busca.");
		error = true;
	}
	if (error == false && field.value.length <= 3) {
	      <!--  closeDivOpac();-->
		alert("Favor digitar uma palavra maior que a busca seja precisa.");
		error = true;
	}
	if (error == false) {
		form.submit();
	}
}

function submitFormSelect(doc, frmName, fieldName) {
	var form = doc.getElementById(frmName);
	var field = doc.getElementById(fieldName);
	var error = false;
	if (field.value=='-1') {
	    closeDivOpac();
		alert("Favor escolher uma opcao.");
		error = true;
	}
	
	if (error == false) {
		form.submit();
	}
}

/************************************************************************/

function submitLoginForm(doc, frmName) {
	var form = doc.getElementById(frmName);
	var login = doc.getElementById('login');
	var password = doc.getElementById('password');
	var ValidChars = "0123456789";
	var Char;
	var error = false;
	if (login.value=='') {
		alert("Campo login invalido.");
		error = true;
	} else if (password.value=='') {
		alert("Campo senha invalido.");
		error = true;
	}
	
	if (error == false) {
		form.submit();
	}
}

/************************************************************************/

 function soNumeros(doc, frmName){
	var form = doc.getElementById(frmName);
	var login = doc.getElementById('login');
	var password = doc.getElementById('password');
	var ValidChars = "0123456789";
	var Char;
	var error = false;
	var onlyNumbers = true;
	
	if(login.value == ""){
		alert("Campo login invalido.");
		error = true;
	}else{
		if (login.value.length != 0) {
			for (i = 0; i < login.value.length; i++){ 
				Char = login.value.charAt(i);
				if (ValidChars.indexOf(Char) == -1){
					onlyNumbers = false;
					error = true;
				}
			}
		}
		if (!onlyNumbers) {
			alert("Somente números no campo Login");
		}
		
		if (password.value.length == 0) {
			alert("Campo senha invalido.");
			error = true;
		}
	
		if (error == false) {
			form.submit();
		}
	}
}


/************************************************************************/

 function validaLogin(frmName){
	var form = document.getElementById(frmName);
	var login = document.getElementById('login');
	var password = document.getElementById('password');
	var operador = document.getElementById('operador');
	var ValidChars = "0123456789";
	var Char;
	var error = false;
	var onlyNumbers = true;
	
	if(login.value == ""){
		alert("Campo login invalido.");
		error = true;
	}else{
		if (login.value.length != 0) {
			for (i = 0; i < login.value.length; i++){ 
				Char = login.value.charAt(i);
				if (ValidChars.indexOf(Char) == -1){
					onlyNumbers = false;
					error = true;
				}
			}
		}
		if (!onlyNumbers) {
			alert("Somente números no campo Login");
		}
		
		if (password.value=="") {
			alert("Campo senha invalida.");
			error = true;
			return false;
		}
		
		if (operador.value=="") {
			alert("Campo operador invalido.");
			error = true;
			return false;
		}
	
		if (error == false) {
			form.submit();
		}
	}
}