$(".unidad_pelayo").click(function(){
var unidad=$(this).attr("data-unidad");
for(i=1;i<=3;i++){
$("#class_unidad_drop_"+i).attr("style","display:none;");
}
$("#class_unidad_drop_"+unidad).attr("style","display:block;");
$(".unidad_pelayo").removeClass('menu-hover');
$(this).addClass('menu-hover');
});
$("ul[id^='class_unidad_drop_']").mouseleave(function(){
$(this).attr("style","display:none;");
$(".unidad_pelayo").removeClass('menu-hover');
});
$(function(){
})
$(function(){
$("body").on("click",".delete-item",function(e){
e.preventDefault();
$.post($("body").data("url"),{"_ajax_": "addProductoCarrito","producto_id" : $(this).data("producto_id") , "remove": 1},function(json){
if(json.cantidad > 0 )
{
$("#ir_al_carro").removeClass("hide");
}
else
{
$("#ir_al_carro").addClass("hide");
}
$("#carrito_productos").html(base64_decode(json.html));
$("#cabecera_carro").html(base64_decode(json.cabecera_carro));
$("#valores_referencia").html(base64_decode(json.referencias));
$("#cabecera_carro").click();
},"json");
})
base64_decode = function (data) {
var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
ac = 0,
dec = '',
tmp_arr = [];
if (!data) {
return data;
}
data += '';
do { // unpack four hexets into three octets using index points in b64
h1 = b64.indexOf(data.charAt(i++));
h2 = b64.indexOf(data.charAt(i++));
h3 = b64.indexOf(data.charAt(i++));
h4 = b64.indexOf(data.charAt(i++));
bits = h1 << 18 | h2 << 12 | h3 << 6 | h4;
o1 = bits >> 16 & 0xff;
o2 = bits >> 8 & 0xff;
o3 = bits & 0xff;
if (h3 == 64) {
tmp_arr[ac++] = String.fromCharCode(o1);
} else if (h4 == 64) {
tmp_arr[ac++] = String.fromCharCode(o1, o2);
} else {
tmp_arr[ac++] = String.fromCharCode(o1, o2, o3);
}
} while (i < data.length);
dec = tmp_arr.join('');
return dec.replace(/\0+$/, '');
};
$("#send_form_plof").submit(function(e){
e.preventDefault()
return false;
});
$('#keyword').keypress(function (e) {
var key = e.which;
if(key == 13) // the enter key code
{
$("#quick-search").click();
return false;
}
});
$("#quick-search").click(function(){
var keyword=$("#keyword").val();
if($("#keyword").val().length>=5)
location.href=$("body").data("url")+"buscar.html?keyword="+$("#keyword").val();
else
alert("La palabra ingresada debe ser mayor a 5 caracteres");
});
$(".agregar_producto").click(function(e){
e.preventDefault();
var producto_id = $(this).data("producto_id");
var cantidad = $("#cantidad_producto").val();
if($(this).data("cantidad") == 1)
{
var cantidad = 1;
}
if(cantidad < 1)
{
alert("La cantidad no puede ser menor a 0");
return false;
}
if($(this).data("cantidad") != 1)
{
if($("#medida_id").attr("id") == "medida_id")
{
producto_id = $("#medida_id").val();
}
}
$.post($("body").data("url"),{"_ajax_": "addProductoCarrito","producto_id" : producto_id , "cantidad": cantidad},function(json){
if(json.cantidad > 0 )
{
$("#ir_al_carro").removeClass("hide");
$(location).attr("href","http://www.refrimarket.com/carrito.html");
}
else
{
$("#ir_al_carro").addClass("hide");
}
$("#carrito_productos").html(base64_decode(json.html));
$("#cabecera_carro").html(base64_decode(json.cabecera_carro));
$("#valores_referencia").html(base64_decode(json.referencias));
$("#cabecera_carro").click();
},"json");
});
})
$(function(){
/*
$.fancybox({
content: '
'
});
*/
});
$(document).ready(function() {
/*
$.fancybox.open('