function limpaCampo(fld, msg, ac) { if ($(fld).value == msg && ac == 1) $(fld).value = ""; if ($(fld).value == "" && ac == 0) $(fld).value = msg; } /*** MAILING ***/ function cadastraMailing(email) { if (email == "Digite aqui seu e-mail") email = ""; layer = 'status_mailing'; $('bt_mailing').focus(); $(layer).innerHTML = "
Carregando...
"; Element.show(layer); var url = "/home/mailing/incluirAjax"; var params = "email_mailing=" + email; var ajax = new Ajax.Request(url, { method: 'post', parameters:params, asynchronous:true, onSuccess:function(t) { $(layer).innerHTML = "" + t.responseText + "
fechar"; Element.show(layer); if (t.responseText.search(/sucesso/i) != -1) { $('email_mailing').value = ""; } }}); } /****** FUNÇÕES PARA ROLAGEM DOS THUMBS ******/ var intervalScroll; var posScroll = 0; function rolaThumbs(ps) { var tPulo = 10; var largura_cont = $('contThumbs').offsetWidth; var largura_thumbs = $('thumbs').offsetWidth; if (typeof(arguments[1]) == 'number') posScroll = arguments[1]; else { if (ps == 1) { if (posScroll + tPulo > (largura_thumbs-largura_cont)) posScroll = (largura_thumbs-largura_cont); else posScroll += tPulo; } else { if (posScroll-tPulo < 0) posScroll = 0; else posScroll -= tPulo; } } new Effect.Scroll('contThumbs', {x:posScroll, y:0, duration:0}); return false; } function ativaScroll(ps) { rolaThumbs(ps); intervalScroll = setInterval('rolaThumbs(' + ps + ')',1); } function desativaScroll() { clearInterval(intervalScroll); } /****** FIM FUNÇÕES PARA ROLAGEM DOS THUMBS ******/ /****** AMPLIAÇÃO LOJAS ******/ function ampliaLoja(loja_id) { addOverlay(); addPopup(); toggleObjOverlay(1,'popup'); var url = "/home/main/lojaAmpliada"; var params = "loja_id=" + loja_id; var ajax = new Ajax.Request(url, { method: 'post', parameters:params, asynchronous:true, onSuccess:function(t) { var retorno = t.responseText; $('popup').innerHTML = retorno; Event.observe('img_gr', 'load', mostraAmpliada, false); }}); } function rmPopup() { toggleObjOverlay(0,'popup'); setTimeout("Element.remove('popup');Element.remove('overlay');",600); } function addPopup() { var pageScrool = getPageScroll(); var objBody = document.getElementsByTagName("body").item(0); var objPopup = document.createElement("div"); objPopup.setAttribute('id','popup'); if (arguments[0]) objPopup.className = arguments[0]; objPopup.style.display = 'none'; if (arguments[1]) var topo = arguments[1]; else var topo = 80; objPopup.style.top = (pageScrool[1]+topo) + 'px'; objBody.appendChild(objPopup); } function mostraAmpliada() { Effect.Appear('img_gr',{ duration:0.3}); } /****** CONTATO ******/ function toggleContato(ac) { if (ac == 1) { addOverlay(); addPopup('contato'); toggleObjOverlay(1,'popup'); } else { toggleObjOverlay(0,'popup'); setTimeout("Element.remove('popup');Element.remove('overlay');",600); return false; } var url = "/home/contato/"; var params = ""; var ajax = new Ajax.Request(url, { method: 'post', parameters:params, asynchronous:true, onSuccess:function(t) { var retorno = t.responseText; $('popup').innerHTML = retorno; }}); } function submitForm(id) { if (id == 'frm_contato') { $('bt_enviar').disabled = true; $('bt_enviar').className = "opaca"; 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 = "/home/contato/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) $('erro_envio').innerHTML = decodeText(retorno.err_envio); else $('erro_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 = ""; }}); } } /*** NOTICIAS ***/ function noticiaIntegra(id, el_ativo) { loadingNoticiaIntegra(1); $('entry').className = "opaca"; var params = "id=" + id; var url = "/home/noticia/integraAjax"; var ajax = new Ajax.Request(url, {method:'get', parameters:params, asynchronous:true, onComplete:function(t) { $('entry').innerHTML = t.responseText; ativaIndiceNoticia(el_ativo); $('entry').className = ""; loadingNoticiaIntegra(0); alteraTitle(); //document.title = decodeText(retorno.titulo); }}); } function alteraTitle() { var filhos = $('entry').childNodes; for (var i=0; i < filhos.length; i++) { if (filhos[i].tagName && filhos[i].tagName.search(/h1/i) != -1) var titulo_materia = filhos[i].innerHTML; } var title_page = document.title; if (title_page.search(/ ::: /) == -1) document.title = document.title + " ::: " + titulo_materia; else { var fim = title_page.indexOf(" ::: "); var novo_title = title_page.substr(0,fim); document.title = novo_title + " ::: " + titulo_materia; } } function ativaIndiceNoticia(elemento) { var pai = elemento.parentNode; var avo = pai.parentNode; var netos = avo.childNodes; for (var i=0; i < netos.length; i++) { if (netos[i].firstChild && netos[i].tagName.search(/li/i) != -1) netos[i].firstChild.className = ""; } elemento.className = "ativo"; } function indiceNoticia(ini) { loadingNoticiaIndice(1); $('cont_indice').className = "opaca"; var params = "ini=" + ini + "&id=" + $('id').value; var url = "/home/noticia/indiceAjax"; var ajax = new Ajax.Request(url, {method:'get', parameters:params, asynchronous:true, onComplete:function(t) { var retorno = t.responseText; $('cont_indice').innerHTML = t.responseText; $('cont_indice').className = ""; loadingNoticiaIndice(0); }}); } function loadingNoticiaIntegra(ac) { if (ac == 1) { var objLoadingNot = document.createElement("div"); objLoadingNot.setAttribute('id','loadingNot'); objLoadingNot.className = "loading"; objLoadingNot.style.height = $('materia').offsetHeight + "px"; $('materia').appendChild(objLoadingNot); } else if ($('loadingNot')) Element.remove('loadingNot'); } function loadingNoticiaIndice(ac) { if (ac == 1) { var objLoadingIndice = document.createElement("div"); objLoadingIndice.setAttribute('id','loadingIndice'); objLoadingIndice.className = "loading"; objLoadingIndice.style.height = $('indice').offsetHeight + "px"; $('indice').appendChild(objLoadingIndice); } else if ($('loadingIndice')) Element.remove('loadingIndice'); } /*** FIM NOTICIAS ***/ /****** 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) { hideSelects(); 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 }); setTimeout("showSelects()",600); } } function hideSelects(){ var oSelects=document.getElementsByTagName("select"); for(var i=0;i < oSelects.length;i++) oSelects[i].style.display = "none"; } function showSelects(){ var oSelects=document.getElementsByTagName("select"); for(var i=0;i < oSelects.length;i++) oSelects[i].style.display = "block"; //oSelects[i].className=oSelects[i].className.replace(" hide",""); } /****** FIM OVERLAY ******/ function getPageScroll(){ var yScroll; var xScroll; if (self.pageYOffset) { yScroll = self.pageYOffset; xScroll = self.pageXOffset; } else if (document.documentElement && document.documentElement.scrollTop){ // Explorer 6 Strict yScroll = document.documentElement.scrollTop; xScroll = document.documentElement.scrollLeft; } else if (document.body) {// all other Explorers yScroll = document.body.scrollTop; xScroll = document.body.scrollLeft; } arrayPageScroll = new Array(xScroll,yScroll) return arrayPageScroll; } 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 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; } // url_decode version 1.0 function url_decode(str) { var n, strCode, strDecode = ""; for (n = 0; n < str.length; n++) { if (str.charAt(n) == "%") { strCode = str.charAt(n + 1) + str.charAt(n + 2); strDecode += String.fromCharCode(parseInt(strCode, 16)); n += 2; } else { strDecode += str.charAt(n); } } return strDecode; } function decodeText(txt) { txt = txt.replace(/\+/g," "); return unescape(txt); } 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; } } } }