<!--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 load_page(url)

{

	divresultado=document.getElementById('prodfavoritos');

	var Aleatorio=parseInt(Math.random()*99999999);

	ajax=new objetoAjax();

	ajax.open("GET",url +"?rand=" + Aleatorio,true);

	ajax.onreadystatechange=useHttpResponse;

	ajax.send(null)

}

function load_page1(url)

{

	divresultado=document.getElementById('prodfavoritos1');

	var Aleatorio=parseInt(Math.random()*99999999);

	ajax=new objetoAjax();

	ajax.open("GET",url +"?rand=" + Aleatorio,true);

	ajax.onreadystatechange=useHttpResponse;

	ajax.send(null)

}



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;
	depa=document.registrate.departamento.value;
	///datos de la mascota
	esp=document.registrate.especie.value;
	nom_mascota=document.registrate.nombre.value;
	raz=document.registrate.raza.value;
	edad=document.registrate.edad.value;

	sex=document.registrate.sexo.value;
	f_nacimiento=document.registrate.nacimiento_mascota.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+"&especie="+esp+"&nombre_mascota="+nom_mascota+"&raza="+raz+"&edad="+edad+"&sexo="+sex+"&nacimiento_mascota="+f_nacimiento+"&departamento="+depa);


}


function cambio_precio(numero,dondeimpirme,codigo)
{
	divresultado=document.getElementById(dondeimpirme);

	var Aleatorio=parseInt(Math.random()*99999999);

	ajax=new objetoAjax();

	ajax.open("POST","jala_precio.php?numero="+numero+"&rand=" + Aleatorio,true);

	ajax.onreadystatechange=useHttpResponse;
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	ajax.send("codigo="+codigo)	
}

function suma_servicio(servicio)
{
		divresultado=document.getElementById('prodfavoritos');
	var Aleatorio=parseInt(Math.random()*99999999);
	ajax=new objetoAjax();
	ajax.open("GET","mete_producto.php?tipo_servicio="+servicio+"&rand="+Aleatorio,true);
	ajax.onreadystatechange=useHttpResponse;
	ajax.send(null)
}

function pago_final(codigo,tipo,total)

{
	
	divresultado=document.getElementById('prodfavoritos');

	var Aleatorio=parseInt(Math.random()*99999999);

	ajax=new objetoAjax();

	ajax.open("GET","pagodeposito.php?codigo="+codigo+"&tipo="+tipo+"&total="+total+"&rand=" + Aleatorio,true);

	ajax.onreadystatechange=useHttpResponse;

	ajax.send(null)

}


function ver_categoria(dato)
{
	divresultado=document.getElementById('inputcodigo');
	var Aleatorio=parseInt(Math.random()*99999999);
	ajax=new objetoAjax();
	ajax.open("GET","show_categoria.php?codigo="+dato+"&rand="+Aleatorio,true);
	ajax.onreadystatechange=useHttpResponse;
	ajax.send(null)
}





function valida_session()
{

alert('Usted debe iniciar session para seguir con este proceso de comprar');
window.location='login.php';

}


function ocultar()
{
		document.getElementById('msg_mail').style.visibility="hidden";
	}
	
function limpiar ()
{
document.registrate.reset();

}


function validar(){ 
    //valido el nombre 
    if (document.form1.txtnick.value==''){ 
       alert("Tiene  que ingresar su E-mail") 
       document.form1.txtnick.focus() 
       return false; 
	   
    } 

    if (document.form1.txtpass.value==''){ 
       alert("Tiene que ingresar su contraseņa") 
       document.form1.txtpass.focus() 
       return false; 
	   
} 
		  
}


function entrega(distrito,peso)

{

	divresultado=document.getElementById('cap_lugar');

	var Aleatorio=parseInt(Math.random()*99999999);

	ajax=new objetoAjax();
 if (distrito=='')
 {
	 alert('Debe seleccionar un lugar de entrega valido')
	
 }
 else
 {
	ajax.open("GET","entrega.php?entrega="+distrito+"&peso="+peso+"&rand=" + Aleatorio,true);

	ajax.onreadystatechange=useHttpResponse;

	ajax.send(null)
 }
}



