function mascaraDataNoticias(){
	sep = '/';
	if(document.f_noticias.txt_data.value.length == 2){
	document.f_noticias.txt_data.value = document.f_noticias.txt_data.value + sep;
	}
	if(document.f_noticias.txt_data.value.length == 5){
	   document.f_noticias.txt_data.value = document.f_noticias.txt_data.value + sep;	
	}
}
function testaCadNoticia(){
	document.f_noticias.txt_titulo.focus();
	stringData = document.f_noticias.txt_data.value;		
	msg = "Todos os campos devem ser preenchidos:";
	if((document.f_noticias.txt_titulo.value == "")||(document.f_noticias.txt_noticias.value == "")||(document.f_noticias.txt_data.value == "")){
		alert(msg);
		return false;
	}	
	dtp1 = stringData.substr(0,2);
	dtp2 = stringData.substr(3,2);
	dtp3 = stringData.substr(6,4);
	 
	if(isNaN(dtp1) == true){
		alert("Dia Incorreto!");	
		return false
	}
	if(isNaN(dtp2) == true){
		alert("Mês Incorreto");			
		return false;
	}
	if(isNaN(dtp3 == true)){
		alert("Ano Incorreto");
		return false;
	}
	if(dtp1 > 31 || dtp1 < 0){
		alert("Dia incorreto");
		return false;		
	} 
	if(dtp2 > 12 || dtp1 < 0){
		alert("Mês incorreto");
		return false;		
	} 
}
function limparNoticias(){
	document.f_noticias.txt_data.value = "";	
	return false;
}
function seltdchNoticias(){
	frm = document.f_noticiasExcluir;
	tam = frm.ch.length;	
	if (frm.chtd.checked == true){
		for (i=0;i<=tam;i++){
			document.f_noticiasExcluir.ch[i].checked = true;
		}
	}
	else
	{
		for (i=0;i<=tam;i++){
			document.f_noticiasExcluir.ch[i].checked = false;
		}		
	}		
}
function btCancelarNoticias(){
	tamanho = document.f_noticiasExcluir.ch.length;
	document.f_noticiasExcluir.chtd.checked = false;
	for(i=0;i<=tamanho;i++){
		document.f_noticiasExcluir.ch[i].checked = false; 
	}
}
function testaEmailContatos(){
	frm = document.f_contatoTrade;
	if ((frm.txt_nome.value == "")||(frm.txt_email.value == "") || (frm.txt_empresa.value == "") || (frm.txt_mensagem.value == "")){
		alert("Todos os campos devem ser preenchidos");
		return false;
	}	
	nome = frm.txt_nome.value;
	nome = isNaN(nome);
	if(nome == false){
		alert("O campo nome não pode conter numeros!");
		return false;
	}
	arroba = document.f_contatoTrade.txt_email.value;
	arroba = arroba.indexOf("@");
	ponto = document.f_contatoTrade.txt_email.value;
	ponto = ponto.indexOf(".");
	if((arroba == -1)||(ponto == -1)){
		alert("Email Inválido!") ;
		return false;		
	}
}
function confirmaExclusaoContato(){
	if (confirm("Você realmente deseja deletar este contato?")){
		return true;
	}else{
				return false;
		    }	
}
function cancelaDadosValorKio(){
	document.frm.valorKio.value = "";
	return false;
	
}
function testaValorKio(){
	if(document.frm.valorKio.value == ""){
		alert("Você precisa digitar um Valor!");
		return false;	
	}	
}

function testa_valorProduto(){
	formProduto = document.frm;
	if((formProduto.txt_nome.value == "")||(formProduto.txt_desc.value == "")||(formProduto.txt_valor.value == "")){
		alert("Todos os campos devem ser preenchidos!");
		return false;
	}
}
//testes envio newletter
function testaEmailNewsletter(){
	nome = document.getElementById("idNomeNewsletter").value;
	email = document.getElementById("idEmailNewsletter").value;
	receberNewsletter = document.getElementById("idReceberNewsletter").checked;
	if((nome == "")||(email == "")){
		alert("Você deve preencher todos os campos!");
		return false;
	}
	if(email.indexOf("@") == -1){
		alert("Email Inválido!");
		return false;
	}
	if(email.indexOf(".") == -1){
		alert("Email Inválido");
		return false;		
	}	
}

