<!--
    function getHTTPObject() {
      var xmlhttp;
      if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
        try {
          xmlhttp = new XMLHttpRequest();
        } catch (e) {
          xmlhttp = false;
        }
      }
      return xmlhttp;
    }
    var http = getHTTPObject();

    function requestNews() {
      var xhr_object = null;
      if(window.XMLHttpRequest) // Firefox
        xhr_object = new XMLHttpRequest();
      else if(window.ActiveXObject) // Internet Explorer
        xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
      else { 
        alert("Seu navegador não tem suporta a XMLHTTPRequest...");
        return;
      }
      var method   = "POST";
      var filename = "./admin/gravarNews.php";
      var nome     = document.news.nome.value;
      var email    = document.news.email.value;
      var data     = null;
      data = "nome="+nome+"&email="+email;
      if(method == "GET" && data != null) {
        filename += "?"+data;
        data      = null;
      }
      xhr_object.open(method, filename, true);
      xhr_object.onreadystatechange = function() {
        if(xhr_object.readyState == 4) {
          var tmp = xhr_object.responseText.split(":");
          document.news.retorno.value = tmp[1];
          alert(tmp[0]);
          if(document.news.retorno.value == 1){
            document.news.reset();
          }
          else{
            window.document.news.nome.focus();
          }
        }
      }
      if(method == "POST")
	    xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      xhr_object.send(data);
    }

    function requestVota(tela) {
      var xhr_object = null;
      if(window.XMLHttpRequest) // Firefox
        xhr_object = new XMLHttpRequest();
      else if(window.ActiveXObject) // Internet Explorer
        xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
      else { 
        alert("Seu navegador não tem suporta a XMLHTTPRequest...");
        return;
      }
      var method   = "POST";
      var filename = "./admin/gravarVoto.php";
      var tela     = tela;
      var id       = document.votacao.id.value;
      var opcao    = document.votacao.auxiliar.value;
      var data     = null;
      data = "tela="+tela+"&id="+id+"&opcao="+opcao;
      if(method == "GET" && data != null) {
        filename += "?"+data;
        data      = null;
      }
      xhr_object.open(method, filename, true);
      xhr_object.onreadystatechange = function() {
        if(xhr_object.readyState == 4) {
          var tmp = xhr_object.responseText.split(":");
          document.votacao.retorno.value = tmp[0];
          if (tela == 'votacao'){
		    if (document.votacao.retorno.value==1){ //votou
			  alert(tmp[1]);
              window.open('./admin/resultado.php?tela=votacao&id='+id+'&opcao='+opcao+'&codigo='+id,'winresult','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,left=0,top=0,width=300,height=300');
			}else{ //nao conseguiu votar
			  alert(tmp[1]);
			}
		  }else{
            window.open('./admin/resultado.php?tela=resultado&codigo='+id,'winresult','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,left=0,top=0,width=300,height=300');		  
		  }
        }
      }
      if(method == "POST")
	    xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      xhr_object.send(data);
    }

    function validaNews() {
      if ((document.news.nome.value != "")&&(document.news.email.value != "")) {
        requestNews();
      }else{
        alert('O cadastro está incompleto!');
      }
    }
    function vota(tela) {
      if (tela=='votacao'){
        if (document.votacao.auxiliar.value != "") {
          requestVota(tela);
        }else{
          alert('Selecione uma das opções!');
        }
	  }else{
	    requestVota(tela);	  
	  }
    }
    function validaEmail() {
      if ((document.contato.nome.value!='')&&(document.contato.email.value!='')&&(document.contato.assunto.value!='')&&(document.contato.mensagem.value!='')) {
        document.contato.submit();
	  }else{
        alert('O cadastro está incompleto!'); 
	  }
	}

    function validaAgenda() {
      if ((document.agenda.mes.value!='')&&(document.agenda.ano.value!='')) {
        document.agenda.submit();
	  }else{
        alert('O cadastro está incompleto!'); 
	  }
	}

	function validaImprensa() {
      if ((document.imprensa.mes.value!='')&&(document.imprensa.ano.value!='')) {
        document.imprensa.submit();
	  }else{
        alert('O cadastro está incompleto!'); 
	  }
	}

//-->
