function m(str, is_binary)
{
	var result = "";
	var i = 0;
	var x;
	var shiftreg = 0;
	var count = -1;

	for (i=0; i < str.length; i++) {
		c = str.charAt(i);
		if ('A' <= c && c <= 'Z')
			x = str.charCodeAt(i) - 65;
		else if ('a' <= c && c <= 'z')
			x = str.charCodeAt(i) - 97 + 26;
		else if ('0' <= c && c <= '9')
			x = str.charCodeAt(i) - 48 + 52;
		else if (c == '+')
			x = 62;
		else if (c == '/')
			x = 63;
		else
			continue;
		count++;
		switch (count % 4)
		{
			case 0:
				shiftreg = x;
				continue;
			case 1:
				v = (shiftreg<<2) | (x >> 4);
				shiftreg = x & 0x0F;
				break;
			case 2:
				v = (shiftreg<<4) | (x >> 2);
				shiftreg = x & 0x03;
				break;
			case 3:
				v = (shiftreg<<6) | (x >> 0);
				shiftreg = x & 0x00;
				break;
		}
		if (!is_binary && (v < 32 || v > 126) && (v != 0x0d) && (v != 0x0a)) {
			result = result + "<";
			result = result + "0123456789ABCDEF".charAt((v/16)&0x0F);
			result = result + "0123456789ABCDEF".charAt((v/1)&0x0F);
			result = result + ">";
		} else
			result = result + String.fromCharCode(v);
	}
	return result.toString();
}
function e(id)
{
	return document.getElementById(id);
}
// uso: test_browser("msie")
function test_browser(br)
{
	return(navigator.userAgent.toLowerCase().indexOf(br) + 1);
}
function do_zoom(obj, inc)
{
	if (!test_browser('msie')) {
		alert('Este navegador no permite esta opcion, puedes agrandar el juego clickeando en pantalla completa.');
		return false;
	}
	var _obj= e(obj);
	var m= inc ? 1.1 : 0.9;
	_obj.width*= m;
	_obj.height*= m;
	return true;
}

var voto_cont_id;
function vota_juego(id_cont, id_juego, voto)
{
	e(id_cont + '1').style.display= 'none';
	e(id_cont + '2').style.display= 'inline';
	voto_cont_id= id_cont;
	snd_req('/rvoto.php?i=' + id_juego + '&v=' + voto, voto_procesado);
}
function voto_procesado(req)
{
	e(voto_cont_id + '2').style.display= 'none';
	if (req == 'OK')
		e(voto_cont_id + '3').style.display= 'inline';
	else
		e(voto_cont_id + '4').style.display= 'inline';
}
function agrega_favorito(juego)
{
	snd_req('/rfavoritos.php?a&i=' + juego, favorito_agregado);
}
function favorito_agregado(req)
{
	if (req == 'AL') {
		alert('El juego ya estaba agregado en tu lista de juegos favoritos.');
	} else {
		alert('El juego se ha agregado a tu lista de favoritos !');
	}
}
function comentarios(juego, pagina)
{
	var c= e('cont_comentarios');
	opacidad(c, 0.5);
	snd_req('/comentarios.php?id=' + juego + '&p=' + pagina, carga_comentarios);
}
function carga_comentarios(req)
{
	var c= e('cont_comentarios');
	c.innerHTML= req;
	opacidad(c, 1);
}