function selecionaTodosContatosNewsletters(){
	frm = document.f_newsletters;
	tam = frm.ch.length;
	
	if (document.f_newsletters.chtd.checked == true){
		for (i=0;i<=frm.ch.length;i++){
			document.f_newsletters.ch[i].checked = true;
		}
	}
	else
	{
		for (i=0;i<=tam;i++){
			document.f_newsletters.ch[i].checked = false;
		}		
	}		
}
//admin newletter

function mascararDataNewsletters(){
	sep = '/';
	if(document.f_newsletters.txt_dataNewsletter.value.length == 2){
		document.f_newsletters.txt_dataNewsletter.value = document.f_newsletters.txt_dataNewsletter.value + sep;
	}
	if(document.f_newsletters.txt_dataNewsletter.value.length == 5){
	   document.f_newsletters.txt_dataNewsletter.value = document.f_newsletters.txt_dataNewsletter.value + sep;	
	}
}
function testaCamposNewsletters(){
	nome =  document.f_newsletters.txt_tituloNewsletter.value;
	msg = document.f_newsletters.txt_newsletter.value;
	data = document.f_newsletters.txt_dataNewsletter.value;
	if ((nome == "" )||(msg == "")||(data == "")){
		alert("Campos Vazios!");
		return false;
	}
	stringData = document.f_newsletters.txt_dataNewsletter.value;
	dtp1 = stringData.substr(0,2);
	dtp2 = stringData.substr(3,2);
	dtp3 = stringData.substr(6,4);
	 
	if(isNaN(dtp1) == true){
		alert("Dia Incorreto!");	
		return false
	}
	if(isNaN(dtp2) == true){
		alert("Mês Incorreto");			
		return false;
	}
	if(isNaN(dtp3 == true)){
		alert("Ano Incorreto");
		return false;
	}
	if(dtp1 > 31 || dtp1 < 0){
		alert("Dia incorreto");
		return false;		
	} 
	if(dtp2 > 12 || dtp1 < 0){
		alert("Mês incorreto");
		return false;		
	} 
}
function testaSenhaCadastroUsuario(){
	senha1 = document.getElementById("txt_senha").value;	
	senha2 = document.getElementById("txt_confirmaSenha").value;	
	usuario = document.getElementById("txt_usuario").value;
	if(senha1 == ""){
		alert("Campos Vazios!");
		return false;
		
	}
	if(senha1 != senha2){
		alert("Senhas Diferentes");
		return false;		
	}

}
//COTAÇÕES

function testaCotacoes(){
	frm = document.f_contacao;
	//teste exportação maritíma
	if((frm.g1_mercadoria.value == "")||(frm.g1_portoDeOrigem.value == "")||(frm.g1_tipoDeContainer.value == "")||(frm.g1_pesoBruto.value == "")||(frm.g1_ZipCode.value =="")||(frm.g1_portoDeDestino.value == "")||(frm.g1_dimensoes.value == "")){
			alert("Preencha todos os campos da Exportação Marítima!");
			return false;
	}	
	pesoBruto = frm.g1_pesoBruto.value;	
	for(i=0;i<=pesoBruto.length-1;i++){
		aux = (pesoBruto.charAt(i));
		if((aux != 1)&&(aux != 2)&&(aux != 3)&&(aux != 4)&&(aux != 5)&&(aux != 6)&&(aux != 7)&&(aux != 8)&&(aux!=9)&&(aux!=10)&&(aux!=0)&&(aux!=",")){
			alert("Peso Inválido!");
			return false;
		}
	}
	//importação maritima
	
	
}