function entregar(distrito,lugar,peso)

{

	divresultado=document.getElementById('contenedor');

	var Aleatorio=parseInt(Math.random()*99999999);

	ajax=new objetoAjax();
 if (distrito=='')
 {
	 alert('Debe seleccionar un lugar de entrega valido')
	
 }
 else
 {
	ajax.open("GET","mete_producto.php?entregar="+distrito+"&lugar="+lugar+"&pesoss="+peso+"&rand=" + Aleatorio,true);

	ajax.onreadystatechange=useHttpResponse;

	ajax.send(null)
 }
}



function eliminar_carrito(url)

{
	divresultado=document.getElementById('prodfavoritos');

	var Aleatorio=parseInt(Math.random()*99999999);

	ajax=new objetoAjax();

	ajax.open("GET",url +"&rand=" + Aleatorio,true);

	ajax.onreadystatechange=useHttpResponse;

	ajax.send(null)

}



function editar_cantidad(linea,stock)

{

	divresultado=document.getElementById('editar'+linea+'cantidad');

	var Aleatorio=parseInt(Math.random()*99999999);

	ajax=new objetoAjax();

	ajax.open("GET","editar_cantidad.php?div="+linea+"&stock="+stock+"&rand=" + Aleatorio,true);

	ajax.onreadystatechange=useHttpResponse;

	ajax.send(null)

}






function editar_cantidad_save(cantidad,linea)

{

	divresultado=document.getElementById('prodfavoritos');

	var Aleatorio=parseInt(Math.random()*99999999);

	ajax=new objetoAjax();

	ajax.open("GET","mete_producto.php?cantidad="+cantidad+"&linea="+linea+"&rand=" + Aleatorio,true);

	ajax.onreadystatechange=useHttpResponse;

	ajax.send(null)

}




function finalizar()


{
	if (document.frmservicio.tipo_servicio.value=='')
	{
	alert('Seleccione el distrito de envio')
	return true;
	}


vari=document.frmservicio.tipo_servicio.value;

divresultado=document.getElementById('prodfavoritos');

	var Aleatorio=parseInt(Math.random()*99999999);

	ajax=new objetoAjax();

	ajax.open("GET","mete_producto.php?formulario=true&tipo_servicio="+vari+"&rand="+ Aleatorio,true);

	ajax.onreadystatechange=useHttpResponse;

	ajax.send(null)

}

function finalizar1(vari)

{
	
var1=document.factura_web.persona_contacto.value;
var2=document.factura_web.telefono.value;
var3=document.factura_web.direccion.value;
var4=document.factura_web.comprobante.value;
var5=document.factura_web.ruc.value;
var6=document.factura_web.razonsocial.value;
var7=document.factura_web.direccion1.value;
var8=document.factura_web.chek.value;


if (var1=='')
{
alert('Debe ingresar la persona de contacto');
document.factura_web.persona_contacto.focus();
return false
}

if (var2=='')
{
alert('Debe ingresar su telefono');
document.factura_web.telefono.focus();
return false
}

if (var3=='')
{
alert('Debe ingresar su direccion');
document.factura_web.direccion.focus();
return false
}

if (var4=='')
{
alert('Seleccionar tipo comprobante');
document.factura_web.comprobante.focus();
return false
}



if (var8=='factura')
{
	
if (var5=='')
{
alert('Debe ingresar su ruc');
document.factura_web.ruc.focus();
return false
}

if (var6=='')
{
alert('Debe ingresar su razon social');
document.factura_web.razonsocial.focus();
return false
}

if (var7=='')
{
alert('Debe ingresar su direccion');
document.factura_web.direccion1.focus();
return false
}

}



divresultado=document.getElementById('prodfavoritos');

	var Aleatorio=parseInt(Math.random()*99999999);

	ajax=new objetoAjax();

	ajax.open("GET","mete_producto.php?fin=true&tipo_servicio="+vari+"&persona_contacto="+var1+"&telefono="+var2+"&direccion="+var3+"&comprobante="+var4+"&ruc="+var5+"&razonsocial="+var6+"&direccion_factura="+var7+"&tipo="+var8+"&rand="+ Aleatorio,true);

	ajax.onreadystatechange=useHttpResponse;

	ajax.send(null)

}

