<!--POWERED BY PUNKNOMAS@HOTMAIL.COM-->
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 ocultar()
{
		document.getElementById('msg_mail').style.visibility="hidden";
	}
function limpiar ()
{
document.registrate.nombres.value='';
document.registrate.apellidos.value='';
document.registrate.email.value='';
document.registrate.pass.value='';
document.registrate.repass.value='';
document.registrate.telefono.value='';
document.registrate.direccion.value='';
document.registrate.distrito.value='';	
}





function enviar()

{

	divresultado=document.getElementById('msg_mail');

	nom=document.registrate.nombres.value;
	ape=document.registrate.apellidos.value;
	mai=document.registrate.email.value;
	pas=document.registrate.pass.value;
	rep=document.registrate.repass.value;
	tel=document.registrate.telefono.value;
	dir=document.registrate.direccion.value;
	dis=document.registrate.distrito.value;
	pai=document.registrate.pais.value;

	
	var Aleatorio=parseInt(Math.random()*99999999);

	ajax=new objetoAjax();

	ajax.open("POST","registrate/registrate.php?rand=" + Aleatorio,true);
	document.getElementById('msg_mail').style.visibility="visible";
	ajax.onreadystatechange=useHttpResponse;
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    ajax.send("email="+mai+"&pass="+pas+"&repass="+rep+"&nombres="+nom+"&apellidos="+ape+"&direccion="+dir+"&distrito="+dis+"&telefono="+tel+"&pais="+pai);


}



var nav4 = window.Event ? true : false;
function acceptNum(evt){	
// NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57	
var key = nav4 ? evt.which : evt.keyCode;	
return (key <= 13 || (key >= 48 && key <= 57));
}




function agregar_carrito(codigo)

{

	divresultado=document.getElementById('carrito');


	var Aleatorio=parseInt(Math.random()*99999999);

	ajax=new objetoAjax();

	ajax.open("GET","mete_producto.php?id="+codigo+"&rand=" + Aleatorio,true);

	ajax.onreadystatechange=useHttpResponse;

	ajax.send(null)
}


function descarga_free(codigo)

{

	divresultado=document.getElementById('carrito');


	var Aleatorio=parseInt(Math.random()*99999999);

	ajax=new objetoAjax();

	ajax.open("GET","descarga_free.php?id="+codigo+"&rand=" + Aleatorio,true);

	ajax.onreadystatechange=useHttpResponse;

	ajax.send(null)
}




function eliminar_carrito(url)

{
	divresultado=document.getElementById('carrito');

	var Aleatorio=parseInt(Math.random()*99999999);

	ajax=new objetoAjax();

	ajax.open("GET",url +"&rand=" + Aleatorio,true);

	ajax.onreadystatechange=useHttpResponse;

	ajax.send(null)

}


function finikitar()

{
	
	if (document.form1.nombres.value=='')
{
alert('Debe ingresar su Nombre')
document.form1.nombres.focus();
 return false; 
}

if (document.form1.apellidos.value=='')
{
alert('Debe ingresar su apellido')
document.form1.apellidos.focus();
 return false; 
}



if (document.form1.email.value=='')
{
alert('Debe ingresar su Email')
document.form1.email.focus();
 return false; 
}

if ((document.form1.email.value.indexOf ('@', 0) == -1)||(document.form1.email.value.length < 5))
	{ 
    alert("Escriba una dirección de correo válida en el campo \"Email\" Ej: nombre@correo.com"); 
    document.form1.email.focus();
     return false; 
  }
  
  
  
 if (document.form1.telefono.value=='')
{
alert('Debe ingresar su Telefono')
document.form1.telefono.focus();
 return false; 
}
  

if (document.form1.direccion.value=='')
{
alert('Debe ingresar su direccion')
document.form1.direccion.focus();
 return false; 
}


if (document.form1.referencia.value=='')
{
alert('Debe ingresar la referencia de su direccion')
document.form1.referencia.focus();
 return false; 
}




  


	

	nom=document.form1.nombres.value;
	ape=document.form1.apellidos.value;
	ema=document.form1.email.value;
	tel=document.form1.telefono.value;
	dir=document.form1.direccion.value;
	ref=document.form1.referencia.value;
	
	var Aleatorio=parseInt(Math.random()*99999999);
	
	ajax=new objetoAjax();

	ajax.open("GET","mete_producto.php?nombres="+nom+"&apellidos="+ape+"&email="+ema+"&telefono="+tel+"&direccion="+dir+"&referencia="+ref+"&finikitar=true&rand=" + Aleatorio,true);

	ajax.onreadystatechange=useHttpResponse;

	ajax.send(null)
}



function finalizar()

{

	
	divresultado=document.getElementById('carrito');


	var Aleatorio=parseInt(Math.random()*99999999);

	ajax=new objetoAjax();

	ajax.open("GET","mete_producto.php?garantia=false&formulario=true&rand=" + Aleatorio,true);

	ajax.onreadystatechange=useHttpResponse;

	ajax.send(null)
}

function load_page(url)

{

	divresultado=document.getElementById('carrito');

	var Aleatorio=parseInt(Math.random()*99999999);

	ajax=new objetoAjax();

	ajax.open("GET",url +"&rand=" + Aleatorio,true);

	ajax.onreadystatechange=useHttpResponse;

	ajax.send(null)

}


