
var pos = 0;
var g_fPlayMode = 1;
var runner;
var pos_mapas = 0;
var g_fPlayMode_mapas = 1;
var runner_mapas;

function home_next()
{
	Stop();
	if( pos + 1 < total )
	{
		document.getElementById("nota_" + pos ).style.display = "none";
		document.getElementById("nota_" + (pos+1) ).style.display = "block";
		pos++;
	}
	else
	{
		document.getElementById("nota_" + (total-1) ).style.display = "none";
		document.getElementById("nota_0").style.display = "block";
		pos = 0;
	}
}

function home_prev()
{
	Stop();
	if( pos-1 < 0)
	{
		document.getElementById("nota_" + (total-1) ).style.display = "block";
		document.getElementById("nota_0").style.display = "none";
		pos = total-1;
	}
	else
	{
		document.getElementById("nota_" + pos ).style.display = "none";
		document.getElementById("nota_" + (pos-1) ).style.display = "block";
		pos--;
	}
}

function control(how)
{
	if (how=="A") Stop();
	if (how=="P") Play();
	if (how=="F") home_next();
	if (how=="B") home_prev();
}

function Play()
{
	g_fPlayMode = 1;
	runner=setInterval("Tick()", g_dwTimeOutSec*2000);
}

function Stop() {
	g_fPlayMode = 0;
	clearInterval(runner);
}

function Tick(total)
{
	if (g_fPlayMode) control("F");
}

function OnImgLoad(total)
{
	if (g_fPlayMode)
	runner=setInterval("Tick()", g_dwTimeOutSec*2000);
}

function home_next_mapas()
{
	Stop_mapas();
	if( pos_mapas + 1 < total_mapas )
	{
		document.getElementById("mapa_" + pos_mapas ).style.display = "none";
		document.getElementById("mapa_" + (pos_mapas+1) ).style.display = "block";
		pos_mapas++;
	}
	else
	{
		document.getElementById("mapa_" + (total_mapas-1) ).style.display = "none";
		document.getElementById("mapa_0").style.display = "block";
		pos_mapas = 0;
	}
}

function home_prev_mapas()
{
	Stop_mapas();
	if( pos_mapas-1 < 0)
	{
		document.getElementById("mapa_" + (total_mapas-1) ).style.display = "block";
		document.getElementById("mapa_0").style.display = "none";
		pos_mapas = total_mapas-1;
	}
	else
	{
		document.getElementById("mapa_" + pos_mapas ).style.display = "none";
		document.getElementById("mapa_" + (pos_mapas-1) ).style.display = "block";
		pos_mapas--;
	}
}

function control_mapas(how)
{
	if (how=="A") Stop_mapas();
	if (how=="P") Play_mapas();
	if (how=="F") home_next_mapas();
	if (how=="B") home_prev_mapas();
}

function Play_mapas()
{
	g_fPlayMode_mapas = 1;
	runner_mapas=setInterval("Tick_mapas()", g_dwTimeOutSec*2000);
}

function Stop_mapas() {
	g_fPlayMode_mapas = 0;
	clearInterval(runner_mapas);
}

function Tick_mapas(total_mapas)
{
	if (g_fPlayMode_mapas) control_mapas("F");
}

function OnImgLoad_mapas(total_mapas)
{
	if (g_fPlayMode_mapas)
	runner_mapas=setInterval("Tick_mapas()", g_dwTimeOutSec*2000);
}

function openCalendar()
{
	myRef=window.open("agenda.php","Calendario","width=720,height=600,scrollbars=yes"); 	
}

function openActividad(id)
{
	document.location.href = "actividad.php?id=" + id;
}

function abrir(id)
{	
	if(id > 0)
		myRef=window.open("foro/viewforum.php?f=" + id,"Foros","width=840,height=650,scrollbars=yes"); 	
	else
		myRef=window.open("foro/index.php","Foros","width=840,height=650,scrollbars=yes"); 	
}

function abrir_topic(id)
{	
	if(id > 0)
		myRef=window.open("foro/viewtopic.php?t=" + id,"Foros","width=840,height=650,scrollbars=yes"); 	
	else
		myRef=window.open("foro/index.php","Foros","width=840,height=650,scrollbars=yes"); 	
}

