function objetoAjax(){
	var xmlhttp=false;
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
		   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
  		}
	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	
	return xmlhttp;
	
}


function portada(entrada) {
	ajax1 = objetoAjax();
	ajax1.open("GET", 'index.php?plat='+entrada, true);
	ajax1.onreadystatechange=function() {
		if (ajax1.readyState==4) {
				location.href='index.php?plat='+entrada;
							}
	}
		ajax1.send(null); 
}



function noticias(entrada) {
	
divResultado = document.getElementById('newes');	
	ajax = objetoAjax();
	ajax.open("GET", 'news.php?plat='+entrada, true);
	ajax.onreadystatechange=function() {
		document.getElementById("INI").className="iconoINI";
		document.getElementById("PS3").className="iconoPS3";
		document.getElementById("X360").className="iconoX360";
		document.getElementById("PC").className="iconoPC";
		document.getElementById("Wii").className="iconoWii";
		document.getElementById("PSP").className="iconoPSP";
		document.getElementById("NDS").className="iconoNDS";
	if (ajax.readyState==4) {
		document.getElementById(entrada).className="icono"+entrada+"1";
	location.href='index.php?plat='+entrada;
	divResultado.innerHTML = ajax.responseText;
		
	}
   }
	ajax.send(null); 
}

function avances(entrada) {
	
divResultado1 = document.getElementById('avances');	
	ajax1 = objetoAjax();
	ajax1.open("GET", 'previ.php?plat='+entrada, true);
	ajax1.onreadystatechange=function() {
		if (ajax1.readyState==4) {
	divResultado1.innerHTML = ajax1.responseText;
	location.href='index.php?plat='+entrada;
		}
	}
		ajax1.send(null); 
}

function analisis(entrada) {
	
divResultado2 = document.getElementById('analisis');	
	ajax2 = objetoAjax();
	ajax2.open("GET", 'revi.php?plat='+entrada, true);
	ajax2.onreadystatechange=function() {
		if (ajax2.readyState==4) {
	divResultado2.innerHTML = ajax2.responseText;
		}
	}
		ajax2.send(null); 
}

 
function actua() { 

var entrada;
 if (document.getElementById("INI").className=="iconoINI1") {
	 entrada = "INI";
 }
 if (document.getElementById("PC").className=="iconoPC1") {
	 entrada = "PC";
 }
 if (document.getElementById("PS3").className=="iconoPS31") {
	 entrada = "PS3";
 }
  if (document.getElementById("X360").className=="iconoX3601") {
	 entrada = "X360";
 }
  if (document.getElementById("Wii").className=="iconoWii1") {
	 entrada = "Wii";
 }
  if (document.getElementById("PSP").className=="iconoPSP1") {
 entrada = "PSP";
  }
 if (document.getElementById("NDS").className=="iconoNDS1") {
	entrada = "NDS";
 }
 portada(entrada); 
 } 

