/* ======= funções referentes à formulários */
// TODO: Valida e submete o formulário de relatório de devolução


function soNumeros(v){
	//alert(v);
    return v.replace(/\D/g,"")
}

function EnviarRelatorioDevolucao()
{
	var message = "";
   	var foco = "";
   	var idx = 0;
   	var arName = new Array();
   	var f = document.frmCaponline;
   	
   	if (validaForm(f.dtOcorrenciaDe.value, 'tb') == false)
   	{
   		//if(foco.length == 0)
   	    message =  message + "» Favor informar a Ocorrência a partir de; \n";
		//foco = f.dtOcorrenciaDe;
   		arName[1] = "dtOcorrenciaDe";		
   	}
	
	if  (!isDate(f.dtOcorrenciaDe.value))
   	{
   		//if(foco.length == 0)
		 message =  message + "» Formato inválido ocorrência a partir de; \n";
   		//foco = f.dtOcorrenciaDe;
   		
   		arName[2] = "dtOcorrenciaDe";		
   	}
	
		if(validaForm(f.dtOcorrenciaAte.value, 'tb') == false)
   	{
   		//if(foco.length == 0)
		message =  message + "» Favor informar a Ocorrência até; \n";
   			//foco = f.dtOcorrenciaAte;
   		
   		arName[3] = "dtOcorrenciaAte";		
   	}
	
	if(!isDate(f.dtOcorrenciaAte.value))
   	{
   		//if(foco.length == 0)
		message =  message + "» Formato inválido ocorrência até; ";
   			//foco = f.dtOcorrenciaAte;
   		
   		arName[4] = "dtOcorrenciaAte";		
   	}
	
	
	
	//if(validaForm(f.txtNotaFiscal.value, 'tb') == false)
   	//{
   		//if(foco.length == 0)
   			//foco = f.dtOcorrenciaDe;
				//	message =  message + "»  Favor informar o número da nota fiscal  ";
   		
   		//if(arName.length == 0)
   			//arName[0] = "txtNotaFiscal";
   		//else
   			//arName[arName.length] = "txtNotaFiscal";
   	//}
   	
   	//if(validaForm(f.txtProtocolo.value, 'tb') == false)
   	//{
   		//if(foco.length == 0)
   			//foco = f.dtOcorrenciaDe;
   		
   		//if(arName.length == 0)
   			//arName[0] = "txtProtocolo";
   		//else
   			//arName[arName.length] = "txtProtocolo";
   	//}
   	
	//alert(arName.length);
   	if(arName.length != 0)
   	{
   		//message = "» Favor informar a Ocorrência a partir de";
   		alert(message);
   		//foco.focus();
   		
   		//var contagem = arName.length;
   		//for(h = 0; h < contagem; h++)
   			//document.getElementById(arName[1]).style.border = '1px solid #ff0000';
			//return false;
   	}
   	else
   	{
   		f.action = 'index.php?carregar=relatorio.devolucao';
   		f.method = 'POST';
   		f.submit();
   	}	
}


function testaDataDe()
{
   	var f = document.frmOcorrencia;

		  if (f.dtOcorrenciaDe.value=='dd/mm/aaaa')
		  {
			alert('Favor informar a data corretamente.');
			f.dtOcorrenciaDe.focus();
			return false;
			
		  }	else {

								return true;
			
		  }
		  
}



function testaDataPara()
{
   	var f = document.frmOcorrencia;

		  		  if (f.dtOcorrenciaAte.value=='dd/mm/aaaa')
		  		  {
				  			alert('Favor informar a data corretamente.');
							f.dtOcorrenciaAte.focus();
							return false;
				} else {
				
								return true;
				}			
			
		  
}


