//ABRE E FECHA SECÇÕES DE CONTEÚDOS (painel de conteúdos)

/*
As secções estão na seguinte estrutura html:
<!--estado fechado-->
<div id="<%=numSec%>1" style="display:block;" onclick="abreSeccao('<%=numSec%>', this, <%=numSecTotal%>)">
  <table >
	<tr>
	<td><img src=""/></td>
	<td>&nbsp;</td>
  </tr>
</table>
</div>
<!--estado aberto-->
<div id="<%=numSec%>2" style="display:none;" onclick="fechaSeccao('<%=numSec%>', this, <%=numSecTotal%>)">
  <table >
	<tr>
	<td><img src=""/></td>
	<td>&nbsp;</td>
  </tr>
</table>
</div>

do que resulta que as secções estão numeradas nos seus id (tag div) por:

11
12
21
22
31
32
etc...
sendo o primeiro dígito o número da secção e o segundo indica se é o estado aberto ou fechado.
*/


function abreSeccao(seccao, origem, total){
	
		origem.style.display="none";
		seccao=String(seccao);
		var oSec=document.getElementById(seccao+'2');
		oSec.style.display="block";
		var i;
		for(i=1; i<=total; i++){
			var j=i;
			j=String(j);
			var oSec2=document.getElementById(j+'2');
			if (oSec2==oSec){
				continue;	
			}else{
				oSec2.style.display="none";
			}
			
		}
		for(i=1; i<=total; i++){
			var j=i;
			j=String(j);
			var oSec3=document.getElementById(j+'1');
			if (oSec3==origem){
				continue;	
			}else{
				oSec3.style.display="block";
			}
		}
	
}

function abreNoticia(seccao, total){
	
		
		seccao=String(seccao);
		var oSec=document.getElementById(seccao+'2');
		oSec.style.display="block";
		var i;
		for(i=1; i<=total; i++){
			var j=i;
			j=String(j);
			var oSec2=document.getElementById(j+'2');
			if (oSec2==oSec){
				continue;	
			}else{
				oSec2.style.display="none";
			}
			
		}
		
	
}
/*
function fechaSeccao(seccao, origem, total){
		origem.style.display="none";
		seccao=String(seccao);
		var oSec=document.getElementById(seccao+'1');
		oSec.style.display="block";
	
}
*/


function abreConteudo(origem, total){
	
		
		var oSec=document.getElementById(origem);
		oSec.style.display="block";
		var i;
		for(i=1; i<=total; i++){
			var j=i;
			j=String(j);
			var oSec2=document.getElementById(j);
			if (oSec2==oSec){
				continue;	
			}else{
				oSec2.style.display="none";
			}
			
		}
	
}

//não usada
function hidemenu(sm) {
    var nr = submenus[sm].getElementsByTagName("a").length*bypixels;
    submenus[sm].style.height = (parseInt(submenus[sm].style.height)-nr)+"px";
    var to = setTimeout("hidemenu("+sm+")", 30);
    if(parseInt(submenus[sm].style.height) <= nr) {
        clearTimeout(to);
        submenus[sm].style.display = "none";
        submenus[sm].style.height = "0px";
        //arrows[sm].src = "slashfiles/collapsed.gif";
        titles[sm].className = "titlehidden";
    }
}

//=============================================================================================
var galeriaLeftDesloc=445;
var galeriaRightDesloc=0;
var desloc=15;
var galeriaLeftDeslocClube=450;
function deslizaImagens(origem, direccao, quantidade, largura){

	var oSec=document.getElementById(origem);
	var pos=oSec.style.left.replace("px","");
	if (direccao=="esquerda"){
		var poslimite=210-(quantidade-1.7)*largura;
		if (pos > poslimite){
		var pos2=Number(pos)-desloc;
		oSec.style.left=pos2+"px";	
		galeriaLeftDesloc+=desloc;
		galeriaRightDesloc+=desloc;
		oSec.style.clip = "rect(0px,"+ galeriaLeftDesloc +"px,180px,"+ galeriaRightDesloc +"px)";
		//document.getElementById("galeria_parent").innerHTML="//"+galeriaLeftDesloc;
		}
	}else{
		if (pos<210){
			var pos3=Number(pos)+desloc;
			oSec.style.left=pos3+"px";	
			galeriaLeftDesloc-=desloc;
			galeriaRightDesloc-=desloc;
			oSec.style.clip = "rect(0px,"+ galeriaLeftDesloc +"px,180px,"+ galeriaRightDesloc +"px)";
		}
		
	}
}

