function testa_ajax(){
	  try {
         ajax = new ActiveXObject("Microsoft.XMLHTTP");
      } 
      catch(e) {
         try {
            ajax = new ActiveXObject("Msxml2.XMLHTTP");
         }
	     catch(ex) {
            try {
               ajax = new XMLHttpRequest();
            }
	        catch(exc) {
               alert("Esse browser não tem recursos para uso do Ajax");
               ajax = null;
            }
         }
      }
return ajax;
}

// CHECAGEM COMPLETA DO EMAIL
function checa_email(nform) {
var erro = true;
		prim = nform.email.value.indexOf("@");
		if(prim < 2) {
			document.getElementById("aviso_email").style.display = 'block';
			document.getElementById("aviso_email").innerHTML = 'O e-mail informado parece não estar correto.';
			document.getElementById("aviso_email").style.color = '#FF0000';
			erro = false;
		}
		if(nform.email.value.indexOf("@",prim + 1) != -1) {
			document.getElementById("aviso_email").style.display = 'block';
			document.getElementById("aviso_email").innerHTML = 'O e-mail informado parece não estar correto.';
			document.getElementById("aviso_email").style.color = '#FF0000';
			erro = false;
		}
		if(nform.email.value == '') {
			document.getElementById("aviso_email").style.display = 'block';
			document.getElementById("aviso_email").innerHTML = 'Você deve fornecer um email.';
			document.getElementById("aviso_email").style.color = '#FF0000';
			erro = false;
		}
		if(nform.email.value.indexOf(".") < 1) {
			document.getElementById("aviso_email").style.display = 'block';
			document.getElementById("aviso_email").innerHTML = 'O e-mail informado parece não estar correto.';
			document.getElementById("aviso_email").style.color = '#FF0000';
			erro = false;
		}
		if(nform.email.value.indexOf(" ") != -1) {
			document.getElementById("aviso_email").style.display = 'block';
			document.getElementById("aviso_email").innerHTML = 'O e-mail informado parece não estar correto.';
			document.getElementById("aviso_email").style.color = '#FF0000';
			erro = false;
		}
		if(nform.email.value.indexOf(".@") > 0) {
			document.getElementById("aviso_email").style.display = 'block';
			document.getElementById("aviso_email").innerHTML = 'O e-mail informado parece não estar correto.';
			document.getElementById("aviso_email").style.color = '#FF0000';
			erro = false;
		}
		if(nform.email.value.indexOf("@.") > 0) {
			document.getElementById("aviso_email").style.display = 'block';
			document.getElementById("aviso_email").innerHTML = 'O e-mail informado parece não estar correto.';
			document.getElementById("aviso_email").style.color = '#FF0000';
			erro = false;
		}
		if(nform.email.value.indexOf(".com.br.") > 0) {
			document.getElementById("aviso_email").style.display = 'block';
			document.getElementById("aviso_email").innerHTML = 'O e-mail informado parece não estar correto.';
			document.getElementById("aviso_email").style.color = '#FF0000';
			erro = false;
		}
		if(nform.email.value.indexOf("/") > 0) {
			document.getElementById("aviso_email").style.display = 'block';
			document.getElementById("aviso_email").innerHTML = 'O e-mail informado parece não estar correto.';
			document.getElementById("aviso_email").style.color = '#FF0000';
			erro = false;
		}
		if(nform.email.value.indexOf("[") > 0) {
			document.getElementById("aviso_email").style.display = 'block';
			document.getElementById("aviso_email").innerHTML = 'O e-mail informado parece não estar correto.';
			document.getElementById("aviso_email").style.color = '#FF0000';
			erro = false;
		}
		if(nform.email.value.indexOf("]") > 0) {
			document.getElementById("aviso_email").style.display = 'block';
			document.getElementById("aviso_email").innerHTML = 'O e-mail informado parece não estar correto.';
			document.getElementById("aviso_email").style.color = '#FF0000';
			erro = false;
		}
		if(nform.email.value.indexOf("(") > 0) {
			document.getElementById("aviso_email").style.display = 'block';
			document.getElementById("aviso_email").innerHTML = 'O e-mail informado parece não estar correto.';
			document.getElementById("aviso_email").style.color = '#FF0000';
			erro = false;
		}
		if(nform.email.value.indexOf(")") > 0) {
			document.getElementById("aviso_email").style.display = 'block';
			document.getElementById("aviso_email").innerHTML = 'O e-mail informado parece não estar correto.';
			document.getElementById("aviso_email").style.color = '#FF0000';
			erro = false;
		}
		if(nform.email.value.indexOf("..") > 0) {
			document.getElementById("aviso_email").style.display = 'block';
			document.getElementById("aviso_email").innerHTML = 'O e-mail informado parece não estar correto.';
			document.getElementById("aviso_email").style.color = '#FF0000';
			erro = false;
		}
		if(erro){
			document.getElementById("aviso_email").style.display = 'block';
			document.getElementById("aviso_email").innerHTML = 'E-mail válido!';
			document.getElementById("aviso_email").style.color = '#009900';
		}
return erro;
}


