

var prevID=1;
var currentID=1;
var maxID=10;
var rotate=true;
var secondsDelay=6;
explanationHTML= new Array();
explanationHTML[1]="<p class=\"explainText\"><a href=\"#\" onclick=\"showExp(); return false;\">Explicación de esta pagina</a> | <span style=\"color:#999999;\">Escoder explicación</span> | <a href=\"#\" onclick=\"closeExp(); return false;\">Cerrar esta</a></p><br>";
explanationHTML[2]="<p class=\"explainText\"><span style=\"color:#999999;\">Explicación de esta pagina</span> | <a href=\"#\" onclick=\"hideExp(); return false;\">Escoder explicación</a> | <a href=\"#\" onclick=\"closeExp(); return false;\">Cerrar esta</a><br>Esta página está partida en diez secciones de tamaño reducido para hacerlo más fácil de entender para usted. La página completará un ciclo automáticamente a través de las secciones cada "+ secondsDelay  +" los segundos. Usted puede parar esta automatización pulsando el botón de PAUSA a la derecha. Usted puede también seleccionar cualquier sección particular pulsando los botones relevantes debajo del botón de PAUSA. Para exhibir todo el contenido en una sola ventana, pulse la exhibición todo el botón. Usted puede acelerar o retrasar cómo rápidamente la actualización de las secciones, aunque retraso no cambiará hasta que la sección siguiente ha cargado.</p><br>";
explanationHTML[3]="";
var explIndex=1;

function startRotate(){
	if(rotate){
		thisSlink="swap"+prevID;
		theLink=document.getElementsByName(thisSlink)[0];
		theLink.className="normalSWAP";
		thisSlink="swap"+currentID;
		theLink=document.getElementsByName(thisSlink)[0];
		theLink.className="activeSWAP";
		buildCentreCont(currentID);
		prevID=currentID;
		currentID++;
		if(currentID>maxID){currentID=1;}
		setTimeout("startRotate()",(secondsDelay*1000));
	}
}

function restart(){
	rotate=true;
	startRotate();
	document.getElementById("pausebutton").innerHTML="<a href=\"#\" onclick=\"stopRotate(); return false;\">Parar</a>";
}

function stopRotate(){
	rotate=false;
	document.getElementById("pausebutton").innerHTML="<a href=\"#\" onclick=\"restart(); return false;\">Continuar</a>";
}

function swapCentreCont(targID){
	thisSlink="swap"+prevID;
	theLink=document.getElementsByName(thisSlink)[0];
	theLink.className="normalSWAP";
	prevID=targID;
	currentID=targID;
	thisSlink="swap"+currentID;
	theLink=document.getElementsByName(thisSlink)[0];
	theLink.className="activeSWAP";
	buildCentreCont(targID);
	stopRotate();
}

function buildCentreCont(x){
	theCont=document.getElementById("cont" + x)
	theContHTML=theCont.innerHTML;
	thetargetDiv=document.getElementById("centreContent");
	thetargetDiv.innerHTML=explanationHTML[explIndex] + theContHTML + "<p align=right>Mostrando : <strong>" + currentID + "</strong> de <strong>" + maxID + "</strong></p>";
	
}

function setStyleById(i, p, v) {
	var n = document.getElementById(i);
	n.style[p] = v;
}

function init(){
	for (i = 1; i <= maxID; i++){
		a="cont" + i;
		setStyleById(a, 'display', 'none');
	}
	startRotate();
	displayTimer();
}

function showExp(){
	explIndex=2;
	buildCentreCont(currentID-1);
}
function hideExp(){
	explIndex=1;
	buildCentreCont(currentID-1);
}
function closeExp(){
	explIndex=3;
	buildCentreCont(currentID-1);
}


function displayAll(){
	stopRotate();
	var tempHTML="";
	for(i = 1; i <= maxID; i++){
		a="cont" + i;
		theCont=document.getElementById(a);
		tempHTML+=theCont.innerHTML;
	}
	thetargetDiv=document.getElementById("centreContent");
	thetargetDiv.innerHTML=explanationHTML[explIndex] + tempHTML + "<p>Mostrando todas las secciones</p>";	
}

function displayTimer(){
	var theHTML="<a href=\"#\" onclick=\"goslower(); return false;\">lento</a> | " + secondsDelay + " seg. intervalo | <a href=\"#\" onclick=\"gofaster(); return false;\">rapido</a>";
explanationHTML[2]="<p class=\"explainText\"><span style=\"color:#999999;\">Explicación de esta Pagina</span> | <a href=\"#\" onclick=\"hideExp(); return false;\">Esconder explicación</a> | <a href=\"#\" onclick=\"closeExp(); return false;\">Cerrar esta</a><br>Esta página está partida en once secciones de tamaño reducido para hacerlo más fácil de entender para usted. La página completará un ciclo automáticamente a través de las secciones cada "+ secondsDelay  +" los segundos. Usted puede parar esta automatización pulsando el botón de PAUSA a la derecha. Usted puede también seleccionar cualquier sección particular pulsando los botones relevantes debajo del botón de PAUSA. Para exhibir todo el contenido en una sola ventana, pulse la exhibición todo el botón. Usted puede acelerar o retrasar cómo rápidamente la actualización de las secciones, aunque retraso no cambiará hasta que la sección siguiente ha cargado.</p><br>";
	theSpan=document.getElementById("speedControl");
	theSpan.innerHTML=theHTML;
}

function goslower(){
	secondsDelay++;
	displayTimer();
}

function gofaster(){
	secondsDelay--;
	if(secondsDelay<1){
		secondsDelay=1;
	}
	displayTimer();
}
