﻿function Capturas(x)
	{
	x = x.substr(x.indexOf("#")+1);
	var tmp="";var tmp2="";
	var ajax = nuevoAjax();
	ajax.open("POST", "capturas.php" ,true);
	ajax.onreadystatechange=function()
		{
		if(ajax.readyState==4) 
			{
			var info = ajax.responseText.split("---");
			switch(info[0])
				{

				case "1":{
				var siguiente = parseInt(x)+5;
				var anterior = parseInt(x)-5;
				var ant = document.getElementById('capturas-')
				document.getElementById('capturas+').href="#"+siguiente;
				if(ant.href.substr(ant.href.indexOf("#")+1) > 4)
					{
					ant.href="#"+anterior;
					}

				tmp = info[2].split("-:-");
				tmp2 = tmp[0].split(" ")[0];
				document.getElementById('Captura-1').innerHTML="<a href='buscar-"+tmp2+"-gratis.html'><img alt='"+tmp[0]+"' src='"+tmp[1]+"' /></a>";

				tmp = info[3].split("-:-");
				tmp2 = tmp[0].split(" ")[0];
				document.getElementById('Captura-2').innerHTML="<a href='buscar-"+tmp2+"-gratis.html'><img alt='"+tmp[0]+"' src='"+tmp[1]+"' /></a>";

				tmp = info[4].split("-:-");
				tmp2 = tmp[0].split(" ")[0];
				document.getElementById('Captura-3').innerHTML="<a href='buscar-"+tmp2+"-gratis.html'><img alt='"+tmp[0]+"' src='"+tmp[1]+"' /></a>";

				tmp = info[5].split("-:-");
				tmp2 = tmp[0].split(" ")[0];
				document.getElementById('Captura-4').innerHTML="<a href='buscar-"+tmp2+"-gratis.html'><img alt='"+tmp[0]+"' src='"+tmp[1]+"' /></a>";

				tmp = info[6].split("-:-");
				tmp2 = tmp[0].split(" ")[0];
				document.getElementById('Captura-5').innerHTML="<a href='buscar-"+tmp2+"-gratis.html'><img alt='"+tmp[0]+"' src='"+tmp[1]+"' /></a>";


				break;}

				case "2":{
				alert(info[1]);
				break;}

				default:{
				alert('Error en el sistema intenta en unos minutos gracias');
				break;}
				}
			}
       		}
	ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	ajax.send("capturas=true&x="+x);
	}

function nuevoAjax()
	{ 
	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; 
	}