// JavaScript Document
function focusInput(defaultText, inputElement) {
	if (inputElement.value==defaultText) {
		inputElement.value = '';
	}
}
function blurInput(defaultText, inputElement) {
	if (inputElement.value.length<1) {
		inputElement.value = defaultText;
	}
}
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);
	alert(_obj);
	var m= inc ? 1.1 : 0.9;
	_obj.width*= m;
	_obj.height*= m;
	return false;
}

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);
}