function RegistroOcorrenciaTipoA()
{
	var message = "";
   	var foco = "";
   	var idx = 0;
   	var arName = new Array();
   	var f = document.frmCaponline;

	
   	if(validaForm(f.txtDescricao.value, 'tb') == false)
   	{
   		if(foco.length == 0)
   			foco = f.txtDescricao;
   		
   		arName[0] = "txtDescricao";	
   		
   		message = message + "» Favor informar a Descrição; \n";	
   	}
	
/*	if(!validaForm(f.txtNomeFuncionario.value))
   	{
   		if(foco.length == 0)
   			foco = f.txtNomeFuncionario;
   		
   		if(arName.length == 0)
   			arName[0] = "txtNomeFuncionario";
   		else
   			arName[arName.length] = "txtNomeFuncionario";
   			
   			
   		message = message + "» Favor informar o Nome do Funcionário corretamente; \n";	
   	}*/
   	
   //	if(isNaN(f.txtNumRg.value) || f.txtNumRg.value.length == 0)
   //	{
   //		if(foco.length == 0)
   //			foco = f.txtNumRg;
   		
  // 		if(arName.length == 0)
   //			arName[0] = "txtNumRg";
   //		else
   //			arName[arName.length] = "txtNumRg";
   			
   			
   //		message = message + "» Favor informar o RG corretamente; \n";	
  // 	}
   	
   //	if(!verificaNumeroInString(f.txtOrgExped.value) || f.txtOrgExped.value.length == 0)
  //	{
   //		if(foco.length == 0)
   ////			foco = f.txtOrgExped;
   		
   	////	if(arName.length == 0)
   	////		arName[0] = "txtOrgExped";
   //		else
   		//	arName[arName.length] = "txtOrgExped";
   			
   			
   		//message = message + "» Favor informar o Órgão Expedidor corretamente; \n";	
  // 	}
   	if(f.txtNome.value =="")
   	{
  			
   		message = message + "» Favor informar o Nome corretamente; \n";
   	}
   	
   	if(validaEmail(f.txtEmail.value) == false)
   	{
   		if(foco.length == 0)
   			foco = f.txtEmail;
   		
   		if(arName.length == 0)
   			arName[0] = "txtEmail";
   		else
   			arName[arName.length] = "txtEmail";
   			
   			
   		message = message + "» Favor informar o E-Mail corretamente; \n";	
   	}
   	
   	if(isNaN(f.txtDdd.value) || f.txtDdd.value.length == 0)
   	{
   		if(foco.length == 0)
   			foco = f.txtDdd;
   		
   		if(arName.length == 0)
   			arName[0] = "txtDdd";
   		else
   			arName[arName.length] = "txtDdd";
   			
   			
   		message = message + "» Favor informar o DDD corretamente; \n";	
   	}
	else
	{
	  if(validaInteger(f.txtTelefone.value)==false)
   	   {

	   		message = message + "» Formato inválido do DDD; \n";
   	    
   	   }	
	}
   	
   	if(validaTelefone(f.txtTelefone.value) == false)
   	{
   		if(foco.length == 0)
   			foco = f.txtTelefone;
   		
   		if(arName.length == 0)
   			arName[0] = "txtTelefone";
   		else
   			arName[arName.length] = "txtTelefone";
   			
   		message = message + "» Favor informar o Telefone corretamente; \n";	
   	}
	else
	{
	  if(validaInteger(f.txtTelefone.value)==false)
   	   {

	   		message = message + "» Formato inválido do telefone; \n";
   	    
   	   }	
	}
   	
   	
   	if(message !="")
   	{
   		alert(message);
   		//foco.focus();
   		
   		//var contagem = arName.length;
   		//for(h = 0; h < contagem; h++)
   			//document.getElementById(arName[h]).style.border = '1px solid #ff0000';
   	}
   	else
   	{
   		f.action = 'index.php?carregar=registro.ocorrencia.submit';
   		f.method = 'POST';
   		f.submit();
   	}
}

function EnviarRelatorioOcorrencia()
{
	var message = "";
   	var foco = "";
   	var idx = 0;
   	var arName = new Array();
   	var f = document.frmOcorrencia;
	var message = "";
	var mensagem=0;
   	
   	if(validaForm(f.dtOcorrenciaDe.value, 'tb') == false)
   	{
   		//if(foco.length == 0)
   		//	foco = f.dtOcorrenciaDe;
   		
   		//arName[0] = "dtOcorrenciaDe";		
		message = message + "» Favor preencher a data inicial;\n";
		mensagem = 1;
		//f.dtOcorrenciaDe.focus();
		
		return false;
   	}
	
	if(!isDate(f.dtOcorrenciaDe.value))
   	{
   		//if(foco.length == 0)
   			//foco = f.dtOcorrenciaDe;
   		message = message + "» Favor preencher a data inicial corretamente;\n";
		mensagem = 1;
	//	f.dtOcorrenciaDe.focus();
   		//arName[0] = "dtOcorrenciaDe";		
   	}
	
		if(validaForm(f.dtOcorrenciaAte.value, 'tb') == false)
   	{
   		//if(foco.length == 0)
   		//	foco = f.dtOcorrenciaAte;
   		
   		//arName[0] = "dtOcorrenciaAte";	
		message = message + "» Favor preencher a data final;\n";
		mensagem = 1;
   	}
	
	if(!isDate(f.dtOcorrenciaAte.value))
   	{
   		//if(foco.length == 0)
   			//foco = f.dtOcorrenciaAte;
   		
   		//arName[0] = "dtOcorrenciaAte";
		message = message + "» Favor preencher a data final corretamente;\n";
		mensagem = 1;
		
   	}
	
	//if(validaForm(f.slcMotivo.options[f.slcMotivo.selectedIndex].value, 'sb') == false)
   //	{
   		//if(foco.length == 0)
   			//foco = f.dtOcorrenciaDe;
   		
   		//if(arName.length == 0)
   		//	arName[0] = "slcMotivo";
   		//else
   		//	arName[arName.length] = "slcMotivo";
		//message = message + "» Favor selecionar um motivo;\n";
		//mensagem = 1;
  // 	}
   	   	
   	if(mensagem > 0)
   	{
   		//message = "» Favor preencher pelo menos um dos campos";
   		alert(message);
   		//foco.focus();
   		
   		//var contagem = arName.length;
   		//for(h = 0; h < contagem; h++)
   			//document.getElementById(arName[h]).style.border = '1px solid #ff0000';
		//	return false;
   	}
   	else
   	{
   		f.action = 'index.php?carregar=relatorio.ocorrencia';
   		f.method = 'POST';
   		f.submit();
   	}	
}

