<!--
/******************************************************************************
 Produzido por Gustavo Valle
 Conteúdo protegido pela lei Nº 9.610/98 de Direitos Autorais.
 É expressamente proibida a cópia ou reprodução sem autorização.
/******************************************************************************/
/********************* FUNÇÕES GERAIS DO ADMINISTRADOR DO SISTEMA *************/
/******************************************************************************/
//EDITOR DE TEXTO
/******************************************************************************/
function header_recortar() {
	if (modeHeader) {
		editor.document.execCommand('cut', false, null);
	}
}

function header_copiar() {
	if (modeHeader) {
		editor.document.execCommand('copy', false, null);
	}
}

function header_colar() {
	if (modeHeader) {
		editor.document.execCommand('paste', false, null);
	}
}

function header_desfazer() {
	if (modeHeader) {
		editor.document.execCommand('undo', false, null);
	}
}

function header_refazer() {
	if (modeHeader) {
		editor.document.execCommand('redo', false, null);
	}
}

function header_negrito() {
	if (modeHeader) {
		editor.document.execCommand('bold', false, null);
	}
}

function header_italico() {
	if (modeHeader) {
		editor.document.execCommand('italic', false, null);
	}
}

function header_sublinhado() {
	if (modeHeader) {
		editor.document.execCommand('underline', false, null);
	}
}

function header_alinharEsquerda() {
	if (modeHeader) {
		editor.document.execCommand('justifyleft', false, null);
	}
}

function header_centralizado()	{
	if (modeHeader) {
		editor.document.execCommand('justifycenter', false, null);
	}
}

function header_alinharDireita() {
	if (modeHeader) {
		editor.document.execCommand('justifyright', false, null);
	}
}

function header_justificado() {
	if (modeHeader) {
		editor.document.execCommand('justifyfull', false, null);
	}
}

function header_numeracao() {
	if (modeHeader) {
		editor.document.execCommand('insertorderedlist', false, null);
	}
}

function header_marcadores() {
	if (modeHeader) {
		editor.document.execCommand('insertunorderedlist', false, null);
	}
}

function header_fonte(fonte) {
	if (modeHeader) {
	if(fonte != '')
		editor.document.execCommand('fontname', false, fonte);
	}
}

