PageSourceSearch

https://rasan.com/js/funciones.js?2.0.32

js rasan.com collected 2026-09-26 03:39:31 UTC 102,492 bytes, 2,328 lines download raw bytes

1function cargaAjax(destino, pagina) {
2    $("#" + destino).load(pagina);
3}
4function cargaAjaxConParametros(destino, pagina) {
5    $("#" + destino).load(pagina, { nombre: "kike", edad: 33 });
6}
7function cargaAjaxConParametrosYAviso(destino, pagina) {
8    $("#" + destino).load(pagina,{nombre: "Pepe", edad: 45}, function(){
9        alert("recibidos los datos por ajax prueba 3");
10    });
11}
12var interval
13function FuncionBusqueda(e, destino, pagina, Pag, PagRela) {
14    clearTimeout(interval);
15    interval = setTimeout(function () {
16        //primero capturo el valor del campo de la busqueda
17        var porId = document.getElementById("buscador");
18        var Busqueda = porId.value;
19        //luego compruebo si se pulsa enter, para enviar a la pagina de busqueda
20        var enterKey = 13;
21        if (e.which == enterKey) {
22            var form = document.createElement("form"); // crear un form
23            with (form) {
24                setAttribute("name", "busquedaproductos"); //nombre del form
25                setAttribute("action", "index.php?pag=BusquedaResultados&Busqueda=2"); // action por defecto
26                setAttribute("method", "post"); // method POST 
27            }
28
29            var input = document.createElement("input"); // Crea un elemento input
30            with (input) {
31                setAttribute("name", "buscador"); //nombre del input
32                setAttribute("type", "hidden"); // tipo hidden
33                setAttribute("value", Busqueda); // valor por defecto
34            }
35
36            form.appendChild(input); // añade el input al formulario
37            form.submit();//por ultimo, envio el formulario
38        }
39        //si no, muestro la busqueda rapida si contiene mas de 3 digitos
40        if (Busqueda.length > 2) {
41            $("#resultadoBusquedaCargando").css("display", "block");
42            $("#" + destino).load(pagina, { busqueda: Busqueda, Pagina: Pag, PaginaRela: PagRela }, function () {
43                $("#resultadoBusquedaCargando").css("display", "none");
44
45                //$("#BusquedaRapidaResultadosContainerRelacionadosProductos").load('BusquedaRapidaRelacionados.php?pagina=' + $('#BusqPag').val() + '&paginaRela=' + $('#BusqReleacionados').val(), { busqueda: Busqueda });
46            });
47        }
48    }, 300);
49}
50function FuncionBusquedaAlter(e, destino, pagina, Pag, PagRela) {
51        //primero capturo el valor del campo de la busqueda
52        var porId = document.getElementById("buscador");
53        var Busqueda = porId.value;
54        var form = document.createElement("form"); // crear un form
55        with (form) {
56            setAttribute("name", "busquedaproductosintro"); //nombre del form
57            setAttribute("action", "index.php?pag=BusquedaResultados&Busqueda=2"); // action por defecto
58            setAttribute("method", "post"); // method POST 
59        }
60        var inputAlt = document.createElement("input"); // Crea un elemento input
61        with (inputAlt) {
62            setAttribute("name", "buscador"); //nombre del input
63            setAttribute("type", "hidden"); // tipo hidden
64            setAttribute("value", Busqueda); // valor por defecto
65        }
66        form.appendChild(inputAlt); // añade el input al formulario
67        document.body.appendChild(form);
68        form.submit();//por ultimo, envio el formulario
69}
70function FuncionBusquedaVerTodos() {
71        //primero capturo el valor del campo de la busqueda
72        var porId = document.getElementById("buscador");
73        var Busqueda = porId.value;
74        var form = document.createElement("form"); // crear un form
75        with (form) {
76            setAttribute("name", "busquedaproductosintro"); //nombre del form
77            setAttribute("action", "index.php?pag=BusquedaResultados&Busqueda=2"); // action por defecto
78            setAttribute("method", "post"); // method POST 
79        }
80        var inputAlt = document.createElement("input"); // Crea un elemento input
81        with (inputAlt) {
82            setAttribute("name", "buscador"); //nombre del input
83            setAttribute("type", "hidden"); // tipo hidden
84            setAttribute("value", Busqueda); // valor por defecto
85        }
86        form.appendChild(inputAlt); // añade el input al formulario
87        document.body.appendChild(form);
88        form.submit();//por ultimo, envio el formulario
89}
90function CerrarTodasVentanasImpresoras(){
91    jQuery('#cabeceraDivBusCarBuscadorPorImpresoraResult').html('');
92    jQuery('#cabeceraDivBusCarBuscadorPorImpresoraModelo').html('');
93    jQuery('#cabeceraDivBusCarBuscadorPorImpresoraTipo').html('');
94    div=document.getElementById('cabeceraDivBusCar');
95    div.dataset.busquedaimpresora=1;
96    
97}
98
99function FuncionVerPptoRapido(destino) {
100    //lo primero, cambio la imagen para mostrar la imagen de over en la parte de presupuesto
101    $("#CabeceraPresupuestoImagenImg").attr("src", "./images/ppto-arriba-over.png");
102
103    $("#resultadoPresupuesto").css("display", "block");
104    $("#" + destino).load("pptoVerRapido.php", {  }, function () {
105    });
106}
107function FuncionVerPptoRapidoRestImg() {
108    //lo primero, cambio la imagen para mostrar la imagen de over en la parte de presupuesto
109    $("#CabeceraPresupuestoImagenImg").attr("src", "./images/ppto-arriba.png");
110}
111function FuncionCerrarPptoRapido(destino) {
112    $("#resultadoPresupuesto").css("display", "block");
113    $("#" + destino).load("EnBlanco.php", {  }, function () {
114    });
115}
116function cargaBusquedaImpresoraModelo(destino, pagina) {
117    //alert("AAA");
118    //$("#" + destino).load(pagina);
119    div=document.getElementById('cabeceraDivBusCar');
120    div.dataset.busquedaimpresora=1;
121    if(document.getElementById(destino).disabled==false)
122    {
123        document.getElementById(destino).disabled=true;
124        CerrarTodasVentanasImpresoras();
125        return '';
126    }
127    document.getElementById(destino).disabled=false;
128    jQuery.ajax({
129        type: "POST", 
130        url: pagina,
131        //data: 'CodFam='+CodFam+'&CodClase='+CodClase,
132        success: function(a) {
133            jQuery('#' + destino).html(a);
134        }
135    }); 
136
137}
138function cargaBusquedaImpresoraTipo(destino, pagina, modelo,Obj) {
139    //alert(document.getElementById(destino));
140    //$("#" + destino).load(pagina, { IdModelo: modelo });
141    jQuery('#cabeceraDivBusCarBuscadorPorImpresoraTipo').html('');
142    jQuery('#cabeceraDivBusCarBuscadorPorImpresoraResult').html('');
143    jQuery('div[data-impresora="modelo"]').each(function(){
144        jQuery(this).removeClass('ImpSeleccionada');
145    });
146    jQuery(Obj).addClass('ImpSeleccionada');
147    div=document.getElementById('cabeceraDivBusCar');
148    div.dataset.busquedaimpresora=2;
149    document.getElementById(destino).disabled=false;
150    jQuery.ajax({
151        type: "POST", 
152        url: pagina,
153        data: 'IdModelo='+modelo,
154        success: function(a) {
155            jQuery('#' + destino).html(a);
156        }
157    }); 
158}
159function cargaBusquedaImpresoraResult(destino, pagina, modelo, tipo,Pagina,Obj) {
160    Pagina=Pagina | 1;
161    Obj=Obj | null;
162    //alert('IdModelo='+modelo+'&IdTipo='+tipo);
163    //$("#" + destino).load(pagina, { IdModelo: modelo, IdTipo: tipo });
164    if(Obj!=null)
165    {
166        jQuery('div[data-impresora="tipo"]').each(function(){
167            jQuery(this).removeClass('ImpSeleccionada');
168        });
169        jQuery(Obj).addClass('ImpSeleccionada');
170    }
171    div=document.getElementById('cabeceraDivBusCar');
172    div.dataset.busquedaimpresora=3;
173    document.getElementById(destino).disabled=false;
174    jQuery.ajax({
175        type: "POST", 
176        url: pagina,
177        data: 'IdModelo='+modelo+'&IdTipo='+tipo+'&Pag='+Pagina,
178        success: function(a) {
179            jQuery('#' + destino).html(a);
180        }
181    }); 
182}
183function FuncionBusquedaAvanzada(pagina) {
184    //primero capturo el valor del campo de la busqueda
185    var porId = document.getElementById("BusquedaAvanzada");
186    var Busqueda = porId.value;
187    //luego compruebo si se pulsa enter, para enviar a la pagina de busqueda
188    var form5 = document.createElement("form"); // crear un form
189    with (form5) {
190        setAttribute("name", "form5"); //nombre del form
191        setAttribute("action", pagina); // action por defecto
192        setAttribute("method", "post"); // method POST 
193    }
194
195    var input = document.createElement("input"); // Crea un elemento input
196    with (input) {
197        setAttribute("name", "buscador"); //nombre del input
198        setAttribute("type", "hidden"); // tipo hidden
199        setAttribute("value", Busqueda); // valor por defecto
200    }
201    $('input[data-buscador=1]').each(function () {
202        form5.appendChild(this);
203    });
204    form5.appendChild(input); // añade el input al formulario
205    $(document.body).append(form5);
206    form5.submit();//por ultimo, envio el formulario
207}
208function FuncionBusquedaCategoria(destino, IdMarca, IdTipo, Pag) {
209    //si no, muestro la busqueda rapida
210    $("#" + destino).load("menuCategoriasModelos.php", { Marca: IdMarca, Tipo: IdTipo, Pagina: Pag });
211}
212function FuncionBusquedaCambioCategorias(destino, pagina, SelectorCategoria) {
213    //primero capturo el valor del campo de la busqueda
214    var porId = document.getElementById("ParametroBusqueda");
215    var Busqueda = porId.value;
216    var form = document.createElement("form"); // crear un form
217    with (form) {
218        setAttribute("name", "busquedaproductos"); //nombre del form
219        setAttribute("action", "index.php?pag=BusquedaCategorias&Tipo=3"); // action por defecto
220        setAttribute("method", "post"); // method POST 
221    }
222    //ahora busco las categorias seleccionadas
223    var CategoriasSeleccionadas = "";
224    var checkboxes = document.getElementsByName(SelectorCategoria);
225    var cont = 0;
226
227    for (var x = 0; x < checkboxes.length; x++) {
228        if (checkboxes[x].checked) {
229            cont = cont + 1;
230            //lo agregamos, con coma si hay mas de uno para separarlos si se necesita
231            if (CategoriasSeleccionadas == "") {
232                CategoriasSeleccionadas = CategoriasSeleccionadas + checkboxes[x].value;
233            } else {
234                CategoriasSeleccionadas = CategoriasSeleccionadas + "," + checkboxes[x].value;
235            }
236        }
237    }
238    //y si al tenerlo completo termina en coma, le quito la coma
239    if (CategoriasSeleccionadas.endsWith(",")) {
240        CategoriasSeleccionadas = CategoriasSeleccionadas.substring(0, CategoriasSeleccionadas.length - 1);
241    }
242
243
244
245    var input = document.createElement("input"); // Crea un elemento input
246    with (input) {
247        setAttribute("name", "ParametroBusqueda"); //nombre del input
248        setAttribute("type", "hidden"); // tipo hidden
249        setAttribute("value", Busqueda); // valor por defecto
250    }
251    form.appendChild(input); // añade el input al formulario
252    var input2 = document.createElement("input"); // Crea un elemento input
253    with (input2) {
254        setAttribute("name", "ParametroCategoria"); //nombre del input
255        setAttribute("type", "hidden"); // tipo hidden
256        setAttribute("value", CategoriasSeleccionadas); // valor por defecto
257    }
258    form.appendChild(input2); // añade el input al formulario
259    form.submit();//por ultimo, envio el formulario
260}
261function irAPaginaBusqueda(url) {
262    //capturo el hidden con el parametro busqueda
263    var porId = document.getElementById("ParametroBusqueda");
264    var Busqueda = porId.value;
265    //por ultimo, creo el form para enviarlo
266    var form = document.createElement("form"); // crear un form
267    with (form) {
268        setAttribute("name", "busquedaproductos"); //nombre del form
269        setAttribute("action", url); // action por defecto
270        setAttribute("method", "post"); // method POST 
271    }
272
273    var input = document.createElement("input"); // Crea un elemento input
274    with (input) {
275        setAttribute("name", "ParametroBusqueda"); //nombre del input
276        setAttribute("type", "hidden"); // tipo hidden
277        setAttribute("value", Busqueda); // valor por defecto
278    }
279
280    form.appendChild(input); // añade el input al formulario
281    form.submit();//por ultimo, envio el formulario
282}
283function MostrarBotonComprar(idDiv) {
284    document.getElementById(idDiv).style.display = 'block';
285}
286function OcultarBotonComprar(idDiv) {
287    document.getElementById(idDiv).style.display = 'none';
288}
289function MostrarBotonUsuario(idDiv,idDivTamano) {
290    document.getElementById(idDiv).style.display = 'block';
291    Ancho = document.getElementById(idDivTamano).offsetWidth;
292    document.getElementById(idDiv).style.width = Ancho;
293}
294function OcultarBotonUsuario(idDiv) {
295    document.getElementById(idDiv).style.display = 'none';
296}
297function AgregarCarritoDesdeSelector(destino, producto) {
298    //alert("hola");
299    //donde se mostrará lo resultados
300    var NombreEmpieza = 'cantidad-' + producto;
301    Elementos = document.getElementsByClassName("cantidad");
302    for (i = 0; i < Elementos.length; i++) {
303        //divido el objeto que recorro
304        Objeto = Elementos[i];
305        //si el id del objeto empieza por el nombre del producto que busco, mirare si el value es mayor a 0, para agregar los correspondientes
306        if (Objeto.id.startsWith(NombreEmpieza)) {
307            //ahora, si el value es mayor que 0
308            if (Objeto.value > 0) {
309                Aux = Objeto.id.replace(NombreEmpieza + '-', "");
310                AuxPartido = Aux.split("-")
311                Color = AuxPartido[0];
312                Talla = AuxPartido[1];
313                //una vez tengo toda la informacion, llamo a agregar carrito
314                AgregarCarrito(destino, producto, Color, Talla);
315            }
316        }
317    }
318    //alert(cant);
319}
320function AgregarCarrito(destino, producto, color, talla) {
321    //alert("hola");
322    //donde se mostrará lo resultados
323    pro = producto;
324    col = color;
325    tal = talla;
326    cant = document.getElementById('cantidad-' + producto + '-' + color + '-' + talla).value;
327	//enviando los valores
328    //si no, muestro la busqueda rapida
329    $("#" + destino).load("AgregarCarrito.php", { producto: pro, cantidad: cant, color: col, talla: tal});
330    //$("#" + destino).load("AgregarCarrito.php", { producto: pro, cantidad: cant, color: col, talla: tal }, function () {
331    //    ObjTemp = this;
332    //    setTimeout(function(){ jQuery(ObjTemp).hide();},5000);
333    //});
334}
335function ModificarCarrito(destino, prod, col, tal, cpac) {
336    cant = document.getElementById('cantidad-' + prod + '-' + col + '-' + tal + '-' + cpac).value;
337    //si es mayor que 0 lo hago, si no muestro mensaje de que la cantidad tiene que ser mayor que 0
338    if (parseInt(cant) > 0) {
339        $("#" + destino).load("AgregarCarritoDesdeCarrito.php", { producto: prod, color: col, talla: tal, codpack: cpac, cantidad: cant }, function () {
340            ObjTemp = this;
341            setTimeout(function () { jQuery(ObjTemp).hide(); }, 5000);
342        });
343    } else {
344        //alert("La cantidad tiene que se mayor que 0.");
345        //si es menor que 0, elimino el producto del carrito
346        EliminarCarrito(destino, prod, col, tal, cpac);
347    }
348}
349function AgregarCarritoDesdeSelectorPack(destino, arrayProducto) {
350    //alert("hola");
351    //recorro el array de los distintos productos a agregar
352    //primero, miraré si hay 1 unidad de cada producto
353    var correcto = true;
354    for (var i = 0; i < arrayProducto.length; i++) {
355        var NombreEmpieza = 'cantidad-' + arrayProducto[i];
356        Elementos = document.getElementsByClassName("cantidad");
357        var totalProducto = 0;
358        for (y = 0; y < Elementos.length; y++) {
359            //divido el objeto que recorro
360            Objeto = Elementos[y];
361            //si el id del objeto empieza por el nombre del producto que busco, mirare si el value es mayor a 0, para agregar los correspondientes
362            if (Objeto.id.startsWith(NombreEmpieza)) {
363                //ahora, si el value es mayor que 0
364                if (Objeto.value > 0) {
365                    Aux = Objeto.id.replace(NombreEmpieza + '-', "");
366                    AuxPartido = Aux.split("-")
367                    Color = AuxPartido[0];
368                    Talla = AuxPartido[1];
369                    Pack = AuxPartido[2];
370                    //ahora, miro las unidades que hay y las sumo al total
371                    cant = document.getElementById('cantidad-' + arrayProducto[i] + '-' + Color + '-' + Talla + '-' + Pack).value;
372                    totalProducto = totalProducto + parseInt(cant);
373                }
374            }
375        }
376        //ahora miro, si de ese producto hay 1 cantidad, podré seguir, si hay mas de 1 cantidad, mostraré error mas adelante
377        if (totalProducto > 1 || totalProducto < 1) {
378            correcto = false;
379        }
380    };
381    //despues, si es correcto, creo el array para luego agregar
382    if (correcto) {
383        var agregarACarrito = [];
384        for (var x = 0; x < arrayProducto.length; x++) {
385            var NombreEmpieza = 'cantidad-' + arrayProducto[x];
386            Elementos = document.getElementsByClassName("cantidad");
387            for (z = 0; z < Elementos.length; z++) {
388                //divido el objeto que recorro
389                Objeto = Elementos[z];
390                //si el id del objeto empieza por el nombre del producto que busco, mirare si el value es mayor a 0, para agregar los correspondientes
391                if (Objeto.id.startsWith(NombreEmpieza)) {
392                    //ahora, si el value es mayor que 0
393                    if (Objeto.value > 0) {
394                        Aux = Objeto.id.replace(NombreEmpieza + '-', "");
395                        AuxPartido = Aux.split("-")
396                        Color = AuxPartido[0];
397                        Talla = AuxPartido[1];
398                        Pack = AuxPartido[2];
399                        cant = document.getElementById('cantidad-' + arrayProducto[x] + '-' + Color + '-' + Talla + '-' + Pack).value;
400                        //una vez tengo toda la informacion, llamo a agregar carrito
401                        var articulo = [arrayProducto[x], cant, Color, Talla, Pack];
402                        agregarACarrito.push(articulo);
403                        //AgregarCarritoPack(destino, arrayProducto[x], Color, Talla, Pack);
404                    }
405                }
406            }
407        };
408        //despues, voy a la función para agregar el pack comleto de una vez al carrito
409        AgregarCarritoPack(destino, agregarACarrito);
410    } else {
411        //mostramos error
412        window.alert("Error, para agregar debe seleccionar 1 unidad únicamente de cada producto del pack");
413    }
414    
415
416
417}
418function AgregarCarritoPack(destino, agregarACarrito) {
419    //convierto el array a json para enviarlo, y lo envio a la pagina para procesarlo por php
420    var arrayJson = JSON.stringify(agregarACarrito);
421    $("#" + destino).load("AgregarCarritoPack.php", { articulos: arrayJson });
422    //$("#" + destino).load("AgregarCarrito.php", { producto: pro, cantidad: cant, color: col, talla: tal }, function () {
423    //    ObjTemp = this;
424    //    setTimeout(function(){ jQuery(ObjTemp).hide();},5000);
425    //});
426    location.reload();
427}
428function AgregarPresupuestoDesdeSelector(destino, producto, NumPresupuesto) {
429    //alert("hola");
430    //donde se mostrará lo resultados
431    var NombreEmpieza = 'cantidad-' + producto;
432    Elementos = document.getElementsByClassName("cantidad");
433    for (i = 0; i < Elementos.length; i++) {
434        //divido el objeto que recorro
435        Objeto = Elementos[i];
436        //si el id del objeto empieza por el nombre del producto que busco, mirare si el value es mayor a 0, para agregar los correspondientes
437        if (Objeto.id.startsWith(NombreEmpieza)) {
438            //ahora, si el value es mayor que 0
439            if (Objeto.value > 0) {
440                Aux = Objeto.id.replace(NombreEmpieza + '-', "");
441                AuxPartido = Aux.split("-")
442                Color = AuxPartido[0];
443                Talla = AuxPartido[1];
444                //una vez tengo toda la informacion, llamo a agregar carrito
445                AgregarPresupuesto(destino, producto, Color, Talla, NumPresupuesto);
446            }
447        }
448    }
449    //alert(cant);
450}
451function AgregarPresupuesto(destino, producto, color, talla, NumPresupuesto) {
452    //alert("hola");
453    //donde se mostrará lo resultados
454    pro = producto;
455    col = color;
456    tal = talla;
457    cant = document.getElementById('cantidad-' + producto + '-' + color + '-' + talla).value;
458    //enviando los valores
459    //si no, muestro la busqueda rapida
460    $("#" + destino).load("AgregarPresupuesto.php", { producto: pro, cantidad: cant, color: col, talla: tal, Presupuesto: NumPresupuesto });
461    //$("#" + destino).load("AgregarCarrito.php", { producto: pro, cantidad: cant, color: col, talla: tal }, function () {
462    //    ObjTemp = this;
463    //    setTimeout(function(){ jQuery(ObjTemp).hide();},5000);
464    //});
465}
466function AgregarPresupuestoDesdeCarrito(destino, NumPresupuesto) {
467    //alert("hola");
468    //donde se mostrará lo resultados
469    //enviando los valores
470    //si no, muestro la busqueda rapida
471    $("#" + destino).load("AgregarPresupuestoDesdeCarrito.php", { Presupuesto: NumPresupuesto });
472    //$("#" + destino).load("AgregarCarrito.php", { producto: pro, cantidad: cant, color: col, talla: tal }, function () {
473    //    ObjTemp = this;
474    //    setTimeout(function(){ jQuery(ObjTemp).hide();},5000);
475    //});
476}
477function AgregarCarritoDesdePresupuesto(destino, NumPresupuesto) {
478    //alert("hola");
479    //donde se mostrará lo resultados
480    //enviando los valores
481    //si no, muestro la busqueda rapida
482    $("#" + destino).load("AgregarCarritoDesdePresupuesto.php", { Presupuesto: NumPresupuesto });
483    //$("#" + destino).load("AgregarCarrito.php", { producto: pro, cantidad: cant, color: col, talla: tal }, function () {
484    //    ObjTemp = this;
485    //    setTimeout(function(){ jQuery(ObjTemp).hide();},5000);
486    //});
487}
488function ModificarCarritoBotones(destino, prod, Accion) {
489    cant = document.getElementById('Cantidad-' + prod).value;
490    if (Accion == "Sumar") {
491        cant = parseInt(cant) + 1;
492
493    }
494    if (Accion == "Restar" && (parseInt(cant) - 1) > 0) {
495        cant = parseInt(cant) - 1;
496    }
497    //si no, muestro la busqueda rapida
498    $("#" + destino).load("ModificarCarrito.php", { producto: prod, cantidad: cant }, function () {
499        ObjTemp = this;
500        setTimeout(function () { jQuery(ObjTemp).hide(); }, 5000);
501    });
502}
503function PresupuestoCalcularOfertas(destino) {
504    //si no, muestro la busqueda rapida
505    $("#" + destino).load("PresupuestoCalcularOfertas.php", {});
506}
507function PresupuestoMarcarTodos() {
508    //capturo los checkbox
509    oCheckbox = document.getElementsByClassName("checkbox");
510    //lo primero, vemos si el primero está true, si está true, desmarcaremos todos, si no, marcaremos todos
511    if (oCheckbox[0].checked == true) {
512        for (var i = 0; i < oCheckbox.length; i++) {
513            oCheckbox[i].checked = false;
514        }
515    } else {
516        for (var i = 0; i < oCheckbox.length; i++) {
517            oCheckbox[i].checked = true;
518        }
519    }
520} 
521function PresupuestoAnadirCarrito(destino) {
522    //si no, muestro la busqueda rapida
523    oCheckbox = document.getElementsByClassName("checkbox");
524    //alert(oCheckbox[0].checked);
525    //codprod     prueba[0].value
526    //recorro los chekbox
527    ListadoCantidad = "*";
528    ListadoProductos = "*";
529    for (var i = 0; i < oCheckbox.length; i++) {
530        //primero, miro si es true, y si es true, insertaré al carrito
531        if (oCheckbox[i].checked == true) {
532            //capturo datos necesarios
533            CodProd = oCheckbox[i].value
534            var porId = document.getElementById("Cantidad-" + CodProd);
535            var Cantidad = porId.value;
536            //agrego al listado
537            ListadoProductos = ListadoProductos + "," + CodProd;
538            ListadoCantidad = ListadoCantidad + "," + Cantidad;
539            //una vez tengo los datos, agrego al carrito
540            //lo anulo y lo incluyo en la siguiente porque si no no lo hace bien
541            //$("#" + destino).load("AgregarCarrito.php", { cantidad: Cantidad, producto: CodProd });
542            //y una vez está agregado, marco esa linea como pendiente = 1
543            //y con esto, ya estará pasado al carrito y quitado del presupuesto
544        }
545    }
546    //despues, envio si hay resultados
547    if (ListadoProductos != "*") {
548        //pongo el formato correcto a los listados
549        ListadoProductos = ListadoProductos.replace("*,", "");
550        ListadoCantidad = ListadoCantidad.replace("*,", "");
551        $("#" + destino).load("PresupuestoMarcarPasadoCarrito.php", { cantidad: ListadoCantidad, producto: ListadoProductos });
552    }
553    //una vez lo he hecho con todos, recargo la pagina del presupuesto.
554    //window.location.replace('index.php?pag=Presupuesto');
555}
556function AgregarRestos(destino, product, cliente, tarifa, albar, lin, idDir, ErrorDireccion, CantidadMaxima) {
557    pro = product;
558    cli = cliente;
559    tar = tarifa;
560    //agrego variable que luego me marcara si tengo que pasar el resto o el articulo normal
561    EsLineaResto = 0;
562    cant = document.getElementById('cantidad-' + pro).value;
563    //si la cantidad a agregar es menor o igual a la maxima, agrego
564    if (cant <= CantidadMaxima) {
565        //alert(ErrorDireccion);
566        procesar = true;
567        //si hemos mandado que muestre la advertencia de direccion, la mostramos
568        if (ErrorDireccion == 1) {
569            //preguntamos si desea seguir, y depende de lo que elija procesaremos o no, segun el idioma
570            switch (Idioma) {
571                case "it":
572                    //italiano
573                    if (confirm("La dirección del “resto” es distinta a la actual del carrito. Si agrega el “resto”, este será enviado a la dirección del carrito. ¿Desea continuar?")) {
574                        procesar = true;
575                    } else {
576                        procesar = false;
577                    }
578                    break;
579                case "fr":
580                    //frances
581                    if (confirm("La dirección del “resto” es distinta a la actual del carrito. Si agrega el “resto”, este será enviado a la dirección del carrito. ¿Desea continuar?")) {
582                        procesar = true;
583                    } else {
584                        procesar = false;
585                    }
586                    break;
587                case "pr":
588                    //portugues
589                    if (confirm("La dirección del “resto” es distinta a la actual del carrito. Si agrega el “resto”, este será enviado a la dirección del carrito. ¿Desea continuar?")) {
590                        procesar = true;
591                    } else {
592                        procesar = false;
593                    }
594                    break;
595                default:
596                    //español
597                    if (confirm("La dirección del “resto” es distinta a la actual del carrito. Si agrega el “resto”, este será enviado a la dirección del carrito. ¿Desea continuar?")) {
598                        procesar = true;
599                    } else {
600                        procesar = false;
601                    }
602                    break;
603            }
604        }
605
606        //si hay que procesar, procesamos
607        if (procesar == true) {
608            //si no, muestro la busqueda rapida
609            $("#" + destino).load("AgregarRestos.php", { producto: pro, cantidad: cant, albaran: albar, linea: lin, iddireccion: idDir }, function () {
610                ObjTemp = this;
611                setTimeout(function () { jQuery(ObjTemp).hide(); }, 500000);
612            });
613        }
614    } else {
615        //si no, dare mensaje de error
616        alert("Error, la cantidad a agregar es mayor que la cantidad que puede agregar (" + CantidadMaxima + " unidades).");
617    }
618}
619
620function BorrarRestos(destino, albar, lin, cant) {
621    $("#" + destino).load("BorrarRestos.php", { albaran: albar, linea: lin, cantidad: cant }, function () {
622        ObjTemp = this;
623        setTimeout(function () { jQuery(ObjTemp).hide(); }, 5000);
624    });
625
626    ajax.send("albaran=" + albaran + "&linea=" + linea + "&cantidad=" + cantidad)
627
628}
629function AgregarCarritoAlter(destino, Producto, IdCantidad, Almacen) {
630    //primero capturo el valor del campo de la busqueda
631    var porId = document.getElementById(IdCantidad);
632    var Cantidad = porId.value;
633    //si no, muestro la busqueda rapida
634    $("#" + destino).load("AgregarCarrito.php", { cantidad: Cantidad, producto: Producto, almacen: Almacen });
635}
636function AgregarRMA(destino, product, pedid) {
637    //alert("hola");
638    //donde se mostrará lo resultados
639    pro = product;
640    ped = pedid;
641    cant = document.getElementById('cantidad-' + pro + ped).value;
642    //valores de los inputs
643
644    //si no, muestro la busqueda rapida
645    $("#" + destino).load("AgregarRMA.php", { producto: pro, cantidad: cant, pedido: ped }, function () {
646        ObjTemp = this;
647        setTimeout(function () { jQuery(ObjTemp).hide(); }, 5000);
648    });
649}
650function AgregarRMANoWeb(destino) {
651    //alert("hola");
652    //donde se mostrará lo resultados
653    ped = "";//document.getElementById('pedido').value;
654    cod = document.getElementById('codart').value;
655    ref = document.getElementById('refpro').value;
656    des = document.getElementById('descripcion').value;
657    cant = document.getElementById('cantidad').value;
658    prec = document.getElementById('precio').value;
659    //valores de los inputs
660
661    //si no, muestro la busqueda rapida
662    $("#" + destino).load("AgregarRMANoWeb.php", { pedido: ped, codart: cod, refpro: ref, descripcion: des, cantidad: cant, precio: prec }, function () {
663        ObjTemp = this;
664        setTimeout(function () { jQuery(ObjTemp).hide(); }, 5000);
665    });
666}
667function EliminarRMA(destino, IdLinea, Orig) {
668    //si no, muestro la busqueda rapida
669    $("#" + destino).load("EliminarRMA.php", { Linea: IdLinea, Origen: Orig });
670}
671var intervalCarritoMini
672function ActualizarCantidadCarritoMini(destino, Producto, IdCantidad, IdLinea) {
673    clearTimeout(intervalCarritoMini);
674    intervalCarritoMini = setTimeout(function () {
675        //primero capturo el valor del campo de la busqueda
676        var porId = document.getElementById(IdCantidad);
677        var Cantidad = porId.value;
678        //si no, muestro la busqueda rapida
679        $("#" + destino).load("ActualizarCantidadCarritoMini.php", { cantidad: Cantidad, producto: Producto, idlinea: IdLinea });
680    }, 500);
681}
682var intervalCarrito
683function ActualizarCantidadCarrito(destino, Producto, IdCantidad, IdLinea) {
684    clearTimeout(intervalCarrito);
685    intervalCarrito = setTimeout(function () {
686        //primero capturo el valor del campo de la busqueda
687        var porId = document.getElementById(IdCantidad);
688        var Cantidad = porId.value;
689        //si no, muestro la busqueda rapida
690        $("#" + destino).load("ActualizarCantidadCarrito.php", { cantidad: Cantidad, producto: Producto, idlinea: IdLinea });
691    }, 500);
692}
693
694function IrAPagina(pagina, CogerHid) {
695    //CogerHid = CogerHid || '';
696    CogerHid = typeof CogerHid !== 'undefined' ? CogerHid : '';
697    VarExtra = ' ';
698
699    if (CogerHid.length > 0) {
700        div = document.getElementById(CogerHid);
701        if (div)
702            VarExtra = '&' + CogerHid + '=' + div.value;
703    }
704    if (pagina == "") {
705        location.href = "index.php";
706    } else {
707        location.href = "index.php?pag=" + pagina + VarExtra;
708    }
709}
710function FinalizarCarrito(pagina, idioma) {
711    CheckAceptar = document.getElementById('checkfinalizar');
712    if (CheckAceptar.checked == true) {
713        IrAPagina(pagina);
714    } else {
715        switch (idioma) {
716            case 'fr':
717                alert('Afin de finaliser la commande, vous devez accepter notre politique de confidentialité des données.');
718                break;
719            case 'it':
720                alert('Al fine di finalizzare l\'ordine, è necessario accettare la nostra politica sulla privacy dei dati.');
721                break;
722            case 'pr':
723                alert('Para finalizar o pedido, você deve aceitar nossa política de privacidade de dados.');
724                break;
725            default:
726                alert('Para poder finalizar el pedido, debe aceptar nuestra política de privacidad de datos.');
727        }
728    }
729}
730function IrAWeb(pagina) {
731    location.href = pagina;
732}
733function IrAPaginaNuevaPestana(pagina) {
734    var a = document.createElement("a");
735    a.target = "_blank";
736    a.href = pagina;
737    a.click();
738}
739function IrAPaginaCon2Parametros(pagina, NombreParam1, param1, NombreParam2, param2) {
740
741
742    var form = document.createElement("form"); // crear un form
743    with (form) {
744        setAttribute("name", "busquedaproductos"); //nombre del form
745        setAttribute("action", "index.php?pag=" + pagina); // action por defecto
746        setAttribute("method", "post"); // method POST 
747    }
748
749    var input = document.createElement("input"); // Crea un elemento input
750    with (input) {
751        setAttribute("name", NombreParam1); //nombre del input
752        setAttribute("type", "hidden"); // tipo hidden
753        setAttribute("value", param1); // valor por defecto
754    }
755
756    form.appendChild(input); // añade el input al formulario
757    var input2 = document.createElement("input"); // Crea un elemento input
758    with (input2) {
759        setAttribute("name", NombreParam2); //nombre del input
760        setAttribute("type", "hidden"); // tipo hidden
761        setAttribute("value", param2); // valor por defecto
762    }
763
764    form.appendChild(input2); // añade el input al formulario
765    document.body.appendChild(form)
766    form.submit();//por ultimo, envio el formulario
767}
768function IrAPaginaCon4Parametros(pagina, NombreParam1, param1, NombreParam2, param2, NombreParam3, param3, NombreParam4, param4) {
769
770
771    var form = document.createElement("form"); // crear un form
772    with (form) {
773        setAttribute("name", "busquedaproductos"); //nombre del form
774        setAttribute("action", "index.php?pag=" + pagina); // action por defecto
775        setAttribute("method", "post"); // method POST 
776    }
777
778    var input = document.createElement("input"); // Crea un elemento input
779    with (input) {
780        setAttribute("name", NombreParam1); //nombre del input
781        setAttribute("type", "hidden"); // tipo hidden
782        setAttribute("value", param1); // valor por defecto
783    }
784
785    form.appendChild(input); // añade el input al formulario
786    var input2 = document.createElement("input"); // Crea un elemento input
787    with (input2) {
788        setAttribute("name", NombreParam2); //nombre del input
789        setAttribute("type", "hidden"); // tipo hidden
790        setAttribute("value", param2); // valor por defecto
791    }
792
793    form.appendChild(input2); // añade el input al formulario
794    var input3 = document.createElement("input"); // Crea un elemento input
795    with (input3) {
796        setAttribute("name", NombreParam3); //nombre del input
797        setAttribute("type", "hidden"); // tipo hidden
798        setAttribute("value", param3); // valor por defecto
799    }
800
801    form.appendChild(input3); // añade el input al formulario
802    var input4 = document.createElement("input"); // Crea un elemento input
803    with (input4) {
804        setAttribute("name", NombreParam4); //nombre del input
805        setAttribute("type", "hidden"); // tipo hidden
806        setAttribute("value", param4); // valor por defecto
807    }
808
809    form.appendChild(input4); // añade el input al formulario
810    document.body.appendChild(form)
811    form.submit();//por ultimo, envio el formulario
812}
813function IrAPaginaCon1Parametros(pagina, NombreParam1, param1) {
814
815
816    var form3 = document.createElement("form"); // crear un form
817    with (form3) {
818        setAttribute("name", "formularioCarrito"); //nombre del form
819        setAttribute("action", "index.php?pag=" + pagina); // action por defecto
820        setAttribute("method", "post"); // method POST 
821    }
822
823    var input = document.createElement("input"); // Crea un elemento input
824    with (input) {
825        setAttribute("name", NombreParam1); //nombre del input
826        setAttribute("type", "hidden"); // tipo hidden
827        setAttribute("value", param1); // valor por defecto
828    }
829
830    form3.appendChild(input); // añade el input al formulario
831    document.body.appendChild(form3)
832    form3.submit();//por ultimo, envio el formulario
833}
834function FinalizarPedido(destino, pagina, fase, idCabecera, dato1) {
835    //segun sea la fase 1,2 o 3, hago lo que corresponda
836
837    if (fase == 0) {
838        $("#" + destino).load(pagina, { idCabecera: idCabecera });
839    } else if (fase == 1) {
840        //recupero el dato 1 para enviarlo
841        var porId = document.getElementById(dato1);
842        var ValorDato1 = porId.value;
843        $("#" + destino).load(pagina, { idCabecera: idCabecera, Observaciones: ValorDato1 });
844    } else if (fase == 2) {
845        $("#" + destino).load(pagina, { idCabecera: idCabecera, nombre: "kike", edad: 33 });
846    } else if (fase == 3) {
847        $("#" + destino).load(pagina, { idCabecera: idCabecera, nombre: "kike", edad: 33 });
848    }
849}
850function FinalizarPedidoCambioDireccion(destino, pagina, idCabecera, idDireccion) {
851    //pagina de cambio de direccion
852    $("#" + destino).load(pagina, { idCabecera: idCabecera, idDireccion: idDireccion });
853}
854function FinalizarPedidoCambioFormaPago(destino, pagina, FormaPago, idCabecera) {
855    $("#" + destino).load(pagina, { idCabecera: idCabecera, FormaPago: FormaPago });
856}
857function MostrarCarritoMini(destino, pagina) {
858    $("#" + destino).load(pagina, {  });
859}
860function CarritoCambioCantidadProducto(destino, pagina, idProducto, idCabecera, IdCantidad) {
861    //primero capturo el valor del campo de la busqueda
862    if (IdCantidad != "0") {
863        var porId = document.getElementById(IdCantidad);
864        var Cantidad = porId.value;
865    } else {
866        var Cantidad = "0";
867    }
868    $("#" + destino).load(pagina, { idProducto: idProducto, idCabecera: idCabecera, Cantidad: Cantidad });
869}
870function MostrarOcultar(idDiv) {
871    //var a = document.getElementById(idDiv);
872    //si esta oculto muestro, si no oculto
873    if (document.getElementById(idDiv).style.display == 'none') {
874        document.getElementById(idDiv).style.display = 'block';
875    } else {
876        document.getElementById(idDiv).style.display = 'none';
877    }
878}
879function MostrarOcultarAlter(idDiv) {
880    //si esta oculto muestro, si no oculto
881    if (document.getElementById(idDiv).style.display == 'block') {
882        document.getElementById(idDiv).style.display = 'none';
883    } else {
884        document.getElementById(idDiv).style.display = 'block';
885    }
886}
887function MostrarOcultarCaracteristicas(idDiv) {
888    //si esta oculto muestro, si no oculto
889    if (document.getElementById(idDiv).style.display == 'block') {
890        document.getElementById(idDiv).style.display = 'none';
891        $('.accordion-titulo').removeClass('open');
892    } else {
893        document.getElementById(idDiv).style.display = 'block';
894        $('.accordion-titulo').addClass('open');
895    }
896}
897function MostrarOcultarFiltros(idDivTitulo, idDivContenido) {
898    //si esta oculto muestro, si no oculto
899    if (document.getElementById(idDivContenido).style.display == 'block') {
900        document.getElementById(idDivContenido).style.display = 'none';
901        //$(idDivTitulo).removeClass('open');
902        //$('#' + idDivTitulo).text($('#' + idDivTitulo).text().replace('-', '+'));
903        //$('#' + idDivTitulo).text($('#' + idDivTitulo).text().replace('-', '+'));
904        $('#' + idDivTitulo).removeClass('open');
905    } else {
906        document.getElementById(idDivContenido).style.display = 'block';
907        //$('#' + idDivTitulo).text($('#' + idDivTitulo).text().replace('+', '-'));
908        //$('#' + idDivTitulo).text($('#' + idDivTitulo).text().replace('+', '-'));
909        //$(idDivTitulo).addClass('open');
910        $('#' + idDivTitulo).addClass('open');
911    }
912}
913function OcultarTodo(idDiv) {
914    //capturo todos los divs que contengan parte de esta id
915    $("[id*=" + idDiv + "]").hide();
916
917    
918}
919function BloquearDesbloquearInput(idInput) {
920    //si esta oculto muestro, si no oculto
921    if (document.getElementById(idInput).disabled == true) {
922        document.getElementById(idInput).disabled = false;
923    } else {
924        document.getElementById(idInput).disabled = true;
925    }
926}
927
928function LanzarFormulario(idFormulario) {
929    form = document.getElementById(idFormulario);
930    form.submit()
931    //document.forms[idFormulario].submit();
932}
933function MostrarBotonSubCat(idDiv) {
934    $("[id*=SubCat]").hide();
935    document.getElementById(idDiv).style.display = 'block';
936}
937function OcultarBotonSubCat(idDiv) {
938    $("[id*=SubCat]").hide();
939    document.getElementById(idDiv).style.display = 'none';
940}
941function MostrarBotonSubSubCat(idDiv) {
942    setTimeout(function () {
943        $("[id*=SubSubCat]").hide();
944        document.getElementById(idDiv).style.display = 'block';
945    }, 500);
946    
947}
948function OcultarBotonSubSubCat(idDiv) {
949    $("[id*=SubSubCat]").hide();
950    document.getElementById(idDiv).style.display = 'none';
951}
952function MostrarForzar(idDiv) {
953    document.getElementById(idDiv).style.display = 'block';
954}
955function OcultarForzar(idDiv) {
956    document.getElementById(idDiv).style.display = 'none';
957}
958function MostrarForzarStocks(idDiv, CodigoColor) {
959    document.getElementById(idDiv).style.display = 'block';
960    document.getElementById("img-" + CodigoColor).style.borderColor = 'red';
961}
962function OcultarForzarStocks(ParteID, CodigoColor) {
963    //lo primero, capturo todos los elementos con la etiqueta re
963cibida
964    oDiv = document.querySelectorAll('[id^="' + ParteID + '"]');
965    for (var i = 0; i < oDiv.length; i++) {
966        oDiv[i].style.display = 'none';
967    }
968    //ahora, el de la imagen
969    oDivImg = document.querySelectorAll('[id^="img-' + CodigoColor + '"]');
970    for (var i = 0; i < oDivImg.length; i++) {
971        oDivImg[i].style.borderColor = 'lightgrey';
972    }
973}
974function CambiarMenuCategorias(destino, Valor) {
975    //si no, muestro la busqueda rapida
976    $("#" + destino).load("CambiarMenuCategorias.php", { valor: Valor });
977}
978function CambiarModoVisualizacion(destino, NombreVariable, Valor) {
979    //si no, muestro la busqueda rapida
980    $("#" + destino).load("CambiarModoVisualizacion.php", { nombreVariable: NombreVariable, valor: Valor });
981}
982function CambiarModoVisualizacionBusquedaRapida(destino, NombreVariable, Valor) {
983    //si no, muestro la busqueda rapida
984    $("#" + destino).load("CambiarModoVisualizacionBusquedaRapida.php", { nombreVariable: NombreVariable, valor: Valor });
985}
986function CambiarVariableGlobal(destino, NombreVariable, Valor) {
987    //si no, muestro la busqueda rapida
988    $("#" + destino).load("CambiarVariableGlobal.php", { nombreVariable: NombreVariable, valor: Valor });
989}
990function CambiarVariableGlobalRefrescar(destino, NombreVariable, Valor) {
991    //si no, muestro la busqueda rapida
992    $("#" + destino).load("CambiarVariableGlobalRefrescar.php", { nombreVariable: NombreVariable, valor: Valor });
993}
994function CambiarVariableGlobalBusquedaRapida(destino, NombreVariable, Valor) {
995    //si no, muestro la busqueda rapida
996    $("#" + destino).load("CambiarVariableGlobalBusquedaRapida.php", { nombreVariable: NombreVariable, valor: Valor });
997}
998function VariarCantidad(IdCantidad, Accion) {
999    //primero capturo el valor del campo de la busqueda
1000    if (Accion == "Sumar") {
1001        div = document.getElementById(IdCantidad);
1002        if (parseInt(div.dataset.max) > parseInt(document.getElementById(IdCantidad).value))
1003            document.getElementById(IdCantidad).value = parseInt(document.getElementById(IdCantidad).value) + 1;
1004
1005    }
1006    if (Accion == "Restar") {
1007        if (parseInt(document.getElementById(IdCantidad).value) > 1) {
1008            document.getElementById(IdCantidad).value = parseInt(document.getElementById(IdCantidad).value) - 1;
1009        }
1010    }
1011    div = document.getElementById('hid' + IdCantidad)
1012    if (div) {
1013        div.value = document.getElementById(IdCantidad).value;
1014    }
1015}
1016function VerificarCantidadMaxima(IdCantidad, Maximo) {
1017    //primero capturo el valor del campo de la busqueda
1018    var num = $("#" + IdCantidad).val();
1019
1020    //ahora, si la cantidad es mayor que la maxima, pongo la maxima
1021    if (parseInt(num) > parseInt(Maximo)) {
1022        $("#" + IdCantidad).val(parseInt(Maximo));
1023    }
1024    //ahora, si es inferior a 0, pongo 0
1025    if (parseInt(num) < parseInt(0)) {
1026        $("#" + IdCantidad).val(parseInt(0));
1027    }
1028}
1029function VariarCantidadAlter(IdCantidad, Accion, Maximo) {
1030    //primero capturo el valor del campo de la busqueda
1031    var num = $("#" + IdCantidad).val();
1032
1033    if (Accion == "Sumar") {
1034        //ahora, si la suma se queda en una cantidad inferior, lo establecemos
1035        if ((parseInt(num) + parseInt(1)) <= Maximo){
1036            $("#" + IdCantidad).val(parseInt(num) + 1);
1037        }
1038    }
1039    if (Accion == "Restar") {
1040        if (num > 0) {
1041            $("#" + IdCantidad).val(parseInt(num) - 1);
1042        }
1043    }
1044}
1045function VariarCantidadAlter2(IdCantidad, Accion) {
1046    //primero capturo el valor del campo de la busqueda
1047    var num = $("#" + IdCantidad).val();
1048
1049    if (Accion == "Sumar") {
1050        $("#" + IdCantidad).val(parseInt(num) + 1);
1051
1052    }
1053    if (Accion == "Restar") {
1054        if (num > 1) {
1055            $("#" + IdCantidad).val(parseInt(num) - 1);
1056        }
1057    }
1058}
1059function VariarCantidadAlterPack(IdCantidad, Accion, Maximo, elementosIds, seleccionarId) {
1060    //primero capturo el valor del campo de la busqueda
1061    var num = $("#" + IdCantidad).val();
1062
1063    if (Accion == "Sumar") {
1064        //ahora, si la suma se queda en una cantidad inferior, lo establecemos
1065        if ((parseInt(num) + parseInt(1)) <= Maximo) {
1066            $("#" + IdCantidad).val(parseInt(num) + 1);
1067            //ahora, marco como que se ha seleccioando talla en la pagina del pack
1068            ObjetoSeleccionarId = document.getElementById(seleccionarId);
1069            ObjetoSeleccionarId.innerHTML = "Talla Seleccionada";
1070            ObjetoSeleccionarId.style.backgroundColor = "green";
1071            //si toca incrementar, deshabilito el resto de cheks de este color para las otras tallas, asi solo pueden poner 1
1072            //busco los elementos que coinciden
1073            totalElementos = elementosIds.split('|');
1074            for (i = 0; i < totalElementos.length; i++) {
1075                //si el elemento es distinto del que hemos seleccionado
1076                if (totalElementos[i] != IdCantidad) {
1077                    //capturo el elemento
1078                    Objeto = document.getElementById(totalElementos[i]);
1079                    //lo pongo en disabled para que no se escriba cantidad
1080                    //Objeto.disabled = true;
1081                    //ahora, capturo el boton de suma
1082                    ObjetoSuma = document.getElementById(totalElementos[i] + '-botonsuma');
1083                    //lo pongo en disabled para que no se escriba cantidad
1084                    //ObjetoSuma.disabled = true;
1085                    //ahora, capturo el boton de resta
1086                    ObjetoResta = document.getElementById(totalElementos[i] + '-botonresta');
1087                    //lo pongo en disabled para que no se escriba cantidad
1088                    //ObjetoResta.disabled = true;
1089                }
1090            }
1091        }
1092    }
1093    if (Accion == "Restar") {
1094        if (num > 0) {
1095            $("#" + IdCantidad).val(parseInt(num) - 1);
1096            //ahora, marco como que se ha desseleccioando talla en la pagina del pack
1097            ObjetoSeleccionarId = document.getElementById(seleccionarId);
1098            ObjetoSeleccionarId.innerHTML = "Seleccionar Talla";
1099            ObjetoSeleccionarId.style.backgroundColor = "#138BC7";
1100            //si toca restar, habilito el resto de cheks de este color para las otras tallas, asi solo pueden poner 1
1101            //busco los elementos que coinciden
1102            totalElementos = elementosIds.split('|');
1103            for (i = 0; i < totalElementos.length; i++) {
1104                //si el elemento es distinto del que hemos seleccionado
1105                if (totalElementos[i] != IdCantidad) {
1106                    //capturo el elemento
1107                    Objeto = document.getElementById(totalElementos[i]);
1108                    //lo pongo en disabled para que no se escriba cantidad
1109                    //Objeto.disabled = false;
1110                    //ahora, capturo el boton de suma
1111                    ObjetoSuma = document.getElementById(totalElementos[i] + '-botonsuma');
1112                    //lo pongo en disabled para que no se escriba cantidad
1113                    //ObjetoSuma.disabled = false;
1114                    //ahora, capturo el boton de resta
1115                    ObjetoResta = document.getElementById(totalElementos[i] + '-botonresta');
1116                    //lo pongo en disabled para que no se escriba cantidad
1117                    //ObjetoResta.disabled = false;
1118                }
1119            }
1120        }
1121    }
1122}
1123function VariarOfertaGasolina(IdCantidad, IdPrecioOferta, Precio) {
1124    //primero capturo el valor del campo de la busqueda
1125    Cantidad = document.getElementById(IdCantidad).value;
1126    //ahora modifico el valor concreto del conseguido de la oferta
1127    document.getElementById(IdPrecioOferta).innerHTML = (Math.round((Cantidad * Precio)*100)/100) + "€";
1128}
1129function SeleccionarAlmacen(Almacen, idDivPrecio, idDivPortes, IdHiddenAlmacen, PrecioNuevo, PortesNuevos, ColorPortes) {
1130    document.getElementById(idDivPrecio).innerText = PrecioNuevo;
1131    document.getElementById(idDivPortes).innerText = PortesNuevos;
1132    document.getElementById(idDivPortes).style.color = ColorPortes;
1133    document.getElementById(IdHiddenAlmacen).value = Almacen;
1134
1135}
1136function SeleccionarAlmacenCarrito(destino, IdAlmacen, IdCantidad, IdLinea) {
1137    //primero capturo el valor del campo de la busqueda
1138    var porId = document.getElementById(IdCantidad);
1139    var Cantidad = porId.value;
1140    //si no, muestro la busqueda rapida
1141    $("#" + destino).load("ActualizarAlmacenCarrito.php", { cantidad: Cantidad, almacen: IdAlmacen, idlinea: IdLinea });
1142
1143}
1144function AgregarAvisoStock(destino, Producto, IdCliente) {
1145    //si no, muestro la busqueda rapida
1146    $("#" + destino).load("AgregarAvisoStock.php", { cliente: IdCliente, producto: Producto });
1147}
1148function aceptoCookies(destino, IdCliente) {
1149    //si no, muestro la busqueda rapida
1150    $("#" + destino).load("aceptoCookies.php", { cliente: IdCliente});
1151}
1152function EliminarAvisoStock(destino, Producto, IdCliente) {
1153    //si no, muestro la busqueda rapida
1154    $("#" + destino).load("EliminarAvisoStock.php", { cliente: IdCliente, producto: Producto });
1155}
1156function EliminarCarrito(destino, CodArt, CodColor, CodTalla) {
1157    //si no, muestro la busqueda rapida
1158    $("#" + destino).load("EliminarCarrito.php", { Articulo: CodArt, Color: CodColor, Talla: CodTalla });
1159}
1160function EliminarCarritoReferencia(destino, CodArt, Color) {
1161    //si no, muestro la busqueda rapida
1162    $("#" + destino).load("EliminarCarritoReferencia.php", { Articulo: CodArt, Col: Color });
1163}
1164function EliminarCarritoReferenciaPack(destino, CodArt, Color, CodPack) {
1165    //muestro advertencia de que si elimina un artículo de pack, los elimina todos, y opción de continuar
1166    var resultado = window.confirm('Si borra un artículo de Pack, se eliminarán TODOS los artículos de ese Pack. ¿Desea eliminar el artículo?');
1167    if (resultado === true) {
1168        $("#" + destino).load("EliminarCarritoReferenciaPack.php", { Articulo: CodArt, Col: Color, Pack: CodPack });
1169    }
1170}
1171function EliminarPresupuesto(destino, CodArt, CodColor, CodTalla, IdCabecera) {
1172    //si no, muestro la busqueda rapida
1173    $("#" + destino).load("EliminarPresupuesto.php", { Articulo: CodArt, Color: CodColor, Talla: CodTalla, id: IdCabecera });
1174}
1175function EliminarPresupuestoReferencia(destino, CodArt, Color, IdCabecera) {
1176    //si no, muestro la busqueda rapida
1177    $("#" + destino).load("EliminarPresupuestoReferencia.php", { Articulo: CodArt, Col: Color, id: IdCabecera });
1178}
1179function ModificarPresupuesto(destino, prod, col, tal, IdCabecera) {
1180    cant = document.getElementById('cantidad-' + prod + '-' + col + '-' + tal).value;
1181    //si es mayor que 0 lo hago, si no muestro mensaje de que la cantidad tiene que ser mayor que 0
1182    if (parseInt(cant) > 0) {
1183        $("#" + destino).load("ModificarPresupuesto.php", { producto: prod, color: col, talla: tal, cantidad: cant, id: IdCabecera }, function () {
1184            ObjTemp = this;
1185            setTimeout(function () { jQuery(ObjTemp).hide(); }, 5000);
1186        });
1187    } else {
1188        EliminarPresupuesto(destino, prod, col, tal, IdCabecera);
1189    }
1190}
1191
1192function cambiaFormaPago(destino, IdCliente, ped, val) {
1193    $("#" + destino).load("cambiaFormaPago.php", { cliente: IdCliente, pedido: ped, valor: val });
1194}
1195
1196function cambiaFormaPagoPendiente(destino, IdCliente, ped, val) {
1197    $("#" + destino).load("cambiaFormaPagoPendiente.php", { cliente: IdCliente, pedido: ped, valor: val });
1198}
1199function contador_regresivo(idDiv, d, h, m, s) {
1200    var interval = setInterval(function () {
1201        contador_regresivoBasic(idDiv, d, h, m, s);
1202        //se actualizara cada 30 segundos en lugar de cada segundo, para no colapsar tanto   },1000);
1203    }, 60000);
1204}
1205function contador_regresivoBasic(idDiv, d, h, m, s) {
1206        if (s > 0) { s--; }
1207        else
1208        {
1209            if (m > 0) {
1210                m--;
1211                s = 59;
1212            }
1213            else {
1214                if (h > 0) {
1215                    h--;
1216                    m = 59;
1217                    s = 59;
1218                }
1219                else {
1220                    if (d > 0) {
1221                        d--;
1222                        h = 24;
1223                        m = 59;
1224                        s = 59;
1225                    }
1226                    else {
1227                        clearInterval(interval);
1228                    }
1229                }
1230            }
1231        }
1232        //ahora comnpongo la cadena que enviaré con el tiempo que queda:
1233        var cadena = "";
1234        if (d > 0) {
1235            cadena = cadena + " " + d + " d.";
1236        }
1237        if (h > 0) {
1238            cadena = cadena + " " + h + " h.";
1239        }
1240        if (m > 0) {
1241            cadena = cadena + " " + m + " min.";
1242        }
1243        if (s > 0) {
1244            //cadena = cadena + " " + s + " seg.";
1245        }
1246
1247        var Objeto = document.getElementsByClassName(idDiv);
1248        //ahora recorro todos los elementos que coinciden y lo pongo
1249        for (i = 0; i < Objeto.length; i++) {
1250            Objeto[i].innerHTML = cadena;
1251        }
1252}
1253function addDays(theDate, days) {
1254    return new Date(theDate.getTime() + days * 24 * 60 * 60 * 1000);
1255}
1256function CalcularTiempoEnvio(idDestino, Almacen) {
1257    //alert("A");
1258    //Almacen=Almacen || 0;
1259    Almacen = typeof Almacen !== 'undefined' ? Almacen : 0;
1260    //lo primero que tengo que hacer, es obtener la fecha actual
1261    var FechaActual = new Date();
1262    var MilisegundosActual = FechaActual.getTime();
1263    //despues, compruebo si hoy es dia laboral
1264    var NumeroDiaActual = FechaActual.getDay();
1265    var HoraActual = FechaActual.getHours();
1266    var MinActual=FechaActual.getMinutes();
1267    var MesActual=FechaActual.getMonth();
1268    var DiaActual=FechaActual.getDate();
1269    var HoySePuedeReservar=true;
1270    if (NumeroDiaActual < 6 && NumeroDiaActual > 0) {
1271        //si es laboral, miro si es viernes
1272        if (NumeroDiaActual == 5) {
1273
1274            /*fecha Y desde el 20 de julio al 31 de agosto de cada año todos hasta las 1:30 excepto el almacen 1*/
1275            //AnoActual=FechaActual.getYear();
1276           
1277            //primera parte fechas indicadas y almacen diferente al 1, hora de corte 1:30  , Segunda parte , el amacen 1 siempre saca hasta las 2
1278            //Mes 6 es = a Julio y mes siete = Agosto ( cosa de ingleses )
1279            if (((MesActual >= 6 && DiaActual >= 20) && MesActual <= 7 && Almacen != 1 && ((HoraActual == 18 && MinActual >= 00) || (HoraActual > 13))) || (Almacen == 0 && ((HoraActual == 18 && MinActual >= 00) || (HoraActual > 18))) || (Almacen == 1 && HoraActual > 18))
1280            {
1281                HoySePuedeReservar=false;
1282            }
1283
1284
1285
1286            //si es viernes, y es mas tarde de las 13 horas, pongo la hora objetivo como dentro de 3 dias a las 17h.
1287            if ( !HoySePuedeReservar ) { //Es mayor de las 2 , pues lo recibiras el l
1288                //si la hora actual es mas que 16, es que son las 17 o mas, por lo que saldrá al día siguiente, por lo que pongo la hora objetivo a dentro de 3 dias a las 17h
1289                var AuxDia = addDays(new Date(), 3);
1290                //ahora, defino el dia con la hora de salida correcta
1291                var FechaObjetivo = new Date(AuxDia.getFullYear(), AuxDia.getMonth(), AuxDia.getDate(), 18, 00, 00);
1292                //por ultimo, guardo los milisegundos de este
1293                var MilisegundosObjetivo = FechaObjetivo.getTime();
1294            } else {
1295                //si la hora actual es menos que 16, pongo cuenta atras dia de hoy a las 17h
1296                //ahora, defino el dia con la hora de salida correcta
1297                if(Almacen==0)//Si no es el almacen 1 , todo sale antes de la 1:30 , sino a las 2
1298                {
1299                    var FechaObjetivo = new Date(FechaActual.getFullYear(), FechaActual.getMonth(), FechaActual.getDate(), 18, 00, 00);
1300                }else{
1301                    var FechaObjetivo = new Date(FechaActual.getFullYear(), FechaActual.getMonth(), FechaActual.getDate(), 18, 00, 00);
1302                }
1303                //por ultimo, guardo los milisegundos de este
1304                var MilisegundosObjetivo = FechaObjetivo.getTime();
1305            }
1306        } else {
1307
1308            //primera parte fechas indicadas y almacen diferente al 1, hora de corte 1:30  , Segunda parte , el amacen 1 siempre saca hasta las 2
1309            //Mes 6 es = a Julio y mes siete = Agosto ( cosa de ingleses )
1310            if(((MesActual>=6 && DiaActual>=20) && MesActual<=7 && Almacen!=1 && HoraActual>=18 && MinActual>=00) || (Almacen==1 && HoraActual>18)  )
1311            {
1312                HoySePuedeReservar=false;
1313            }
1314            //si NO es viernes, y es mas tarde de las 17 horas, pongo la hora objetivo como dentro de 1 dias a las 17h.
1315            if ((HoraActual > 18 || (HoraActual ==18 && MinActual>00 ) && HoySePuedeReservar)) {
1316                //si la hora actual es mas que 16, es que son las 17 o mas, por lo que saldrá al día siguiente, por lo que pongo la hora objetivo a dentro de 3 dias a las 17h
1317                var AuxDia = addDays(new Date(), 1);
1318                //ahora, defino el dia con la hora de salida correcta
1319                var FechaObjetivo = new Date(AuxDia.getFullYear(), AuxDia.getMonth(), AuxDia.getDate(), 18, 00, 00);
1320                //por ultimo, guardo los milisegundos de este
1321                var MilisegundosObjetivo = FechaObjetivo.getTime();
1322            } else {
1323                //si la hora actual es menos que 16, pongo cuenta atras dia de hoy a las 17h
1324                //ahora, defino el dia con la hora de salida correcta
1325                if(Almacen==1 || !(Almacen==0 && ((MesActual<=6 && DiaActual<20) || MesActual>7) ) )//Si no es el almacen 1 , todo sale antes de la 1:30 , sino a las 2
1326                {
1327                    var FechaObjetivo = new Date(FechaActual.getFullYear(), FechaActual.getMonth(), FechaActual.getDate(), 18, 00, 00);
1328                }
1329                else
1330                {
1331                    var FechaObjetivo = new Date(FechaActual.getFullYear(), FechaActual.getMonth(), FechaActual.getDate(), 18, 00, 00);
1332                }
1333                //por ultimo, guardo los milisegundos de este
1334                var MilisegundosObjetivo = FechaObjetivo.getTime();
1335            }
1336        }
1337    } else {
1338        //ahora, es sabado o domingo
1339        if (NumeroDiaActual == 5) {
1340            //si es sabado, pongo la hora objetivo como dentro de 2 dias a las 17h.
1341            //si la hora actual es mas que 16, es que son las 17 o mas, por lo que saldrá al día siguiente, por lo que pongo la hora objetivo a dentro de 3 dias a las 17h
1342            var AuxDia = addDays(new Date(), 2);
1343          
1344        } else {
1345            //si es domingo, pongo la hora objetivo como dentro de 1 dias a las 17h.
1346            //si la hora actual es mas que 16, es que son las 17 o mas, por lo que saldrá al día siguiente, por lo que pongo la hora objetivo a dentro de 3 dias a las 17h
1347            var AuxDia = addDays(new Date(), 1);
1348        }
1349        if (((MesActual >= 6 && DiaActual >= 20) && MesActual <= 7 && Almacen != 1))
1350        {
1351            //ahora, defino el dia con la hora de salida correcta
1352            var FechaObjetivo = new Date(AuxDia.getFullYear(), AuxDia.getMonth(), AuxDia.getDate(), 18, 00, 00);
1353        }else
1354        {
1355            //ahora, defino el dia con la hora de salida correcta
1356            var FechaObjetivo = new Date(AuxDia.getFullYear(), AuxDia.getMonth(), AuxDia.getDate(), 18, 00, 00);
1357        }
1358
1359        //por ultimo, guardo los milisegundos de este
1360        var MilisegundosObjetivo = FechaObjetivo.getTime();
1361    }
1362    //ahora calculo los milisegundos de diferencia
1363    var MilisegundosDiferencia = MilisegundosObjetivo - MilisegundosActual;
1364    //por ultimo, saco los dias, horas, minutos y segundos de diferencia
1365    var msecPerMinute = 1000 * 60;
1366    var msecPerHour = msecPerMinute * 60;
1367    var msecPerDay = msecPerHour * 24;
1368
1369    var Dias = Math.floor(MilisegundosDiferencia / msecPerDay);
1370    MilisegundosDiferencia = MilisegundosDiferencia - (Dias * msecPerDay);
1371
1372    var Horas = Math.floor(MilisegundosDiferencia / msecPerHour);
1373    MilisegundosDiferencia = MilisegundosDiferencia - (Horas * msecPerHour);
1374
1375    var Minutos = Math.floor(MilisegundosDiferencia / msecPerMinute);
1376    MilisegundosDiferencia = MilisegundosDiferencia - (Minutos * msecPerMinute);
1377
1378    var Segundos = Math.floor(MilisegundosDiferencia / 1000);
1379
1380
1381    contador_regresivoBasic(idDestino, Dias, Horas, Minutos, Segundos);
1382    contador_
1382regresivo(idDestino, Dias, Horas, Minutos, Segundos); // 0 Dias 0 Horas 1 Minuto 20 Segundos
1383}
1384function ObtenerNombreMes(Mes) {
1385    //le sumo uno al mes porque envia numero menos 1
1386    Mes = Mes + 1;
1387    var NombreMes = "";
1388    switch (Mes) {
1389        case Mes = 1:
1390            NombreMes = "Enero";
1391            break;
1392        case Mes = 2:
1393            NombreMes = "Febrero";
1394            break;
1395        case Mes = 3:
1396            NombreMes = "Marzo";
1397            break;
1398        case Mes = 4:
1399            NombreMes = "Abril";
1400            break;
1401        case Mes = 5:
1402            NombreMes = "Mayo";
1403            break;
1404        case Mes = 6:
1405            NombreMes = "Junio";
1406            break;
1407        case Mes = 7:
1408            NombreMes = "Julio";
1409            break;
1410        case Mes = 8:
1411            NombreMes = "Agosto";
1412            break;
1413        case Mes = 9:
1414            NombreMes = "Septiembre";
1415            break;
1416        case Mes = 10:
1417            NombreMes = "Octubre";
1418            break;
1419        case Mes = 11:
1420            NombreMes = "Noviembre";
1421            break;
1422        case 12:
1423            NombreMes = "Diciembre";
1424            break;
1425    }
1426    return NombreMes;
1427}
1428function ObtenerNombreDia(Dia) {
1429    //le sumo uno al mes porque envia numero menos 1
1430    //Dia = Dia + 1; con el dia, esto no pasa
1431    //ahora, si dia es mayor que 7, le quito 7, porque ha dado la vuelta a la semana.
1432    if (Dia > 7) {
1433        Dia = Dia - 7;
1434    }
1435    var NombreDia = "";
1436    switch (Dia) {
1437        case Mes = 1:
1438            NombreDia = "Lunes";
1439            break;
1440        case Mes = 2:
1441            NombreDia = "Martes";
1442            break;
1443        case Mes = 3:
1444            NombreDia = "Miercoles";
1445            break;
1446        case Mes = 4:
1447            NombreDia = "Jueves";
1448            break;
1449        case Mes = 5:
1450            NombreDia = "Viernes";
1451            break;
1452        case Mes = 6:
1453            NombreDia = "Sabado";
1454            break;
1455        case Mes = 7:
1456            NombreDia = "Domingo";
1457            break;
1458    }
1459    return NombreDia;
1460}
1461function CalcularDiaEnvio(idDestino,DiasEntrega,Almacen) {
1462    //Almacen = Almacen || 0;
1463    Almacen = typeof Almacen !== 'undefined' ? Almacen : 0;
1464    //lo primero que tengo que hacer, es obtener la fecha actual
1465    var FechaActual = new Date();
1466    var cadena = "";
1467    //despues, compruebo si hoy es dia laboral
1468    var NumeroDiaActual = FechaActual.getDay();
1469    var HoraActual = FechaActual.getHours();
1470    var MinActual=FechaActual.getMinutes();
1471    var MesActual=FechaActual.getMonth();
1472    var DiaActual=FechaActual.getDate();
1473    var HoySePuedeReservar=true;
1474    if (((MesActual >= 6 && DiaActual >= 20) && MesActual <= 7 && Almacen != 1 && ((HoraActual == 18 && MinActual >= 00) || (HoraActual > 18))) || (Almacen == 1 && HoraActual > 18))
1475    {
1476        HoySePuedeReservar=false;
1477    }//Falta acabar esto
1478    if (NumeroDiaActual < 6 && NumeroDiaActual > 0) {
1479        //si es laboral, miro si es viernes
1480        if (NumeroDiaActual == 5) {
1481            //al ser viernes , miramos que la hora de corte de los almacenes sea la 1:30
1482            if (HoySePuedeReservar && Almacen != 1 && ((HoraActual == 18 && MinActual >= 00 ) || (HoraActual>18))) HoySePuedeReservar = false;
1483            //si es viernes, y es mas tarde de las 14 horas, pongo la hora objetivo como dentro de 3 dias a las 16:30 h.
1484            if (!HoySePuedeReservar) {
1485                //si la hora actual es mas que 16, es que son las 17 o mas, por lo que saldrá al día siguiente, por lo que pongo la hora objetivo a dentro de 3 dias a las 17h
1486                var AuxDia = addDays(new Date(), 3);
1487                //ahora, defino el dia con la hora de salida correcta
1488                //si es el almacen 1
1489                if (Almacen == 1 || !(((MesActual >= 6 && DiaActual >= 20) && MesActual <= 7 && Almacen != 1 && ((HoraActual == 18 && MinActual >= 00)|| HoraActual>18))))
1490                    var FechaObjetivo = new Date(AuxDia.getFullYear(), AuxDia.getMonth(), AuxDia.getDate(), 18, 00, 00);
1491                else
1492                    var FechaObjetivo = new Date(AuxDia.getFullYear(), AuxDia.getMonth(), AuxDia.getDate(), 18, 00, 00);
1493                var FechaEntrega = addDays(new Date(), 3 + DiasEntrega);
1494                var NombreMes = ObtenerNombreMes(FechaEntrega.getMonth());
1495                var NombreDia = ObtenerNombreDia(FechaEntrega.getDay());
1496                cadena = NombreDia + " " + FechaEntrega.getDate();// + " de " + NombreMes;
1497            } else {
1498                //si la hora actual es menos que 16, pongo cuenta atras dia de hoy a las 17h
1499                var AuxDia = addDays(new Date(), 0);
1500                //ahora, defino el dia con la hora de salida correcta
1501                if (Almacen == 1)
1502                    var FechaObjetivo = new Date(AuxDia.getFullYear(), AuxDia.getMonth(), AuxDia.getDate(), 18, 00, 00);
1503                else
1504                    var FechaObjetivo = new Date(AuxDia.getFullYear(), AuxDia.getMonth(), AuxDia.getDate(), 18, 00, 00);
1505               // var FechaObjetivo = new Date(AuxDia.getFullYear(), AuxDia.getMonth(), AuxDia.getDate(),16, 30, 00);
1506                var FechaEntrega = addDays(new Date(), 2 + DiasEntrega);
1507                var NombreMes = ObtenerNombreMes(FechaEntrega.getMonth());
1508                var NombreDia = ObtenerNombreDia(FechaEntrega.getDay());
1509                cadena = NombreDia + " " + FechaEntrega.getDate();// + " de " + NombreMes;
1510            }
1511        } else {
1512            //si no es viernes, y es mas tarde de las 17 horas, pongo la hora objetivo como dentro de 1 dias a las 17h.
1513            if (!HoySePuedeReservar){ //(HoraActual > 16 || (HoraActual ==16 && MinActual>30 )) {
1514                //si es pasadas las 16h, y es  jueves, entonces habrá que sumarle 1 dia
1515                if (NumeroDiaActual == 4) {
1516                    //si la hora actual es mas que 16, es que son las 17 o mas, por lo que saldrá al día siguiente, por lo que pongo la hora objetivo a dentro de 3 dias a las 17h
1517                    var AuxDia = addDays(new Date(), 1);
1518                    //ahora, defino el dia con la hora de salida correcta
1519                    if(((MesActual >= 6 && DiaActual >= 20) && MesActual <= 7 && Almacen != 1 &&  ((HoraActual == 18 && MinActual >= 00)|| HoraActual>18)))
1520                        var FechaObjetivo = new Date(AuxDia.getFullYear(), AuxDia.getMonth(), AuxDia.getDate(),18, 00, 00);
1521                    else
1522                        var FechaObjetivo = new Date(AuxDia.getFullYear(), AuxDia.getMonth(), AuxDia.getDate(),18, 00, 00);
1523                    var FechaEntrega = addDays(new Date(), 3 + DiasEntrega);
1524                    var NombreMes = ObtenerNombreMes(FechaEntrega.getMonth());
1525                    var NombreDia = ObtenerNombreDia(FechaEntrega.getDay());
1526                } else {
1527                    //si la hora actual es mas que 16, es que son las 17 o mas, por lo que saldrá al día siguiente, por lo que pongo la hora objetivo a dentro de 3 dias a las 17h
1528                    var AuxDia = addDays(new Date(), 0);
1529                    //ahora, defino el dia con la hora de salida correcta
1530                    if(((MesActual >= 6 && DiaActual >= 20) && MesActual <= 7 && Almacen != 1 &&  ((HoraActual == 18 && MinActual >= 00)|| HoraActual>18)))
1531                        var FechaObjetivo = new Date(AuxDia.getFullYear(), AuxDia.getMonth(), AuxDia.getDate(),18, 00, 00);
1532                    else
1533                        var FechaObjetivo = new Date(AuxDia.getFullYear(), AuxDia.getMonth(), AuxDia.getDate(),18, 00, 00);
1534                    var FechaEntrega = addDays(new Date(), 1 + DiasEntrega);
1535                    var NombreMes = ObtenerNombreMes(FechaEntrega.getMonth());
1536                    var NombreDia = ObtenerNombreDia(FechaEntrega.getDay());
1537                }
1538                cadena = NombreDia + " " + FechaEntrega.getDate();// + " de " + NombreMes;
1539            } else {
1540                //si la hora actual es menos que 16, pongo cuenta atras dia de hoy a las 17h
1541                var AuxDia = addDays(new Date(), 0);
1542                //ahora, defino el dia con la hora de salida correcta
1543                if(((MesActual >= 6 && DiaActual >= 20) && MesActual <= 7 && Almacen != 1 &&  ((HoraActual == 18 && MinActual >= 00)|| HoraActual>18)))
1544                    var FechaObjetivo = new Date(AuxDia.getFullYear(), AuxDia.getMonth(), AuxDia.getDate(),18, 00, 00);
1545                else
1546                    var FechaObjetivo = new Date(AuxDia.getFullYear(), AuxDia.getMonth(), AuxDia.getDate(),18, 00, 00);
1547                //var FechaObjetivo = new Date(AuxDia.getFullYear(), AuxDia.getMonth(), AuxDia.getDate(),16, 30, 00);
1548                var FechaEntrega = addDays(new Date(), DiasEntrega);
1549                var NombreMes = ObtenerNombreMes(FechaEntrega.getMonth());
1550                var NombreDia = ObtenerNombreDia(FechaEntrega.getDay());
1551                cadena = NombreDia + " " + FechaEntrega.getDate();// + " de " + NombreMes;
1552            }
1553        }
1554    } else {
1555        //ahora, es sabado o domingo
1556        if (NumeroDiaActual == 5) {
1557            //si es sabado, pongo la hora objetivo como dentro de 2 dias a las 17h.
1558            //si la hora actual es mas que 16, es que son las 17 o mas, por lo que saldrá al día siguiente, por lo que pongo la hora objetivo a dentro de 3 dias a las 17h
1559            var AuxDia = addDays(new Date(), 2);
1560            //ahora, defino el dia con la hora de salida correcta
1561            if(((MesActual >= 6 && DiaActual >= 20) && MesActual <= 7 && Almacen != 1 &&  ((HoraActual == 18 && MinActual >= 00)|| HoraActual>18)))
1562                var FechaObjetivo = new Date(AuxDia.getFullYear(), AuxDia.getMonth(), AuxDia.getDate(), 18, 00, 00);
1563            else
1564                var FechaObjetivo = new Date(AuxDia.getFullYear(), AuxDia.getMonth(), AuxDia.getDate(), 18, 00, 00);
1565            //var FechaObjetivo = new Date(AuxDia.getFullYear(), AuxDia.getMonth(), AuxDia.getDate(), 16, 30, 00);
1566            var FechaEntrega = addDays(new Date(), 2 + DiasEntrega);
1567            var NombreMes = ObtenerNombreMes(FechaEntrega.getMonth());
1568            var NombreDia = ObtenerNombreDia(FechaEntrega.getDay());
1569            cadena = NombreDia + " " + FechaEntrega.getDate();// + " de " + NombreMes;
1570        } else {
1571            //si es domingo, pongo la hora objetivo como dentro de 1 dias a las 17h.
1572            //si la hora actual es mas que 16, es que son las 17 o mas, por lo que saldrá al día siguiente, por lo que pongo la hora objetivo a dentro de 3 dias a las 17h
1573            var AuxDia = addDays(new Date(), 1);
1574            //ahora, defino el dia con la hora de salida correcta
1575            if(((MesActual >= 6 && DiaActual >= 20) && MesActual <= 7 && Almacen != 1 &&  ((HoraActual == 18 && MinActual >= 00)|| HoraActual>18)))
1576                var FechaObjetivo = new Date(AuxDia.getFullYear(), AuxDia.getMonth(), AuxDia.getDate(), 18, 00, 00);
1577            else
1578                var FechaObjetivo = new Date(AuxDia.getFullYear(), AuxDia.getMonth(), AuxDia.getDate(), 18, 00, 00);
1579            //var FechaObjetivo = new Date(AuxDia.getFullYear(), AuxDia.getMonth(), AuxDia.getDate(), 16, 30, 00);
1580            var FechaEntrega = addDays(new Date(), 1 + DiasEntrega);
1581            var NombreMes = ObtenerNombreMes(FechaEntrega.getMonth());
1582            var NombreDia = ObtenerNombreDia(FechaEntrega.getDay());
1583            cadena = NombreDia + " " + FechaEntrega.getDate();// + " de " + NombreMes;
1584        }
1585    }
1586    //por ultimo, formateo la capa recibida agregando para la fecha objetivo
1587    var Objeto = document.getElementsByClassName(idDestino);
1588    //ahora recorro todos los elementos que coinciden y lo pongo
1589    for (i = 0; i < Objeto.length; i++) {
1590        Objeto[i].innerHTML = cadena;
1591    }
1592}
1593function MostrarCamposTextoDevolucion(IdLinea,Seleccionado)
1594{
1595    if(Seleccionado==0)
1596    {
1597        $('#DevolucionesPedidosLineasComentariosCelda' + IdLinea).addClass('Ocultar');
1598    }
1599    else
1600    {
1601        
1602        $('#DevolucionesPedidosLineasComentariosCelda' + IdLinea).removeClass('Ocultar');
1603        $('#TxtEnvioMailIndicaciones' + IdLinea).removeClass('Ocultar');
1604        $('#HorarioTxt' + IdLinea).show();
1605        
1606        if (Seleccionado == 1) {
1607            $('#DevolTransporte' + IdLinea).show();
1608            $('#DivImgDevolucion' + IdLinea).show();
1609        } else { $('#DevolTransporte' + IdLinea).hide(); $('#DivImgDevolucion' + IdLinea).hide(); }//Mostramos el campo de texto
1610        if (Seleccionado == 2) {
1611            $('#DevolCliente' + IdLinea).show();
1612            SeleccionEnvioCliente(IdLinea);
1613            //Valor = $('input:radio[name=TipoEnvio' + IdLinia + ']:checked').val();
1614            //if (Valor == 'E')
1615            //    $('#Horario' + IdLinea).show();
1616            //else $('#Horario' + IdLinea).hide();
1617        } else {
1618            $('#Horario' + IdLinea).show();
1619            $('#DevolCliente' + IdLinea).hide();
1620        }
1621        
1622    }
1623}
1624function SeleccionEnvioCliente(IdLinea)
1625{
1626    if ($('input[name="TipoEnvio' + IdLinea + '"]:checked').val() == 'C')
1627    {
1628        $('#Horario' + IdLinea).hide();
1629        $('#HorarioTxt' + IdLinea).hide();
1630        $('#TxtEnvioMailIndicaciones' + IdLinea).removeClass('Ocultar');
1631    }
1632      
1633else
1634{
1635        $('#Horario' + IdLinea).show();
1636        $('#HorarioTxt' + IdLinea).show();
1637         $('#TxtEnvioMailIndicaciones' + IdLinea).addClass('Ocultar');
1638        }
1639    
1640
1641}
1642
1643/* Validaciones */
1644
1645RevisionValidos = function (BtnOk, DivBuscar, Grupo) {
1646    DivBuscar = DivBuscar || 'body';
1647
1648    NoMasValidaciones = true;
1649    if (Grupo != null) {
1650        jQuery(' [data-checkear*=S]').each(function () {
1651            if (typeof (this.dataset.grupovalidador) != 'undefined') {
1652                if (this.dataset.grupovalidador == Grupo) {
1653                    if (NoMasValidaciones)
1654                        if (ComprobarValidacionRequerido(this) == false) {
1655                            NoMasValidaciones = false;
1656                        }
1657                }
1658            }
1659        });
1660    }
1661    else {
1662        jQuery(' [data-checkear*=S]').each(function () {
1663            if (NoMasValidaciones)
1664                if (ComprobarValidacionRequerido(this) == false) {
1665                    NoMasValidaciones = false;
1666                }
1667        });
1668    }
1669    if (NoMasValidaciones)BtnOk();
1670    return NoMasValidaciones;
1671}
1672
1673function myTrim(x) {
1674    return x.replace(/^\s+|\s+$/gm, '');
1675}
1676
1677ComprobarValidacionRequerido = function (Obj) {
1678    if (Obj.dataset.controlrel == "#DropPais") {
1679        if (jQuery(Obj.dataset.controlrel).val() == 1001) {
1680            Obj.dataset.checkrequerido = 'S';
1681        } else {
1682            Obj.dataset.checkrequerido = 'N';
1683        }
1684    }
1685    if (Obj.dataset.checkrequerido == 'S') {
1686        Txt = myTrim(Obj.value);
1687        if (Txt.length == 0) {
1688            MostrarMsgValidador(Obj.id);
1689            return false
1690        }
1691    }
1692    if (typeof Obj.dataset.checkiguala != 'undefined') {
1693        div = document.getElementById(Obj.dataset.checkiguala);
1694        if (div.value != Obj.value) {
1695            MostrarMsgValidador(Obj.id);
1696            return false
1697        }
1698    }
1699    if (typeof Obj.dataset.checkdiferente != 'undefined') {
1700       // if (div) carList.options[carList.selectedIndex].value
1701        if (Obj.value == Obj.dataset.checkdiferente) {
1702            MostrarMsgValidador(Obj.id);
1703            return false
1704        }
1705    }
1706    if (typeof Obj.dataset.checkformula != 'undefined') {
1707        if (ChekeoExpRegular(Obj) == false) {
1708            MostrarMsgValidador(Obj.id);
1709            return false
1710        }
1711    }
1712    if (Obj.type == 'checkbox')
1713    {
1714        if(Obj.checked==false)
1715        {
1716            MostrarMsgValidador(Obj.id);
1717            return false
1718        }
1719    }
1720
1721    //MostrarMsgValidador(Obj.id);
1722    return true;
1723}
1724
1725//La cantidad es las veces q se llama a si misma
1726MostrarMsgValidador = function (IdObj, Cant) {
1727    Cant = Cant || 0;
1728    Obj = document.getElementById(IdObj);
1729    if (Obj) {
1730        Tipo = 0;
1731        if (typeof Obj.dataset.mensajeerror != 'undefined') {
1732            Msg = Obj.dataset.mensajeerror;
1733
1734        } else if (typeof jQuery(Obj).parent().data("mensajeerror") != 'undefined') {
1735            Msg = jQuery(Obj).parent().data("mensajeerror");
1736            Tipo = 1;
1737        }
1738        if (typeof Obj.dataset.tipo != 'undefined') Tipo = parseInt(Obj.dataset.tipo);
1739        if (jQuery(Obj).prev().data("controlerror") == 'ok') {
1740            jQuery(Obj).prev().removeClass('ErrorActive').addClass('ErrorActive');
1741            jQuery(Obj).bind("click", OcultarMsgValido);
1742        }
1743        else {
1744            div = jQuery('<div/>', { 'class': 'MsgError ErrorActive', 'style': '', 'data-controlerror': 'ok', 'id': jQuery(Obj).attr('id') + 'Error', 'data-tipo': Tipo });
1745            jQuery(div).html(Msg);
1746            jQuery(Obj).before(div);
1747            jQuery(Obj).bind("click", OcultarMsgValido);
1748            CentrarMsgValido(div, IdObj);
1749        }
1750        ScrollSuave(jQuery(Obj).prev().attr('id'), 80);
1751    }
1752    else {
1753        Cant++;
1754        if (Cant < 6) setTimeout(function () { MostrarMsgValidador(IdObj, Cant); }, 400);
1755    }
1756}
1757function ChekeoExpRegular(DatoCheck) {
1758    Formula = myTrim(DatoCheck.dataset.checkformula);
1759    Valor = myTrim(DatoCheck.value);
1760
1761    if ((Valor.length > 0) && (Formula.length > 0))//si hay valor y hay formula
1762    {
1763        var ExpRegular = new RegExp(Formula);
1764        Resultado = ExpRegular.test(Valor);
1765        if (Resultado) return true;
1766        else return false;
1767    }
1768
1769    return true;
1770}
1771OcultarMsgValido = function (Obj) {
1772    jQuery(this).prev().removeClass('ErrorActive')
1773    jQuery(this).unbind("click");
1774}
1775CentrarMsgValido = function (ObjCentrar, IdObjReferencia) {
1776
1777    if (jQuery(ObjCentrar).data("tipo") == 1)
1778        jQuery(ObjCentrar).css('margin-top', '-' + (ObjCentrar.outerHeight() + 20) + 'px');
1779    else if (jQuery(ObjCentrar).data("tipo") == 2) // Si 
1780        jQuery(ObjCentrar).css('margin-top', '-' + (ObjCentrar.outerHeight() + 20) + 'px').css('left', jQuery('#' + IdObjReferencia).offset().left + 'px');
1781    else
1782        jQuery(ObjCentrar).css('top', '-' + ObjCentrar.outerHeight() + 'px');
1783}
1784function ScrollSuave(strAncla, RestarProsicion) {
1785    RestarProsicion = RestarProsicion || 0;
1786    if (ScrollActivo) {
1787        strAncla = document.getElementById(strAncla);
1788        //utilizamos body y html, ya que dependiendo del navegador uno u otro no funciona
1789        if (strAncla) {
1790            Pos = jQuery(strAncla).offset().top;
1791            if ((Pos - RestarProsicion) > 0) Pos = Pos - RestarProsicion;
1792            jQuery('body,html').stop(true, true).animate({
1793                //realizamos la animacion hacia el ancla    
1794                scrollTop: Pos// $(strAncla).offset().top
1795            }, 1000);
1796        }
1797    }
1798    ScrollActivo = true;
1799}
1800ScrollActivo = false;
1801
1802function PonerImgPredeterminadaModal(IdBase,Numero){
1803    jQuery('div[id^="' + IdBase + '"').each(function () {
1804        jQuery(this).removeClass('active');
1805    })
1806    jQuery('#' + IdBase +''+ Numero ).addClass('active');
1807}
1808function abrir(direccion, pantallacompleta, herramientas, direcciones, estado, barramenu, barrascroll, cambiatamano, ancho, alto, izquierda, arriba, sustituir) {
1809    var opciones = "fullscreen=" + pantallacompleta +
1810                ",toolbar=" + herramientas +
1811                ",location=" + direcciones +
1812                ",status=" + estado +
1813                ",menubar=" + barramenu +
1814                ",scrollbars=" + barrascroll +
1815                ",resizable=" + cambiatamano +
1816                ",width=" + ancho +
1817                ",height=" + alto +
1818                ",left=" + izquierda +
1819                ",top=" + arriba;
1820    var ventana = window.open(direccion, "venta", opciones, sustituir);
1821
1822}
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839//direcciones
1840function anadirdireccion(destino) {
1841
1842    //donde se mostrará lo resultados
1843
1844
1845    //valores de los inputs
1846    cliente1 = document.getElementById('clienten').value;
1847    nombre1 = document.getElementById('nombren').value;
1848    direccion1 = document.getElementById('direccionn').value;
1849    poblacion1 = document.getElementById('poblacionn').value;
1850    provincia1 = document.getElementById('provincian').value;
1851    telefono1 = document.getElementById('telefonon').value;
1852
1853
1854
1855    $("#" + destino).load("AgregarDireccion.php", { nombre: nombre1, direccion: direccion1, poblacion: poblacion1, provincia: provincia1, cliente: cliente1, telefono: telefono1 });
1856
1857}
1858
1859//editar
1860
1861function editardireccion(destino) {
1862    //alert("hola");
1863
1864
1865    //valores de los inputs
1866
1867    nombre1 = document.getElementById('nombre').value;
1868    cliente1 = document.getElementById('cliente').value;
1869    cc1 = document.getElementById('cc').value;
1870    direccion1 = document.getElementById('direccion').value;
1871    poblacion1 = document.getElementById('poblacion').value;
1872    provincia1 = document.getElementById('provincia').value;
1873    telefono1 = document.getElementById('telefono').value;
1874
1875
1876
1877
1878    
1879    $("#" + destino).load("EditarDireccion.php", { nombre: nombre1, direccion: direccion1, poblacion: poblacion1, provincia: provincia1, cliente: cliente1, cc: cc1, telefono: telefono1 });
1880
1881}
1882
1883
1884
1885//borrar
1886
1887function borrar(destino, cliente1, cc1) {
1888
1889
1890    
1891    $("#" + destino).load("BorrarDireccion.php", { cliente: cliente1, cc: cc1 });
1892
1893}
1894
1895//buscar
1896
1897function buscar(destino, pedido1) {
1898
1899    nombre = document.getElementById('NombreCli').value;
1900    CP = document.getElementById('CPCli').value;
1901    Poblacion = document.getElementById('PoblacionCli').value;
1902
1903    
1904    
1905    $("#" + destino).load("BuscarDireccion.php", { NombreCli: nombre, CPCli: CP, PoblacionCli: Poblacion, pedido: pedido1 });
1906}
1907
1908function direccion(destino,direccion1, cliente1, pedido1) {
1909
1910
1911    //valores de los inputs
1912
1913    //buscado1 = document.getElementById(direccion).value;
1914
1915
1916    //enviando los valores
1917
1918
1919
1920    $("#" + destino).load("SeleccionarDireccion.php", { buscado: direccion1, cliente: cliente1, pedido: pedido1 });
1921
1922}
1923
1924
1925
1926function busqueda(destino,pedido){
1927    alert ("Por favor, espere a que se complete la búsqueda");
1928    buscar(destino, pedido);
1929}
1930
1931function nuevo(destino){
1932    //alert("Su pedido esta siendo enviado, este proceso puede tardar varios segundos");
1933
1934
1935
1936    div1 = document.getElementById(destino);
1937
1938 
1939
1940
1941    document.getElementById('nombren').value=""; 
1942    document.getElementById('poblacionn').value=""; 
1943    document.getElementById('provincian').value=""; 
1944    document.getElementById('telefonon').value=""; 
1945    document.getElementById('direccionn').value=""; 
1946
1947    div1.style.visibility = 'visible';
1948
1949
1950
1951
1952}
1953
1954
1955
1956function editar(nombre, poblacion, provincia, direccion, cliente, cc, telefono){
1957    //alert("modificando direccion");
1958
1959
1960
1961    div1 = document.getElementById('mensaje'); 
1962
1963    div1.style.visibility = 'visible';
1964
1965    document.getElementById('nombre').value=nombre.replace(/^\s*|\s*$/g,"");
1966    document.getElementById('direccion').value=direccion.replace(/^\s*|\s*$/g,"");
1967    document.getElementById('poblacion').value=poblacion.replace(/^\s*|\s*$/g,"");
1968    document.getElementById('provincia').value=provincia.replace(/^\s*|\s*$/g,"");
1969    document.getElementById('cliente').value=cliente;
1970    document.getElementById('cc').value=cc;
1971    document.getElementById('telefono').value=telefono.replace(/^\s*|\s*$/g,"");
1972    //var name_element = document.getElementById('nombre'); 
1973
1974
1975}
1976
1977
1978function quitaraviso() {
1979
1980    //alert("Su pedido esta siendo enviado, este proceso puede tardar varios segundos");
1981
1982    div1 = document.getElementById('mensaje');
1983    div1.style.visibility = 'hidden';
1984
1985
1986
1987
1988}
1989function quitaravisonuevo() {
1990
1991    //alert("Su pedido esta siendo enviado, este proceso puede tardar varios segundos");
1992
1993    div1 = document.getElementById('mensajenuevo');
1994
1995    div1.style.visibility = 'hidden';
1996
1997
1998}
1999function ESPGuardaRespuesta(destino, Pregunta, Respuesta) {
2000    //si no, muestro la busqueda rapida
2001    $("#" + destino).load("ESPGuardaRespuesta.php", { Preg: Pregunta, Resp: Respuesta }, function () {
2002        ObjTemp = this;
2003        setTimeout(function () { jQuery(ObjTemp).hide(); }, 100);
2004    });
2005}
2006function ESPNoLogGuardaRespuesta(destino, Pregunta, Respuesta) {
2007    //si no, muestro la busqueda rapida
2008    $("#" + destino).load("ESPNoLogGuardaRespuesta.php", { Preg: Pregunta, Resp: Respuesta }, function () {
2009        ObjTemp = this;
2010        setTimeout(function () { jQuery(ObjTemp).hide(); }, 100);
2011    });
2012}
2013function ESPNoLogGuardaEmail(destino, idEmail) {
2014    //primero capturo el valor del campo de la busqueda
2015    var porId = document.getElementById(idEmail);
2016    var ValorEmail = porId.value
2017    if (ValorEmail != "") {
2018        //si no, muestro la busqueda rapida
2019        $("#" + destino).load("ESPNoLogGuardaEmail.php", { Email: ValorEmail }, function () {
2020            ObjTemp = this;
2021            setTimeout(function () { jQuery(ObjTemp).hide(); }, 100);
2022        });
2023        OcultarTodo('Pregunta');
2024        MostrarOcultarAlter('Pregunta1');
2025    } else {
2026        alert("Debe introducir un Email válido.");
2027    }
2028}
2029function ESPSolicitarClaves(destino) {
2030    //si no, muestro la busqueda rapida
2031    $("#" + destino).load("ESPSolicitarClaves.php", {}, function () {
2032        ObjTemp = this;
2033        setTimeout(function () { jQuery(ObjTemp).hide(); }, 100);
2034    });
2035}
2036function MostrarDireccionRMA() {
2037    //capturo todos los divs que contengan parte de esta id
2038    Prueba = $("[id*=-Motivo]");
2039    OcultarDireccion = true;
2040    for (var i = 0; i < Prueba.length; i++) {
2041        IndiceElegido = Prueba[i].value;
2042        if (IndiceElegido != 1 && IndiceElegido != 10){
2043            OcultarDireccion = false;
2044        }
2045    }
2046    //ahora, si tengo que ocultarla, la oculto, si no, la muestro
2047    if (OcultarDireccion) {
2048        document.getElementById("horario").required = false;
2049        document.getElementById("nombre").required = false;
2050        document.getElementById("direccion").required = false;
2051        document.getElementById("poblacion").required = false;
2052        document.getElementById("provincia").required = false;
2053        document.getElementById("telefono").required = false;
2054        document.getElementById("cp").required = false;
2055
2056        document.getElementById("horarioDiv").style.display = 'none';
2057        document.getElementById("tituloDiv").style.display = 'none';
2058        document.getElementById("nombreDiv").style.display = 'none';
2059        document.getElementById("direccionDiv").style.display = 'none';
2060        document.getElementById("poblacionDiv").style.display = 'none';
2061        document.getElementById("provinciaDiv").style.display = 'none';
2062        document.getElementById("telefonoDiv").style.display = 'none';
2063    } else {
2064        document.getElementById("horarioDiv").style.display = 'block';
2065        document.getElementById("tituloDiv").style.display = 'block';
2066        document.getElementById("nombreDiv").style.display = 'block';
2067        document.getElementById("direccionDiv").style.display = 'block';
2068        document.getElementById("poblacionDiv").style.display = 'block';
2069        document.getElementById("provinciaDiv").style.display = 'block';
2070        document.getElementById("telefonoDiv").style.display = 'block';
2071
2072        document.getElementById("horario").required = true;
2073        document.getElementById("nombre").required = true;
2074        document.getElementById("direccion").required = true;
2075        document.getElementById("poblacion").required = true;
2076        document.getElementById("provincia").required = true;
2077        document.getElementById("telefono").required = true;
2078        document.getElementById("cp").required = true;
2079    }
2080}
2081function RMAModificarRegistro(destino, CampoAModificar, IdValorCampoAModificar, TablaAModificar, IdValor, IdCampoNombre) {
2082    var porId = document.getElementById(IdValorCampoAModificar);
2083    var ValorCampoModificar = porId.value;
2084    $("#" + destino).load("RMAModificarRegistro.php", { CampoMod: CampoAModificar, ValorCampoMod: ValorCampoModificar, Tabla: TablaAModificar, ValorID: IdValor, CampoID: IdCampoNombre }, function () {
2085        ObjTemp = this;
2086        setTimeout(function () { jQuery(ObjTemp).hide(); }, 100);
2087    });
2088}
2089function AgregarDeseado(destino, CodProd) {
2090    //alert("hola");
2091    //donde se mostrará lo resultados
2092    Producto = CodProd;
2093    //valores de los inputs
2094
2095    //si no, muestro la busqueda rapida
2096    $("#" + destino).load("AgregarDeseados.php", { producto: Producto }, function () {
2097        ObjTemp = this;
2098        setTimeout(function () { jQuery(ObjTemp).hide(); }, 5000);
2099    });
2100}
2101function QuitarDeseado(destino, CodProd) {
2102    //alert("hola");
2103    //donde se mostrará lo resultados
2104    Producto = CodProd;
2105    //valores de los inputs
2106
2107    //si no, muestro la busqueda rapida
2108    $("#" + destino).load("QuitarDeseados.php", { producto: Producto }, function () {
2109        ObjTemp = this;
2110        setTimeout(function () { jQuery(ObjTemp).hide(); }, 5000);
2111    });
2112}
2113function showimage(rutafoto) {
2114    $('body').append('<div id="ImagenPantallaCompleta" class = "ImagenPantallaCompleta Cursor" style="background-image: url(' + rutafoto + ');"  onclick="$( \'#ImagenPantallaCompleta\' ).remove();"><div style="text-align: center; font-size: 20px; font-weight: bold;"><span>X Cerrar</span></div></div>'); 
2115}
2116function ProductoSeleccionarFamilia(idSelect, Producto) {
2117
2118    var oSelect = document.getElementById(idSelect);
2119    var ValorFamilia = oSelect[oSelect.selectedIndex].value;
2120
2121    var form = document.createElement("form"); // crear un form
2122    with (form) {
2123        setAttribute("name", "Producto"); //nombre del form
2124        setAttribute("action", "index.php?pag=Producto&Producto=" + Producto); // action por defecto
2125        setAttribute("method", "post"); // method POST 
2126    }
2127    var input = document.createElement("input"); // Crea un elemento input
2128    with (input) {
2129        setAttribute("name", "FamiliaElegida"); //nombre del input
2130        setAttribute("type", "hidden"); // tipo hidden
2131        setAttribute("value", ValorFamilia); // valor por defecto
2132    }
2133
2134    form.appendChild(input); // añade el input al formulario
2135    document.body.appendChild(form);
2136    form.submit();//por ultimo, envio el formulario
2137
2138}
2139function ProductoSeleccionarSubFamilia(idSelectFam, idSelectSubFam) {
2140
2141    var oSelectFam = document.getElementById(idSelectFam);
2142    var ValorFamilia = oSelectFam[oSelectFam.selectedIndex].value;
2143    var oSelectSubFam = document.getElementById(idSelectSubFam);
2144    var ValorSubFamilia = oSelectSubFam[oSelectSubFam.selectedIndex].value;
2145
2146    var form = document.createElement("form"); // crear un form
2147    with (form) {
2148        setAttribute("name", "Categoria"); //nombre del form
2149        setAttribute("action", "index.php?pag=Categoria&Ap=" + ValorFamilia + "&Sap=" + ValorSubFamilia); // action por defecto
2150        setAttribute("method", "post"); // method POST 
2151    }
2152    document.body.appendChild(form);
2153    form.submit();//por ultimo, envio el formulario
2154
2155}
2156function CambiarFormaPago(destino, Cabecera, FormaPago) {
2157    //alert("hola");
2158    //donde se mostrará lo resultados
2159    IdCabecera = Cabecera;
2160    IdFormaPago = FormaPago;
2161    //valores de los inputs
2162
2163    //si no, muestro la busqueda rapida
2164    $("#" + destino).load("CambiarFormaPago.php", { cabecera: IdCabecera, formapago: IdFormaPago }, function () {
2165    });
2166}
2167function CambiarFormaPagoPedPendiente(destino, Cabecera, FormaPago) {
2168    //alert("hola");
2169    //donde se mostrará lo resultados
2170    IdCabecera = Cabecera;
2171    IdFormaPago = FormaPago;
2172    //valores de los inputs
2173
2174    //si no, muestro la busqueda rapida
2175    $("#" + destino).load("CambiarFormaPagoPedPendiente.php", { cabecera: IdCabecera, formapago: IdFormaPago }, function () {
2176    });
2177}
2178
2179function ColectivosActDireccion(destino, Cabecera, NombreDirEnvio, DireccionDirEnvio, PoblacionDirEnvio, ProvinciaDirEnvio, CodPosDirEnvio, TelefonoDirEnvio) {
2180    //alert("hola");
2181    //donde se mostrará lo resultados
2182    IdCabecera = Cabecera;
2183
2184    var IdNombreDirEnvio = document.getElementById(NombreDirEnvio).value;
2185    var IdDireccionDirEnvio = document.getElementById(DireccionDirEnvio).value;
2186    var IdPoblacionDirEnvio = document.getElementById(PoblacionDirEnvio).value;
2187    var IdProvinciaDirEnvio = document.getElementById(ProvinciaDirEnvio).value;
2188    var IdCodPosDirEnvio = document.getElementById(CodPosDirEnvio).value;
2189    var IdTelefonoDirEnvio = document.getElementById(TelefonoDirEnvio).value;
2190    //ahora, si algún valor es vacío, mando mensaje de que tiene que poner los datos de la dirección, y no hago nada mas
2191    if (IdNombreDirEnvio == "" || IdDireccionDirEnvio == "" || IdPoblacionDirEnvio == "" || IdProvinciaDirEnvio == "" || IdCodPosDirEnvio == "" || IdTelefonoDirEnvio == "") {
2192        alert("Debe poner los datos de la dirección en la que desea recibir el pedido.");
2193    } else {
2194        $("#" + destino).load("ColCambiarDirCarrito.php", { cabecera: IdCabecera, NombreDirEnvio: IdNombreDirEnvio, DireccionDirEnvio: IdDireccionDirEnvio, PoblacionDirEnvio: IdPoblacionDirEnvio, ProvinciaDirEnvio: IdProvinciaDirEnvio, CodPosDirEnvio: IdCodPosDirEnvio, TelefonoDirEnvio: IdTelefonoDirEnvio }, function () { });
2195    }
2196}
2197
2198function ColectivosRestDireccion(destino, Cabecera) {
2199    //alert("hola");
2200    //donde se mostrará lo resultados
2201    IdCabecera = Cabecera;
2202    //valores de los inputs
2203
2204    //si no, muestro la busqueda rapida
2205    $("#" + destino).load("ColRestablecerDirCarrito.php", { cabecera: IdCabecera }, function () {
2206    });
2207}
2208
2209
2210
2211function SerigrafiaGuardar(destino, IdCabecera, IdProducto, DatosSerigrafia) {
2212    //alert("hola");
2213    //donde se mostrará lo resultados
2214    Cabecera = IdCabecera;
2215    Producto = IdProducto;
2216    var Serigrafia = document.getElementById(DatosSerigrafia).value;
2217    //valores de los inputs
2218
2219    //si no, muestro la busqueda rapida
2220    $("#" + destino).load("ColSerigrafGuardarCarrito.php", { idCabecera: Cabecera, idProducto: Producto, datosSerigrafia: Serigrafia }, function () {
2221    });
2222}
2223
2224function ColectivosSelEscudo(destino, Escudo) {
2225    //alert("hola");
2226    //donde se mostrará lo resultados
2227    NombreEscudo = Escudo;
2228    //valores de los inputs
2229
2230    //si no, muestro la busqueda rapida
2231    $("#" + destino).load("ColSeleccionarEscudo.php", { escudo: NombreEscudo }, function () {
2232    });
2233}
2234
2235function FinalizarPagoRedsys(nombreForm, action, version, merchant, firma) {
2236
2237
2238    var form3 = document.createElement("form"); // crear un form
2239    with (form3) {
2240        setAttribute("name", "formularioCarrito"); //nombre del form
2241        setAttribute("action", action); // action por defecto
2242        setAttribute("method", "post"); // method POST 
2243    }
2244
2245    var input = document.createElement("input"); // Crea un elemento input
2246    with (input) {
2247        setAttribute("name", "Ds_SignatureVersion"); //nombre del input
2248        setAttribute("type", "hidden"); // tipo hidden
2249        setAttribute("value", version); // valor por defecto
2250    }
2251
2252    form3.appendChild(input); // añade el input al formulario
2253    var input2 = document.createElement("input"); // Crea un elemento input
2254    with (input2) {
2255        setAttribute("name", "Ds_MerchantParameters"); //nombre del input
2256        setAttribute("type", "hidden"); // tipo hidden
2257        setAttribute("value", merchant); // valor por defecto
2258    }
2259
2260    form3.appendChild(input2); // añade el input al formulario
2261    var input3 = document.createElement("input"); // Crea un elemento input
2262    with (input3) {
2263        setAttribute("name", "Ds_Signature"); //nombre del input
2264        setAttribute("type", "hidden"); // tipo hidden
2265        setAttribute("value", firma); // valor por defecto
2266    }
2267
2268    form3.appendChild(input3); // añade el input al formulario
2269    document.body.appendChild(form3)
2270    form3.submit();//por ultimo, envio el formulario
2271}
2272
2273function ImagenPonerActiva(IdCarousel, ImgActiva) {
2274    //capturo las imagenes
2275    oCarusel = $("#" + IdCarousel).find($(".item"));
2276    //quito la clase activa
2277    $("#" + IdCarousel).find($(".active")).removeClass('active');
2278    //ahora, establezco la que tiene que estar activa
2279    $("#" + IdCarousel).find($("#Imagen" + ImgActiva)).addClass('active');
2280    
2281}
2282function FuncionBusquedaAvanzadaFiltros(pagina) {
2283    //primero capturo el valor del campo de la busqueda
2284    var porId = document.getElementById("BusquedaAvanzada");
2285    var Busqueda = porId.value;
2286    //luego compruebo si se pulsa enter, para enviar a la pagina de busqueda
2287    var form5 = document.createElement("form"); // crear un form
2288    with (form5) {
2289        setAttribute("name", "form5"); //nombre del form
2290        setAttribute("action", "index.php?pag=BusquedaAvanzada"); // action por defecto
2291        setAttribute("method", "post"); // method POST 
2292    }
2293
2294    var input = document.createElement("input"); // Crea un elemento input
2295    with (input) {
2296        setAttribute("name", "buscador"); //nombre del input
2297        setAttribute("type", "hidden"); // tipo hidden
2298        setAttribute("value", Busqueda); // valor por defecto
2299    }
2300    $('select[data-buscador=1]').each(function () {
2301        form5.appendChild(this);
2302    });
2303    $('select[data-buscador=2]').each(function () {
2304        form5.appendChild(this);
2305    });
2306    //ahora, agregamos el precio min
2307    form5.appendChild(input); // añade el input al formulario
2308    //ahora, falta incluir el valor del precio seleccionado
2309    Precios = document.getElementById("filtro_precio").value.split(",");
2310    PrecioMin = Precios[0];
2311    var inputPrecMin = document.createElement("input"); // Crea un elemento input
2312    with (inputPrecMin) {
2313        setAttribute("name", "PrecioMin"); //nombre del input
2314        setAttribute("type", "hidden"); // tipo hidden
2315        setAttribute("value", PrecioMin); // valor por defecto
2316    }
2317    form5.appendChild(inputPrecMin); // añade el input al formulario
2318    PrecioMax = Precios[1];
2319    var inputPrecMax = document.createElement("input"); // Crea un elemento input
2320    with (inputPrecMax) {
2321        setAttribute("name", "PrecioMax"); //nombre del input
2322        setAttribute("type", "hidden"); // tipo hidden
2323        setAttribute("value", PrecioMax); // valor por defecto
2324    }
2325    form5.appendChild(inputPrecMax); // añade el input al formulario
2326    $(document.body).append(form5);
2327    form5.submit();//por ultimo, envio el formulario
2328}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.