function buscaNumeroOcorrencia()
{
	var f = document.frmOcorrencia;
	f.action = 'index.php?carregar=relatorio.ocorrencia&buscaOcorrencia=true';
  	f.method = 'POST';
  	f.submit();
}

function RegistroOcorrenciaTipoB()
{
	var message = "";
   	var foco = "";
   	var idx = 0;
   	var arName = new Array();
   	var f = document.frmCaponline;
   	
   	if(validaData(f.txtDtPedido.value) == false)
   	{
   		if(foco.length == 0)
   			foco = f.txtDtPedido;
   		
   		if(arName.length == 0)
   			arName[0] = "txtDtPedido";
   		else
   			arName[arName.length] = "txtDtPedido";
   			
   			
   		message = message + "» Favor informar a Data do Pedido corretamente; \n";	
   	}
   	
   	if(validaForm(f.txtDescricao.value, 'tb') == false)
   	{
   		if(foco.length == 0)
   			foco = f.txtDescricao;
   		
   		arName[0] = "txtDescricao";	
   		
   		message = message + "» Favor informar a Descrição; \n";	
   	}
	
   	if(f.txtNome.value =="")
   	{
  			
   		message = message + "» Favor informar o Nome corretamente; \n";
   	}
		
   	if(validaEmail(f.txtEmail.value) == false)
   	{
   		if(foco.length == 0)
   			foco = f.txtEmail;
   		
   		if(arName.length == 0)
   			arName[0] = "txtEmail";
   		else
   			arName[arName.length] = "txtEmail";
   			
   			
   		message = message + "» Favor informar o E-Mail corretamente; \n";	
   	}
   	
   	if(isNaN(f.txtDdd.value) || f.txtDdd.value.length == 0)
   	{
   		if(foco.length == 0)
   			foco = f.txtDdd;
   		
   		if(arName.length == 0)
   			arName[0] = "txtDdd";
   		else
   			arName[arName.length] = "txtDdd";
   			
   			
   		message = message + "» Favor informar o DDD corretamente; \n";	
   	}
   	
   	if(validaTelefone(f.txtTelefone.value) == false)
   	{
   		if(foco.length == 0)
   			foco = f.txtTelefone;
   		
   		if(arName.length == 0)
   			arName[0] = "txtTelefone";
   		else
   			arName[arName.length] = "txtTelefone";
   			
   		message = message + "» Favor informar o Telefone corretamente; \n";	
   	}
   	
   	
   	if(message!="")
   	{
   		alert(message);
   		//foco.focus();
   		
   		//var contagem = arName.length;
   		//for(h = 0; h < contagem; h++)
   			//document.getElementById(arName[h]).style.border = '1px solid #ff0000';
		//	return false;
   	}
   	else
   	{
   		f.action = 'index.php?carregar=registro.ocorrencia.submit';
   		f.method = 'POST';
   		f.submit();
   	}	
}

//ainda não está implementada pois depende da funcionalidade
function EnviarFaleConosco()
{
	var message = "";
   	var foco = "";
   	var idx = 0;
   	var arName = new Array();
   	var f = document.frmCaponline;
   	
   if(validaForm(f.txtNome.value, 'tb') == false)
   	{
   		if(foco.length == 0)
   			foco = f.txtNome;
   		
   		arName[0] = "txtNome";	
   		
   		message = message + "» Favor preencher o Nome (Contato); \n";	
   	}
	
	
	   if(validaForm(f.txtddd.value, 'tb') == false)
   	{
   		if(foco.length == 0)
   			foco = f.txtddd;
   		
   		arName[0] = "txtddd";	
   		
   		message = message + "» Favor preencher o DDD; \n";	
   	}
	
	
	
	
	if(validaTelefone(f.txtTelefone.value) == false)
   	{
   		if(foco.length == 0)
   			foco = f.txtTelefone;
   		
   		if(arName.length == 0)
   			arName[0] = "txtTelefone";
   		else
   			arName[arName.length] = "txtTelefone";
   			
   		message = message + "» Favor preencher o Telefone; \n";	
   	}
		  	
   	if(validaEmail(f.txtEmail.value) == false)
   	{
   		if(foco.length == 0)
   			foco = f.txtEmail;
   		
   		if(arName.length == 0)
   			arName[0] = "txtEmail";
   		else
   			arName[arName.length] = "txtEmail";
   			
   			
   		message = message + "» Favor preencher o E-mail; \n";	
   	}
   	
   	if(validaForm(f.txtDsc.value,'tb') == false)
   	{
   		if(foco.length == 0)
   			foco = f.txtDsc;
   		
   		if(arName.length == 0)
   			arName[0] = "txtDsc";
   		else
   			arName[arName.length] = "txtDsc";
   			
   			
   		message = message + "» Favor preencher a Descrição.";	
   	}
   	
   	if(arName.length)
   	{
   		alert(message);
   		//foco.focus();
   		
   		//var contagem = arName.length;
   		//for(h = 0; h < contagem; h++)
   			//document.getElementById(arName[h]).style.border = '1px solid #ff0000';
   	}
   	else
   	{
   		f.action = 'index.php?carregar=fale.conosco.submit';
   		f.method = 'POST';
   		f.submit();
   	}	
}

