
var url_lorena='core/lorenaochoa.php';

$(function(){

Categorias(1);
UltimosProductos(1,' AND productos.principal=1',6);
HeaderProductos();


});

function HeaderProductos()
{
var data = {funcion :'HeaderProductos'}
$.ajax({type:'POST',url:url_lorena,data:data,dataType:'json',success:function respuesta(res){  
$('#numeroProductos').html(res[0]);
$('#precioTotalCompra').html(res[1]);
$('#masvendidos').html(res[2]);
}});
}


function Categorias(pagina)
{
var data = {funcion :'Categorias',pagina:pagina}
$.ajax({type: 'POST',url:url_lorena,data: data,dataType: 'json',success:function respuesta(res){ $('#lista_categorias').html(res);}});
}

function UltimosProductos(pagina,filtro,paginacion)
{	
var data = {funcion :'UltimosProductos',pagina:pagina,filtro:filtro,paginacion:paginacion}
$.ajax({type: 'POST',url:url_lorena,data: data,dataType: 'json',success:function respuesta(res){ $('#Ultimosp').html(res);}});
}


function PaginaProductos(pagina) { UltimosProductos(pagina,' AND productos.principal=1',6); }

//function filtraProductos(idCategoria){ UltimosProductos(1,' AND productos.idCategoria='+idCategoria) }

function filtraProductos(idCategoria)
{
var data = {funcion :'ListadoCategorias',categoria:idCategoria}
$.ajax({type: 'POST',url:url_lorena,data: data,dataType: 'json',success:function respuesta(res){ if(res){window.location="listado.html";}} });
}

function VerDetalle(id)
{
var data = {funcion :'gDetalle',producto:id}
$.ajax({type: 'POST',url:url_lorena,data: data,dataType: 'json',success:function respuesta(res){ if(res){window.location="detalle.html";}} });
}