function header_tamanho(tamanho) {
	if (modeHeader) {
	if(tamanho != '')
		editor.document.execCommand('fontsize', false, tamanho);
	}
}
/******************************************************************************/
// JUNP MENU
/******************************************************************************/
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
/******************************************************************************/
// POPUP
/******************************************************************************/
function Popup(mypage, popup, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no'
win = window.open(mypage, popup, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
/******************************************************************************/
// RESTRINGE OS CAMPOS A NUMÉRICO
/******************************************************************************/
function Numerico(Campo) {
	var	strValor = Campo.value;
	var intTam = strValor.length;
	var intLoop = 0;
	var strCaracter;
	for (; intLoop < intTam; intLoop++){
		strCaracter = strValor.substring(intLoop, intLoop + 1);
		if (strCaracter == 0 || strCaracter == 1 || strCaracter == 2 || strCaracter == 3 || strCaracter == 4 || strCaracter == 5 || strCaracter == 6 || strCaracter == 7 || strCaracter == 8 || strCaracter == 9 || strCaracter == ',' || strCaracter == '(' || strCaracter == ')' || strCaracter == '-' || strCaracter == ':' || strCaracter == '/' || strCaracter == '.') {
		}
		else{
			Campo.value = strValor.substring(0, intLoop );
		}
	}
}
/******************************************************************************/
//COLOCA BARRAS NA DATA
/******************************************************************************/
function DataVer (formato,objeto)
{
	Campo = eval (objeto);
	// DATA
	if (formato=='data')
	{
		separador = '/'; 
		conjunto1 = 2;
		conjunto2 = 5;
		if (Campo.value.length == conjunto1)
		{
			Campo.value = Campo.value + separador;
		}
		if (Campo.value.length == conjunto2)
		{
			Campo.value = Campo.value + separador;
		}
	}
}
/******************************************************************************/
// VERIFICA QUANTIDADE DE DIAS EM FEVEREIRO
/******************************************************************************/
function DiasInFevereiro (pnAno) {
    return (  ((pnAno % 4 == 0) && ( (!(pnAno % 100 == 0)) || (pnAno % 400 == 0) ) ) ? 29 : 28 );
}

// VALIDA DATA
function ValidaData(field) {
	if (field.value == "") {
		return true;
	}
	var hoje = new Date();
	var anoAtual = hoje.getFullYear();
	var barras = field.value.split("/");
	if (barras.length == 3) {
		var dia = barras[0];
		var mes = barras[1];
		var ano = barras[2];
		var resultado = (!isNaN(dia) && (dia > 0) && (dia < 32)) && (!isNaN(mes) && (mes > 0) && (mes < 13)) && (!isNaN(ano) && (ano.length == 4));
		if (!resultado) {
			alert("Formato de data inválido. Ex.: (dd/mm/aaaa)");
			field.focus();
			field.select();
			return false;
		}
		if (ano.length != 4) {
			alert("O ano deve ter 4 digitos.");
			field.focus();
			field.select();
			return false;
		}
		//if (ano < anoAtual) {
			//alert("O ano não pode ser menor que o ano atual.");
			//field.focus();
			//field.select();
			//return false;
		//}
		dias = new Array(13);
		dias[1] = 31;
		dias[2] = DiasInFevereiro(ano);   // deve ser verificado o caso de anos bissextos
		dias[3] = 31;
		dias[4] = 30;
		dias[5] = 31;
		dias[6] = 30;
		dias[7] = 31;
		dias[8] = 31;
		dias[9] = 30;
		dias[10] = 31;
		dias[11] = 30;
		dias[12] = 31;
		if (dia > dias[mes]) {
			alert("Dia inválido.");
			field.focus();
			field.select();
			return false;
		}
	} else {
		alert("Formato de data inválido. Ex.: (dd/mm/aaaa)");
		field.focus();
		field.select();
		return false;
	}
}
/******************************************************************************/
// VALIDA HORA MINUTO
/******************************************************************************/
function ValidaHora(field) {
	if (field.value == "") {
		return true;
	}
	if (field.value.length != 5) {
		alert("Formato de hora inválido. Ex.: (hh:mm)");
		field.focus();
		field.select();
		return false;
	}
	var barras = field.value.split(":");
	if (barras.length == 2) {
		var hora = barras[0];
		var minuto = barras[1];
		var resultado = (!isNaN(hora) && (hora >= 0) && (hora < 24)) && (!isNaN(minuto) && (minuto >= 0) && (minuto < 60));
		if (!resultado) {
			alert("Formato de hora inválido. Ex.: (hh:mm)");
			field.focus();
			field.select();
			return false;
		}
	}
	else {
		alert("Formato da hora inválido. Ex.: (hh:mm)");
		field.focus();
		field.select();
		return false;
	}
}
/******************************************************************************/
//COLOCA PONTO E TRACO NO CEP
/******************************************************************************/
function CEPVer (formato,objeto)
{
	Campo = eval (objeto);
	// CEP
	if (formato=='cep')
	{
		separador1 = '.';
		separador2 = '-';
		conjunto1 = 2;
		conjunto2 = 6;
		if (Campo.value.length == conjunto1)
		{
			Campo.value = Campo.value + separador1;
		}
		if (Campo.value.length == conjunto2)
		{
			Campo.value = Campo.value + separador2;
		}
	}
}
/******************************************************************************/
//VALIDA ENVIO DE CONTATO
/******************************************************************************/
function Submit_Contato(){

var nomeForm = document.Registro_Contato;

var txt_nome=nomeForm.txt_nome.value;
if (txt_nome==""){
alert("Digite o seu nome.")
nomeForm.txt_nome.focus()
return false
	}

var txt_email=nomeForm.txt_email.value;
if (txt_email==""){
alert("Didite o seu e-mail.")
nomeForm.txt_email.focus()
return false
	}
	
var txt_telefone=nomeForm.txt_telefone.value;
if (txt_telefone==""){
alert("Didite o seu telefone.")
nomeForm.txt_telefone.focus()
return false
	}

var txt_assunto=nomeForm.txt_assunto.value;
if (txt_assunto==""){
alert("Selecione um assunto.")
nomeForm.txt_assunto.focus()
return false
	}

var txt_texto=nomeForm.txt_texto.value;
if (txt_texto==""){
alert("Didite o texto.")
nomeForm.txt_texto.focus()
return false
	}

nomeForm.submit();
}
/******************************************************************************/
//VALIDA SOLICITE UM VISITA
/******************************************************************************/
function Submit_Solicite(){

var nomeForm = document.Registro_Solicite;

var txt_nome=nomeForm.txt_nome.value;
if (txt_nome==""){
alert("Digite o seu nome.")
nomeForm.txt_nome.focus()
return false
	}

var txt_empresa=nomeForm.txt_empresa.value;
if (txt_empresa==""){
alert("Digite a sua empresa.")
nomeForm.txt_empresa.focus()
return false
	}

var txt_email=nomeForm.txt_email.value;
if (txt_email==""){
alert("Didite o seu e-mail.")
nomeForm.txt_email.focus()
return false
	}
	
var txt_endereco=nomeForm.txt_endereco.value;
if (txt_endereco==""){
alert("Didite o seu endereco.")
nomeForm.txt_endereco.focus()
return false
	}
	
var txt_cep=nomeForm.txt_cep.value;
if (txt_cep==""){
alert("Didite o seu CEP.")
nomeForm.txt_cep.focus()
return false
	}	

var txt_telefone=nomeForm.txt_telefone.value;
if (txt_telefone==""){
alert("Didite o seu telefone.")
nomeForm.txt_telefone.focus()
return false
	}

var txt_bairro=nomeForm.txt_bairro.value;
if (txt_bairro==""){
alert("Didite o seu bairro.")
nomeForm.txt_bairro.focus()
return false
	}

var txt_cidade=nomeForm.txt_cidade.value;
if (txt_cidade==""){
alert("Didite o sua cidade.")
nomeForm.txt_cidade.focus()
return false
	}

var txt_estado=nomeForm.txt_estado.value;
if (txt_estado==""){
alert("Selecione um estado.")
nomeForm.txt_estado.focus()
return false
	}

var txt_texto=nomeForm.txt_texto.value;
if (txt_texto==""){
alert("Didite o texto.")
nomeForm.txt_texto.focus()
return false
	}

nomeForm.submit();
}
/******************************************************************************/
// Valida o CEP
/******************************************************************************/
function ValidaCEP(field) {
	var lcValor = new String(field.value); 
	if (lcValor.length == 0) {
		return true;
	}
	// Último Caracter Digitado
	var lcCaracter_Digitado = lcValor.substring(lcValor.length - 1, 10);
	
	// Verifica se o usuário entrou com um caracter válido
	if ( !(lcCaracter_Digitado.charCodeAt() >=48 && lcCaracter_Digitado.charCodeAt() <= 57) ) {
		field.value = lcValor.substring(0, lcValor.length - 1);
		alert("Caracter inválido!");
		field.focus();
	}
	if (lcValor.length < 5) {
		if (lcCaracter_Digitado == "/") {
			// Remove caracter
			field.value = lcValor.substring(0, lcValor.length - 1);
			field.value = "";
			field.focus();
		}
	}
	if (lcValor.length == 5) {
		// Adiciona caracter
		field.value = poObjeto.value + "-";
		field.focus();
	}
	if (lcValor.length > 9) {
		if (lcCaracter_Digitado == "/") {
			// Remove caracter
			field.value = lcValor.substring(0, lcValor.length - 1);
			field.value = "";
			field.focus();
		}
	}
	return true;
}
/******************************************************************************/
//COLOCA BARRAS NO CPF
/******************************************************************************/
function CPFVer (formato,objeto)
{
	Campo = eval (objeto);
	// CPF
	if (formato=='cpf')
	{
		separador = '.';
		separador1 = '-';
		conjunto1 = 3;
		conjunto2 = 7;
		conjunto3 = 11;
		if (Campo.value.length == conjunto1)
		{
			Campo.value = Campo.value + separador;
		}
		if (Campo.value.length == conjunto2)
		{
			Campo.value = Campo.value + separador;
		}
		if (Campo.value.length == conjunto3)
		{
			Campo.value = Campo.value + separador1;
		}
	}
}
/******************************************************************************/
//VALIDA CPF
/******************************************************************************/
function validaCPF(campo) {
    cpf = campo.value;
    numeros = "0123456789"
    cpfx = "";
      for (x = 0; x <= 14; x++)
      {
      if (numeros.indexOf(cpf.charAt(x)) >= 0)
      cpfx = cpfx + cpf.charAt(x);
      }
  valor = true;
  erro = new String;
  //if (cpf.length < 11) erro += "CPF incompleto. ";
  //campo.value = "";
  var nonNumbers = /\D/;
  if (nonNumbers.test(cpfx)) erro += "A verificacao de CPF suporta apenas Números!";
  if (cpf == "000.000.000-00" || cpf == "111.111.111-11" || cpf == "222.222.222-22" || cpf == "333.333.333-33" || cpf == "444.444.444-44" || cpf == "555.555.555-55" || cpf == "666.666.666-66" || cpf == "777.777.777-77" || cpf == "888.888.888-88" || cpf == "999.999.999-99"){
      erro += "Número de CPF invalido!"
      //campo.value = "";
  }
  var a = [];
  var b = new Number;
  var c = 11;
  for (i=0; i<11; i++){
    a[i] = cpfx.charAt(i);
    if (i < 9) b += (a[i] *  --c);
  }
  if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x }
  b = 0;
  c = 11;
  for (y=0; y<10; y++) b += (a[y] *  c--);
  if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }
  if ((cpfx.charAt(9) != a[9]) || (cpfx.charAt(10) != a[10])){
    erro +="Número de CPF invalido!";
    //campo.value = "";
  }
  if (erro.length > 0){
    alert(erro);
    campo.focus();
    return false;
  }
  return true;
  }