function RegistroOcorrenciaTipoCE()
{
	var message = "";
   	var foco = "";
   	var idx = 0;
   	var arName = new Array();
   	var f = document.frmCaponline;
   	
   if(validaForm(f.txtDescricao.value, 'tb') == false)
   	{
   		
   		message = message + "» Favor informar a Descrição; \n";	
   	}
	
	if(validaForm(f.txtNome.value,'tb') == false)
   	{
       message = message + "» Favor informar o Nome corretamente; \n";
   	}
	  	  	
   	if(validaEmail(f.txtEmail.value) == false)
   	{
   	 			
   		message = message + "» Favor informar o E-Mail corretamente; \n";	
   	}
	

	if(validaForm(f.txtDdd.value,'tb') == false)
   	{
		
  			
   		message = message + "» Favor informar o DDD corretamente; \n";
   	}
   	
	
	if(validaForm(f.txtTelefone.value,'tb') == false)
   	{
		
   			
   		message = message + "» Favor informar o Telefone corretamente; \n";
   	}
   	
   	
   	if(message != "")
   	{
   		alert(message);

   	}
   	else
   	{
   		f.action = 'index.php?carregar=registro.ocorrencia.submit';
   		f.method = 'POST';
   		f.submit();
   	}	
}

function RegistroOcorrenciaTipoD()
{
	var message = "";
   	var foco = "";
   	var idx = 0;
   	var arName = new Array();
   	var f = document.frmCaponline;
	var c = f.countProd.value;

	
   if(validaForm(f.txtTipoOcorrencia.value, 'tb') == false)
   	{
   		//if(foco.length == 0)
   			//foco = f.txtTipoOcorrencia;
   		
   		//arName[0] = "txtTipoOcorrencia";	
   		
   		message = message + "» Favor informar o Tipo de Ocorrência; \n";	
   	}
	   	  	
   	if(validaForm(f.txtNumNotaF.value, 'tb') == false)
   	{
   		//if(foco.length == 0)
   		//	foco = f.txtNumNotaF;
   		
   		if(arName.length == 0)
   			arName[0] = "txtNumNotaF";
   		else
   			arName[arName.length] = "txtNumNotaF";
   			
   			
   		message = message + "» Favor informar o número da nota fiscal corretamente; \n";	
   	}
   	
	 if(f.dtEmissao.value =="")
    {
   			
   		message = message + "» Favor informar o data de emissão corretamente; \n";	
   	}
	else
	{
		if(!isDate(f.dtEmissao.value))
		{
			message = message + "» Favor informar o data da emissão corretamente; \n";	
		}
		
	}
	
	 if(f.Nota.value =="false")
   	{
  			
   		message = message + "» Favor verificar a nota; \n";
   	}

	if (f.Nota.value=="true")
	{
	 var aprov=true;	
	for(i=0; i<=c; i++)
	{		
		campo = "cdProduto_"+ i;
		
		if(validaForm(document.getElementById(campo).value, 'tb') == false)
		{
			
			//if(foco.length == 0)
				//foco = f.campo;
			
			if(arName.length == 0)
				arName[0] = campo;
			else
				arName[arName.length] = campo;
				
			message = message + "» Favor informar o Código Produto "+i+" corretamente; \n";	
		}
		
		campo = "quant_"+i;
		if(validaForm(document.getElementById(campo).value, 'tb') == false)
		{
			//if(foco.length == 0)
			//	foco = f.campo;
			
			if(arName.length == 0)
				arName[0] = campo;
			else
				arName[arName.length] = campo;
				
			message = message + "» Favor informar o Quantidade corretamente; \n";	
		}
		
        campo = "controlado_"+i;
		//alert(document.getElementById(campo).value);
		if (document.getElementById(campo).value == 'false'){
   		  message = message + "» Produto Controlado:Prazo expirado, Informe outro produto ou finalize o registro; \n";		
		}
	
		
		campo = "txtProduto_"+i;
		if(validaForm(document.getElementById(campo).value, 'tb') == false)
		{
			//if(foco.length == 0)
				//foco = f.campo;
			
			if(arName.length == 0)
				arName[0] = campo;
			else
				arName[arName.length] = campo;
				
			message = message + "» Favor informar o Produto corretamente; \n";	
		}
		
		campo = "slcLoteNF_"+i;
		if(validaForm(document.getElementById(campo).value, 'tb') == false)
		{
			//if(foco.length == 0)
			//	foco = f.campo;
			
			if(arName.length == 0)
				arName[0] = campo;
			else
				arName[arName.length] = campo;
				
			message = message + "» Favor informar o Lote Nota Fiscal corretamente; \n";	
		}
		
		campo = "slcLoteP_"+i;
		if(validaForm(document.getElementById(campo).value, 'tb') == false)
		{
			//if(foco.length == 0)
			//	foco = f.campo;
			
			if(arName.length == 0)
				arName[0] = campo;
			else
				arName[arName.length] = campo;
				
			message = message + "» Favor informar o Lote Produto corretamente; \n";	
		}
	}
	}
	
	
	 if(f.txtNome.value =="")
   	{
  			
   		message = message + "» Favor informar o Nome corretamente; \n";
   	}
	
	if(validaEmail(f.txtEmail.value) == false)
   	{
   	//	if(foco.length == 0)
   		//	foco = f.txtEmail;
   		
   		if(arName.length == 0)
   			arName[0] = "txtEmail";
   		else
   			arName[arName.length] = "txtEmail";
   			
   			
   		message = message + "» Favor informar o E-Mail corretamente; \n";	
   	}
   	
   	if(isNaN(f.txtDdd.value) || f.txtDdd.value.length == 0)
   	{
   	//	if(foco.length == 0)
   		//	foco = f.txtDdd;
   		
   		if(arName.length == 0)
   			arName[0] = "txtDdd";
   		else
   			arName[arName.length] = "txtDdd";
   			
   			
   		message = message + "» Favor informar o DDD corretamente; \n";	
   	}
   	
   	if(validaTelefone(f.txtTelefone.value) == false)
   	{
   		//if(foco.length == 0)
   		//	foco = f.txtTelefone;
   		
   		if(arName.length == 0)
   			arName[0] = "txtTelefone";
   		else
   			arName[arName.length] = "txtTelefone";
   			
   		message = message + "» Favor informar o Telefone corretamente; \n";	
   	}
	//alert(f.controlado.value);
	
   	if(message!="")
   	{
		
		
   		alert(message);
	//	foco.focus();
   		//var contagem = arName.length;
   	//	for(h = 0; h < contagem; h++)
   		//	document.getElementById(arName[h]).style.border = '1px solid #ff0000';
		
		//return false;
			
   	}
   	else
   	{ 
	
	//alert('passou');
   		f.action = 'index.php?carregar=registro.ocorrencia.submit';
   		f.method = 'POST';
   		f.submit();
   	}	
	
}