function deslizaImagensClube(origem, direccao, quantidade, largura){

	var oSec=document.getElementById(origem);
	var pos=oSec.style.left.replace("px","");
	if (direccao=="esquerda"){
		var poslimite=207-(quantidade)*largura+450;
		if (pos > poslimite){
		var pos2=Number(pos)-desloc;
		oSec.style.left=pos2+"px";	
		galeriaLeftDeslocClube+=desloc;
		galeriaRightDesloc+=desloc;
		oSec.style.clip = "rect(0px,"+ galeriaLeftDeslocClube +"px,180px,"+ galeriaRightDesloc +"px)";
		//document.getElementById("galeria_parent").innerHTML="//"+galeriaLeftDesloc;
		}
	}else{
		if (pos<207){
			var pos3=Number(pos)+desloc;
			oSec.style.left=pos3+"px";	
			galeriaLeftDeslocClube-=desloc;
			galeriaRightDesloc-=desloc;
			oSec.style.clip = "rect(0px,"+ galeriaLeftDeslocClube +"px,180px,"+ galeriaRightDesloc +"px)";
		}
		
	}
}

function gereIntervaloImagens(origem, overout, direccao, quantidade, largura, pagina){
	
	if (overout=="over") {
		if (pagina=="clube"){
		
			refIntervalo=setInterval("deslizaImagensClube('"+ origem +"', '" + direccao +"', "+ quantidade +", "+ largura +")", 100);
		}
		else{
		
			refIntervalo=setInterval("deslizaImagens('"+ origem +"', '" + direccao +"', "+ quantidade +", "+ largura +")", 100);
		}
	}else{
		clearInterval(refIntervalo);
		
	}
	
}

function clubeMostraUtilizador(texto,idfoto){
	var oSec=document.getElementById('nomeUtilizador');
	var oSecValue=document.getElementById('idFoto');
	oSec.innerHTML='&nbsp;<br/>'+texto;
	oSecValue.setAttribute('value',idfoto);
	
}

function clubeEnviaFoto(total,idfoto,contador){
	
	var oSecValue=document.getElementById('idFoto');
	var oSec=document.getElementById(contador);
	oSec.className="imagemClube";
	
	for (i=1;i<=total; i++){
		var oSec2=document.getElementById(i);
		if(i!=contador){
			oSec2.className="imagemClubeSel";
		}
	}
	oSecValue.setAttribute('value',idfoto);
	
	
	
}
function clubeEscolheFoto(total,idfoto,contador){
	
	var oSecValue=document.getElementById('idFoto');
	var oSec=document.getElementById('img'+contador);
	oSec.className="imagemClubeSel";
	
	for (i=1;i<=total; i++){
		var oSec2=document.getElementById('img'+i);
		if(i!=contador){
			oSec2.className="imagemClube";
		}
	}
	
	
	
	
}

//==========================================================================

//-------------------------------------------------------------------------------------
//	ANIMAÇÃO DAS NOTICIAS ESCORRIDAS

//window.onload=deslizaNoticias("noticias", 0);

//cria a referencia de um qualquer objecto dependendo do browser (IE ou Firefox)
function detectaObjecto( objecto ) {
  var sObjecto
  if ( document.all ) {
    sObjecto = document.all.item( obj );
  } else if ( document.getElementById ) {
    sObjecto = document.getElementById( obj );
  }
  return sObjecto;
}

//variáveis usadas nas notícias (scrolling)
//idênticas às propriedades do #noticias (css)
var theTop = 20;
var theHeight = 100;
var theWidth = 150;
var theLeft = 650;
var toClip = 55;

function deslizaNoticias( divnoticias, desloc ) {
	secNoticias = detectaObjecto( divnoticias.toString() );
	secNoticias = secNoticias.style;
	//corrige o clipping do div das noticias
	secNoticias.clip = "rect(" + topo + "px " + (theWidth + theLeft) + "px " + (topo + toClip) + "px 0px)";
	//desloca o div das noticias na vertical
	secNoticias.top = topo - desloc + 'px';
	 
	//incrementa e repete a função, criando a animação no tempo
	desloc = (desloc + 1);
	setTimeout("deslizaNoticias('" + divnoticias + "'," + desloc + ")", 100);
	
	//verifica se chegou ao fim da extensão do div, e reposiciona em baixo:
	if ( ( theTop + theHeight - desloc ) < ( theTop - theHeight - 20 ) ) {
		desloc = 0;
		secNoticias.clip = "rect(" + desloc + "px " + (theWidth + theLeft) + "px " + (secNoticias + toClip) + "px 0px)";
		secNoticias.top = topo + 'px';
    }

}
	
