/*** FUNÇÕES MUDANÇA CONTEÚDO ABAS ***/
function mudaContAba(el_link) {
//alert(el_link);
$('cont_int').addClassName("opaca");
loadingContAba(1);
var link_aba = el_link.href;
var ns = link_aba.substring(link_aba.lastIndexOf("ns=")+3);
var ac = link_aba.substring(link_aba.lastIndexOf("ac=")+3);
var pg_int = link_aba.substring(link_aba.lastIndexOf("p=")+2);
//alert(ns + " - " + ac + " - " + pg_int);
//return false;
var links_abas = $('abas').childNodes;
for (var i=0;i < links_abas.length; i++) {
links_abas[i].className = '';
}
$(pg_int).className = 'ativo';
var url = link_aba;
var params = "ajax=true";//"ac=cont-abas&pg=" + pg + "&pg_int=" + pg_int;
var ajax = new Ajax.Request(url, { method: 'post', parameters:params, asynchronous:true,
onSuccess:function(t) {
var retorno = t.responseText;
loadingContAba(0);
$('cont_int').className = pg_int;
$('cont_int').innerHTML = retorno;
}});
}
function mudaContAba2(el_link) {
$('cont_int').addClassName("opaca");
loadingContAba(1);
var link_aba = el_link.href;
var ns = link_aba.substring(link_aba.lastIndexOf("ns=")+3);
var ac = link_aba.substring(link_aba.lastIndexOf("ac=")+3);
var pg_int = link_aba.substring(link_aba.lastIndexOf("p=")+2);
//alert(ns + " - " + ac + " - " + pg_int);
//return false;
var links_abas = $('abas').childNodes;
for (var i=0;i < links_abas.length; i++) {
links_abas[i].className = '';
}
$(pg_int).className = 'ativo';
var url = link_aba;
var params = "ajax=true";//"ac=cont-abas&pg=" + pg + "&pg_int=" + pg_int;
var ajax = new Ajax.Request(url, { method: 'post', parameters:params, asynchronous:true,
onSuccess:function(t) {
var retorno = t.responseText;
loadingContAba(0);
$('cont_int').className = pg_int;
$('cont_int').innerHTML = retorno;
}});
}
function loadingContAba(ac) {
if (ac == 1) {
var objLoadingCont = document.createElement("div");
objLoadingCont.setAttribute('id','loadingCont');
objLoadingCont.style.height = $('conteudo').offsetHeight + "px";
$('conteudo').appendChild(objLoadingCont);
}
else if ($('loadingCont')) Element.remove('loadingCont');
}
/*** FIM FUNÇÕES MUDANÇA CONTEÚDO ABAS ***/
/*** FUNÇÕES MUDANÇA DE FOTOS ***/
function mudaFoto(el) {
var str_link = el.href;
var id_img = str_link.substring(str_link.lastIndexOf("id_img=")+7);
Effect.Fade($('img'),{ duration:0.3});
//alert("id_img: " + id_img);
var params = "ajax=true&id_img=" + id_img;
var url = "/index.php?ns=home&ac=main&op=carregaImagem"; //inc-site/ajax.ac.php";
var ajax = new Ajax.Request(url, {method:'get', parameters:params, asynchronous:true,
onComplete:function(t) {
var retorno = t.responseText;
$('img_gr').innerHTML = t.responseText;
if (window.opera)
mostraAmpliada();
else
Event.observe('img', 'load', mostraAmpliada, false);
}});
var lista_links = $('thumbs').childNodes;
for (var i=0;i < lista_links.length;i++) {
if (lista_links[i].tagName && lista_links[i].tagName.search(/a/i) != -1) {
lista_links[i].className = "";
}
}
el.className = "ativo";
}
function mostraAmpliada() { Effect.Appear('img',{ duration:0.3}); }
/*** FIM FUNÇÕES MUDANÇA DE FOTOS ***/
/*** FUNÇÕES EQUIPE ***/
function toggleMaisMenos(el) {
var id_equipe = el.parentNode.className;
if ($(id_equipe).style.display == 'none') {
$(id_equipe).style.display = 'block';
el.className = "aberto";
}
else {
$(id_equipe).style.display = 'none';
el.className = "";
}
}
/*** FIM FUNÇÕES EQUIPE ***/
/*** FUNÇÕES DO BLOG ***/
function validaComment() {
var erro = "";
if ($('author') && $F('author') == "")
erro += "Preencha o campo Nome
";
if ($('email')) {
if ($F('email') == "")
erro += "Preencha o campo E-mail
";
else if (!validaMail($F('email')))
erro += "O E-mail inserido é inválido
";
}
if ($F('comment') == "")
erro += "Preencha o campo comentário
";
if (erro != "") {
$('erro_form').innerHTML = erro;
$('erro_form').style.display = 'block';
}
else {
$('erro_form').style.display = 'none';
$('commentform').submit();
}
}
function validaMail(mail){
var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
if(typeof(mail) == "string"){
if(er.test(mail)){ return true; }
}else if(typeof(mail) == "object"){
if(er.test(mail.value)){
return true;
}
}else{
return false;
}
}
/*** FIM FUNÇÕES DO BLOG ***/
function url_encode(str) {
var hex_chars = "0123456789ABCDEF";
var noEncode = /^([a-zA-Z0-9\_\-\.])$/;
var n, strCode, hex1, hex2, strEncode = "";
for(n = 0; n < str.length; n++) {
if (noEncode.test(str.charAt(n))) {
strEncode += str.charAt(n);
} else {
strCode = str.charCodeAt(n);
hex1 = hex_chars.charAt(Math.floor(strCode / 16));
hex2 = hex_chars.charAt(strCode % 16);
strEncode += "%" + (hex1 + hex2);
}
}
return strEncode;
}
function submitForm(id) {
if (id == 'frm_contato') {
$('bt_enviar').disabled = true;
$('bt_enviar').className = $('bt_enviar').className + " bt_disabled";
var params = "nome=" + escape(url_encode($('id_nome').value)) +
"&email=" + escape(url_encode($('id_email').value)) +
"&assunto=" + escape(url_encode($('id_assunto').value)) +
"&mensagem=" + escape(url_encode($('id_msg').value)) +
"&ajax=true";
var url = "/index.php?ns=home&ac=contato&op=enviarContato";
var ajax = new Ajax.Request(url, {method:'get', parameters:params, asynchronous:true,
onComplete:function(t) {
eval("var retorno = " + t.responseText);
//adicionaConteudo(retorno.descricao, "descr_perso");
if (retorno.err_nome)
$("err_nome").innerHTML = decodeText(retorno.err_nome);
else
$('err_nome').innerHTML = "";
if (retorno.err_email)
$('err_email').innerHTML = decodeText(retorno.err_email);
else
$('err_email').innerHTML = "";
if (retorno.err_assunto)
$('err_assunto').innerHTML = decodeText(retorno.err_assunto);
else
$('err_assunto').innerHTML = "";
if (retorno.err_msg)
$('err_msg').innerHTML = decodeText(retorno.err_msg);
else
$('err_msg').innerHTML = "";
if (retorno.err_envio)
$('err_envio').innerHTML = decodeText(retorno.err_envio);
else
$('err_envio').innerHTML = "";
if (retorno.msg_sucesso) {
Form.reset(id);
$('msg_sucesso').innerHTML = decodeText(retorno.msg_sucesso);
Element.show('msg_sucesso');
}
else {
Element.hide('msg_sucesso');
$('msg_sucesso').innerHTML = "";
}
$('bt_enviar').disabled = false;
$('bt_enviar').className = "botao";
}});
}
}
/***** FIM SUBMETER FORMULÁRIO ***/
/****** OVERLAY ******/
function addOverlay() {
var objBody = document.getElementsByTagName("body").item(0);
var objOverlay = document.createElement("div");
objOverlay.setAttribute('id','overlay');
objOverlay.style.display = 'none';
objBody.appendChild(objOverlay);
}
function startOverlay() {
if ($('overlay')) {
var arrayPageSize = getPageSize();
$('overlay').style.height = arrayPageSize[1] +"px";
Effect.BlindDown('overlay', { duration:0.3 });
}
}
function toggleObjOverlay(ac, obj) {
if (ac == 1) {
startOverlay();
Effect.Appear(obj, { duration:0.3, delay:0.3 })
}
else {
Effect.Fade(obj, { duration:0.3 })
Effect.BlindUp('overlay', { duration:0.3, delay:0.3 });
}
}
/****** FIM OVERLAY ******/
function getPageSize(){
var xScroll, yScroll;
if (window.innerHeight && window.scrollMaxY) {
xScroll = document.body.scrollWidth;
yScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
xScroll = document.body.scrollWidth;
yScroll = document.body.scrollHeight;
} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
xScroll = document.body.offsetWidth;
yScroll = document.body.offsetHeight;
}
var windowWidth, windowHeight;
if (self.innerHeight) { // all except Explorer
windowWidth = self.innerWidth;
windowHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
windowWidth = document.documentElement.clientWidth;
windowHeight = document.documentElement.clientHeight;
} else if (document.body) { // other Explorers
windowWidth = document.body.clientWidth;
windowHeight = document.body.clientHeight;
}
// for small pages with total height less then height of the viewport
if(yScroll < windowHeight){
pageHeight = windowHeight;
} else {
pageHeight = yScroll;
}
// for small pages with total width less then width of the viewport
if(xScroll < windowWidth){
pageWidth = windowWidth;
} else {
pageWidth = xScroll;
}
arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
return arrayPageSize;
}
function decodeText(txt) {
txt = txt.replace(/\+/g," ");
return unescape(txt);
}
/** FORMATA CAMPO INPUT PARA CPF
EX. UTILIZAÇÃO:
onkeyup="formatarcpf(this,event)"
*/
function mascaracpf(Campo, evento) {
var tecla = evento.keyCode;
var campo = Campo;
// digitos aceitos
var digits="0123456789-.";
var campo_temp;
for (var i = 0; i < campo.value.length; i++){
campo_temp = campo.value.substring(i,i+1);
if (digits.indexOf(campo_temp)==-1){
campo.value = campo.value.substring(0,i);
break;
}
}
// faz substituições
var vr = new String(Campo.value);
vr = vr.replace(".", "");
vr = vr.replace(".", "");
vr = vr.replace("-", "");
tam = vr.length + 1;
// efetua a mascara
if (tecla != 9 && tecla != 8) {
if (tam > 3 && tam < 7) { Campo.value = vr.substr(0, 3) + '.' + vr.substr(3, tam); }
if (tam >= 7 && tam <10) { Campo.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,tam-6); }
if (tam >= 10 && tam < 12) { Campo.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,3) + '-' + vr.substr(9,tam-9); }
}
} //mascaracpf
/** FORMATA CAMPO INPUT (SÓ ACEITA NÚMEROS E EXTRAS)
EX. UTILIZAÇÃO:
onkeyup="formatoNumero(this,event,',')"
*/
function formatoNumero(Campo, evento, extra) {
var tecla = evento.keyCode;
var campo = Campo;
// digitos aceitos
var digits = "0123456789" + extra;
var campo_temp;
for (var i = 0; i < campo.value.length; i++){
campo_temp = campo.value.substring(i,i+1);
if (digits.indexOf(campo_temp)==-1){
campo.value = campo.value.substring(0,i);
break;
}
}
} //formatoNumero
/** FORMATA CAMPO INPUT
EX. UTILIZAÇÃO:
onkeypress="return mascaraTexto(this,event,true,1)" aceita números e permite caracteres de e-mail
onkeypress="return mascaraTexto(this,event,false,0)" não aceita números
*/
function mascaraTexto(Campo, e, numero, extra) {
var tecla = (navigator.appName != 'Microsoft Internet Explorer') ? e.which : e.keyCode;
var ctrlKey = e.ctrlKey; // ctrl
var shift = e.shiftKey; // shift
// respectiva ordem (áàãÁÀÃéèêÉÈÊíìÍÌóòôÓÒÔúùÚÙçÇ)
var teclasAcentuadas = ',225,224,227,193,192,195,233,232,234,201,200,202,237,236,205,204,243,242,244,211,210,212,250,249,218,217,231,199';
// validação extra
switch(extra){
// email: permite @ tecla 64
case 1 :
if (shift && tecla == 64) return true; break;
// nome: nao aceita ,._
case 2 :
if (tecla == 44 || tecla == 46 || tecla == 95) return false; break;
}
// habilita teclas: enter, backspace, algumas teclas são 0 (com o tab, setas)
if (tecla == 13 || tecla == 8 || tecla == 0) return true;
// não pode '\[]'
if (tecla == 92 || tecla == 91 || tecla == 93) return false;
// bloqueia ctrl+v (colar, v ou V)
if (e.ctrlKey && (tecla == 118 || tecla == 86)) return false;
// verifica teclas (se número é verdadeiro, aceita números)
// maiúsculas e minúsculas a-z A-Z
// 44 46 = (,.)
// 32 (espaço)
// acentuação maiúsculas e minúsculas
if ((numero && (tecla >= 48 && tecla <= 57)) ||
(tecla >= 65 && tecla <= 122) ||
tecla == 44 || tecla == 46 || tecla == 32 ||
teclasAcentuadas.indexOf(','+tecla) >= 0
)
return true;
else
return false;
} //mascaraTexto
/* não permite colcar texto no campo
ex: onkeydown="return semColar(event)"
obs: deve ser utilizada no evento onkeydown */
function semColar(e){
var tecla = (navigator.appName != 'Microsoft Internet Explorer') ? e.which : e.keyCode;
var ctrlKey = e.ctrlKey;
if (ctrlKey && (tecla == 118 || tecla == 86)) return false;
}
/* MÁSCARA PARA FORMATO MOEDA
UTILIZAÇÃO:
onkeypress="return(mascaraMoeda(this,event,9))"
*/
function mascaraMoeda(campo, e, maxChar) {
var SeparadorDecimal = ","
var SeparadorMilesimo = "."
var sep = 0;
var key = '';
var i = j = 0;
var len = len2 = 0;
var strCheck = '0123456789';
var aux = aux2 = '';
var whichCode = (navigator.appName != 'Microsoft Internet Explorer') ? e.which : e.keyCode;
// habilita teclas: enter, backspace, algumas teclas são 0 (com o tab, setas)
if (whichCode == 13 || whichCode == 8 || whichCode == 0) return true;
key = String.fromCharCode(whichCode); // Valor para o código da Chave
if (strCheck.indexOf(key) == -1) return false; // Chave inválida
len = campo.value.length;
// máximo de caracteres
if (len >= maxChar) return false;
for(i = 0; i < len; i++)
if ((campo.value.charAt(i) != '0') && (campo.value.charAt(i) != SeparadorDecimal)) break;
aux = '';
for(; i < len; i++)
if (strCheck.indexOf(campo.value.charAt(i))!=-1) aux += campo.value.charAt(i);
aux += key;
len = aux.length;
if (len == 0) campo.value = '';
if (len == 1) campo.value = '0'+ SeparadorDecimal + '0' + aux;
if (len == 2) campo.value = '0'+ SeparadorDecimal + aux;
if (len > 2) {
aux2 = '';
for (j = 0, i = len - 3; i >= 0; i--) {
if (j == 3) {
aux2 += SeparadorMilesimo;
j = 0;
}
aux2 += aux.charAt(i);
j++;
}
campo.value = '';
len2 = aux2.length;
for (i = len2 - 1; i >= 0; i--)
campo.value += aux2.charAt(i);
campo.value += SeparadorDecimal + aux.substr(len - 2, len);
}
return false;
}// mascaraMoeda
function createExternalLinks() {
if(document.getElementsByTagName) {
var anchors = document.getElementsByTagName('a');
for(var i=0; i < anchors.length; i++) {
var anchor = anchors[i];
if(anchor.getAttribute("href") && anchor.getAttribute('rel')=='externo') { // <-- É necessário inserir rel="externo" no link
anchor.target = '_blank';
//var title = anchor.title + ' (Este link abre uma nova janela)'; // <-- Insere este texto no final do Title do link
//anchor.title = title;
}
}
}
}
window.onload = function() { createExternalLinks(); }