function Relacionado(rel) {
	if (rel != "--"){
		this.location="juegos-buscar-"+rel+".html";
	}
}
/*function Mostrar(id){
	var i;
	for(i=1;i<=5;i++){
		if (i == id){
			//alert("Mostrar"+i);
			$(document).ready(function() {
				$("#ult"+i).removeClass("oculto");
			});
		} else {
			//alert("Ocultar"+i);
			$(document).ready(function() {
				$("#ult"+i).addClass("oculto");
			});
		}
	}
	setTimeout("Mostrar_desp("+id+")",0);
}*/
function Mostrar(id,continuo){
	var i;
	for(i=1;i<=5;i++){
		if (i == id){
			//alert("Mostrar"+i);
			$(document).ready(function() {
				$("#ult"+i).removeClass("oculto");
			});
		} else {
			//alert("Ocultar"+i);
			$(document).ready(function() {
				$("#ult"+i).addClass("oculto");
			});
		}
	}
	if (continuo == 1) {
		if (id == 5) {
			id = 1;
		} else {		
			id = id+1;
		}
		idfunc = setTimeout("Mostrar("+id+",1)",2000); 
	} else {
		clearTimeout(idfunc);
	}
}
function nuevoAjax()
{
	/* Crea el objeto AJAX. Esta funcion es generica para cualquier utilidad de este tipo, por
	lo que se puede copiar tal como esta aqui */
	var xmlhttp=false; 
	try 
	{ 
		// Creacion del objeto AJAX para navegadores no IE
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
	}
	catch(e)
	{
		try
		{ 
			// Creacion del objet AJAX para IE 
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
		} 
		catch(E) { xmlhttp=false; }
	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp=new XMLHttpRequest(); } 

	return xmlhttp; 
}
function Votar(id)
{
		combo=document.getElementById("select-votar");
		ajax=nuevoAjax();
		ajax.open("GET", "sumarvotos.php?id="+id, true);
		ajax.onreadystatechange=function() 
		{ 
			if (ajax.readyState==1)
			{
				combo.length=0;
				combo.disabled=true;
			}
			if (ajax.readyState==4)
			{ 
				combo.length=0;
				combo.disabled=true;
				document.getElementById("juegog-descarga-centro-punt").innerHTML = ajax.responseText;
			}
		}
		ajax.send(null);
}
function CambiarImg(buttonName,sourceImage) {
	document.images[buttonName].src = sourceImage
	return true;
}
$(document).ready(function() {
    $("a[rel='external']").addClass("external").click(function() {
		window.open($(this).href());
		return false;
	});	
	$("a[rel='popup']").addClass("popup").click(function() {
		var ample = 930;
		var alt = 705;
		var x = (screen.availWidth - ample)/2;
		var y = (screen.availHeight - alt)/2;		
		window.open($(this).href(), $(this).title(), "width = " + ample + ", height = " + alt + ", left = " + x + ", top = " + y + ", scrollbars = yes, menubar = yes, toolbar = no, location = yes, directories = no, resizable = yes");
		return false; 
	});
	$("a[rel]").click(function() {
		if (this.rel.indexOf("legal") >= 0) {
			window.open(this.href, "","menubar=0,resizable=0,width=581,height=256"); 
			return false;
		}
	});	
	$("#buscador_boton").click(function(){
		busqueda = document.getElementById("busqueda").value;
		if (busqueda != "") {
			pageTracker._trackPageview ('/buscar?q=' + busqueda);
			$.ajax({
				type: "POST",
				url: "anadirbusqueda.php",
				data: "busqueda="+busqueda,
				succes: window.location= "/juegos-buscar-"+busqueda+".html"
			});
		}
		return false;
	});
	
});