function tipo_comprobante(tipo)

{

if (tipo=='factura')
{
document.getElementById('factura').style.visibility='visible'
document.getElementById('factura').style.display ='';
document.factura_web.chek.value='factura';

}
else if (tipo=='boleta')
{
document.getElementById('factura').style.visibility='hidden'
document.getElementById('factura').style.display ='none';
document.factura_web.chek.value='boleta';

}
}

function comprar(documento,vari)
{

   
	   	   if (document.frmdata.dia.value==''){ 
       alert("Por favor ingrese dia") 
       document.frmdata.dia.focus() 
       return false; } 
	   
	   if (document.frmdata.mes.value==''){ 
       alert("Por favor ingrese mes") 
       document.frmdata.mes.focus() 
       return false; } 
	
	   
	   	   if (document.frmdata.ano.value==''){ 
       alert("Por favor ingrese ano") 
       document.frmdata.ano.focus() 
       return false; } 
	   
	   	   if (document.frmdata.lugar_entrega.value==''){ 
       alert("Por favor ingrese lugar_entrega") 
       document.frmdata.lugar_entrega.focus() 
       return false; } 
	   
	   	   if (document.frmdata.direccion_entrega.value==''){ 
       alert("Por favor ingrese direccion_entrega") 
       document.frmdata.direccion_entrega.focus() 
       return false; } 
	   
	     	   if (document.frmdata.telefono_entrega.value==''){ 
       alert("Por favor ingrese telefono_entrega") 
       document.frmdata.telefono_entrega.focus() 
       return false; } 
	   
	      	   if (document.frmdata.nombre.value==''){ 
       alert("Por favor ingrese nombre") 
       document.frmdata.nombre.focus() 
       return false; } 
	   
	      	   if (document.frmdata.paterno.value==''){ 
       alert("Por favor ingrese paterno") 
       document.frmdata.paterno.focus() 
       return false; } 
	   
	      	   if (document.frmdata.materno.value==''){ 
       alert("Por favor ingrese materno") 
       document.frmdata.materno.focus() 
       return false; } 
	   
	   
	      	   if (document.frmdata.mensaje.value==''){ 
       alert("Por favor ingrese mensaje") 
       document.frmdata.mensaje.focus() 
       return false; } 
	   
	   
dia=document.frmdata.dia.value;
mes=document.frmdata.mes.value;
ano=document.frmdata.ano.value;
horario=document.frmdata.horario.value;
lugar_entrega=document.frmdata.lugar_entrega.value;
direccion_entrega=document.frmdata.direccion_entrega.value;
telefono_entrega=document.frmdata.telefono_entrega.value;
otras_ubicaciones=document.frmdata.otras_ubicaciones.value;
nombre=document.frmdata.nombre.value;
paterno=document.frmdata.paterno.value;
materno=document.frmdata.materno.value;
referencia=document.frmdata.referencia.value;
mensaje=document.frmdata.mensaje.value;
factura=document.frmdata.factura.value;
razon_social=document.frmdata.razon_social.value;
ruc=document.frmdata.ruc.value;

divresultado=document.getElementById('prodfavoritos');


	var Aleatorio=parseInt(Math.random()*99999999);

	ajax=new objetoAjax();
	

	ajax.open("GET","mete_producto.php?fin=true&dia="+dia+"&mes="+mes+"&ano="+ano+"&horario=" + horario+"&lugar_entrega="+lugar_entrega+"&direccion_entrega="+direccion_entrega+"&telefono_entrega="+telefono_entrega+"&otras_ubicaciones="+otras_ubicaciones+"&nombre="+nombre+"&paterno="+paterno+"&materno="+materno+"&referencia="+referencia+"&mensaje="+mensaje+"&factura="+factura+"&razon_social="+razon_social+"&ruc="+ruc+"&documento="+documento+"&tipo_servicio="+vari+"&rand="+Aleatorio,true);

	ajax.onreadystatechange=useHttpResponse;

	ajax.send(null)
	
	
	   
}






