var TVLib=window.TVLib||{};TVLib.rotativoDeChamadas={painel:null,itens:null,botoes:null,botoesTxts:{next:"proximo",prev:"anterior",stop:"parar",play:"executar"},botaoRef:"",ativado:0,anterior:0,proximo:0,navMSIE:!!navigator.userAgent.match(/MSIE/g),timeOut:null,timer:6,animando:false,banner:document.createElement("div"),showBanner:false,contaTrocas:0,init:function(A){this.painel=document.getElementById(A["id"]);this.timer=A["timer"]||this.timer;this.botaoRef=A["botaoRef"]||this.botaoRef;this.botoesTxts=A["botoesTxts"]||this.botoesTxts;if(typeof mostrabanner=="undefined"){mostrabanner=0}this.showBanner=showBanner=(document.cookie.indexOf("rotativoDeChamadasNoBanner=1")==-1)?true:false;this.itens=this.painel.getElementsByTagName("li");this.setNavegacao(this.ativado);this.aplicarSombras();if(this.itens.length==1){A["startOff"]=true}else{this.montarBotoes()}if(document.cookie.indexOf("rotativoDeChamadasStop=1")!=-1){A["startOff"]=true}if(!A["startOff"]){this.stopPlay()}else{this.setBtStopPlay("play")}},events:{preventDefault:function(A){if(A.preventDefault){A.preventDefault()}else{A.returnValue=false}},add:function(C,B,A){if(document.attachEvent){C.attachEvent("on"+B,A)}else{if(document.addEventListener){C.addEventListener(B,A,true)}}}},stopPlay:function(A){if((!A&&this.timeOut==null)||(A&&this.timeOut!=null)){clearInterval(this.timeOut);this.timeOut=setInterval(function(){TVLib.rotativoDeChamadas.navegar(1)},TVLib.rotativoDeChamadas.timer*1000);document.cookie="rotativoDeChamadasStop=0; path=/";this.setBtStopPlay("stop")}else{document.cookie="rotativoDeChamadasStop=1; path=/";clearInterval(this.timeOut);this.timeOut=null;this.setBtStopPlay("play")}},setBtStopPlay:function(A){if(this.botoes!=null){var B=this.botoes.getElementsByTagName("a")[1];B.className="bt"+A;B.innerHTML=this.botoesTxts[A]}},setNavegacao:function(A){this.ativado=(parseInt(A)+(this.ativado||this.itens.length))%this.itens.length;this.anterior=((this.ativado||this.itens.length)-1)%this.itens.length;this.proximo=((this.ativado||this.itens.length)+1)%this.itens.length},fadeIO:function(B,D,C){if(D){B.style.opacity=0;B.style.filter="Alpha(Opacity=0)"}else{B.style.opacity=1;B.style.filter="Alpha(Opacity=100)"}TVLib.rotativoDeChamadas.animando=true;for(var A=1;A<=5;A++){setTimeout(function(E){return function(){if(TVLib.rotativoDeChamadas.navMSIE){B.style.filter="Alpha(Opacity="+(D?20*E:100-20*E)+")"}else{B.style.opacity=(D?0.2*E:1-0.2*E)}if(E==5){TVLib.rotativoDeChamadas.animando=false;if(TVLib.rotativoDeChamadas.navMSIE){B.style.filter="none"}if(typeof C=="function"){C()}}}}(A),75*A)}},fecharBanner:function(){document.cookie="rotativoDeChamadasNoBanner=1; path=/";this.showBanner=false;clearTimeout(TVLib.rotativoDeChamadas.bannerFadeOutTimer);this.bannerFadeOut()},bannerFadeOut:function(){this.fadeIO(this.banner,false,function(){TVLib.rotativoDeChamadas.banner.style.display="none";TVLib.rotativoDeChamadas.botoes.style.display="block"});this.fadeIO(this.botoes,true,null)},navegar:function(B){var A=this.ativado;this.removerBanner=false;this.contaTrocas++;if(mostrabanner==1&&this.showBanner&&this.contaTrocas>0&&this.contaTrocas%this.itens.length==0){this.banner.style.display="block";this.fadeIO(this.banner,true,function(){TVLib.rotativoDeChamadas.botoes.style.display="none"});this.fadeIO(this.botoes,false,null);if(this.timeOut!=null){TVLib.rotativoDeChamadas.bannerFadeOutTimer=setTimeout(function(){TVLib.rotativoDeChamadas.bannerFadeOut()},TVLib.rotativoDeChamadas.timer*1000)}}else{this.setNavegacao(B);this.itens[this.ativado].className=this.itens[this.ativado].className.replace(/desativado/g,"");this.itens[this.ativado].style.zIndex=3;this.fadeIO(this.itens[this.ativado],true,function(){TVLib.rotativoDeChamadas.itens[A].className="desativado"},true);this.itens[A].style.zIndex=2;this.writeBotoesHTML();if(this.timeOut==null){this.setBtStopPlay("play")}else{this.setBtStopPlay("stop")}}},montarBotoes:function(){this.botoes=document.createElement("div");this.botoes.className="botoesNavegacao";this.writeBotoesHTML();this.painel.appendChild(this.botoes)},aplicarSombras:function(){var B=document.createElement("div");B.className="sombra";for(var A=0;A<this.itens.length;A++){if(A>0){this.itens[A].className+=" desativado"}this.itens[A].appendChild(B.cloneNode(true))}},writeBotoesHTML:function(){this.botoes.innerHTML="<a rel='-1' href='"+this.itens[this.anterior].getElementsByTagName("a")[0].href+"' class='anterior' name='"+this.botaoRef+"'>"+this.botoesTxts.prev+"</a>      <a rel='0' href='"+this.itens[this.ativado].getElementsByTagName("a")[0].href+"' class='' name='"+this.botaoRef+"'></a>      <a rel='+1' href='"+this.itens[this.proximo].getElementsByTagName("a")[0].href+"' class='proximo' name='"+this.botaoRef+"'>"+this.botoesTxts.next+"</a>";var B=this.botoes.getElementsByTagName("a");for(var A=0;A<B.length;A++){this.events.add(B[A],"click",function(C){TVLib.rotativoDeChamadas.events.preventDefault(C);if(C.srcElement){C.target=C.srcElement}if(C.target.rel==0){TVLib.rotativoDeChamadas.stopPlay()}else{if(TVLib.rotativoDeChamadas.animando==false){TVLib.rotativoDeChamadas.navegar(C.target.rel);TVLib.rotativoDeChamadas.stopPlay(true)}}})}}}
