// JavaScript Document
var apuntadorZ=0;
var rotadorNoticias;
var notasEnVista = new Array("a","b","c");
var apuntadorY=0;
var cicloNoticias=0;
var tiempoDeCambio=5000;//5000



function establecer(){
	rotadorNoticias = setInterval('rotarNoticias();',tiempoDeCambio);
	}




function mostrar(que,enClick){
	cuantos=totalNoticias;
	clearInterval(rotadorNoticias);
	if(enClick){rotadorNoticias = setInterval("rotarNoticias();",15000);
		}
	else{rotadorNoticias = setInterval("rotarNoticias();",tiempoDeCambio);}
	
	ocultarTodo(cuantos,false);
	window.document.getElementById(que).style.display='block';
	window.document.getElementById(que+""+(que.charCodeAt(0)-97)).style.display='block';
	window.document.getElementById(que+""+(que.charCodeAt(0)-97)+""+(que.charCodeAt(0)-97)).className="post";
	//alert("for "+notasEnVista+" ("+que+")");
	for(i=0; i<3; i++){
		if(notasEnVista[i]==que){apuntadorY=i;}//alert("yes: "+i+", "+notasEnVista[i]+" "+que);}
		}
	}




function rotarNoticias(){
	apuntadorY++; 
	cicloNoticias++;
	if(cicloNoticias >= 3){
		cargarDeAdel(false);
		cicloNoticias=0;
	}
	//alert("out: "+notasEnVista[0]+" "+notasEnVista[1]+" "+notasEnVista[2]);
	if(apuntadorY >= totalNoticias){apuntadorY=0;}
	//alert(notasEnVista[cicloNoticias]+"("+cicloNoticias+")");
	mostrar(notasEnVista[cicloNoticias],false);
	}




function cargarDeAdel(enClick){
	if(enClick){
		cicloNoticias=0;
		clearInterval(rotadorNoticias);
		rotadorNoticias = setInterval("rotarNoticias();",tiempoDeCambio);
		}
	cuantos=totalNoticias;
	ocultarTodo(cuantos,true);
	rotarApuntadorMas(cuantos,3);
	for(i=0; i<3; i++){//alert(i+":"+notasEnVista[0]+" "+notasEnVista[1]+" "+notasEnVista[2]);
		notasEnVista[i]= String.fromCharCode(apuntadorZ+97);//linea agregada
		identificador = String.fromCharCode(apuntadorZ+97);
		window.document.getElementById(identificador+""+apuntadorZ+""+apuntadorZ).style.display='block';
		switch(i){
			case 0: 
				window.document.getElementById(identificador+""+apuntadorZ+""+apuntadorZ).className="post";//titulo
				window.document.getElementById(identificador+""+apuntadorZ+""+apuntadorZ).style.left="15px";
				window.document.getElementById(identificador+""+apuntadorZ).style.display='block';//fecha
				window.document.getElementById(identificador).style.display='block';//info
				break;
			case 1: 
				window.document.getElementById(identificador+""+apuntadorZ+""+apuntadorZ).style.left="210px";
				break;
			case 2: 
				window.document.getElementById(identificador+""+apuntadorZ+""+apuntadorZ).style.left="405px";
				break;
			}
		rotarApuntadorMas(cuantos,1);
		}
	rotarApuntadorMenos(cuantos,3);
	//alert("out: "+notasEnVista[0]+" "+notasEnVista[1]+" "+notasEnVista[2]);
	}
	
	
	
function cargarDeAtraz(enClick){
	if(enClick){
		cicloNoticias=0;
		clearInterval(rotadorNoticias);
		rotadorNoticias = setInterval("rotarNoticias();",tiempoDeCambio);
		}
	cuantos=totalNoticias;
	ocultarTodo(cuantos,true);
	rotarApuntadorMenos(cuantos,3);
	for(i=0; i<3; i++){
		notasEnVista[i]= String.fromCharCode(apuntadorZ+97);//linea agregada
		identificador = String.fromCharCode(apuntadorZ+97);
		window.document.getElementById(identificador+""+apuntadorZ+""+apuntadorZ).style.display='block';
		switch(i){
			case 0: 
				window.document.getElementById(identificador+""+apuntadorZ+""+apuntadorZ).className="post";//titulo
				window.document.getElementById(identificador+""+apuntadorZ+""+apuntadorZ).style.left="15px";
				window.document.getElementById(identificador+""+apuntadorZ).style.display='block';//fecha
				window.document.getElementById(identificador).style.display='block';//info
				break;
			case 1: 
				window.document.getElementById(identificador+""+apuntadorZ+""+apuntadorZ).style.left="210px";
				break;
			case 2: 
				window.document.getElementById(identificador+""+apuntadorZ+""+apuntadorZ).style.left="405px";
				break;
			}
		rotarApuntadorMas(cuantos,1);
		}
	rotarApuntadorMenos(cuantos,3);
	}

	

function ocultarTodo(cuantos, ocultaTitulos){
	for(j=0; j<cuantos; j++){
		identificador=String.fromCharCode(j+97);
		window.document.getElementById(identificador).style.display='none';//fecha
		window.document.getElementById(identificador+""+j).style.display='none';//informacion
		window.document.getElementById(identificador+""+j+""+j).className="post1";//titulo
		if(ocultaTitulos){
			window.document.getElementById(identificador+""+j+""+j).style.display="none";//titulo
			}
		}
	}




function rotarApuntadorMas(cuantos, hasta){
		for(k=0; k<hasta; k++){
		apuntadorZ++;
		if(apuntadorZ >= cuantos){
			apuntadorZ = 0;
			}
		}
	}
	
	
	
function rotarApuntadorMenos(cuantos,hasta){
	for(k=0; k<hasta; k++){
		apuntadorZ--;
		if(apuntadorZ < 0){
			apuntadorZ = cuantos-1;
			}
		}
	}