function ver_carrito(url)

{

	divresultado=document.getElementById('carrito');

	var Aleatorio=parseInt(Math.random()*99999999);

	ajax=new objetoAjax();

	ajax.open("GET",url +"?rand=" + Aleatorio,true);

	ajax.onreadystatechange=useHttpResponse;

	ajax.send(null)

}





function useHttpResponse() {

	

   if (ajax.readyState == 4) 

   {

   		 if(ajax.status == 200) 

		{

			divresultado.innerHTML=ajax.responseText;

			

		}

  } 

  else 

  {

  divresultado.innerHTML = '<center><p /><br /><p /><br /><p /><br /><p /><br /><p /><p /><div align="center" id="msg" style="width:100%;height:35px; font-family:Arial, Helvetica,sans-serif; color:#000000;  font-size:11px;"><br />Cargando...<br /><img src="images/cargan.gif" alt="Cargando" /></div></center>';

  }


}

function login()
{
	ajax=objetoAjax();
	divresultado=document.getElementById('msg');
	nick=document.form1.txtnick.value
	pass=document.form1.txtpass.value;
	free=document.form1.free.value;
	ajax.open("POST","login/login.php" ,true);
	ajax.onreadystatechange=useHttpResponse_login;
	//muy importante este encabezado ya que hacemos uso de un formulario
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	//enviando los valores
	ajax.send("txtnick="+nick+"&txtpass="+pass+"&free="+free)
}

function login_now()
{
	ajax=objetoAjax();
	divresultado=document.getElementById('msg');
	nick=document.form1.txtnick.value
	pass=document.form1.txtpass.value
	ajax.open("POST","login/login.php" ,true);
	ajax.onreadystatechange=useHttpResponse_login_now;
	//muy importante este encabezado ya que hacemos uso de un formulario
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	//enviando los valores
	ajax.send("txtnick="+nick+"&txtpass="+pass)
}

function login_free(codigo)
{
	ajax=objetoAjax();
	divresultado=document.getElementById('msg');
	nick=document.form1.txtnick.value
	pass=document.form1.txtpass.value
	ajax.open("POST","login/login.php" ,true);
	ajax.onreadystatechange=useHttpResponse_login_free(codigo);
	//muy importante este encabezado ya que hacemos uso de un formulario
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	//enviando los valores
	ajax.send("txtnick="+nick+"&txtpass="+pass)
}


function useHttpResponse_login() {
	
   if (ajax.readyState == 4) {
	 
    if(ajax.status == 200) {
		
	
       divresultado.innerHTML=ajax.responseText;
	   	if (ajax.responseText=='<img src="images/cargan.gif" boder="1">')
	  		{ 
		//	alert('Ingreso a su cuenta')
	   		window.location=('ebook.php');
	   		}
	   
    }
  } else {
		document.getElementById('msg').style.visibility="visible";  
  document.getElementById('msg').innerHTML = '<img src="images/cargan.gif" boder="1">';
  }
  
}


function useHttpResponse_login_now() {
	
   if (ajax.readyState == 4) {
	 
    if(ajax.status == 200) {
		
	
       divresultado.innerHTML=ajax.responseText;
	   	if (ajax.responseText=='<img src="images/cargan.gif" boder="1">')
	  		{ 
			
					document.getElementById('carrito').innerHTML='<p /><br /><p /><br /><p /><br /><p /><br /><div style="	text-decoration: none;	color: #D51F22;	font-family: Arial, Helvetica, sans-serif;	font-size: 14px;	font-weight: bold;"><center><img src="images/cargan.gif" boder="0"> INICIANDO SESSION...</center></span>';
					setTimeout("ver_carrito('mete_producto.php')",2000);	
				
			
	   		}
	   
    }
  } else {
		document.getElementById('msg').style.visibility="visible";  
  document.getElementById('msg').innerHTML = '<img src="images/cargan.gif" boder="0">';
  }
  
}







function useHttpResponse_login_free(codigo) {
	
   if (ajax.readyState == 4) {
	 
    if(ajax.status == 200) {
		
	
       divresultado.innerHTML=ajax.responseText;
	   	if (ajax.responseText=='<img src="images/cargan.gif" boder="1">')
	  		{ 
			
					document.getElementById('carrito').innerHTML='<p /><br /><p /><br /><p /><br /><p /><br /><div style="	text-decoration: none;	color: #D51F22;	font-family: Arial, Helvetica, sans-serif;	font-size: 14px;	font-weight: bold;"><center><img src="images/cargan.gif" boder="0"> INICIANDO DESCARGA...</center></span>';
					window.open('descarga_free.php?id='+codigo,'_blank');
				
			
	   		}
	   
    }
  } else {
		document.getElementById('msg').style.visibility="visible";  
  document.getElementById('msg').innerHTML = '<img src="images/cargan.gif" boder="0">';
  }
  
}





function useHttpResponsee() {

	

   if (ajax.readyState == 4) 

   {

   		 if(ajax.status == 200) 

		{

			divresultado.innerHTML=ajax.responseText;

			

		}

  } 

  else 

  {

  divresultado.innerHTML = '...';

  }


}



	