<!--

// Copyright 2008 por luis_adolfo (webmaster de Zona Ocio)
// Este script fue hecho especialmente para el CMS del mismo nombre.
// Se prohibe su reproducción parcial o total, sin permiso previo.

i    = 1;
last = 0;

usuario  = [];
avatar   = [];
mensajes = [];
precarga = [];
ordinal  =
[
	'er',
	'do',
	'er',
	'to',
	'to',
	'to',
	'mo',
	'vo',
	'no',
	'mo'
]

function init_posters()
{
	lugar = [];
	var posix = 0;

	for (j = 0; j < usuario.length; j++)
	{
		lugar[j] = posix;

		if (mensajes[j] > mensajes[j+1])
		{
			posix++;
		}
	}

	for (j = 0; j < avatar.length; j++)
	{
		precarga[j] = new Image();
		precarga[j].src = avatar[j];
	}

	top_posters(0);
}

function top_posters(i)
{
	if (i >= 0 && (i == undefined || usuario[i] == undefined))
	{
		i = 0;
	}
	else if (i < 0)
	{
		i = usuario.length - 1;
	}

	var img_izq = document.createElement('img');
	img_izq.setAttribute('src', 'themes/'+theme['nombre']+'/imagenes/top_posters/anterior.gif');
	img_izq.onclick = function () { set_posters(i-1); }

	var img_der = document.createElement('img');
	img_der.setAttribute('src', 'themes/'+theme['nombre']+'/imagenes/top_posters/siguiente.gif');
	img_der.onclick = function () { set_posters(i+1); }

	var div_izq = document.createElement('div');
	div_izq.appendChild(img_izq);
	div_izq.className = 'atras';

	var div_der = document.createElement('div');
	div_der.appendChild(img_der);
	div_der.className = 'adelante';

	var nivel = document.createElement('div');
	nivel.appendChild(document.createTextNode((lugar[i]+1)+get_ord(lugar[i])+'. lugar'));
	nivel.className = 'nivel';

	var nav = document.createElement('div');
	nav.appendChild(div_izq);
	nav.appendChild(nivel);
	nav.appendChild(div_der);
	nav.className = 'datos';

	var linea = document.createElement('hr');

	var imagen = document.createElement('img');
	imagen.setAttribute('src', avatar[i]);
	imagen.className = 'avatar';

	var posts = document.createElement('div');
	posts.appendChild(document.createTextNode(mensajes[i]+' mensajes'));

	var nick = document.createElement('div');
	nick.appendChild(document.createTextNode(usuario[i]));

	var info = document.getElementById('poster');

	while(info.firstChild)
	{
		info.removeChild(info.firstChild);
	}

	info.appendChild(nav);
	info.appendChild(linea);
	info.appendChild(nick);
	info.appendChild(imagen);
	info.appendChild(posts);

	if (last > 0)
	{
		document.getElementById('lugar_'+last).className = '';
	}

	document.getElementById('lugar_'+(i+1)).className = 'actual';

	ciclo = setTimeout('top_posters('+(i+1)+')', 3000);

	last = i+1;
}

function set_posters(i)
{
	clearTimeout(ciclo);

	top_posters(i);
}

function get_ord(i)
{
	if (i > 9)
	{
		var i = i+'';
		var x = i.charAt(i.length - 1);
	}
	else
	{
		var x = i;
	}

	return ordinal[x];
}

window.onload = init_posters;

//-->