//##21/01/2008 - victor barros##//
//JAVASCRIPT REF. HOME
 function ValidaCampo()
 {
	var message = "";
   	var foco = "";
   	var idx = 0;
   	var arName = new Array();
   	var f = document.formLogin;
     
    if(validaForm(f.login.value, 'tb') == false)
   	{
   	   	
   		if(foco.length == 0)
			foco = f.login;
	   		arName[0] = "login";	
	   		message = message + "» Favor informar o CNPJ; \n";	
   	
   	}
   	
   	if(validaForm(f.password.value, 'tb') == false)
   	{
   	   	
   		if(foco.length == 0)
			foco = f.password;
	   		arName[1] = "password";	
	   		message = message + "» Favor informar a senha; \n";	
   	
   	}
 
    if(message!="")
   	{
   		alert(message);
   		//foco.focus();
   		
   		//var contagem = arName.length;
   	
   		//for(h = 0; h < contagem; h++)
   		//{
//   	     document.getElementById(arName[h]).style.border = '1px solid #ff0000';
       // }
        return false;
   	}
   	else
   	{
   		f.action = 'index.php?carregar=login.submit';
   		f.method = 'POST';
   		f.submit();
   	}	
 	
 }
 
 function ValidaDadosCadastrais()
  {
  
    var message = "";
   	var foco = "";
   	var idx = 0;
   	var arName = new Array();
   	var f = document.FormDadosCadastral;

 	if(validaForm(f.DDD1.value, 'tb') == false)
   	{
   		if(foco.length == 0)
			foco = f.DDD1;
	   		arName[0] = "DDD1";	
	   		message = message + "» Favor informar o ddd da sua cidade; \n";	
   	
   	}
   	else
   	{
   	    if(validaInteger(f.DDD1.value)==false)
   	   {
   	      if(foco.length == 0)
			foco = f.DDD1;
	   		arName[0] = "DDD1";	
	   		message = message + "» Formato inválido do ddd; \n";
   	    
   	   }
   	
   	}
   	
   	if(validaForm(f.TEL2.value, 'tb') == false)
   	{
   		if(foco.length == 0)
			foco = f.TEL2;
	   		arName[1] = "TEL2";	
	   		message = message + "» Favor informar o telefone; \n";	
   	
   	}
   	else
   	{
   	   if(validaTelefone(f.TEL2.value)==false)
   	   {
   	      if(foco.length == 0)
			foco = f.TEL2;
	   		arName[1] = "TEL2";	
	   		message = message + "» Formato inválido de telefone; \n";
   	    
   	   }
   	
   	
   	}
   	
   	if(validaForm(f.EMAIL1.value, 'tb') == false)
   	{
   		if(foco.length == 0)
			foco = f.EMAIL1;
	   		arName[2] = "EMAIL1";	
	   		message = message + "» Favor informar o E-Mail; \n";	
   	
   	}
   	else
   	{
	   	   if(validaForm(f.EMAIL1.value, 'email') == false)
	     	{
	   		if(foco.length == 0)
				foco = f.EMAIL1;
		   		arName[2] = "EMAIL1";	
		   		message = message + "» Formato E-Mail inválido.; \n";	
	   	
	   	    }
   	
   	}
	
	
		if(validaForm(f.CONTATO.value, 'tb') == false)
   	{
   		if(foco.length == 0)
			foco = f.CONTATO;
	   		arName[1] = "CONTATO";	
	   		message = message + "» Favor informar o contato; \n";	
   	
   	}
  
    if(arName.length)
   	{
   		alert(message);
   		//foco.focus();
       // var contagem = arName.length;
   		//for(h = 0; h < 1; h++)
   		//{
   		 
   	     //document.getElementById(arName[h]).style.border = '1px solid #ff0000';
     //   }
       // return false;
   	}
   	else
   	{
		
		//alert('passou aqui');
   		f.action = 'index.php?carregar=DadosCadastrais.submit';
   		f.method = 'POST';
   		f.submit();
   	}
 
 
 }
 
 
 function ValidaDadosCadastrais_2()
  {
  
    var message = "";
   	var foco = "";
   	var idx = 0;
   	var arName = new Array();
   	var f = document.FormDadosCadastral;

 	if(validaForm(f.DDD1.value, 'tb') == false)
   	{
   		if(foco.length == 0)
			foco = f.DDD1;
	   		arName[0] = "DDD1";	
	   		message = message + "» Favor informar o ddd da sua cidade; \n";	
   	
   	}

   	
   	if(validaForm(f.TEL2.value, 'tb') == false)
   	{
   		if(foco.length == 0)
			foco = f.TEL2;
	   		arName[1] = "TEL2";	
	   		message = message + "» Favor informar o telefone; \n";	
   	
   	}

   	if(validaForm(f.EMAIL1.value, 'tb') == false)
   	{
   		if(foco.length == 0)
			foco = f.EMAIL1;
	   		arName[2] = "EMAIL1";	
	   		message = message + "» Favor informar o E-Mail; \n";	
   	
   	}

	
		if(validaForm(f.CONTATO.value, 'tb') == false)
   	{
   		if(foco.length == 0)
			foco = f.CONTATO;
	   		arName[1] = "CONTATO";	
	   		message = message + "» Favor informar o contato; \n";	
   	
   	}
  
    if(arName.length)
   	{
   		alert(message);
   		//foco.focus();
       // var contagem = arName.length;
   		//for(h = 0; h < 1; h++)
   		//{
   		 
   	     //document.getElementById(arName[h]).style.border = '1px solid #ff0000';
     //   }
       // return false;
   	}
   	else
   	{
   		f.action = 'index.php?carregar=DadosCadastrais.submit';
   		f.method = 'POST';
   		f.submit();

   	}
 
 
 
 }
 
 //Nova senha//
 function ValidaCampoNovaSenha()
 {
	var message = "";
   	var foco = "";
   	var idx = 0;
   	var arName = new Array();
   	var f = document.formNovaSenha;
     
    if(validaForm(f.password2.value, 'tb') == false)
   	{
   	   	
   		if(foco.length == 0)
			foco = f.password2;
	   		arName[0] = "password2";	
	   		message = message + "» Favor informar a nova senha; \n";	
   	
   	}
   	
   	if(validaForm(f.password3.value, 'tb') == false)
   	{
   	   	
   		if(foco.length == 0)
			foco = f.password3;
	   		arName[1] = "password3";	
	   		message = message + "» Favor informar novamente a senha; \n";	
   	
   	}
   	
   	if(f.password3.value != f.password2.value)
   	{
   		if(foco.length == 0)
			foco = f.password3;
	   		arName[2] = "password3";	
	   		message = message + "» Senhas devem ser iguais; \n";	
   	
   	}
   	
   	 if(f.Flag.checked== false)
   	{
   	   	
   		if(foco.length == 0)
   		 
			foco = f.Flag;
	   		arName[3] = "Flag";	
	   		message = message + "» Termo de aceite do uso do sistema não selecionado; \n";
	   		//document.getElementById('Flag').style.border = '1px solid #ff0000';	
	   	
	   
   	}
   	else
	{
	   	// document.getElementById('Flag').style.border = '0px solid #ffffff';	
	}	
   	
   	
 
    if(arName.length)
   	{
   		alert(message);
   		//foco.focus();
   		
   		//var contagem = arName.length;
   		//for(h = 0; h < 2; h++)
   		//{
   		 
   	   //  document.getElementById(arName[h]).style.border = '1px solid #ff0000';
      //  }
       // return false;
   	}
   	else
   	{
   		f.action = 'index.php?carregar=login.submit';
   		f.method = 'POST';
   		f.submit();
   	}	
 	
 }
 