function carrito(codigo,sabor,cantidad,tamano)
{

	divresultado=document.getElementById('prodfavoritos');


	var Aleatorio=parseInt(Math.random()*99999999);

	ajax=new objetoAjax();

	ajax.open("GET","mete_producto.php?sabor="+sabor+"&codigo="+codigo+"&cantidad="+cantidad+"&tamano="+tamano+"&rand=" + Aleatorio,true);

	ajax.onreadystatechange=useHttpResponse;

	ajax.send(null)
}





function validar(){ 
    //valido el nombre 
    if (document.form1.txtnick.value==''){ 
       alert("Tiene  que ingresar su E-mail") 
       document.form1.txtnick.focus() 
       return false; 
	   
    } 

    if (document.form1.txtpass.value==''){ 
       alert("Tiene que ingresar su contraseņa") 
       document.form1.txtpass.focus() 
       return false; 
	   
} 
		  
}
	
	
	
function validar1(){ 
    //valido el nombre 
    if (document.form5.txtnick.value==''){ 
       alert("Tiene  que ingresar su E-mail") 
       document.form5.txtnick.focus() 
       return false; 
	   
    } 

    if (document.form5.txtpass.value==''){ 
       alert("Tiene que ingresar su contraseņa") 
       document.form5.txtpass.focus() 
       return false; 
	   
} 
		  
}
	





function valida_final(){ 
    //valido el nombre 
    if (document.frmfin.nombre.value==''){ 
       alert("Tiene que ingresar el nombre del contacto") 
       document.frmfin.nombre.focus() 
       return false; 
	   
    } 

    if (document.frmfin.telefono.value==''){ 
       alert("Tiene que ingresar el telefono del contacto") 
       document.frmfin.telefono.focus() 
       return false; 
	   
    } 
	    if (document.frmfin.direccion.value==''){ 
       alert("Tiene que ingresar en lugar de entrega") 
       document.frmfin.direccion.focus() 
       return false; 
	   
    } 
	    if (document.frmfin.referencia.value==''){ 
       alert("Tiene que ingresar la referencia del lugar de entrega") 
       document.frmfin.referencia.focus() 
       return false; 
	   
    } 
		  
}



function enviar_olvido()

{
	divresultado=document.getElementById('msg_olvido');
	olv=document.frmolvido.olvido.value;

	
	
	var Aleatorio=parseInt(Math.random()*99999999);

	ajax=new objetoAjax();

	ajax.open("POST","olvido/olvido.php?rand=" + Aleatorio,true);
	document.getElementById('msg_olvido').style.visibility="visible";
	ajax.onreadystatechange=useHttpResponse;
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    ajax.send("olvido="+olv);


}




function ocultar_olvido()
{	
	 document.getElementById('msg_olvido').style.visibility="hidden";

}

function limpiar_olvido()
{
	
	document.frmolvido.olvido.value='';
	document.frmolvido.olvido.focus() 
return false; 


}




function useHttpResponse() {

	

   if (ajax.readyState == 4) 

   {

   		 if(ajax.status == 200) 

		{

			divresultado.innerHTML=ajax.responseText;

			

		}

  } 

  else 

  {

  divresultado.innerHTML = '<center><p /><img src="images/cargando.gif" alt="cargando..."></center>';

  }


}

	