// ******************** FUNÇÕES LIGADAS A NOTÍCIA ******************************

// validação de todos os campos de notícia

function mascaraData(campoData){
     var data = campoData.value;
     if(data.length == 2){
       data = data + '/';
       campoData.value = data;
       return true;
     }

     if(data.length == 5){
       data = data + '/';
       campoData.value = data;
       return true;
      }
  }



function validaItensNoticia() {

	with (document.frmDados) {
	
		if (strTitulo.value == "") {
			alert("Título inválido!");
			strTitulo.focus();
			return false;
		}
		
		if (strConteudo.value == "") {
			alert("Conteúdo inválido!");
			strConteudo.focus();
			return false;
		}
		
//		if (strImagem.value == "" && strArquivoGravado.value == "") {
//			alert("Imagem inválida!");
//			strImagem.focus();
//			return false;
//		}

		if (intCodLingua.value == "") {
			alert("Selecione um idioma!");
			intCodLingua.focus();
			return false;
		}

		return true
		
	}
	
}

// validação de uma inserção/edição de uma notícia
function validaNoticia() {
	with (document.frmDados)
		if (validaItensNoticia())
			submit();
}

// insere uma notícia nova
function inserirNoticia() {

	with (document.frmDados) {
		action = "adm_noticia_inserir.php";
		intCodNoticia.value = 0;
		submit();
	}

}
function inserirBlog() {

	with (document.frmDados) {
		action = "adm_Blog_inserir.php";
		//intCodNoticia.value = 0;
		submit();
	}

}
// edita uma notícia específica
function editarNoticia(auxIntCodNoticia) {

	with (document.frmDados) {
		action = "adm_noticia_inserir.php";
		intCodNoticia.value = auxIntCodNoticia;
		submit();
	}

}

// exclui uma notícia específica
function excluirNoticia(auxIntCodNoticia) {

	with (document.frmDados) {
		if (confirm("Você tem certeza da exclusão desta notícia ?")) {
			action = "adm_noticia_excluir.php";
			intCodNoticia.value = auxIntCodNoticia;
			submit();
		}
	}

}


function excluirBlog(auxIntCodBlog) {

	with (document.frmDados) {
		if (confirm("Você tem certeza da exclusão desta notícia ?")) {
			action = "adm_noticia_blog.php";
			intCodBlog.value = auxIntCodBlog;
			submit();
		}
	}

}
// serve para ativar ou desativar uma notícia específica
function atiDesNoticia(auxIntCodNoticia) {

	with (document.frmDados) {
		action = "adm_noticia_mudar_status.php";
		intCodNoticia.value = auxIntCodNoticia;
		submit();
	}

}

// chama a página para detalhar uma notícia específica
function detalharNoticia(auxIntCodNoticia) {

	with (document.frmDados) {
		intCodNoticia.value = auxIntCodNoticia;
		action = 'noticias.php';
		submit();
	}
}

// chama a página para detalhar uma notícia específica
function detalharNoticiaPg(auxIntCodNoticia) {

	with (document.frmNoticias) {
		intCodNoticiaPg.value = auxIntCodNoticia;
		action = 'noticias.php';
		submit();
	}
}