/******************************************************************************/
// VALIDA EMAILS
/******************************************************************************/
function ValidaEmail(field) {
	var mail='';
	if (field.value == '') { return false; }
	else { mail = field; }
	
	if (mail.value == "") {
		alert("Informe seu e-mail.");
		mail.focus();
		mail.select();
		return false;
	}
	else {
		prim = mail.value.indexOf("@")
		if (prim < 2) {
			alert("O e-mail informado parece não estar correto.");
			mail.focus();
			mail.select();
			return false;
		}
		if (mail.value.indexOf("@",prim + 1) != -1) {
			alert("O e-mail informado parece não estar correto.");
			mail.focus();
			mail.select();
			return false;
		}
		if (mail.value.indexOf(".") < 1) {
			alert("O e-mail informado parece não estar correto.");
			mail.focus();
			mail.select();
			return false;
		}
		if (mail.value.indexOf(" ") != -1) {
			alert("O e-mail informado parece não estar correto.");
			mail.focus();
			mail.select();
			return false;
		}
		if (mail.value.indexOf("zipmeil.com") > 0) {
			alert("O e-mail informado parece não estar correto.");
			mail.focus();
			mail.select();
			return false;
		}
		if (mail.value.indexOf("hotmeil.com") > 0) {
			alert("O e-mail informado parece não estar correto.");
			mail.focus();
			mail.select();
			return false;
		}
		if (mail.value.indexOf(".@") > 0) {
			alert("O e-mail informado parece não estar correto.");
			mail.focus();
			mail.select();
			return false;
		}
		if (mail.value.indexOf("@.") > 0) {
			alert("O e-mail informado parece não estar correto.");
			mail.focus();
			mail.select();
			return false;
		}
		if (mail.value.indexOf(".com.br.") > 0) {
			alert("O e-mail informado parece não estar correto.");
			mail.focus();
			mail.select();
			return false;
		}
		if (mail.value.indexOf("/") > 0) {
			alert("O e-mail informado parece não estar correto.");
			mail.focus();
			mail.select();
			return false;
		}
		if (mail.value.indexOf("[") > 0) {
			alert("O e-mail informado parece não estar correto.");
			mail.focus();
			mail.select();
			return false;
		}
		if (mail.value.indexOf("]") > 0) {
			alert("O e-mail informado parece não estar correto.");
			mail.focus();
			mail.select();
			return false;
		}
		if (mail.value.indexOf("(") > 0) {
			alert("O e-mail informado parece não estar correto.");
			mail.focus();
			mail.select();
			return false;
		}
		if (mail.value.indexOf(")") > 0) {
			alert("O e-mail informado parece não estar correto.");
			mail.focus();
			mail.select();
			return false;
		}
		if (mail.value.indexOf("..") > 0) {
			alert("O e-mail informado parece não estar correto.");
			mail.focus();
			mail.select();
			return false;
		}
	}
	return true;
}
/******************************************************************************/
//VALIDA ENVIO DE MATÉRIA
/******************************************************************************/
function Submit_Materia(){

var nomeForm = document.Registro_Materia;

var txt_nome_dest=nomeForm.txt_nome_dest.value;
if (txt_nome_dest==""){
alert("Digite o nome do destinatário.")
nomeForm.txt_nome_dest.focus()
return false
	}
	
var txt_email_dest=nomeForm.txt_email_dest.value;
if (txt_email_dest==""){
alert("Didite o e-mail do destinatário.")
nomeForm.txt_email_dest.focus()
return false
	}


var txt_nome=nomeForm.txt_nome.value;
if (txt_nome==""){
alert("Digite o seu nome.")
nomeForm.txt_nome.focus()
return false
	}
	
var txt_email=nomeForm.txt_email.value;
if (txt_email==""){
alert("Didite o seu e-mail.")
nomeForm.txt_email.focus()
return false
	}

	
nomeForm.submit();
}
/******************************************************************************/
//VALIDA A IMAGEM
/******************************************************************************/
function Submit_Imagem(){

var nomeForm = document.Registro_Imagem;

var txt_imagem=nomeForm.txt_imagem.value;
if (txt_imagem==""){
alert("Insira uma imagem.")
nomeForm.txt_imagem.focus()
return false
	}

extArray = new Array(".jpg");
var file=nomeForm.txt_imagem.value;
allowSubmit = false;
if (!file) return;
while (file.indexOf("\\") != -1)
file = file.slice(file.indexOf("\\") + 1);
ext = file.slice(file.indexOf(".")).toLowerCase();
for (var i = 0; i < extArray.length; i++) {
if (extArray[i] == ext) { allowSubmit = true; break; }
}
if (allowSubmit) nomeForm.submit();
else
alert("Por favor, só serão aceitos arquivos nas terminações:  " 
+ (extArray.join("  ")) + "\nEscolha uma nova "
+ "imagem e envie novamente.");
return false

nomeForm.submit();
}
/******************************************************************************/
//VALIDA O ARQUIVO
/******************************************************************************/
function Submit_Arquivo(){

var nomeForm = document.Registro_Arquivo;

var txt_arquivo=nomeForm.txt_arquivo.value;
if (txt_arquivo==""){
alert("Insira um arquivo.")
nomeForm.txt_arquivo.focus()
return false
	}

extArray = new Array(".xls",".pdf");
var file=nomeForm.txt_arquivo.value;
allowSubmit = false;
if (!file) return;
while (file.indexOf("\\") != -1)
file = file.slice(file.indexOf("\\") + 1);
ext = file.slice(file.indexOf(".")).toLowerCase();
for (var i = 0; i < extArray.length; i++) {
if (extArray[i] == ext) { allowSubmit = true; break; }
}
if (allowSubmit) nomeForm.submit();
else
alert("Por favor, só serão aceitos arquivos nas terminações:  " 
+ (extArray.join("  ")) + "\nEscolha um novo "
+ "arquivo e envie novamente.");
return false

nomeForm.submit();
}
/******************************************************************************/
// VALIDA PONTO ELETRÔNICO
/******************************************************************************/
function Submit_Ponto(){

var nomeForm = document.Registro_Ponto;

var txt_senha=nomeForm.txt_senha.value;
if (txt_senha==""){
alert("Digite sua Senha.")
nomeForm.txt_senha.focus()
return false
	}

nomeForm.submit();
}
/******************************************************************************/
// VALIDA BUSCA
/******************************************************************************/
function Submit_Busca(){

var nomeForm = document.Reg_Busca;

var txt_busca=nomeForm.txt_busca.value;
if (txt_busca==""){
alert("Digite a Palavra para Busca.")
nomeForm.txt_busca.focus()
return false
	}

nomeForm.submit();
}
/******************************************************************************/
//VALIDA ENQUETE
/******************************************************************************/
function Submit_Enquete(){

var nomeForm = document.Reg_Enquete;

	marcado = -1
	for (i=0; i<nomeForm.txt_opcao.length; i++) {
		if (nomeForm.txt_opcao[i].checked) {
			marcado = i
			resposta = nomeForm.txt_opcao[i].value
		}
	}
	
	if (marcado == -1) {
		alert("Selecione uma resposta.");
		nomeForm.txt_opcao[0].focus();
		return false;
	} 

with (nomeForm) {
method = "POST";
action="enquete.asp?acao=1";
jan=Popup('enquete.asp?acao=1','popup','370','390','yes');
target='popup';
submit();
}
return true;

}
/******************************************************************************/
// VALIDA NEWSLETTER
/******************************************************************************/
function Submit_Newsletter(){

var nomeForm = document.Reg_Newsletter;

var txt_email=nomeForm.txt_email.value;
if (txt_email==""){
alert("Digite seu E-mail.")
nomeForm.txt_email.focus()
return false
	}
	
nomeForm.submit();
}
/******************************************************************************/
// VALIDA LOGIN ACESSO RESTRITO
/******************************************************************************/
function Submit_Login(){

var nomeForm = document.Reg_Login;

var txt_email=nomeForm.txt_email.value;
if (txt_email==""){
alert("Digite seu E-mail.")
nomeForm.txt_email.focus()
return false
	}
	
var txt_senha=nomeForm.txt_senha.value;
if (txt_senha==""){
alert("Digite sua Senha.")
nomeForm.txt_senha.focus()
return false
	}
	
nomeForm.submit();
}
/******************************************************************************/
// -->	