//JAVSCRITP REGISTRO DE DEVOLUCAO 
 //Registro//
 function BuscarProduto()
 {
	var message = "";
   	var foco = "";
   	var idx = 0;
   	var arName = new Array();
   	var f = document.frmDevolucao;
     
    if(validaForm(f.Date.value, 'tb') == false)
   	{
   	   	
   		if(foco.length == 0)
			foco = f.Date;
	   		arName[0] = "Date";	
	   		message = message + "» Favor informar a data da nota; \n";	
   	
   	}
   	
 	
    if(validaForm(f.NotaFiscal.value, 'tb') == false)
   	{
   		if(foco.length == 0)
			foco = f.NotaFiscal;
	   		arName[1] = "NotaFiscal";	
	   		message = message + "» Favor selecionar o número da nota; \n";	
   	
   	}
   	
   	if(validaForm(f.Responsavel.value, 'tb') == false)
   	{
   		if(foco.length == 0)
			foco = f.Responsavel;
	   		arName[2] = "Responsavel";	
	   		message = message + "» Favor informar o responsável; \n";	
   	
   	}
   	
   	if(validaForm(f.ddd.value, 'tb') == false)
   	{
   		if(foco.length == 0)
			foco = f.ddd;
	   		arName[3] = "ddd";	
	   		message = message + "» Favor informar o ddd da sua cidade; \n";	
   	
   	}
   	else
   	{
   	    if(validaInteger(f.ddd.value)==false)
   	   {
   	      if(foco.length == 0)
			foco = f.ddd;
	   		arName[3] = "Telefone";	
	   		message = message + "» Formato inválido do ddd; \n";
   	    
   	   }
   	
   	}
   	
   	if(validaForm(f.Telefone.value, 'tb') == false)
   	{
   		if(foco.length == 0)
			foco = f.Telefone;
	   		arName[4] = "Telefone";	
	   		message = message + "» Favor informar o telefone; \n";	
   	
   	}
   	else
   	{
   	   if(validaTelefone(f.Telefone.value)==false)
   	   {
   	      if(foco.length == 0)
			foco = f.Telefone;
	   		arName[4] = "Telefone";	
	   		message = message + "» Formato inválido de telefone; \n";
   	    
   	   }
   	
   	
   	}
   	
   	if(validaForm(f.Email.value, 'tb') == false)
   	{
   		if(foco.length == 0)
			foco = f.Email;
	   		arName[5] = "Email";	
	   		message = message + "» Favor informar o E-Mail; \n";	
   	
   	}
   	else
   	{
	   	   if(validaForm(f.Email.value, 'email') == false)
	     	{
	   		if(foco.length == 0)
				foco = f.Email;
		   		arName[5] = "Email";	
		   		message = message + "» Formato E-Mail inválido.; \n";	
	   	
	   	    }
   	
   	}
   	
   
  
    if(arName.length)
   	{
   		alert(message);
   	//	foco.focus();
      //  var contagem = arName.length;
   		//for(h = 0; h < 1; h++)
   		//{
   		 
   	     //document.getElementById(arName[h]).style.border = '1px solid #ff0000';
       // }
       // return false;
   	}
   	else
   	{
   		f.action = 'index.php?carregar=Registro1Parte.submit';
   		f.method = 'POST';
   		f.submit();
   	}	
 	
 }
 
 
 //Sobra
  function SalvarSobra2()
  {

    var message = "";
   	var foco = "";
   	var idx = 0;
   	var arName = new Array();
   	var f = document.frmSobra2;

    if(validaForm(f.CodBarra_0.value, 'tb') == false)
   	{
   		if(foco.length == 0)
			foco = f.CodBarra_0;
	   		arName[0] = "CodBarra_0";	
	   		message = message + "» Favor informar o código de Barra; \n";	
   	}
   	else
   	{
   	  if(validaForm(f.NomeProduto.value, 'tb') == false)
   	  {
   		if(foco.length == 0)
			foco = f.NomeProduto;
	   		arName[0] = "NomeProduto";	
	   		message = message + "» Código de Barra inválido; \n";	
   	  }
   	
   	}
   	
   	if(validaForm(f.Qtd.value, 'tb') == false)
   	{
   		if(foco.length == 0)
			foco = f.Qtd;
	   		arName[1] = "Qtd";	
	   		message = message + "» Favor informar a quantidade; \n";	
   	
   	}
   	else
   	{
   	  if(validaInteger(f.Qtd.value)==false)
   	   {
   	      if(foco.length == 0)
			foco = f.Qtd;
	   		arName[1] = "Qtd";	
	   		message = message + "» Formato inválido da quantidade; \n";
   	    
   	   }
   	
   	}

 	  
    if(arName.length)
   	{
   		alert(message);
   		//foco.focus();
       // var contagem = arName.length;
   		//for(h = 0; h < 1; h++)
   		//{
   		 
   	     //document.getElementById(arName[h]).style.border = '1px solid #ff0000';
       // }
        //return false;
   	}
   	else
   	{
   		f.action = 'index.php?carregar=InserirSobra.submit';
   		f.method = 'POST';
   		f.submit();
   	}
 
 
 
 }
 
 	function somente_numero(campo){
		var digits="0123456789"
		var campo_temp
		for (var i=0;i<campo.value.length;i++){
			campo_temp=campo.value.substring(i,i+1)
			if (digits.indexOf(campo_temp)==-1){
				campo.value = campo.value.substring(0,i);
			break;
		}
		}
	}
	
	
