//funciones iniciales
$(document).ready(function() {
$(".carrito").load("https://www.nevillegrowshopmadrid.com/ajax/carrito.php", {mostrar: 1} );
$(".carrito").click(function (){
document.location.href = "https://www.nevillegrowshopmadrid.com/pedido";
})
var pagina = window.location.pathname;
$("#pedido").load("https://www.nevillegrowshopmadrid.com/ajax/carrito.php", {pedido: 1, pagina: pagina} );
if( $('#pasos').length )
{
$("#pasos").load("https://www.nevillegrowshopmadrid.com/ajax/carrito.php", {pasos: 1} );
}
$(document).on('click', '.buy', function(evento){
evento.preventDefault();
$(".img_carrito").html('');
var nombre = '#nombre' + $(this).attr('id');
var cantidades = '#cantidad' + $(this).attr('id');
var valor = '#precio' + $(this).attr('id');
var iva = '#iva' + $(this).attr('id');
var recargo = '#recargo' + $(this).attr('id');
var descuento = '#descuento' + $(this).attr('id');
$(".carrito").load("https://www.nevillegrowshopmadrid.com/ajax/carrito.php", {sumar: 1, id: $(this).attr('id'), producto: $(nombre).val(), cantidad: $(cantidades).val(), precio: $(valor).val(), iva: $(iva).val(), recargo: $(recargo).val(), descuento: $(descuento).val() }, function(){
$("#pedido").load("https://www.nevillegrowshopmadrid.com/ajax/carrito.php", {pedido: 1, pagina: pagina} );
$(".sliderContainer").load("https://www.nevillegrowshopmadrid.com/ajax/carrito.php", {slider: 1} );
});
//$("#pedido").load("https://www.nevillegrowshopmadrid.com/ajax/carrito.php", {pedido: 1, pagina: pagina} );
});
$(document).on('click', '.gastosEnvio', function(evento){
evento.preventDefault();
$(".img_carrito").html('');
$("#pedido").load("https://www.nevillegrowshopmadrid.com/ajax/carrito.php", {pedido: 1, pagina: pagina, gastosEnvio: 2} );
$(".carrito").load("https://www.nevillegrowshopmadrid.com/ajax/carrito.php", {mostrar: 1} );
});
$(document).on('click', '.gastosEnvioAnular', function(evento){
evento.preventDefault();
$(".img_carrito").html('');
$("#pedido").load("https://www.nevillegrowshopmadrid.com/ajax/carrito.php", {pedido: 1, pagina: pagina, gastosEnvio: 0} );
$(".carrito").load("https://www.nevillegrowshopmadrid.com/ajax/carrito.php", {mostrar: 1} );
});
$(document).on('click', '.cpGastosEnvio', function(evento){
evento.preventDefault();
$(".img_carrito").html('');
$("#pedido").load("https://www.nevillegrowshopmadrid.com/ajax/carrito.php", {pedido: 1, pagina: pagina, cp: $('#cp').val()} );
$(".carrito").load("https://www.nevillegrowshopmadrid.com/ajax/carrito.php", {mostrar: 1} );
});
$('#guardarPedido').click(function (){
$("#pedido").load("https://www.nevillegrowshopmadrid.com/ajax/carrito.php", {guardarPedido: 1} );
$(".img_carrito").html('');
setTimeout('$("#pasos").load("https://www.nevillegrowshopmadrid.com/ajax/carrito.php", {pasos: 1} );$(".carrito").load("https://www.nevillegrowshopmadrid.com/ajax/carrito.php", {mostrar: 1} );jAlert("El pedido se ha guardado de manera correcta."); ',1250);
setTimeout('$(location).attr("href", "https://www.nevillegrowshopmadrid.com/compras");',3000);
});
$('a[name^=continuarCompra]').on('click', function(evento) {
evento.preventDefault();
$(".img_carrito").html('');
$("#compras").load("https://www.nevillegrowshopmadrid.com/ajax/carrito.php", {continuarCompra: $(this).attr('id') } );
})
$('a[name^=modificarCompra]').on('click', function(evento) {
evento.preventDefault();
$(".img_carrito").html('');
$("#compras").load("https://www.nevillegrowshopmadrid.com/ajax/carrito.php", {modificarCompra: $(this).attr('id') } );
})
$('#anular').click(function (){
$("#pedido").load("https://www.nevillegrowshopmadrid.com/ajax/carrito.php", {anular: 1, pedido: 1} );
$(".img_carrito").html('');
setTimeout('$("#pasos").load("https://www.nevillegrowshopmadrid.com/ajax/carrito.php", {pasos: 1} );$(".carrito").load("https://www.nevillegrowshopmadrid.com/ajax/carrito.php", {mostrar: 1} ); ',1250);
});
$('#anularCompra').click(function (){
$("#pedido").load("https://www.nevillegrowshopmadrid.com/ajax/carrito.php", {anular: 1, pedido: 1} );
$(".img_carrito").html('');
setTimeout('$("#pasos").load("https://www.nevillegrowshopmadrid.com/ajax/carrito.php", {pasos: 1} );$(".carrito").load("https://www.nevillegrowshopmadrid.com/ajax/carrito.php", {mostrar: 1} ); ',1250);
});
Pattaya.Mall.Home.LeftNav.init();
var $win = $(window);
var $pos = 180;
$win.scroll(function () {
if ($win.scrollTop() > $pos)
{
$('#flotante').removeClass('flotante1');
$('#flotante').addClass('flotante2');
}
else
{
$('#flotante').removeClass('flotante2');
$('#flotante').addClass('flotante1');
}
});
$('#enviar').click(function() {
var form = document.nueva;
var enviar = true;
for (i = 0; i < form.length; i ++)
{
if( (form[i].type == "text" || form[i].type == "textarea") && form[i].id != 'clave' )
{
form[i].value = form[i].value.toUpperCase();
if( form[i].value.length == 0 )
{
jAlert('El campo '+ form[i].name +' no puede quedarse vacío.');
enviar = false;
break;
}
}
}
if( enviar )
document.nueva.submit();
})
$('#cp').blur(function() {
var cp;
if( $(this).val() == '' )
cp = '00000';
else
cp = $(this).val();
$(".tiempo").html("");
$("#contLocalidad").load("https://www.nevillegrowshopmadrid.com/ajax/direccion.php", { cp: cp });
$("#contProvincia").load("https://www.nevillegrowshopmadrid.com/ajax/direccion.php", { provincia: cp });
})
$(document).on('click', 'a[name^=factura]', function(evento) {
evento.preventDefault();
$(".carga").html("");
$("#tablaDirecciones").load("https://www.nevillegrowshopmadrid.com/ajax/direccion.php", {factura: $(this).attr('id') } );
})
$(document).on('click', 'a[name^=envio]', function(evento) {
evento.preventDefault();
$(".carga").html("");
$("#tablaDirecciones").load("https://www.nevillegrowshopmadrid.com/ajax/direccion.php", {envio: $(this).attr('id') } );
})
$(document).on('click', 'a[name^=eliminar]', function(evento) {
evento.preventDefault();
var del = $(this).attr('id');
$(".carga").html("");
jConfirm('ESTAS SEGUR@ DE ELIMINAR ESTA DIRECCIÓN?', 'AVISO', function(r){
if( r )
$("#tablaDirecciones").load("https://www.nevillegrowshopmadrid.com/ajax/direccion.php", {eliminar: del } );
else
$(".carga").html('');
});
})
function toCapitalize(obj)
{
var mystring = obj.value;
var sp = mystring.split(' ');
var wl = 0;
var f ,r;
var word = new Array();
for (i = 0 ; i < sp.length ; i ++ )
{
f = sp[i].substring(0,1).toUpperCase();
r = sp[i].substring(1).toLowerCase();
word[i] = f + r;
}
newstring = word.join(' ');
obj.value = newstring;
return true;
}
$('#nombreProd').blur(function() {
toCapitalize(this);
})
$('#mas18').click(function() {
$('#avisoMayor').fadeOut();
})
$('#cookies').click(function() {
$(location).attr("href", "https://www.nevillegrowshopmadrid.com/cookies");
})
$('.imCalendario').on('click', function(evento){
evento.preventDefault();
$("#calendarioMarca").html('');
$("#calendarioMarca").load("https://www.nevillegrowshopmadrid.com/ajax/calendarios", {idCalendario: $(this).attr('id') });
var name = '#' + $(this).attr('name');
setTimeout('$(location).attr("href", "' + name + '");',500);
});
var ancla = location.hash;
var pagina = window.location.pathname;
if( ancla.length > 2 && pagina == '/calendarios' )
{
$("#calendarioMarca").html('');
$("#calendarioMarca").load("https://www.nevillegrowshopmadrid.com/ajax/calendarios", {imCalendario: ancla });
setTimeout('$(location).attr("href", "' + ancla + '");',500);
}
$('.albaranPdf').click(function() {
$(location).attr("href", "https://www.nevillegrowshopmadrid.com/descargar.php?tipo=albaran&archivo=" + $(this).attr('id'));
})
$('.facturaPdf').click(function() {
$(location).attr("href", "https://www.nevillegrowshopmadrid.com/descargar.php?tipo=factura&archivo=" + $(this).attr('id'));
})
$(document).on('click', '#metodoTransferencia', function() {
/*$(location).attr("href", "https://www.nevillegrowshopmadrid.com/completado?metodo=0&observacion=" + $('#observacion').val());*/
$('#completado').load("https://www.nevillegrowshopmadrid.com/ajax/card.php" , {detalles: 55, kit: 1, metodo: 1} );
})
$(document).on('click', '#metodoBizum', function() {
/*$(location).attr("href", "https://www.nevillegrowshopmadrid.com/completado?metodo=0&observacion=" + $('#observacion').val());*/
$('#completado').load("https://www.nevillegrowshopmadrid.com/ajax/card.php" , {detalles: 55, kit: 1, metodo: 4} );
})
$(document).on('click', '#metodoIngreso', function() {
$(location).attr("href", "https://www.nevillegrowshopmadrid.com/completado?metodo=1&observacion=" + $('#observacion').val());
})
$('#metodoReembolso').click(function() {
$(location).attr("href", "https://www.nevillegrowshopmadrid.com/completado?metodo=2&observacion=" + $('#observacion').val());
})
$('#codigoPromocional').click(function() {
$(location).attr("href", pagina + "?ref=" + $('#campoCodigoPromocional').val());
})
$('#tieneRecargo').change(function() {
$("#cargaRecargo").html('');
$("#cargaRecargo").load("https://www.nevillegrowshopmadrid.com/ajax/recargo.php", {recargo: $(this).val()});
setTimeout('$("#cargaRecargo").html("");', 2500);
})
$('.redesSociales').click(function() {
if( $(this).attr('tipo') == 'FB' )
window.open("http://www.facebook.com/sharer.php?u="+ encodeURI($(this).attr('url')),'shareFB','toolbar=no,directories=no,status=no,scrollbars=no,top=20,left=20,width=600,height=420');
else if( $(this).attr('tipo') == 'GO' )
window.open("https://plus.google.com/share?url="+ encodeURI($(this).attr('titulo')) +' - '+ encodeURI($(this).attr('url')),'shareGO','toolbar=no,directories=no,status=no,scrollbars=no,top=20,left=20,width=600,height=600');
else if( $(this).attr('tipo') == 'LK' )
window.open("http://www.linkedin.com/shareArticle?mini=true&url=" + encodeURI($(this).attr('url')) + "&title=" + encodeURI($(this).attr('titulo')) + "&source=LinkedIn");
else if( $(this).attr('tipo') == 'MN' )
window.open("http://meneame.net/submit.php?url=" + encodeURI($(this).attr('url')) + "&title=" + encodeURI($(this).attr('titulo')));
else if( $(this).attr('tipo') == 'TW' )
{
var str = encodeURI($(this).attr('titulo'));
window.open("https://twitter.com/intent/tweet?text=" + str.replace('#', '%23') + "&url=" + encodeURI($(this).attr('url')) + "&related=", 'shareTW','toolbar=no,directories=no,status=no,scrollbars=no,top=20,left=20,width=600,height=420');
}
})
$('.suscribirseBoletin').click(function() {
var caract = new RegExp(/^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/);
email = $('.suscribirse').val();
if (caract.test(email))
{
$("#errorSuscripcion").load("https://www.nevillegrowshopmadrid.com/ajax/boletin_suscripcion.php", {email: $('.suscribirse').val() });
}
else
$('#errorSuscripcion').html('El email es erroneo');
})
$('.cerrarSuscripcion').click(function() {
$("#errorSuscripcion").load("https://www.nevillegrowshopmadrid.com/ajax/boletin_suscripcion.php", {cerrarSuscripcion: 1});
$( ".registroBoletin" ).hide();
})
var arrobas = 0;
var hastags = 0;
$('.arroba, .sharp').on('click', function(evento) {
evento.preventDefault();
if( $(this).css('background-color') == 'rgba(0, 0, 0, 0)')
{
$(this).css('background-color', 'yellow');
$('.resultado').val( $('.resultado').val() + ' ' + $(this).attr('id') );
if( $(this).hasClass('arroba') )
arrobas ++;
if( $(this).hasClass('sharp') )
hastags ++;
}
else
{
$(this).css('background-color', 'unset');
var miTexto = $('.resultado').val();
miTexto = miTexto.replace(' ' + $(this).attr('id'), '');
$('.resultado').val(miTexto);
if( $(this).hasClass('arroba') )
arrobas --;
if( $(this).hasClass('sharp') )
hastags --;
}
$('.contadorArrobas').html(arrobas);
$('.contadorHastags').html(hastags);
});
if( $(window).width() < 768 && $('.ul-paginacion li').length == 22 )
{
$('.in-active1, .in-active2, .in-active8, .in-active9').hide();
}
if( $(window).width() < 768 && $('.ul-paginacion li').length == 24 )
{
$('.in-active7, .in-active8, .in-active9, .in-active10').hide();
}
$(document).on('click', '.quantity-right-plus', function(e) {
var campoMas = '.quantity' + $(this).attr('campo');
var quantity = parseInt($( campoMas ).val());
$( campoMas ).val(quantity + 1);
});
$(document).on('click', '.quantity-left-minus', function(e) {
var campoMenos = '.quantity' + $(this).attr('campo');
var quantity = parseInt($( campoMenos ).val());
if (quantity > 0) {
$( campoMenos ).val(quantity - 1);
}
});
function flyToElement(flyer, flyingTo) {
var $func = $(this);
var divider = 3;
var flyerClone = $(flyer).clone();
$(flyerClone).css({position: 'absolute', top: $(flyer).offset().top + "px", left: $(flyer).offset().left + "px", opacity: 1, 'z-index': 1000});
$('body').append($(flyerClone));
var gotoX = $(flyingTo).offset().left + ($(flyingTo).width() / 2) - ($(flyer).width()/divider)/2;
var gotoY = $(flyingTo).offset().top + ($(flyingTo).height() / 2) - ($(flyer).height()/divider)/2;
$(flyerClone).animate({
opacity: 0,
left: gotoX,
top: gotoY,
width: $(flyer).width()/divider,
height: $(flyer).height()/divider
}, 700,
function () {
$(flyingTo).fadeOut('fast', function () {
$(flyingTo).fadeIn('fast', function () {
$(flyerClone).fadeOut('fast', function () {
$(flyerClone).remove();
});
});
});
});
}
$(document).on('click', '.subir-carrito', function(){
//Select item image and pass to the function
var itemImg = $(this).attr('numImg');
flyToElement($('.' + itemImg), $('.cart_anchor'));
});
});