// FUNÇÃO QUE MOSTRA O DIA E A HORA EM TEMPO REAL NA PARTE INTERNA DO SISTEMA
function moveRelogio(nome){
	meses = new Array('janeiro', 'fevereiro','março','abril','maio','junho','julho','agosto','setembro','outubro','novembro','dezembro');
	dias_semana = new Array('Domingo', 'Segunda-Feira','Terça-Feira','Quarta-Feira','Quinta-Feira','Sexta-Feira','Sábado');
    momentoAtual = new Date();
    ano = momentoAtual.getFullYear();
    mes = momentoAtual.getMonth();
    dia = momentoAtual.getDate();
    hora = momentoAtual.getHours();
    minuto = momentoAtual.getMinutes() < 10 ? '0' + momentoAtual.getMinutes() : momentoAtual.getMinutes();
    segundo = momentoAtual.getSeconds() < 10 ? '0' + momentoAtual.getSeconds() : momentoAtual.getSeconds();
	
	saudacao = 'Bom dia';
		if(hora > 11){
			saudacao = 'Boa tarde';
		}
		if(hora > 17){
			saudacao = 'Boa noite';
		}
	saudacao = ' - ' + saudacao + '&nbsp;<b>' + nome + '</b>.';
	//alert(nome);
    horaImprimivel = "&nbsp;&nbsp;<span class='txt_12_bold'>" + dia + '</span> - ' + meses[mes] + ' | ' + hora + ":" + minuto + ":" + segundo + "h" + saudacao;
    document.getElementById('data_hora').innerHTML = horaImprimivel;
    setTimeout("moveRelogio('" + nome + "')",1000)
}
// FIM DA FUNÇÃO QUE MOSTRA O DIA E A HORA EM TEMPO REAL NA PARTE INTERNA DO SISTEMA





// ENVIA HELP DESK PARA O E-MAIL DE SUPORTE
function envia_help_desk() {
document.getElementById('confimar_help_desk').disabled = true;
document.getElementById('confimar_help_desk').value = 'Enviando...';

document.getElementById('img_carregando').style.display = 'block';

      //verifica se o browser tem suporte a ajax
	  //se tiver suporte ajax
		a = testa_ajax();
	  	if(a) {
		ajax = a;
		ajax.open("POST", ("../ajax_envia_help_desk.php"), true);
		 msg = document.getElementById('msg_help_desk').value;
				 ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

				 ajax.onreadystatechange = function() {
					//após ser processado - chama função processXML que vai varrer os dados
					if(ajax.readyState == 4 ) {
					   if(ajax.responseXML) {
						  processXML_dados_help_desk(ajax.responseXML);
					   }
					}
				 }
				 //passa o setor escolhido
				 params = 'msg=' + msg;
				 ajax.send(params);
	   }//FECHA IF AJAX
}

function processXML_dados_help_desk(obj){
	var dataArray   = obj.getElementsByTagName("resposta");
		if(dataArray[0].getElementsByTagName("encontrado")[0].firstChild.nodeValue != 1) {
			document.getElementById('retorno_help_desk').innerHTML = 'Houve um erro no envio da mensagem!<br /> Contacte-nos pelo telefone:<br /> <b>24 2255-1940</b>.';
			MM_effectBlind('suporte', 500, '260px', '305px', false);
			document.getElementById('confimar_help_desk').disabled = false;
			document.getElementById('confimar_help_desk').value = 'Enviar';
			document.getElementById('img_carregando').style.display = 'none';
			setTimeout("MM_effectBlind('suporte', 500, '305px', '27px', false)",30000)
		}
	  	else{
			var protocolo = dataArray[0].getElementsByTagName("protocolo")[0].firstChild.nodeValue;
			document.getElementById('confimar_help_desk').disabled = false;
			document.getElementById('confimar_help_desk').value = 'Enviar';
			document.getElementById('img_carregando').style.display = 'none';
			document.getElementById('msg_help_desk').value = '';
			document.getElementById('retorno_help_desk').innerHTML = 'Mensagem enviada com sucesso.<br />N&ordm;. do Ticket: <b>' + protocolo + '</b>';
			MM_effectBlind('suporte', 500, '260px', '300px', false);
			setTimeout("MM_effectBlind('suporte', 500, '300px', '27px', false)",40000)
			}
}


// FUNÇÕES QUE GERAM, LÊEM E EXCLUEM COOKIES
function GerarCookie(strCookie, strValor, lngDias)
{
    var dtmData = new Date();

    if(lngDias)
    {
        dtmData.setTime(dtmData.getTime() + (lngDias * 24 * 60 * 60 * 1000));
        var strExpires = "; expires=" + dtmData.toGMTString();
    }
    else
    {
        var strExpires = "";
    }
    document.cookie = strCookie + "=" + strValor + strExpires + "; path=/";
}

// Função para ler o cookie.
function LerCookie(strCookie)
{
    var strNomeIgual = strCookie + "=";
    var arrCookies = document.cookie.split(';');

    for(var i = 0; i < arrCookies.length; i++)
    {
        var strValorCookie = arrCookies[i];
        while(strValorCookie.charAt(0) == ' ')
        {
            strValorCookie = strValorCookie.substring(1, strValorCookie.length);
        }
        if(strValorCookie.indexOf(strNomeIgual) == 0)
        {
            return strValorCookie.substring(strNomeIgual.length, strValorCookie.length);
        }
    }
    return null;
}

// Função para excluir o cookie desejado.
function ExcluirCookie(strCookie)
{
    GerarCookie(strCookie, '', -1);
}
// FIM DA FUNÇÃO QUE MOSTRA O DIA E A HORA EM TEMPO REAL NA PARTE INTERNA DO SISTEMA


function testa_tamanho(id, destino, maximo){
var valor = document.getElementById(id).value;
var num = valor.length;
	if(num == maximo){
	document.getElementById(destino).style.color = '#FF0000';
	document.getElementById(destino).innerHTML = maximo - num;
	}
	else{
	document.getElementById(destino).style.color = '#006633';
	document.getElementById(destino).innerHTML = maximo - num;
	}
}

function imprime_manifestacao(controle){
/*
var historico = document.getElementById('imprimir_historico' + controle);
var manifestante = document.getElementById('imprimir_dados_manifestante' + controle);
var manifestacao = document.getElementById('imprimir_manifestacao' + controle);
var url = 'imprimir.php';
*/
	document.getElementById();
}