var count = 0;
var intervalo;

selecionaDestaque = function(num){

	count = num;

	var itens = $$('#destaque_foto li');
	var numeros = $$('#numeros li');
	var cc1 = 0;
	var cc2 = 0;
	
	//Loop nos itens para ocultar e exibir o selecionado
	itens.each(function(el) {
		
		if(cc1 != num){
			el.style.display = 'none';
			
		} else {
		
			if(el.style.display != ''){
				el.style.display = '';
			
				//Efeito alpha
				var fx = new Fx.Styles(el, {duration:3000, wait:false, transition: Fx.Transitions.Quad.easeOut});
				fx.start({'opacity': [0,1] });
			}
		}
		
		cc1++;
	});
	
	//Loop nos números para marcar o selecionado
	numeros.each(function(el) {
		if(cc2 != num){
			$E('a',el).className = '';
		} else {
			$E('a',el).className = 'ativo';
		}
		
		cc2++;
	});
	
	//Incrementa o contador
	count++;
	
	//Se chegou ao fim, volta ao início da contagem
	if(count == itens.length){
		count = 0;
	}
	
	//Limpa o intervalo
	$clear(intervalo);
	
	//Intervalo para próxima imagem
	intervalo = selecionaDestaque.delay(10000, this, [count]);

};

window.addEvent('domready', function(){
										$('destaque_foto').style.display = 'block';
										selecionaDestaque(count);
									});


function changeMaisTabs(clicked, tab){
	var itens = $$('#lidas_comentadas ul');
	var bts = $$('#botoes_lidas_comentadas a');
	
	bts.each(function(el) {
		el.className = '';
	});
	
	//Loop nos itens para ocultar e exibir o selecionado
	itens.each(function(el) {
		if(el.getAttribute("id") == tab){
			el.style.display = 'block';
			
		} else {
			el.style.display = 'none';
		}
	});
	
	clicked.className = 'mais_ativa';
}

function contarCaracteres(entrada, saida, texto, chars) {
var entradaObj = $(entrada); var saidaObj = $(saida);
var tam = chars - entradaObj.value.length;
if(tam <= 0) { tam = 0;
texto = '<span class="disable"> '+texto+' </span>';
entradaObj.value = entradaObj.value.substr(0,chars); }
saidaObj.innerHTML = texto.replace("{CHAR}",tam);
}

function fechaZoom(){
	$('pop-dimmer').style.visibility = 'hidden';
	$('fotoBox').style.visibility = 'hidden';
}

function zoomText(acao,el){
obj=$(el);	
if (obj.style.fontSize=="")	obj.style.fontSize="13px";
atual=parseInt(obj.style.fontSize);
inc=2; maxVal = 19; minVal = 9;
if(acao=="reestablecer"){ obj.style.fontSize="1em" }	
if(acao=="aumentar"){ val=atual+inc; if(val <= maxVal) obj.style.fontSize=val+"px" }	
if(acao=="diminuir"){ val=atual-inc; if(val >= minVal) obj.style.fontSize=val+"px"; }
} 

function GeraSWF(arquivo,largura,altura,id,transp){
var incTransp = '';
document.writeln('<object align="middle" id="globalnav-object" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+largura+'" height="'+altura+'" id="'+id+'" name="'+id+'">');
if(transp == "yes"){ document.writeln('<param name="wmode" value="transparent" />'); incTransp = 'wmode="transparent"'; }
document.writeln('<param name="allowScriptAccess" value="always" />');
document.writeln('<param name="quality" value="high" />');
document.writeln('<param name="scaleMode" value="noScale" />');
document.writeln('<param name="menu" value="false" />');
document.writeln('<param name="movie" value="'+arquivo+'" />');
document.writeln('<embed id="globalnav-embed" src="'+arquivo+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="loc=en_US&htmlApp=false&gatewayURL=gwurl" menu="false" align="middle" quality="high" allowscriptacess="always" scale="noscale" id="'+id+'" width="'+largura+'" height="'+altura+'" '+incTransp+'></embed>');
document.writeln('</object>');
}

function hideLayer(obj, timeOut){ setTimeout("showHideLayers('"+obj+"','','hide')", timeOut); }

var flg1 = true; var flg2 = true; var txtorig1; var txtorig2;

function inn(txt,i) {
if (eval('flg'+i)){ eval('txtorig'+i+'=txt.value;'); eval('flg'+i+'=false;');}	
if (txt.value == eval('txtorig'+i)) txt.value = '';
}

function out(txt,i) { if (txt.value == '') txt.value = eval('txtorig'+i); }

function newWindow(mypage, w, h, scroll) {
var winl = (screen.width - w) / 2; var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',status=yes, resizable';
win = window.open(mypage, '', winprops);
if (parseInt(navigator.appVersion) >= 4) win.window.focus();
}

function MM_changeProp(objName,x,theProp,theValue) {
var obj = MM_findObj(objName);
if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
if (theValue == true || theValue == false) eval("obj."+theProp+"="+theValue);
else eval("obj."+theProp+"='"+theValue+"'");}
}

function MM_findObj(n, d) {
var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_jumpMenu(targ,selObj,restore){
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}

function showHideLayers() {
var i,p,v,obj,args=showHideLayers.arguments;
for (i=0; i<(args.length-2); i+=3) 
if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v}
obj.visibility=v;}
}