function publicarcomentario(datos, resultado){	
	divResultado = document.getElementById(resultado);			
	if(divResultado.innerHTML==''){
		var topic, comen, tema, noticia;
		forum = document.getElementById('forumid').value;
		topic = document.getElementById('topicid').value;
		tema = document.getElementById('tema').value;
		comen = document.getElementById('comentario').value;
		idnoticia = document.getElementById('noticia').value;
		ajax = objetoAjax();
		if(datos!=""){
			divResultado.innerHTML = "<span style='color:#ffffff;'>Publicando comentario...</span>";		
			ajax.open("POST", datos, true);
			ajax.onreadystatechange=function() {
				if (ajax.readyState==4) {
					divResultado.innerHTML = ajax.responseText
					if (ajax.status==200) {
						document.location.reload();
					}
			 }
			 
			}
	
		}else divResultado.innerHTML ="";
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send("forumid="+forum+"&topicid="+topic+"&tema="+tema+"&comentario="+comen+"&noticia="+idnoticia);
}

function valoracion(){	
var noticia = document.getElementById("idjuego").value;
var titulopost =   document.getElementById("titulo").value;
var votoavance =   document.getElementById("votoavance").value;
	divResultado = document.getElementById("cuadropuntuar");			
			ajax = objetoAjax();
			ajax.open("GET", 'valoracion.php?id='+noticia+'&titulo='+titulopost+'&voto='+votoavance, true);
			ajax.onreadystatechange=function() {
				if (ajax.readyState==4) {
					divResultado.innerHTML = ajax.responseText
					if (ajax.status==200) {
						document.location.reload();
					}			
				}
			}
			ajax.send(null);
		
	
}

function expectativa(){	
var noticia = document.getElementById("noticia").value;
var titulopost =   document.getElementById("titulo").value;
var votoavance =   document.getElementById("votoavance").value;
	divResultado = document.getElementById("cuadropuntuar");			
			ajax = objetoAjax();
			ajax.open("GET", 'expectativas.php?id='+noticia+'&titulo='+titulopost+'&expecta='+votoavance, true);
			ajax.onreadystatechange=function() {
				if (ajax.readyState==4) {
					divResultado.innerHTML = ajax.responseText
					if (ajax.status==200) {
						document.location.reload();
					}			
				}
			}
			ajax.send(null);
		
	
}

function votar(){	
var noticia = document.getElementById("noticia").value
var titulopost =   document.getElementById("titulo").value
	divResultado = document.getElementById("numerovoto");			
			ajax = objetoAjax();
			ajax.open("GET", 'votarnoticias.php?id='+noticia+'&titulo='+titulopost, true);
			ajax.onreadystatechange=function() {
				if (ajax.readyState==4) {
					divResultado.innerHTML = ajax.responseText
					document.getElementById("votonoticia").className="votonoti1";
			
				}
			}
			ajax.send(null);
		
	
}

function votarcom(){	
var noticia = document.getElementById("noticia").value
var titulopost =   document.getElementById("titulo").value
	divResultado = document.getElementById("numerovoto");			
			ajax = objetoAjax();
			ajax.open("GET", 'votarcomics.php?id='+noticia+'&titulo='+titulopost, true);
			ajax.onreadystatechange=function() {
				if (ajax.readyState==4) {
					divResultado.innerHTML = ajax.responseText
					document.getElementById("votonoticia").className="votonoti1";
			
				}
			}
			ajax.send(null);
		
	
}

function votarrep(){	
var noticia = document.getElementById("noticia").value
var titulopost =   document.getElementById("titulo").value
	divResultado = document.getElementById("numerovoto");			
			ajax = objetoAjax();
			ajax.open("GET", 'votarreportajes.php?id='+noticia+'&titulo='+titulopost, true);
			ajax.onreadystatechange=function() {
				if (ajax.readyState==4) {
					divResultado.innerHTML = ajax.responseText
					document.getElementById("votonoticia").className="votonoti1";
			
				}
			}
			ajax.send(null);
		
	
}


function votarvid(){	
var noticia = document.getElementById("noticia").value
var titulopost =   document.getElementById("titulo").value
	divResultado = document.getElementById("numerovoto");			
			ajax = objetoAjax();
			ajax.open("GET", 'votarvideos.php?id='+noticia+'&titulo='+titulopost, true);
			ajax.onreadystatechange=function() {
				if (ajax.readyState==4) {
					divResultado.innerHTML = ajax.responseText
					document.getElementById("votonoticia").className="votonoti1";
			
				}
			}
			ajax.send(null);
		
	
}

function votarimg(){	
var noticia = document.getElementById("noticia").value
var titulopost =   document.getElementById("titulo").value
	divResultado = document.getElementById("numerovoto");			
			ajax = objetoAjax();
			ajax.open("GET", 'votarimagenes.php?id='+noticia+'&titulo='+titulopost, true);
			ajax.onreadystatechange=function() {
				if (ajax.readyState==4) {
					divResultado.innerHTML = ajax.responseText
					document.getElementById("votonoticia").className="votonoti1";
			
				}
			}
			ajax.send(null);
		
	
}

function votaravan(){	
var noticia = document.getElementById("noticia").value
var titulopost =   document.getElementById("titulo").value
	divResultado = document.getElementById("numerovoto");			
			ajax = objetoAjax();
			ajax.open("GET", 'votaravances.php?id='+noticia+'&titulo='+titulopost, true);
			ajax.onreadystatechange=function() {
				if (ajax.readyState==4) {
					divResultado.innerHTML = ajax.responseText
					document.getElementById("votonoticia").className="votonoti1";
			
				}
			}
			ajax.send(null);
		
	
}

function votaranalis(){	
var noticia = document.getElementById("noticia").value
var titulopost =   document.getElementById("titulo").value
	divResultado = document.getElementById("numerovoto");			
			ajax = objetoAjax();
			ajax.open("GET", 'votaranalisi.php?id='+noticia+'&titulo='+titulopost, true);
			ajax.onreadystatechange=function() {
				if (ajax.readyState==4) {
					divResultado.innerHTML = ajax.responseText
					document.getElementById("votonoticia").className="votonoti1";
			
				}
			}
			ajax.send(null);
		
	
}



function cambia_plataforma() {
var plataforma = document.buscplat.plat.value;
var palabra =  document.buscplat.pala.value; 
//divResultado1 = document.getElementById('juegosbusca');	
	ajax1 = objetoAjax();
	ajax1.open("GET", 'resulnue.php?plat='+plataforma+'&buscar='+palabra, true);
	ajax1.onreadystatechange=function() {
		if (ajax1.readyState==4) {
				//divResultado1.innerHTML = ajax1.responseText;
				location.href='resulnue.php?buscar='+palabra+'&plat='+plataforma;
				
				}
	}
		ajax1.send(null); 
}