function ConfirmarRProtocolo()
{
	var message = "";
   	var foco = "";
   	var idx = 0;
   	var arName = new Array();
   	var f = document.frmCaponline;
   	
   	if (validaForm(f.dtOcorrenciaDe.value, 'tb') == false)
   	{
   		//if(foco.length == 0)
   	    message =  message + "» Favor informar a Ocorrência a partir de; \n";
		//foco = f.dtOcorrenciaDe;
   		arName[1] = "dtOcorrenciaDe";		
   	}
	else
	{
	
		if  (!isDate(f.dtOcorrenciaDe.value))
		{
			//if(foco.length == 0)
			 message =  message + "» Formato inválido ocorrência a partir de; \n";
			//foco = f.dtOcorrenciaDe;
			
			arName[2] = "dtOcorrenciaDe";		
		}
	}
	
		if(validaForm(f.dtOcorrenciaAte.value, 'tb') == false)
   	{
   		//if(foco.length == 0)
		message =  message + "» Favor informar a Ocorrência até; \n";
   			//foco = f.dtOcorrenciaAte;
   		
   		arName[3] = "dtOcorrenciaAte";		
   	}
	else
	{
	
		if(!isDate(f.dtOcorrenciaAte.value))
		{
			//if(foco.length == 0)
			message =  message + "» Formato inválido ocorrência até; ";
				//foco = f.dtOcorrenciaAte;
			
			arName[4] = "dtOcorrenciaAte";		
		}
	}
	
	
	
	//if(validaForm(f.txtNotaFiscal.value, 'tb') == false)
   	//{
   		//if(foco.length == 0)
   			//foco = f.dtOcorrenciaDe;
				//	message =  message + "»  Favor informar o número da nota fiscal  ";
   		
   		//if(arName.length == 0)
   			//arName[0] = "txtNotaFiscal";
   		//else
   			//arName[arName.length] = "txtNotaFiscal";
   	//}
   	
   	//if(validaForm(f.txtProtocolo.value, 'tb') == false)
   	//{
   		//if(foco.length == 0)
   			//foco = f.dtOcorrenciaDe;
   		
   		//if(arName.length == 0)
   			//arName[0] = "txtProtocolo";
   		//else
   			//arName[arName.length] = "txtProtocolo";
   	//}
   	
	//alert(arName.length);
   	if(arName.length != 0)
   	{
   		//message = "» Favor informar a Ocorrência a partir de";
   		alert(message);
   		//foco.focus();
   		
   		//var contagem = arName.length;
   		//for(h = 0; h < contagem; h++)
   			//document.getElementById(arName[1]).style.border = '1px solid #ff0000';
			//return false;
   	}
   	else
   	{
   		f.action = 'index.php?carregar=submit.protocolo';
   		f.method = 'POST';
   		f.submit();
   	}	
}
	
	
function ConfirmarRProtocoloOlt()
{
	var message = "";
	var f       = document.frmDevolucao;
	//alert(f.NumNota.value);
	
	  if(validaForm(f.NumNota.value, 'tb') == false)
   	  {
   		message = message + "» Favor informar o numero da nota;\n";	
   	  }
	    if(validaForm(f.Protocolo.value, 'tb') == false)
   	  {
   		message = message + "» Favor informar o número protocolo;\n";	
   	  }
	  
	  if(validaForm(f.DataOcorrencia.value, 'tb') == false)
   	  {
   		message = message + "» Favor informar a data;\n";	
   	  }
	  else
	  {
		
			  
				if(!isDate(f.DataOcorrencia.value))
			{
				message = message + "» Favor preencher a data ocorrencia corretamente;\n";
		
			}
	
	  }

   if (message!="")
   {
	   alert(message);
	}
	else
	{
		f.action = 'index.php?carregar=submit.protocolo';
		f.method = 'POST';
		f.submit();
	
	}
}
