PageSourceSearch

https://www.delibros.es/js/DropShipping.js?v=1.336

js delibros.es collected 2026-10-05 20:34:24 UTC 85,406 bytes, 3,090 lines download raw bytes

1var NombreCG = "n";
2var ApellidosCG = "n";
3var EmailCG = "n";
4var PassCG = "n";
5var ConfPassCG = "n";
6
7var DomicilioCG = "n";
8var CodigoPostalCG = "n";
9var PoblacionCG = "n";
10var ProvinciaCG = "n";
11var ProvinciaComboCG = "n";
12var PaisComboCG = "n";
13var TelefonoCG = "n";
14var NIFClienteCG = "n";
15var NombreFacturaCG = "n";
16var DomicilioFacturaCG = "n";
17var CodigoPostalFacturaCG = "n";
18var PoblacionFacturaCG = "n";
19var PaisComboFacturaCG = "n";
20var ProvinciaFacturaComboCG = "n";
21
22
23jQuery(document).ready(function () {
24
25	$('#lblGastosEnvioAsync').hide();
26	$('#lblEuro').hide();
27	$('#containerGastosEnvioAsyncNoTarifas').hide();
28	$('#infoTarifasEnvioNoTarifas').hide();
29	$('#lblGastosEnvioAsyncNoTarifas').hide();
30	$('#icnVery_dissatisfied').hide();
31	$('#icnVery_satisfied').hide();
32
33	if (document.getElementById("txtRepPasswordNewUserCG") != null) {
34		document.getElementById("txtRepPasswordNewUserCG").disabled = true;
35	}
36
37
38	if (document.getElementById("chkEntregaTienda") != null) {
39		document.getElementById("chkEntregaTienda").disabled = true;
40
41	}
42
43	//** CESTA GLOBAL **//
44
45	$('#EMail').on('keyup', function () {
46
47		var input = $(this);
48
49		var re = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/
50
51		var is_email = re.test(input.val());
52
53		if (is_email) {
54			input.removeClass("invalid").addClass("valid");
55		}
56		else {
57			input.removeClass("valid").addClass("invalid");
58		}
59	});
60
61	if (window.location.pathname.indexOf("Registro-Usuario") < 0) {
62		$('#dvErrorValidacionCG').attr("style", "display:none");
63	}
64
65	$('#panel_datos_facturacion').removeClass("visible1").addClass("hidden1");
66
67	if (window.location.pathname.indexOf("/cesta") >= 0) {
68		
69		if (document.getElementById("hddFacturaClienteObligatoria").value == "True") {
70			$('#panel_datos_facturacion').removeClass("hidden1").addClass("visible1");
71			$('#chkfactura_hiddenCG').val("true");
72			$('#txtNIF').focus();
73
74			document.getElementById("chkDatosFacturaCG").click();
75
76			$('#dvDatosFacturaCG').attr("style", "display:none");
77		}
78	}
79
80	if (window.location.pathname.indexOf("MiCesta-Articulos") > 0) {
81		if (document.getElementById("hddIsAuthenticated").value == "True") {
82
83			document.getElementById("btnValidaCamposCestaGlobal").click();
84
85			if (document.getElementById("chkEntregaTienda").checked == true) {
86
87				ActivaEntregaTiendaDistribuidor()
88			}
89			else {
90
91				//getGastosEnvioAsyncClienteWeb();
92			}
93
94			document.getElementById("lblInfoGastosEnvioAsync").hidden = true;
95
96			if (getImporteMinimoCompra() > getImporteSubtotal()) {
97
98				document.getElementById("dvbtnTransfBancaria").setAttribute("style", "display:none");
99				document.getElementById("dvbtnTarjetaCredito").setAttribute("style", "display:none");
100				document.getElementById("dvbtnTarjetaCreditoBizum").setAttribute("style", "display:none");
101				document.getElementById("dvbtnPayPal").setAttribute("style", "display:none");
102				document.getElementById("dvCheckAvisoLegal").hidden = true;
103				document.getElementById("dvErrorValidacionCG").setAttribute("style", "display:none");
104			}
105
106		}
107		else {
108
109			document.getElementById("lblInfoGastosEnvioAsync").hidden = false;
110			document.getElementById("dvCheckAvisoLegal").hidden = true;
111
112			if (getImporteMinimoCompra() > getImporteSubtotal()) {
113
114				document.getElementById("dvbtnTransfBancaria").setAttribute("style", "display:none");
115				document.getElementById("dvbtnTarjetaCredito").setAttribute("style", "display:none");
116				document.getElementById("dvbtnTarjetaCreditoBizum").setAttribute("style", "display:none");
117				document.getElementById("dvbtnPayPal").setAttribute("style", "display:none");
118				document.getElementById("dvSeguirComprandoCesta").setAttribute("style", "display:block");
119			}
120			else {
121				document.getElementById("dvbtnTransfBancaria").setAttribute("style", "display:block");
122				document.getElementById("dvbtnTarjetaCredito").setAttribute("style", "display:block");
123				document.getElementById("dvbtnTarjetaCreditoBizum").setAttribute("style", "display:block");
124				document.getElementById("dvbtnPayPal").setAttribute("style", "display:block");
125				document.getElementById("dvSeguirComprandoCesta").setAttribute("style", "display:none");
126			}
127
128		}
129	}
130
131
132	$('#div_error_autCli').attr("style", "display:none");
133
134	$('#txtNombreCG').on('input', function () {
135		var input = $(this);
136		var element = $('#div_nombre')
137		var is_name = input.val();
138		if (is_name) {
139			NombreCG = "s";
140			input.attr("style", "border-color:#4CAF50;");
141
142			if (NombreCG == "s") {
143
144				$('#dvErrorValidacionCG').attr("style", "display:none");
145				$('#lbl_error_validacionCG').addClass("hidden");
146			}
147
148
149			if (NombreCG == "s" && ApellidosCG == "s" && EmailCG == "s" && PassCG == "s" && ConfPassCG == "s"
150				&& PaisComboCG == "s" && ProvinciaComboCG == "s") {
151
152				$('#dvErrorValidacionCG').attr("style", "display:none");
153				$('#lbl_error_validacionCG').addClass("hidden");
154				document.getElementById("dvCheckAvisoLegal").hidden = false;
155			}
156		}
157		else {
158			input.attr("style", "border-color:#FF0000;");
159			NombreCG = "n";
160
161		}
162	});
163
164	$('#txtApellidosCG').on('input', function () {
165		var input = $(this);
166		var element = $('#div_apellidos')
167		var is_name = input.val();
168		if (is_name) {
169
170			ApellidosCG = "s";
171			input.attr("style", "border-color:#4CAF50;");
172
173			if (ApellidosCG == "s") {
174
175				$('#dvErrorValidacionCG').attr("style", "display:none");
176				$('#lbl_error_validacionCG').addClass("hidden");
177			}
178
179			if (NombreCG == "s" && ApellidosCG == "s" && EmailCG == "s" && PassCG == "s" && ConfPassCG == "s"
180				&& PaisComboCG == "s" && ProvinciaComboCG == "s") {
181
182				$('#dvErrorValidacionCG').attr("style", "display:none");
183				$('#lbl_error_validacionCG').addClass("hidden");
184
185				document.getElementById("dvCheckAvisoLegal").hidden = false;
186			}
187		}
188		else {
189			input.attr("style", "border-color:#FF0000;");
190			ApellidosCG = "n";
191		}
192	});
193
194	/*
195	$("#txtMailNewUserCG").on("keydown", function (event) {
196		$("#log").html(event.type + ": " + event.which);
197	});
198	*/
199
200	var _ExisteUsuario = false;
201
202	var _EmailValido = false;
203
204	$('#txtMailNewUserCG').on('input', function (event) {
205
206		var Tecla = (document.all) ? event.keyCode : event.which;
207
208		if (Tecla == 8) {
209
210			document.getElementById("dvAccountValidation").setAttribute("class", "AccountEMailIdentityValidation hidden1");
211			document.getElementById("dvAccountValidationSuccess").setAttribute("class", "AccountEMailIdentityValidationSuccess hidden1");
212		}
213
214		var input = $(this);
215		var element = $('#div_mail_new_user')
216		//var re = /^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$/;
217		var re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
218
219		var is_email = re.test(input.val());
220		if (is_email) {
221
222			_EmailValido = true;
223
224			if (Tecla != 8) {
225
226				$.ajax({
227					type: "POST",
228					url: "./CestaGlobal.aspx/ExisteUsuario",
229					data: "{EMail:" + JSON.stringify(input.val()) + "}",
230					contentType: "application/json; charset=utf-8",
231					dataType: "json",
232					async: false,
233					success: function (response) {
234
235						if (response.d == true) {
236
237							input.attr("style", "border-color:#FF0000;")
238							EmailCG = "n";
239
240							$('#lblIsCliente').removeClass("hidden").addClass("visible");
241
242							_ExisteUsuario = true;
243
244						}
245						else {
246
247							EmailCG = "s";
248
249							$('#lblIsCliente').removeClass("visible").addClass("hidden");
250
251							input.attr("style", "border-color:#4CAF50;");
252
253							if (EmailCG == "s") {
254
255								$('#dvErrorValidacionCG').attr("style", "display:none");
256								$('#lbl_error_validacionCG').addClass("hidden");
257							}
258
259							if (NombreCG == "s" && ApellidosCG == "s" && EmailCG == "s" && PassCG == "s" && ConfPassCG == "s"
260								&& PaisComboCG == "s" && ProvinciaComboCG == "s") {
261
262								$('#dvErrorValidacionCG').attr("style", "display:none");
263								$('#lbl_error_validacionCG').addClass("hidden");
264
265								document.getElementById("dvCheckAvisoLegal").hidden = false;
266							}
267
268							var emailCliente = input.val().split('@')[1];
269
270							if (document.getElementById("hddCodigoDescuentoDominio") != null) {
271
272								var dominioDescuento = document.getElementById("hddNombreDescuentoDominio").value.toLowerCase().split(':')[1];
273
274								if (emailCliente.indexOf(dominioDescuento) > -1) {
275
276									toggleCampoCodigoDescuento();
277
278									document.getElementById("txbCodigoDescuento").value = document.getElementById("hddCodigoDescuentoDominio").value;
279
280									ValidaCodigoDescuentoWeb();
281
282									AplicarCodigoDescuento();
283
284									//CalculaCodigoDescuentoPostBack()
285
286									if (document.getElementById("hddCodigoDescuentoDominio") != null) {
287
288										document.getElementById("dvMensajeDescuentoDominio").setAttribute("class", "margintop20 visible1");
289									}
290								}
291								else {
292									AnularAplicarCodigoDescuento();
293								}
294							}
295
296
297							if (document.getElementById("hddCodigoDescuentoDominioValUs") != null) {
298
299								var dominioDescuentoValUs = document.getElementById("hddNombreDescuentoDominioValUs").value.toLowerCase().split(':')[1];
300
301								if (emailCliente.indexOf(dominioDescuentoValUs) > -1) {
302
303									document.getElementById("dvMensajeDescuentoDominio").setAttribute("class", "margintop20 visible1");
304								}
305								else {
306
307									document.getElementById("dvMensajeDescuentoDominio").setAttribute("class", "margintop20 hidden1");
308								}
309							}
310
311							_ExisteUsuario = false;
312						}
313
314					},
315					error: function (result) {
316						alert('ERROR ' + result.status + ' ' + result.statusText);
317					}
318				});
319			}
320
321		}
322		else {
323
324			_EmailValido = false;
325
326			input.attr("style", "border-color:#FF0000;")
327			document.getElementById("dvAccountValidation").setAttribute("class", "AccountEMailIdentityValidation hidden1");
328			document.getElementById("dvAccountValidationSuccess").setAttribute("class", "AccountEMailIdentityValidationSuccess hidden1");
329
330			EmailCG = "n";
331
332			$('#dvErrorValidacionCG').attr("style", "display:block");
333			$('#lbl_error_validacionCG').removeClass("hidden").text(getIdioma("lbl00144"));
334
335			if (document.getElementById("hddCodigoDescuentoDominio") != null) {
336				AnularAplicarCodigoDescuento();
337			}
338
339			document.getElementById("dvMensajeDescuentoDominio").setAttribute("class", "margintop20 hidden1");
340
341			document.getElementById("dvAccountValidation").setAttribute("class", "AccountEMailIdentityValidation hidden1");
342
343		}
344
345		var TeclaPulsada = (document.all) ? event.keyCode : event.which;
346
347		if (TeclaPulsada != 8 && _ExisteUsuario == false && _EmailValido == true && JSON.parse(document.getElementById("hddConfirmacionEMail").value.toLowerCase())) {
348
349			let $comment = document.getElementById("txtMailNewUserCG")
350
351			let timeout
352
353			//El evento lo puedes reemplazar con keyup, keypress y el tiempo a tu necesidad
354
355			clearTimeout(timeout)
356			timeout = setTimeout(() => {
357				$.ajax({
358					type: "POST",
359					url: "./CestaGlobal.aspx/AccountEMailIdentityValidate",
360					data: "{EMail:" + JSON.stringify($comment.value) + "}",
361					contentType: "application/json; charset=utf-8",
362					dataType: "json",
363					async: false,
364					success: function (response) {
365
366						if (response.d == true) {
367
368							EmailCG = "s";
369
370							document.getElementById("dvAccountValidation").setAttribute("class", "AccountEMailIdentityValidation hidden1");
371						}
372						else {
373
374							EmailCG = "n";
375
376							document.getElementById("dvAccountValidation").setAttribute("class", "AccountEMailIdentityValidation visible1");
377
378							ProcesoValidacionIdentidadEmail($comment.value);
379						}
380
381					},
382					error: function (result) {
383						alert('ERROR ' + result.status + ' ' + result.statusText);
384					}
385				});
386				clearTimeout(timeout)
387			}, 3000)
388		}
389		else {
390			document.getElementById("dvAccountValidation").setAttribute("class", "AccountEMailIdentityValidation hidden1");
391		}
392
393
394	});
395
396
397	$('#txtPasswordNewUserCG').on('input', function () {
398		var pswd = $('#txtPasswordNewUserCG').val();
399		var element = $('#div_pass_new_user');
400		var input = $(this);
401
402		$('#dvbtnContinuar').addClass("hidden margintop30");
403		$('#txtRepPasswordNewUserCG').val("");
404
405		/*
406		if ($(this).val().length == 0) {
407			$("#password_strength").html("");
408			return;
409		}
410		*/
411
412		$("#password_strength").html("");
413
414		PassCG = "s";
415
416		var passed = 0;
417
418		var messageCommonText = getIdioma("lbl00037");
419		var messageMinLength = document.getElementById("hddMinLengthPassword").value + " " + getIdioma("lbl00038");
420		var messageMaxLength = document.getElementById("hddMaxLengthPassword").value + " " + getIdioma("lbl00039");
421		var messageUpperCase = "";
422		var messageLowerCase = "";
423		var messageDigit = "";
424		var messageSpecialCharacter = "";
425
426		if (pswd.length < parseInt(document.getElementById("hddMinLengthPassword").value)) {
427
428			PassCG = "n";
429			
430		}
431		else {
432
433			messageMinLength = "";
434			//passed = 1;
435        }
436
437		var regexUpperCase = new Array();
438		regexUpperCase.push("[A-Z]");
439
440		var passedUpperCase = 0;
441
442		for (var i = 0; i < pswd.length; i++) {
443
444			if (new RegExp(regexUpperCase[0]).test(pswd.charAt(i))) {
445				passedUpperCase++;
446			}
447		}
448
449		passed += passedUpperCase;
450
451		if (passedUpperCase < parseInt(document.getElementById("hddUpperCasePassword").value) && parseInt(document.getElementById("hddUpperCasePassword").value) > 0) {
452
453			PassCG = "n";
454
455			if (parseInt(document.getElementById("hddUpperCasePassword").value) == 1) {
456
457				messageUpperCase = document.getElementById("hddUpperCasePassword").value + " " + getIdioma("lbl00040s") + " /";
458				
459			}
460			else {
461
462				messageUpperCase = document.getElementById("hddUpperCasePassword").value + " " + getIdioma("lbl00040p") + " /";
463            }
464
465		}
466		else if (parseInt(document.getElementById("hddUpperCasePassword").value) == 0) {
467
468			messageUpperCase = "";
469		}
470		else {
471
472			messageUpperCase = "";
473			
474        }
475
476		var regexLowerCase = new Array();
477		    regexLowerCase.push("[a-z]");
478
479		var passedLowerCase = 0;
480
481		for (var i = 0; i < pswd.length; i++) {
482
483			if (new RegExp(regexLowerCase[0]).test(pswd.charAt(i))) {
484				passedLowerCase++;
485			}
486		}
487
488		passed += passedLowerCase;
489
490		if (passedLowerCase < parseInt(document.getElementById("hddLowerCasePassword").value) && parseInt(document.getElementById("hddLowerCasePassword").value) > 0) {
491
492			PassCG = "n";
493
494			if (parseInt(document.getElementById("hddLowerCasePassword").value) == 1) {
495
496				messageLowerCase = document.getElementById("hddLowerCasePassword").value + " " + getIdioma("lbl00041s") + " /";
497
498			}
499			else {
500
501				messageLowerCase = document.getElementById("hddLowerCasePassword").value + " " + getIdioma("lbl00041p") + " /";
502			}
503			
504		}
505		else if (parseInt(document.getElementById("hddLowerCasePassword").value) == 0) {
506
507			messageLowerCase = "";
508		}
509		else {
510
511			messageLowerCase = "";
512		}
513
514
515		var regexDigit = new Array();
516		    regexDigit.push("[0-9]"); //Digit.
517
518		var passedDigit = 0;
519
520		for (var i = 0; i < pswd.length; i++) {
521
522			if (new RegExp(regexDigit[0]).test(pswd.charAt(i))) {
523				passedDigit++;
524			}
525		}
526
527		passed += passedDigit;
528
529		if (passedDigit < parseInt(document.getElementById("hddDigitPassword").value) && parseInt(document.getElementById("hddDigitPassword").value) > 0) {
530
531			PassCG = "n";
532
533			if (parseInt(document.getElementById("hddDigitPassword").value) == 1) {
534
535				messageDigit = document.getElementById("hddDigitPassword").value + " " + getIdioma("lbl00042s") + " /";
536
537			}
538			else {
539
540				messageDigit = document.getElementById("hddDigitPassword").value + " " + getIdioma("lbl00042p") + " /";
541			}
542			
543		}
544		else if (parseInt(document.getElementById("hddDigitPassword").value) == 0) {
545
546			messageDigit = "";
547		}
548		else {
549
550			messageDigit = "";
551		}
552
553			var regexSpecialCharacter = new Array();
554				regexSpecialCharacter.push("[$@$!%*#?&]");
555
556
557			var passedSpecialCharacter = 0;
558
559		/*
560		for (var i = 0; i < pswd.length; i++) {
561
562			if (new RegExp(regexSpecialCharacter[0]).test(pswd.charAt(i))) {
563				passedSpecialCharacter++;
564			}
565		}
566		*/
567
568		var format = /[ `!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/;
569		
570		for (var i = 0; i < pswd.length; i++) {
571
572			if (format.test(pswd.charAt(i))) {
573
574				passedSpecialCharacter++;
575            }
576		}
577		
578
579		passed += passedSpecialCharacter;
580
581		if (passedSpecialCharacter < parseInt(document.getElementById("hddSpecialCharacterPassword").value) && parseInt(document.getElementById("hddSpecialCharacterPassword").value) > 0) {
582
583			PassCG = "n";
584
585			if (parseInt(document.getElementById("hddSpecialCharacterPassword").value) == 1) {
586
587				messageSpecialCharacter = document.getElementById("hddSpecialCharacterPassword").value + " " + getIdioma("lbl00043s");
588
589			}
590			else {
591
592				messageSpecialCharacter = document.getElementById("hddSpecialCharacterPassword").value + " " + getIdioma("lbl00043p");
593			}
594			
595		}
596		else if (parseInt(document.getElementById("hddSpecialCharacterPassword").value) == 0) {
597
598			messageSpecialCharacter = "";
599		}
600		else {
601
602			messageSpecialCharacter = "";
603			
604		}
605
606
607		var MinPassed = (parseInt(document.getElementById("hddUpperCasePassword").value) +
608			             parseInt(document.getElementById("hddLowerCasePassword").value) +
609				         parseInt(document.getElementById("hddDigitPassword").value) +
610				         parseInt(document.getElementById("hddSpecialCharacterPassword").value));
611
612
613			/*
614			//Validate for length of Password.
615			if (passed > 2 && $(this).val().length >= 8) {
616				passed++;
617			}
618			*/
619
620		//Display status.
621		var color = "";
622		var strength = "";
623
624		if (MinPassed > 0 && passed > MinPassed && MinPassed < parseInt(document.getElementById("hddMaxLengthPassword").value) &&
625			(passedUpperCase >= parseInt(document.getElementById("hddUpperCasePassword").value) &&
626			passedLowerCase >= parseInt(document.getElementById("hddLowerCasePassword").value) &&
627			passedDigit >= parseInt(document.getElementById("hddDigitPassword").value) &&
628			passedSpecialCharacter >= parseInt(document.getElementById("hddSpecialCharacterPassword").value))) {
629
630			switch (passed) {
631
632				case MinPassed:
633					strength = "&nbsp;" + "&#10003;" + "&nbsp;" + getIdioma("lbl00046");
634					color = "darkorange";
635					break;
636				case MinPassed + 1:
637					strength = "&nbsp;" + "&#10003;" + "&nbsp;" + getIdioma("lbl00047");
638					color = "green";
639					break;
640				case MinPassed + 2:
641					strength = "&nbsp;" + "&#10003;" + "&nbsp;" + getIdioma("lbl00048");
642					color = "darkgreen";
643					break;
644				default:
645					strength = "&nbsp;" + "&#10003;" + "&nbsp;" + getIdioma("lbl00048");
646					color = "darkgreen";
647					break;
648			}
649		}
650		else if (MinPassed > 0 && passed == MinPassed &&
651			passedUpperCase >= parseInt(document.getElementById("hddUpperCasePassword").value) &&
652			passedLowerCase >= parseInt(document.getElementById("hddLowerCasePassword").value) &&
653			passedDigit >= parseInt(document.getElementById("hddDigitPassword").value) &&
654			passedSpecialCharacter >= parseInt(document.getElementById("hddSpecialCharacterPassword").value)) {
655
656			switch (passed) {
657				
658				case MinPassed:
659					strength = "&nbsp;" + "&#10003;";
660					color = "green";
661					break;
662			}
663        }
664		else if (MinPassed == 0 && pswd.length >= parseInt(document.getElementById("hddMinLengthPassword").value)) {
665
666			switch (passed) {
667				case 1:
668					strength = "&nbsp;" + getIdioma("lbl00045");
669					color = "red";
670					break;
671				case 2:
672					strength = "&nbsp;" + getIdioma("lbl00046");
673					color = "darkorange";
674					break;
675				case 3:
676					strength = "&nbsp;" + getIdioma("lbl00047");
677					color = "green";
678					break;
679				case 4:
680					strength = "&nbsp;" + getIdioma("lbl00048");
681					color = "darkgreen";
682					break;
683			}
684        }
685		
686
687			$("#password_strength").html(strength);
688			$("#password_strength").css("color", color);
689
690			
691		input.attr("style", "border-color:#4CAF50;");
692
693		if (PassCG == "n") {
694
695			$('#dvErrorValidacionCG').attr("style", "display:block");
696
697
698			if (MinPassed == 0) {
699
700				$('#lbl_error_validacionCG').removeClass("hidden").text(message
700CommonText + " " + messageMinLength);
701			}
702			else {
703
704				var text_lbl_error_validacion = messageCommonText + " " + messageMinLength + " ( " + messageUpperCase + " " + messageLowerCase + " " + messageDigit + " " + messageSpecialCharacter + ")"
705
706				text_lbl_error_validacion = text_lbl_error_validacion.replace('/ )', ')').replace('/  )', ')').replace('/   )', ')').replace('( )', ')');
707
708				$('#lbl_error_validacionCG').removeClass("hidden").text(text_lbl_error_validacion);
709            }
710
711
712			input.attr("style", "border-color:#FF0000;");
713			document.getElementById("txtRepPasswordNewUserCG").disabled = true;
714		}
715
716		if (PassCG == "s") {
717
718			$('#dvErrorValidacionCG').attr("style", "display:none");
719			$('#lbl_error_validacionCG').addClass("hidden");
720			document.getElementById("txtRepPasswordNewUserCG").disabled = false;
721		}
722
723		if (NombreCG == "s" && ApellidosCG == "s" && EmailCG == "s" && PassCG == "s" && ConfPassCG == "s"
724			&& PaisComboCG == "s" && ProvinciaComboCG == "s") {
725
726			$('#dvErrorValidacionCG').attr("style", "display:none");
727			$('#lbl_error_validacionCG').addClass("hidden");
728
729			document.getElementById("dvCheckAvisoLegal").hidden = false;
730		}
731
732		if (pswd.length == 0) {
733
734			$('#dvErrorValidacionCG').attr("style", "display:none");
735			$('#lbl_error_validacionCG').addClass("hidden");
736
737			input.removeAttr("style");
738
739        }
740	});
741
742	$('#txtRepPasswordNewUserCG').on('input', function () {
743
744		var reppswd = $('#txtRepPasswordNewUserCG').val();
745		var pswd = $('#txtPasswordNewUserCG').val();
746		var element = $('#div_rep_pass_new_user');
747		var input = $(this);
748
749		if (reppswd === pswd) {
750
751			ConfPassCG = "s";
752
753			input.attr("style", "border-color:#4CAF50;");
754
755			if (ConfPassCG == "s") {
756
757				$('#dvErrorValidacionCG').attr("style", "display:none");
758				$('#lbl_error_validacionCG').addClass("hidden");
759				$('#dvbtnContinuar').addClass("visible margintop30");
760			}
761
762			if (NombreCG == "s" && ApellidosCG == "s" && EmailCG == "s" && PassCG == "s" && ConfPassCG == "s"
763				&& PaisComboCG == "s" && ProvinciaComboCG == "s") {
764
765				$('#dvErrorValidacionCG').attr("style", "display:none");
766				$('#lbl_error_validacionCG').addClass("hidden");
767
768				document.getElementById("dvCheckAvisoLegal").hidden = false;
769			}
770		}
771		else {
772
773			ConfPass = "n";
774			$('#dvErrorValidacionCG').attr("style", "display:block");
775			input.attr("style", "border-color:#FF0000;");
776			$('#lbl_error_validacionCG').removeClass("hidden").text(getIdioma("lbl00142"));
777			event.preventDefault();
778		}
779	});
780
781	$('#txtDomicilioCG').on('input', function () {
782		var input = $(this);
783		var element = $('#div_domicilio')
784		var is_name = input.val();
785		if (is_name) {
786
787			DomicilioCG = "s";
788			input.attr("style", "border-color:#4CAF50;");
789
790			if (DomicilioCG == "s") {
791
792				$('#dvErrorValidacionCG').attr("style", "display:none");
793				$('#lbl_error_validacionCG').addClass("hidden");
794			}
795
796			if (DomicilioCG == "s" && CodigoPostalCG == "s" && PoblacionCG == "s" && TelefonoCG == "s"
797				&& PaisComboCG == "s" && ProvinciaComboCG == "s") {
798
799				$('#dvErrorValidacionCG').attr("style", "display:none");
800				$('#lbl_error_validacionCG').addClass("hidden");
801
802				document.getElementById("dvCheckAvisoLegal").hidden = false;
803			}
804		}
805		else {
806			input.attr("style", "border-color:#FF0000;")
807			DomicilioCG = "n";
808		}
809	});
810
811
812	$('#txtCP_CG').on('input', function () {
813
814		var input = $(this);
815		var element = $('#div_cp')
816		var re = /(^([0-9]{5,5})|^)$/;
817		var is_name = input.val();
818
819		var inputVal = document.getElementById("txtCP_CG").value;
820
821		var isSpain = false;
822
823		if ($("#ddlPaisCG option:selected").text().toLowerCase().indexOf("españa") > -1) {
824
825			isSpain = true;
826		}
827		else if ($("#ddlPaisCG option:selected").text().toLowerCase().indexOf("espanya") > -1) {
828
829			isSpain = true;
830		}
831		else if ($("#ddlPaisCG option:selected").text().toLowerCase().indexOf("spain") > -1) {
832
833			isSpain = true;
834		}
835
836		var Evaluated = false;
837
838		if (isSpain && inputVal.length == 5 && parseInt(inputVal) >= 1000 && parseInt(inputVal) <= 52999) {
839
840			Evaluated = true;
841
842			CodigoPostalCG = "s";
843			localStorage.setItem("CodigoPostalCG", "s");
844
845
846			input.attr("style", "border-color:#4CAF50;");
847
848			if (CodigoPostalCG == "s") {
849
850				$('#dvErrorValidacionCG').attr("style", "display:none");
851				$('#lbl_error_validacionCG').addClass("hidden");
852			}
853
854			if (DomicilioCG == "s" && CodigoPostalCG == "s" && PoblacionCG == "s" && TelefonoCG == "s"
855				&& PaisComboCG == "s" && ProvinciaComboCG == "s") {
856
857				$('#dvErrorValidacionCG').attr("style", "display:none");
858				$('#lbl_error_validacionCG').addClass("hidden");
859
860				document.getElementById("dvCheckAvisoLegal").hidden = false;
861			}
862		}
863		else {
864
865			//alert("codigo invalido");
866
867			input.attr("style", "border-color:#FF0000;")
868			CodigoPostalCG = "n";
869			localStorage.setItem("CodigoPostalCG", "n");
870		}
871
872
873		if (!isSpain && is_name) {
874
875			CodigoPostalCG = "s";
876			input.attr("style", "border-color:#4CAF50;");
877			localStorage.setItem("CodigoPostalCG", "s");
878
879			if (CodigoPostalCG == "s") {
880
881				$('#dvErrorValidacionCG').attr("style", "display:none");
882				$('#lbl_error_validacionCG').addClass("hidden");
883			}
884
885			if (DomicilioCG == "s" && CodigoPostalCG == "s" && PoblacionCG == "s" && TelefonoCG == "s"
886				&& PaisComboCG == "s" && ProvinciaComboCG == "s") {
887
888				$('#dvErrorValidacionCG').attr("style", "display:none");
889				$('#lbl_error_validacionCG').addClass("hidden");
890
891				document.getElementById("dvCheckAvisoLegal").hidden = false;
892			}
893
894		}
895		else {
896
897			if (!Evaluated) {
898				input.attr("style", "border-color:#FF0000;")
899				CodigoPostalCG = "n";
900				localStorage.setItem("CodigoPostalCG", "n");
901			}
902		}
903
904
905
906
907		/*
908		if (is_name) {
909
910			CodigoPostalCG = "s";
911			input.attr("style", "border-color:#4CAF50;");
912
913			if (CodigoPostalCG == "s") {
914
915				$('#dvErrorValidacionCG').attr("style", "display:none");
916				$('#lbl_error_validacionCG').addClass("hidden");
917			}
918
919			if (DomicilioCG == "s" && CodigoPostalCG == "s" && PoblacionCG == "s" && TelefonoCG == "s"
920				&& PaisComboCG == "s" && ProvinciaComboCG == "s") {
921
922				$('#dvErrorValidacionCG').attr("style", "display:none");
923				$('#lbl_error_validacionCG').addClass("hidden");
924
925				document.getElementById("dvCheckAvisoLegal").hidden = false;
926			}
927
928		}
929		else {
930			input.attr("style", "border-color:#FF0000;")
931			CodigoPostalCG = "n";
932		}
933		*/
934
935
936	});
937
938	$('#txtPoblacionCG').on('input', function () {
939		var input = $(this);
940		var element = $('#div_poblacion')
941		var is_name = input.val();
942		if (is_name) {
943
944			PoblacionCG = "s";
945			input.attr("style", "border-color:#4CAF50;");
946
947			if (PoblacionCG == "s") {
948
949				$('#dvErrorValidacionCG').attr("style", "display:none");
950				$('#lbl_error_validacionCG').addClass("hidden");
951			}
952
953
954			if (DomicilioCG == "s" && CodigoPostalCG == "s" && PoblacionCG == "s" && TelefonoCG == "s"
955				&& PaisComboCG == "s" && ProvinciaComboCG == "s") {
956
957				$('#dvErrorValidacionCG').attr("style", "display:none");
958				$('#lbl_error_validacionCG').addClass("hidden");
959
960				document.getElementById("dvCheckAvisoLegal").hidden = false;
961			}
962
963		}
964		else {
965			PoblacionCG = "n";
966			input.attr("style", "border-color:#FF0000;")
967		}
968	});
969
970	$('#ddlProvinceConfirmaDatosCG').on('change', function (event) {
971
972		if ($("#ddlProvinceConfirmaDatosCG :selected").val() == '0') {
973
974			$("#ddlProvinceConfirmaDatosCG").attr("style", "border:1px solid #FF0000;");
975			ProvinciaComboCG = "n";
976		}
977		else {
978
979			$("#ddlProvinceConfirmaDatosCG").attr("style", "border:1px solid #4CAF50;");
980			ProvinciaComboCG = "s"
981		}
982
983		if (document.getElementById("hddIsAuthenticated").value == "False") {
984
985			ValidaCamposAltaCliente(event);
986		}
987
988	});
989
990	$('#ddlPaisCG').on('change', function (event) {
991
992		if ($("#ddlPaisCG :selected").val() == '0') {
993
994			$("#ddlPaisCG").attr("style", "border:1px solid #FF0000;");
995			PaisComboCG = "n";
996		}
997		else {
998
999			$("#ddlPaisCG").attr("style", "border:1px solid #4CAF50;");
1000			PaisComboCG = "s"
1001		}
1002
1003		if (document.getElementById("hddIsAuthenticated").value == "False") {
1004
1005			ValidaCamposAltaCliente(event);
1006		}
1007	});
1008
1009	$('#txtTelefonoCG').on('input', function () {
1010		var input = $(this);
1011		var element = $('#div_telefono')
1012		var re = /^([0-9]+){9}$/;
1013		var is_name = input.val();
1014		if (is_name) {
1015
1016			TelefonoCG = "s";
1017			input.attr("style", "border-color:#4CAF50;");
1018
1019			if (TelefonoCG == "s") {
1020
1021				$('#dvErrorValidacionCG').attr("style", "display:none");
1022				$('#lbl_error_validacionCG').addClass("hidden");
1023			}
1024
1025			if (DomicilioCG == "s" && CodigoPostalCG == "s" && PoblacionCG == "s" && TelefonoCG == "s"
1026				&& PaisComboCG == "s" && ProvinciaComboCG == "s") {
1027
1028				$('#dvErrorValidacionCG').attr("style", "display:none");
1029				$('#lbl_error_validacionCG').addClass("hidden");
1030
1031				document.getElementById("dvCheckAvisoLegal").hidden = false;
1032			}
1033		}
1034		else {
1035			TelefonoCG = "n";
1036			input.attr("style", "border-color:#FF0000;")
1037		}
1038	});
1039
1040	//FACTURA
1041
1042	$('#txtNIF_CG').on('input', function () {
1043		var input = $(this);
1044		var element = $('#div_nif')
1045		var is_name = false;
1046		var primerCaracter = input.val().substr(0, 1).toUpperCase();
1047
1048		if (primerCaracter.match(/^[ABCDEFGHJKLMNPQRSUVWXYZ]$/)) {
1049			is_name = validateCIF(input.val());
1050		}
1051		else {
1052			is_name = validateDNI(input.val());
1053		}
1054
1055		if (is_name) {
1056			NIFClienteCG = "s";
1057			input.attr("style", "border-color:#4CAF50;");
1058
1059			if (NIFClienteCG == "s") {
1060
1061				$('#dvErrorValidacionCG').attr("style", "display:none");
1062				$('#lbl_error_validacionCG').addClass("hidden");
1063			}
1064
1065			if (NIFClienteCG == "s" && NombreFacturaCG == "s" && DomicilioFacturaCG == "s" && CodigoPostalFacturaCG == "s" && PoblacionFacturaCG == "s"
1066				&& PaisComboFacturaCG == "s" && ProvinciaFacturaComboCG == "s") {
1067
1068				$('#dvErrorValidacionCG').attr("style", "display:none");
1069				$('#lbl_error_validacionCG').addClass("hidden");
1070
1071				document.getElementById("dvCheckAvisoLegal").hidden = false;
1072			}
1073		}
1074		else {
1075			input.attr("style", "border-color:#FF0000;")
1076			NIFClienteCG = "n";
1077		}
1078
1079
1080	});
1081
1082	$('#txtNombreFactCG').on('input', function () {
1083		var input = $(this);
1084		var element = $('#div_nombre_fact')
1085		var is_name = input.val();
1086		if (is_name) {
1087			NombreFacturaCG = "s";
1088			input.attr("style", "border-color:#4CAF50;");
1089
1090			if (NombreFacturaCG == "s") {
1091
1092				$('#dvErrorValidacionCG').attr("style", "display:none");
1093				$('#lbl_error_validacionCG').addClass("hidden");
1094			}
1095
1096			if (NIFClienteCG == "s" && NombreFacturaCG == "s" && DomicilioFacturaCG == "s" && CodigoPostalFacturaCG == "s" && PoblacionFacturaCG == "s"
1097				&& PaisComboFacturaCG == "s" && ProvinciaFacturaComboCG == "s") {
1098
1099				$('#dvErrorValidacionCG').attr("style", "display:none");
1100				$('#lbl_error_validacionCG').addClass("hidden");
1101
1102				document.getElementById("dvCheckAvisoLegal").hidden = false;
1103			}
1104		}
1105		else {
1106			input.attr("style", "border-color:#FF0000;")
1107			NombreFacturaCG = "n";
1108		}
1109	});
1110
1111	$('#txtDomicilioFactCG').on('input', function () {
1112		var input = $(this);
1113		var element = $('#div_domicilio_fact')
1114		var is_name = input.val();
1115		if (is_name) {
1116			DomicilioFacturaCG = "s";
1117			input.attr("style", "border-color:#4CAF50;")
1118
1119			if (DomicilioFacturaCG == "s") {
1120
1121				$('#dvErrorValidacionCG').attr("style", "display:none");
1122				$('#lbl_error_validacionCG').addClass("hidden");
1123			}
1124
1125			if (NIFClienteCG == "s" && NombreFacturaCG == "s" && DomicilioFacturaCG == "s" && CodigoPostalFacturaCG == "s" && PoblacionFacturaCG == "s"
1126				&& PaisComboFacturaCG == "s" && ProvinciaFacturaComboCG == "s") {
1127
1128				$('#lbl_error_validacionCG').addClass("hidden");
1129				$('#dvErrorValidacionCG').attr("style", "display:none");
1130
1131				document.getElementById("dvCheckAvisoLegal").hidden = false;
1132			}
1133		}
1134		else {
1135			input.attr("style", "border-color:#FF0000;")
1136			DomicilioFacturaCG = "n";
1137		}
1138	});
1139
1140	$('#txtCPFactCG').on('input', function () {
1141
1142		var input = $(this);
1143
1144		var element = $('#div_cp_fact')
1145		var re = /(^([0-9]{5,5})|^)$/;
1146		var is_name = input.val();
1147
1148		var isSpain = false;
1149
1150		if ($("#cmbPaisFacCG option:selected").text().toLowerCase().indexOf("españa") > -1) {
1151			isSpain = true;
1152		}
1153		else if ($("#cmbPaisFacCG option:selected").text().toLowerCase().indexOf("espanya") > -1) {
1154			isSpain = true;
1155		}
1156		else if ($("#cmbPaisFacCG option:selected").text().toLowerCase().indexOf("spain") > -1) {
1157			isSpain = true;
1158		}
1159
1160		var Evaluated = false;
1161
1162		if (isSpain && is_name.length == 5 && parseInt(is_name) >= 1000 && parseInt(is_name) <= 52999) {
1163
1164			Evaluated = true;
1165
1166			CodigoPostalFacturaCG = "s";
1167			input.attr("style", "border-color:#4CAF50;");
1168			localStorage.setItem("CodigoPostalFacturaCG", "s");
1169
1170			if (CodigoPostalFacturaCG == "s") {
1171
1172				$('#dvErrorValidacionCG').attr("style", "display:none");
1173				$('#lbl_error_validacionCG').addClass("hidden");
1174			}
1175
1176			if (NIFClienteCG == "s" && NombreFacturaCG == "s" && DomicilioFacturaCG == "s" && CodigoPostalFacturaCG == "s" && PoblacionFacturaCG == "s"
1177				&& PaisComboFacturaCG == "s" && ProvinciaFacturaComboCG == "s") {
1178
1179				$('#dvErrorValidacionCG').attr("style", "display:none");
1180				$('#lbl_error_validacionCG').addClass("hidden");
1181
1182				document.getElementById("dvCheckAvisoLegal").hidden = false;
1183			}
1184		}
1185		else {
1186
1187			input.attr("style", "border-color:#FF0000;")
1188			CodigoPostalFacturaCG = "n";
1189			localStorage.setItem("CodigoPostalFacturaCG", "n");
1190		}
1191
1192
1193		if (!isSpain && is_name) {
1194			CodigoPostalFacturaCG = "s";
1195			localStorage.setItem("CodigoPostalFacturaCG", "s");
1196			input.attr("style", "border-color:#4CAF50;");
1197
1198			if (CodigoPostalFacturaCG == "s") {
1199
1200				$('#dvErrorValidacionCG').attr("style", "display:none");
1201				$('#lbl_error_validacionCG').addClass("hidden");
1202			}
1203
1204			if (NIFClienteCG == "s" && NombreFacturaCG == "s" && DomicilioFacturaCG == "s" && CodigoPostalFacturaCG == "s" && PoblacionFacturaCG == "s"
1205				&& PaisComboFacturaCG == "s" && ProvinciaFacturaComboCG == "s") {
1206
1207				$('#dvErrorValidacionCG').attr("style", "display:none");
1208				$('#lbl_error_validacionCG').addClass("hidden");
1209
1210				document.getElementById("dvCheckAvisoLegal").hidden = false;
1211			}
1212		}
1213		else {
1214
1215			if (!Evaluated) {
1216
1217				input.attr("style", "border-color:#FF0000;")
1218				CodigoPostalFacturaCG = "n";
1219				localStorage.setItem("CodigoPostalFacturaCG", "n");
1220			}
1221		}
1222	});
1223
1224	$('#txtPoblacionFactCG').on('input', function () {
1225
1226		var input = $(this);
1227		var element = $('#div_poblacion_fact')
1228		var is_name = input.val();
1229		if (is_name) {
1230			PoblacionFacturaCG = "s";
1231			input.attr("style", "border-color:#4CAF50;");
1232
1233			if (PoblacionFacturaCG == "s") {
1234
1235				$('#dvErrorValidacionCG').attr("style", "display:none");
1236				$('#lbl_error_validacionCG').addClass("hidden");
1237			}
1238
1239			if (NIFClienteCG == "s" && NombreFacturaCG == "s" && DomicilioFacturaCG == "s" && CodigoPostalFacturaCG == "s" && PoblacionFacturaCG == "s"
1240				&& PaisComboFacturaCG == "s" && ProvinciaFacturaComboCG == "s") {
1241				$('#dvErrorValidacionCG').attr("style", "display:none");
1242				$('#lbl_error_validacionCG').addClass("hidden");
1243
1244				document.getElementById("dvCheckAvisoLegal").hidden = false;
1245			}
1246		}
1247		else {
1248			input.attr("style", "border-color:#FF0000;")
1249			PoblacionFacturaCG = "n";
1250		}
1251	});
1252
1253	$('#cmbPaisFacCG').on('change', function (event) {
1254
1255		if ($("#cmbPaisFacCG :selected").val() == '0') {
1256
1257			$("#cmbPaisFacCG").attr("style", "border:1px solid #FF0000;");
1258			PaisComboFacturaCG = "n";
1259		}
1260		else {
1261
1262			$("#cmbPaisFacCG").attr("style", "border:1px solid #4CAF50;");
1263			PaisComboFacturaCG = "s"
1264		}
1265
1266
1267		if (window.location.pathname.indexOf("MiCesta-Articulos") > 0) {
1268			if (document.getElementById("hddIsAuthenticated").value == "False") {
1269
1270				ValidaCamposAltaCliente(event);
1271			}
1272		}
1273	});
1274
1275	$('#ddlProvinceFactConfirmaDatosCG').on('change', function (event) {
1276
1277		if ($("#ddlProvinceFactConfirmaDatosCG :selected").val() == '0') {
1278
1279			$("#ddlProvinceFactConfirmaDatosCG").attr("style", "border:1px solid #FF0000;");
1280			ProvinciaFacturaComboCG = "n";
1281		}
1282		else {
1283
1284			$("#ddlProvinceFactConfirmaDatosCG").attr("style", "border:1px solid #4CAF50;");
1285			ProvinciaFacturaComboCG = "s"
1286		}
1287
1288		if (window.location.pathname.indexOf("MiCesta-Articulos") > 0) {
1289			if (document.getElementById("hddIsAuthenticated").value == "False") {
1290
1291				ValidaCamposAltaCliente(event);
1292			}
1293		}
1294	});
1295
1296});
1297
1298function ProcesoValidacionIdentidadEmail(Email) {
1299
1300
1301	$.ajax({
1302		type: "POST",
1303		url: "./CestaGlobal.aspx/ProcesoValidacionIdentidadEmail",
1304		data: "{EMail:" + JSON.stringify(Email) + "}",
1305		contentType: "application/json; charset=utf-8",
1306		dataType: "json",
1307		async: false,
1308		success: function (response) {
1309
1310			if (response.d == true) {
1311
1312				const myInterval =	setInterval(function timer() {
1313
1314						if (TimerVerificacion(Email)) {
1315
1316							clearInterval(myInterval);
1317
1318							EmailCG = "s";
1319
1320							console.log(EmailCG)
1321
1322							document.getElementById("hddEmailAccountValidated").value = "s";
1323							
1324						}
1325						else {
1326
1327							EmailCG = "no";
1328
1329							console.log(EmailCG)
1330						}
1331					}, 3000);
1332				
1333			}
1334			else {
1335
1336				// se ha producido un error técnico..
1337            }
1338
1339		},
1340		error: function (result) {
1341			alert('ERROR ' + result.status + ' ' + result.statusText);
1342		}
1343	});
1344
1345}
1346
1347function TimerVerificacion(Email) {
1348
1349	var result = false;
1350
1351	$.ajax({
1352		type: "POST",
1353		url: "./CestaGlobal.aspx/TimerVerificacion",
1354		data: "{EMail:" + JSON.stringify(Email) + "}",
1355		contentType: "application/json; charset=utf-8",
1356		dataType: "json",
1357		async: false,
1358		success: function (response) {
1359
1360			if (response.d == true) {
1361
1362				result = true;
1363
1364				document.getElementById("dvAccountValidation").setAttribute("class", "AccountEMailIdentityValidation hidden1");
1365				document.getElementById("dvAccountValidationSuccess").setAttribute("class", "AccountEMailIdentityValidationSuccess visible1");
1366			}
1367			
1368
1369		},
1370		error: function (result) {
1371			alert('ERROR ' + result.status + ' ' + result.statusText);
1372		}
1373	});
1374
1375	return result;
1376}
1377
1378function getGastosEnvioAsync() {
1379
1380	$("#importeGastosEnvioAsync").empty();
1381
1382	$('#lblGastosEnvioAsyncNoTarifas').hide();
1383
1384	var error_free = new Array();
1385
1386	if ($("#ddlProvince :selected").val() == '0' || $("#ddlProvince").hasClass("invalid")) {
1387		$("#RequiredProvince").removeClass("error").addClass("error_show");
1388		error_free.push(false);
1389	}
1390	else {
1391		$("#RequiredProvince").removeClass("error_show").addClass("error");
1392	}
1393
1394	if ($("#ddlCountry :selected").val() == '0' || $("#ddlCountry").hasClass("invalid")) {
1395		$("#RequiredCountry").removeClass("error").addClass("error_show");
1396		error_free.push(false);
1397	}
1398	else {
1399		$("#RequiredCountry").removeClass("error_show").addClass("error");
1400	}
1401
1402
1403	if ($.inArray(false, error_free) > -1) {
1404
1405		if ($("#ddlProvinceConfirmaDatosCG :selected").val() != '0') {
1406
1407			getGastosEnvioAsyncClienteWeb();
1408		}
1409		else {
1410			event.preventDefault();
1411		}
1412
1413
1414
1415
1416		return
1417	}
1418
1419	var Local_Host = "";
1420
1421	if (window.location.href.indexOf("ediweb") > 0) {
1422		Local_Host = "/ediweb";
1423	}
1424
1425	$.ajax({
1426		type: "POST",
1427		url: "./CestaGlobal.aspx/calculaTotalesAsync2",
1428		data: "{Country:" + JSON.stringify($('#ddlCountry').val()) + "," + "Province:" + JSON.stringify($('#ddlProvince').val()) + "}",
1429		//data: "{Country:" + JSON.stringify($('#ddlCountry').val()) + "," + "Province:" + JSON.stringify($('#ddlProvince option:selected').text()) + "}",
1430		contentType: "application/json; charset=utf-8",
1431		dataType: "json",
1432		success: function (response) {
1433
1434			var GastosEnvio = response.d[0].GastosEnvio.toString().replace(",", ".");
1435
1436			document.getElementById("hddIDFormaEnvio").value = response.d[0].FormaEnvio.toString();
1437
1438			document.getElementById("hddIDZona").value = response.d[0].ZonaEnvio.toString();
1439
1440			var checkResult = isNaN(GastosEnvio)
1441
1442			if (!checkResult) {
1443
1444				if (parseFloat(GastosEnvio) > 0) {
1445
1446					$('#containerGastosEnvioAsync').show();
1447					$('#infoTarifasEnvio').show();
1448					$('#importeGastosEnvioAsync').show();
1449					$("#importeGastosEnvioAsync").append(number_format(parseFloat(GastosEnvio), 2));
1450					$('#lblGastosEnvioAsync').show();
1451					//	$('#dvOpcionesDropShipping').hide();
1452
1453					$('#icnVery_satisfied').hide();
1454
1455					$('#lblEuro').show();
1456
1457					$('#containerGastosEnvioAsyncNoTarifas').hide();
1458					$('#infoTarifasEnvioNoTarifas').hide();
1459
1460					// $('#lblInfoGastosEnvioAsync').hide();
1461
1462					document.getElementById("divBotonesProcesoCompra").setAttribute("style", "display:block");
1463
1464					document.getElementById("icnInfoGastos").setAttribute("class", "inline-icon material-icons blue");
1465
1466
1467					//Calculamos el TOTAL del pedido
1468
1469					var lblParcial = parseFloat(document.getElementById("lblParcial").textContent.replace(",", "."));
1470
1471					var importeGastosEnvioAsync = parseFloat(document.getElementById("importeGastosEnvioAsync").textContent.replace(",", "."));
1472
1473					var lblTotal = parseFloat(document.getElementById("lblTotal").textContent.replace(",", "."));
1474
1475
1476
1477					document.getElementById("lblTotal").textContent = number_format(lblParcial + importeGastosEnvioAsync, 2) + " €";
1478
1479					toogleCamposCalculo();
1480
1481				}
1482				else {
1483					$('#containerGastosEnvioAsync').show();
1484					$('#infoTarifasEnvio').show();
1485					$('#importeGastosEnvioAsync').show();
1486					$("#importeGastosEnvioAsync").append(getIdioma("lbl00167"));
1487					$('#lblGastosEnvioAsync').show();
1488					//	$('#dvOpcionesDropShipping').hide();
1489					$('#icnVery_satisfied').show();
1490					$('#lblEuro').hide();
1491
1492					$('#containerGastosEnvioAsyncNoTarifas').hide();
1493					$('#infoTarifasEnvioNoTarifas').hide();
1494
1495					//  $('#lblInfoGastosEnvioAsync').hide();
1496
1497					document.getElementById("divBotonesProcesoCompra").setAttribute("style", "display:block");
1498
1499					document.getElementById("icnInfoGastos").setAttribute("class", "inline-icon material-icons blue");
1500
1501					//Calculamos el TOTAL del pedido
1502
1503					var lblParcial = parseFloat(document.getElementById("lblParcial").textContent.replace(",", "."));
1504
1505					var importeGastosEnvioAsync = parseFloat(document.getElementById("importeGastosEnvioAsync").textContent.replace(",", "."));
1506
1507					var lblTotal = parseFloat(document.getElementById("lblTotal").textContent.replace(",", "."));
1508
1509					document.getElementById("lblTotal").textContent = number_format(lblParcial, 2) + " €";
1510
1511					toogleCamposCalculo();
1512				}
1513			}
1514			else {
1515
1516				document.getElementById("icnInfoGastos").setAttribute("class", "inline-icon material-icons blue");
1517
1518				$('#sentiment_very_dissatisfied').show();
1519
1520				// $('#containerGastosEnvioAsync').hide();
1521				$('#infoTarifasEnvio').hide();
1522				$("#importeGastosEnvioAsync").append(GastosEnvio);
1523				$('#lblGastosEnvioAsync').hide();
1524				$('#lblEuro').hide();
1525
1526				$('#containerGastosEnvioAsyncNoTarifas').show();
1527				$('#infoTarifasEnvioNoTarifas').show();
1528				$('#lblGastosEnvioAsyncNoTarifas').show();
1529
1530
1531				//   $('#lblInfoGastosEnvioAsync').hide();
1532				//   $('#icnInfoGastos').hide();
1533				$('#importeGastosEnvioAsync').hide();
1534				//	$('#dvOpcionesDropShipping').hide();
1535
1536				document.getElementById("divBotonesProcesoCompra").setAttribute("style", "display:none")
1537
1538				toogleCamposCalculo();
1539			}
1540		},
1541		error: function (result) {
1542			alert('ERROR ' + result.status + ' ' + result.statusText);
1543		}
1544	});
1545
1546}
1547
1548function getGastosEnvioAsyncClienteWeb() {
1549
1550	if (document.getElementById("chkEntregaTienda") != null) {
1551		document.getElementById("chkEntregaTienda").disabled = false;
1552	}
1553
1554	$("#importeGastosEnvioAsync").empty();
1555
1556	$('#lblGastosEnvioAsyncNoTarifas').hide();
1557
1558	document.getElementById("ddlProvinceConfirmaDatosCG_hidden").value = $('#ddlProvinceConfirmaDatosCG').val();
1559
1560	var Local_Host = "";
1561
1562	if (window.location.href.indexOf("ediweb") > 0) {
1563		Local_Host = "/ediweb";
1564	}
1565
1566	//##
1567
1568	var IsZonaEnvioIntracomunitario = false;
1569
1570	var country = $('#ddlPaisCG').val();
1571	var province = $('#ddlProvinceConfirmaDatosCG').val();
1572
1573	if ($("#cmbPaisFacCG :selected").val() != '0' &&
1574		$("#ddlProvinceFactConfirmaDatosCG :selected").val() != '0' &&
1575		document.getElementById("chkfactura_hiddenCG").value == 'true') {
1576
1577		//country = $('#cmbPaisFacCG').val();
1578		//province = $('#ddlProvinceFactConfirmaDatosCG').val();
1579    }
1580
1581	$.ajax({
1582
1583		type: 'POST',
1584		url: "./CestaGlobal.aspx/IsZonaEnvioIntracomunitario",
1585		data: "{Country:" + JSON.stringify(country) + "," + "Province:" + JSON.stringify(province) + "}",
1586		contentType: "application/json; charset=utf-8",
1587		dataType: "json",
1588		async: false,
1589		success: function (result) {
1590
1591			IsZonaEnvioIntracomunitario = result.d;
1592
1593			document.getElementById("hddPaisClienteIntracomunitario").value = result.d;
1594
1595			if (IsZonaEnvioIntracomunitario == false) {
1596
1597				document.getElementById("dvDtoExencionIVA").setAttribute("class", "visible1")
1598			}
1599			else {
1600
1601				document.getElementById("dvDtoExencionIVA").setAttribute("class", "hidden1")
1602			}
1603
1604		},
1605		error: function (jqXHR, textStatus, errorThrown) {
1606			alert("textStatus: " + textStatus + "\n" + "jqXHR: " + jqXHR + "\n" + "errorThrown: " + errorThrown);
1607			// Handle errors here
1608			console.log("textStatus: " + textStatus + "\n" + "jqXHR: " + jqXHR + "\n" + "errorThrown: " + errorThrown);
1609		},
1610		complete: function (event, ui) {
1611			//alert("AJAX Complete");
1612		}
1613	});
1614
1615	var TotalCestaSinIVA = 0.0;
1616
1617	if (document.getElementById("hddPaisClienteIntracomunitario").value == "false") {
1618
1619		$.ajax({
1620
1621			type: 'POST',
1622			url: "./Default.aspx/getTotalCestaSinIVA",
1623			data: "{}",
1624			contentType: "application/json; charset=utf-8",
1625			dataType: "json",
1626			async: false,
1627			success: function (result) {
1628
1629				if (result.d) {
1630
1631					TotalCestaSinIVA = result.d;
1632				}
1633			},
1634			error: function (jqXHR, textStatus, errorThrown) {
1635				alert("textStatus: " + textStatus + "\n" + "jqXHR: " + jqXHR + "\n" + "errorThrown: " + errorThrown);
1636				// Handle errors here
1637				console.log("textStatus: " + textStatus + "\n" + "jqXHR: " + jqXHR + "\n" + "errorThrown: " + errorThrown);
1638			},
1639			complete: function (event, ui) {
1640				//alert("AJAX Complete");
1641			}
1642		});
1643	}
1644
1645	//##
1646
1647	$.ajax({
1648		type: "POST",
1649		url: "./CestaGlobal.aspx/calculaTotalesAsync2",
1650		data: "{Country:" + JSON.stringify(country) + "," + "Province:" + JSON.stringify(province) + "}",
1651		contentType: "application/json; charset=utf-8",
1652		dataType: "json",
1653		success: function (response) {
1654
1655			var GastosEnvio = response.d[0].GastosEnvio.toString().replace(",", ".");
1656
1657			document.getElementById("hddIDFormaEnvio").value = response.d[0].FormaEnvio.toString();
1658
1659			document.getElementById("hddIDZona").value = response.d[0].ZonaEnvio.toString();
1660
1661			var checkResult = isNaN(GastosEnvio)
1662
1663			if (parseFloat(GastosEnvio) > 0) {
1664
1665				$('#containerGastosEnvioAsync').show();
1666				$('#infoTarifasEnvio').show();
1667				$('#importeGastosEnvioAsync').show();
1668				$("#importeGastosEnvioAsync").append(number_format(parseFloat(GastosEnvio), 2));
1669
1670				document.getElementById("importeGastosEnvioAsync_hidden").innerHTML = number_format(parseFloat(GastosEnvio), 2);
1671
1672				$('#lblGastosEnvioAsync').show();
1673				$('#lblEuro').show();
1674
1675				$('#containerGastosEnvioAsyncNoTarifas').hide();
1676				$('#infoTarifasEnvioNoTarifas').hide();
1677
1678				$('#icnVery_satisfied').hide();
1679				$('#icnVery_dissatisfied').hide();
1680
1681				document.getElementById("divBotonesProcesoCompra").setAttribute("style", "display:block");
1682
1683				var lblParcial = parseFloat(document.getElementById("lblParcial").textContent.replace(",", "."));
1684
1685				if (IsZonaEnvioIntracomunitario == false) {
1686
1687					document.getElementById("lblDtoExencionImpuestos").textContent = number_format(lblParcial - TotalCestaSinIVA, 2) + " €";
1688
1689					document.getElementById("lblTotal").textContent = number_format(
1690						(lblParcial + parseFloat(document.getElementById("importeGastosEnvioAsync").textContent.replace(",", "."))) - (lblParcial - TotalCestaSinIVA), 2) + " €";
1691
1692				}
1693				else {
1694
1695					document.getElementById("lblDtoExencionImpuestos").textContent = number_format(0, 2) + " €";
1696
1697					document.getElementById("lblTotal").textContent = number_format(
1698						(lblParcial + parseFloat(document.getElementById("importeGastosEnvioAsync").textContent.replace(",", "."))), 2) + " €";
1699
1700				}
1701
1702
1703			}
1704			else if (parseFloat(GastosEnvio) == 0) {
1705
1706				$('#containerGastosEnvioAsync').show();
1707				$('#infoTarifasEnvio').show();
1708				$('#importeGastosEnvioAsync').show();
1709				$("#importeGastosEnvioAsync").append(getIdioma("lbl00167"));
1710
1711				document.getElementById("importeGastosEnvioAsync_hidden").innerHTML = number_format(parseFloat(0), 2);
1712
1713				$('#lblGastosEnvioAsync').show();
1714				$('#icnVery_satisfied').show();
1715				$('#icnVery_dissatisfied').hide();
1716
1717				$('#lblEuro').hide();
1718
1719				$('#containerGastosEnvioAsyncNoTarifas').hide();
1720				$('#infoTarifasEnvioNoTarifas').hide();
1721
1722				document.getElementById("divBotonesProcesoCompra").setAttribute("style", "display:block");
1723
1724				$('#icnInfoGastos').hide();
1725
1726				var lblParcial = parseFloat(document.getElementById("lblParcial").textContent.replace(",", "."));
1727
1728				//var importeGastosEnvioAsync = parseFloat(document.getElementById("importeGastosEnvioAsync").textContent.replace(",", "."));
1729
1730				//var lblTotal = parseFloat(document.getElementById("lblTotal").textContent.replace(",", "."));
1731
1732				//document.getElementById("lblTotal").textContent = number_format(lblParcial, 2) + " €";
1733
1734				if (IsZonaEnvioIntracomunitario == false) {
1735
1736					document.getElementById("lblDtoExencionImpuestos").textContent = number_format(lblParcial - TotalCestaSinIVA, 2) + " €";
1737
1738					document.getElementById("lblTotal").textContent = number_format(
1739						(TotalCestaSinIVA), 2) + " €";
1740				}
1741				else {
1742
1743					document.getElementById("lblDtoExencionImpuestos").textContent = number_format(parseFloat(0), 2) + " €";
1744
1745					document.getElementById("lblTotal").textContent = number_format((lblParcial), 2) + " €";
1746				}
1747
1748			}
1749			else {
1750
1751				document.getElementById("icnInfoGastos").setAttribute("class", "inline-icon material-icons blue");
1752
1753				// $('#containerGastosEnvioAsync').hide();
1754				$('#infoTarifasEnvio').hide();
1755				$("#importeGastosEnvioAsync").append(GastosEnvio);
1756
1757				document.getElementById("importeGastosEnvioAsync_hidden").innerHTML = number_format(parseFloat(0), 2);
1758
1759				$('#lblGastosEnvioAsync').hide();
1760				$('#lblEuro').hide();
1761
1762				$('#containerGastosEnvioAsyncNoTarifas').show();
1763				$('#infoTarifasEnvioNoTarifas').show();
1764				$('#lblGastosEnvioAsyncNoTarifas').show();
1765
1766				$('#icnVery_satisfied').hide();
1767				$('#importeGastosEnvioAsync').hide();
1768
1769				$('#icnVery_satisfied').hide();
1770				$('#icnVery_dissatisfied').show();
1771
1772				document.getElementById("divBotonesProcesoCompra").setAttribute("style", "display:none");
1773
1774			}
1775		},
1776		error: function (result) {
1777			alert('ERROR ' + result.status + ' ' + result.statusText);
1778		}
1779	});
1780
1781}
1782
1783function AnulaCalculoGastosEnvio() {
1784
1785	var Local_Host = "";
1786
1787	if (window.location.href.indexOf("ediweb") > 0) {
1788		Local_Host = "/ediweb";
1789	}
1790
1791	$.ajax({
1792		type: "POST",
1793		url: "./CestaGlobal.aspx/AnulaGastosEnvio",
1794		data: "{}",
1795		contentType: "application/json; charset=utf-8",
1796		dataType: "json",
1797		success: function (response) {
1798
1799		},
1800		error: function (result) {
1801			alert('ERROR ' + result.status + ' ' + result.statusText);
1802		},
1803		complete: function (event, ui) {
1804
1805			var lblParcial = parseFloat(document.getElementById("lblParcial").textContent.replace(",", "."));
1806
1807			document.getElementById("lblTotal").textContent = number_format(lblParcial, 2) + " €";
1808		}
1809	});
1810
1811}
1812
1813function FillComboProvincias() {
1814
1815	$('#containerGastosEnvioAsyncNoTarifas').hide();
1816	$('#lblGastosEnvioAsyncNoTarifas').hide();
1817	$('#icnVery_dissatisfied').hide();
1818	$('#icnVery_satisfied').hide();
1819	$('#icnInfoGastos').show();
1820	$('#lblInfoGastosEnvioAsync').show();
1821
1822	var IDPais = $("#ddlCountry").val();
1823
1824	var Local_Host = "";
1825
1826	if (window.location.href.indexOf("ediweb") > 0) {
1827		Local_Host = "/ediweb";
1828	}
1829
1830	$.ajax({
1831
1832		type: 'POST',
1833		url: "./CestaGlobal.aspx/getProvinces",
1834		data: "{IdPais:" + JSON.stringify(IDPais) + "}",
1835		contentType: "application/json; charset=utf-8",
1836		async: false,
1837		dataType: "json",
1838		success: function (result) {
1839
1840
1841			$('#ddlProvince').children('option:not(:first)').remove();
1842
1843
1844
1845			if (result.d.length > 0) {
1846
1847				for (var i = 0; i < result.d.length; i++) {
1848
1849					var opt = document.createElement('option');
1850
1851					opt.innerHTML = result.d[i].Descripcion
1852					opt.value = result.d[i].id_Region;
1853
1854					document.getElementById("ddlProvince").appendChild(opt);
1855				}
1856
1857				document.getElementById("flechaDDLCountry").setAttribute("style", "display:none");
1858				document.getElementById("flechaDDLProvince").setAttribute("style", "display:normal");
1859
1860				$('#dvDDLProvince').show();
1861
1862			}
1863			else {
1864
1865
1866				$('#dvDDLProvince').hide();
1867
1868				$('#containerGastosEnvioAsyncNoTarifas').show();
1869				$('#infoTarifasEnvioNoTarifas').show();
1870				$('#lblGastosEnvioAsyncNoTarifas').show();
1871
1872				$('#icnVery_dissatisfied').show();
1873
1874				//	$('#lblInfoGastosEnvioAsync').hide();
1875				//	$('#icnInfoGastos').hide();
1876				$('#importeGastosEnvioAsync').hide();
1877				//	$('#dvOpcionesDropShipping').hide();
1878				$('#lblGastosEnvioAsync').hide();
1879				$('#lblEuro').hide();
1880
1881
1882
1883
1884			}
1885
1886		},
1887		error: function (jqXHR, textStatus, errorThrown) {
1888			alert("textStatus: " + textStatus + "\n" + "jqXHR: " + jqXHR + "\n" + "errorThrown: " + errorThrown);
1889			// Handle errors here
1890			console.log("textStatus: " + textStatus + "\n" + "jqXHR: " + jqXHR + "\n" + "errorThrown: " + errorThrown);
1891		},
1892		complete: function (event, ui) {
1893			//alert("AJAX Complete");
1894		}
1895	});
1896
1897}
1898
1899function FillDDLProvincias() {
1900
1901	$('#containerGastosEnvioAsyncNoTarifas').hide();
1902	$('#lblGastosEnvioAsyncNoTarifas').hide();
1903	$('#icnVery_dissatisfied').hide();
1904	$('#icnVery_satisfied').hide();
1905	$('#icnInfoGastos').show();
1906	$('#lblGastosEnvioAsync').show();
1907	$('#importeGastosEnvioAsync').show();
1908
1909	document.getElementById("ddlProvinceConfirmaDatosCG_hidden").value = $('#ddlProvinceConfirmaDatosCG').val();
1910
1911
1912	if (document.getElementById("importeGastosEnvioAsync") != null) {
1913
1914		document.getElementById("importeGastosEnvioAsync").textContent = "...";
1915
1916	}
1917
1918	//document.getElementById("chkEntregaTienda").disabled = false;
1919
1920	if (document.getElementById("chkEntregaTienda") != null) {
1921
1922		document.getElementById("chkEntregaTienda").checked = false;
1923	}
1924
1925
1926
1927	//ActivaEntregaTiendaDistribuidor();
1928
1929	var IDPais = $("#ddlPaisCG").val();
1930
1931	var Local_Host = "";
1932
1933	if (window.location.href.indexOf("ediweb") > 0) {
1934		Local_Host = "/ediweb";
1935	}
1936
1937	$.ajax({
1938
1939		type: 'POST',
1940		url: "./CestaGlobal.aspx/getProvinces",
1941		data: "{IdPais:" + JSON.stringify(IDPais) + "}",
1942		contentType: "application/json; charset=utf-8",
1943		async: false,
1944		dataType: "json",
1945		success: function (result) {
1946
1947			document.getElementById("ddlProvinceConfirmaDatosCG_hidden").value = $('#ddlProvinceConfirmaDatosCG').val();
1948
1949			$('#ddlProvinceConfirmaDatosCG').children('option:not(:first)').remove();
1950
1951			if (result.d.length > 0) {
1952
1953				for (var i = 0; i < result.d.length; i++) {
1954
1955					var opt = document.createElement('option');
1956
1957					opt.innerHTML = result.d[i].Descripcion
1958					opt.value = result.d[i].id_Region;
1959
1960					document.getElementById("ddlProvinceConfirmaDatosCG").appendChild(opt);
1961				}
1962
1963				if (document.getElementById("flechaDDLCountry") != null) {
1964					document.getElementById("flechaDDLCountry").setAttribute("style", "display:none");
1965				}
1966
1967				if (document.getElementById("flechaDDLProvince") != null) {
1968					document.getElementById("flechaDDLProvince").setAttribute("style", "display:normal");
1969				}
1970
1971				$('#dvDDLProvince').show();
1972
1973			}
1974			else {
1975
1976
1977				$('#dvDDLProvince').hide();
1978
1979				$('#containerGastosEnvioAsyncNoTarifas').show();
1980				$('#infoTarifasEnvioNoTarifas').show();
1981				$('#lblGastosEnvioAsyncNoTarifas').show();
1982
1983				$('#icnVery_dissatisfied').show();
1984
1985				//	$('#lblInfoGastosEnvioAsync').hide();
1986				//	$('#icnInfoGastos').hide();
1987				$('#importeGastosEnvioAsync').hide();
1988				//	$('#dvOpcionesDropShipping').hide();
1989				$('#lblGastosEnvioAsync').hide();
1990				$('#lblEuro').hide();
1991
1992
1993
1994
1995			}
1996
1997		},
1998		error: function (jqXHR, textStatus, errorThrown) {
1999			alert("textStatus: " + textStatus + "\n" + "jqXHR: " + jqXHR + "\n" + "errorThrown: " + errorThrown);
2000			// Handle errors here
2001			console.log("textStatus: " + textStatus + "\n" + "jqXHR: " + jqXHR + "\n" + "errorThrown: " + errorThrown);
2002		},
2003		complete: function (event, ui) {
2004			//alert("AJAX Complete");
2005		}
2006	});
2007
2008}
2009
2010function FillDDLProvinciasFact() {
2011
2012	document.getElementById("ddlProvinceFactConfirmaDatosCG_hidden").value = "";
2013
2014	var IDPais = $("#cmbPaisFacCG").val();
2015
2016	var Local_Host = "";
2017
2018	if (window.location.href.indexOf("ediweb") > 0) {
2019		Local_Host = "/ediweb";
2020	}
2021
2022	$.ajax({
2023
2024		type: 'POST',
2025		url: "./CestaGlobal.aspx/getProvinces",
2026		data: "{IdPais:" + JSON.stringify(IDPais) + "}",
2027		contentType: "application/json; charset=utf-8",
2028		async: false,
2029		dataType: "json",
2030		success: function (result) {
2031
2032			$('#ddlProvinceFactConfirmaDatosCG').children('option:not(:first)').remove();
2033
2034			if (result.d.length > 0) {
2035
2036				for (var i = 0; i < result.d.length; i++) {
2037
2038					var opt = document.createElement('option');
2039
2040					opt.innerHTML = result.d[i].Descripcion
2041					opt.value = result.d[i].id_Region;
2042
2043					document.getElementById("ddlProvinceFactConfirmaDatosCG").appendChild(opt);
2044				}
2045
2046			}
2047
2048
2049		},
2050		error: function (jqXHR, textStatus, errorThrown) {
2051			alert("textStatus: " + textStatus + "\n" + "jqXHR: " + jqXHR + "\n" + "errorThrown: " + errorThrown);
2052			// Handle errors here
2053			console.log("textStatus: " + textStatus + "\n" + "jqXHR: " + jqXHR + "\n" + "errorThrown: " + errorThrown);
2054		},
2055		complete: function (event, ui) {
2056			//alert("AJAX Complete");
2057		}
2058	});
2059
2060}
2061
2062function toogleCamposCalculo() {
2063
2064	event.preventDefault();
2065
2066	$("#pnlImportesDropShipping").toggle();
2067}
2068
2069$('#txtMail').on('input', function (event) {
2070	var input = $(this);
2071	var re = /^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$/;
2072	var is_email = re.test(input.val());
2073	if (is_email) {
2074
2075		input.attr("style", "border-color:#4CAF50;");
2076		$('#div_error_autCli').attr("style", "display:none");
2077		$('#div_error_aut').attr("style", "display:none");
2078		$('#lblErrorAutCli').addClass("hidden");
2079	}
2080	else {
2081		$('#div_error_autCli').attr("style", "display:block");
2082		$('#div_error_aut').attr("style", "display:none");
2083		input.attr("style", "border-color:#FF0000;");
2084		$('#lblErrorAutCli').removeClass("hidden").text(getIdioma("lbl00144"));
2085	}
2086});
2087
2088$('#lnkRecuperarPass').on('click', function (event) {
2089
2090	var input = $('#txtMail');
2091	var re = /^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$/;
2092	var is_email = re.test(input.val());
2093	if (is_email) {
2094
2095		input.attr("style", "border-color:#4CAF50;");
2096		$('#div_error_autCli').attr("style", "display:none");
2097		$('#div_error_aut').attr("style", "display:none");
2098		$('#lblErrorAutCli').addClass("hidden");
2099
2100	}
2101	else {
2102		input.attr("style", "border-color:#FF0000;");
2103		$('#div_error_autCli').attr("style", "display:block");
2104		$('#lblErrorAutCli').removeClass("hidden").text("Debes consignar el e-mail");
2105		event.preventDefault();
2106	}
2107});
2108
2109function chkFacturaCG() {
2110
2111	if ($("#chkDatosFacturaCG").is(':checked')) {
2112		var div = $('#panel_datos_facturacion').removeClass("hidden1").addClass("visible1");
2113		$('#chkfactura_hiddenCG').val("true");
2114		$('#txtNIF').focus();
2115
2116	} else {
2117		var div = $('#panel_datos_facturacion').removeClass("visible1").addClass("hidden1");
2118		$('#chkfactura_hiddenCG').val("false");
2119
2120	}
2121
2122	if (document.getElementById("chkAceptoCondicionesEnvioCG").checked == true) {
2123
2124		document.getElementById("chkAceptoCondicionesEnvioCG").checked = false;
2125	}
2126
2127
2128}
2129
2130function ActivaEntregaTiendaDistribuidor() {
2131
2132	if (document.getElementById("chkEntregaTienda").checked == true) {
2133
2134		//	document.getElementById("dvTiendasDistribudor").setAttribute("style","display:normal")
2135
2136		document.getElementById("ddlTiendasDistribuidor").disabled = false;
2137
2138		$('#icnVery_satisfied').show();
2139		$('#lblGastosEnvioAsync').show();
2140		$('#importeGastosEnvioAsync').show();
2141		$("#importeGastosEnvioAsync").text(getIdioma("lbl00167"));
2142		document.getElementById("divBotonesProcesoCompra").setAttribute("style", "display:block");
2143
2144
2145		$('#icnVery_dissatisfied').hide();
2146		$('#lblGastosEnvioAsyncNoTarifas').hide();
2147
2148		$('#icnInfoGastos').hide();
2149		$('#lnkCalculaGastos').hide();
2150
2151		$('#lblEuro').hide();
2152
2153		AnulaCalculoGastosEnvio();
2154	}
2155	else {
2156
2157		AnulaEntregaTiendaDistribuidor();
2158	}
2159
2160
2161
2162}
2163
2164function AnulaEntregaTiendaDistribuidor() {
2165
2166	//document.getElementById("dvTiendasDistribudor").setAttribute("style", "display:none");
2167
2168	document.getElementById("ddlTiendasDistribuidor").disabled = true;
2169
2170	$("#importeGastosEnvioAsync").text("");
2171
2172	$('#lblGastosEnvioAsync').hide();
2173
2174	$('#icnVery_satisfied').hide();
2175
2176	$("#importeGastosEnvioAsync").append("");
2177
2178	$('#icnInfoGastos').show();
2179
2180	$('#lnkCalculaGastos').show();
2181
2182	if (document.getElementById("hddIsAuthenticated").value == "True") {
2183
2184		document.getElementById("ddlTiendasDistribuidor").value = "0";
2185
2186		getGastosEnvioAsyncClienteWeb();
2187	}
2188	else {
2189
2190		/*
2191		if ($("#ddlProvince :selected").val() != '0') {
2192
2193			getGastosEnvioAsync();
2194		}
2195		*/
2196
2197		document.getElementById("ddlTiendasDistribuidor").value = "0";
2198
2199		getGastosEnvioAsync();
2200
2201	}
2202
2203
2204}
2205
2206function SetValueNewsLetterCG() {
2207	if ($("#chkNewsletterCG").is(':checked')) {
2208		$('#hidd_chkNewsletterCG').val("true");
2209
2210	} else {
2211
2212		$('#hidd_chkNewsletterCG').val("false");
2213
2214	}
2215}
2216
2217function setProvinceFacturaValue() {
2218
2219	document.getElementById("ddlProvinceFactConfirmaDatosCG_hidden").value = $('#ddlProvinceFactConfirmaDatosCG').val();
2220}
2221
2222function setAceptoCondicionesEnvioCG() {
2223
2224
2225	if (document.getElementById("chkAceptoCondicionesEnvioCG").checked == true) {
2226
2227		$('#dvbtnTransfBancaria').attr("style", "display:normal");
2228		$('#dvbtnTarjetaCredito').attr("style", "display:normal");
2229		$('#dvbtnTarjetaCreditoBizum').attr("style", "display:normal");
2230		$('#dvbtnPayPal').attr("style", "display:normal");
2231
2232		$('#dvSeguirComprandoCesta').attr("style", "display:none");
2233
2234		$('#dvErrorValidacionCG').attr("style", "display:none");
2235	}
2236	else {
2237
2238		$('#dvbtnTransfBancaria').attr("style", "display:normal");
2239		$('#dvbtnTarjetaCredito').attr("style", "display:normal");
2240		$('#dvbtnTarjetaCreditoBizum').attr("style", "display:normal");
2241		$('#dvbtnPayPal').attr("style", "display:normal");
2242
2243		$('#dvSeguirComprandoCesta').attr("style", "display:none");
2244
2245		$('#dvErrorValidacionCG').attr("style", "display:none");
2246	}
2247
2248
2249
2250
2251}
2252
2253function ValidaCamposAltaCliente(event) {
2254
2255	this.value = 'Cursando alta....';
2256
2257	$('#dvErrorValidacionCG').attr("style", "display:none");
2258
2259
2260	var ErrorDatosIdentificativos = "false";
2261	var ErrorDatosComunes = "false";
2262	var ErrorDatosFactura = "false";
2263
2264
2265	if (NombreCG == "n" || ApellidosCG == "n" || EmailCG == "n" || PassCG == "n" || ConfPassCG == "n") {
2266
2267		event.preventDefault();
2268
2269		$('#dvErrorValidacionCG').attr("style", "display:block");
2270		$('#lbl_error_validacionCG').removeClass("hidden").text(getIdioma("lbl00090"));
2271
2272		ErrorDatosIdentificativos = "true";
2273
2274		if (NombreCG == "n") {
2275			$('#txtNombreCG').attr("style", "border-color:#FF0000;");
2276		}
2277
2278		if (ApellidosCG == "n") {
2279			$('#txtApellidosCG').attr("style", "border-color:#FF0000;");
2280		}
2281
2282		if (EmailCG == "n") {
2283			$('#txtMailNewUserCG').attr("style", "border-color:#FF0000;");
2284		}
2285
2286		if (PassCG == "n") {
2287			$('#txtPasswordNewUserCG').attr("style", "border-color:#FF0000;");
2288		}
2289
2290		if (ConfPassCG == "n") {
2291			$('#txtRepPasswordNewUserCG').attr("style", "border-color:#FF0000;");
2292		}
2293	}
2294
2295	if ($("#ddlProvinceConfirmaDatosCG :selected").val() == '0') {
2296
2297		ProvinciaComboCG = "n";
2298	}
2299	else {
2300		ProvinciaComboCG = "s";
2301	}
2302
2303	if ($("#ddlProvinceFactConfirmaDatosCG :selected").val() == '0') {
2304
2305		ProvinciaFacturaComboCG = "n";
2306	}
2307	else {
2308		ProvinciaFacturaComboCG = "s";
2309	}
2310
2311	if ($("#ddlPaisCG :selected").val() == '0') {
2312
2313		PaisComboCG = "n";
2314	}
2315	else {
2316		PaisComboCG = "s";
2317	}
2318
2319
2320	if ($("#cmbPaisFacCG :selected").val() == '0') {
2321
2322		PaisComboFacturaCG = "n";
2323	}
2324	else {
2325		PaisComboFacturaCG = "s";
2326	}
2327
2328
2329	if (DomicilioCG == "n" || CodigoPostalCG == "n" || PoblacionCG == "n" || TelefonoCG == "n" || PaisComboCG == "n"
2330		|| ProvinciaComboCG == "n") {
2331
2332		event.preventDefault();
2333
2334		$('#dvErrorValidacionCG').attr("style", "display:block");
2335		$('#lbl_error_validacionCG').removeClass("hidden").text(getIdioma("lbl00090"));
2336
2337		ErrorDatosComunes = "true";
2338
2339		if (DomicilioCG == "n") {
2340			$('#txtDomicilioCG').attr("style", "border-color:#FF0000;");
2341		}
2342		if (CodigoPostalCG == "n") {
2343			$('#txtCP_CG').attr("style", "border-color:#FF0000;");
2344		}
2345		if (PoblacionCG == "n") {
2346			$('#txtPoblacionCG').attr("style", "border-color:#FF0000;");
2347		}
2348		if (TelefonoCG == "n") {
2349			$('#txtTelefonoCG').attr("style", "border-color:#FF0000;");
2350		}
2351		if (PaisComboCG == "n") {
2352			$("#ddlPaisCG").attr("style", "border:2px solid #FF0000;");
2353		}
2354		if (ProvinciaComboCG == "n") {
2355			$('#ddlProvinceConfirmaDatosCG').attr("style", "border:1px solid #FF0000");
2356		}
2357	}
2358
2359	if ($("#chkDatosFacturaCG").is(':checked')) {
2360		if (NIFClienteCG == "n" || NombreFacturaCG == "n" || DomicilioFacturaCG == "n" || CodigoPostalFacturaCG == "n" ||
2361			PoblacionFacturaCG == "n" || PaisComboFacturaCG == "n" || ProvinciaFacturaComboCG == "n") {
2362
2363			event.preventDefault();
2364
2365			$('#dvErrorValidacionCG').attr("style", "display:block");
2366			$('#lbl_error_validacionCG').removeClass("hidden").text(getIdioma("lbl00090"));
2367
2368			ErrorDatosFactura = "true";
2369
2370			if (NIFClienteCG == "n") {
2371				$('#txtNIF_CG').attr("style", "border-color:#FF0000;");
2372			}
2373			if (NombreFacturaCG == "n") {
2374				$('#txtNombreFactCG').attr("style", "border-color:#FF0000;");
2375			}
2376			if (DomicilioFacturaCG == "n") {
2377				$('#txtDomicilioFactCG').attr("style", "border-color:#FF0000;");
2378			}
2379			if (CodigoPostalFacturaCG == "n") {
2380				$('#txtCPFactCG').attr("style", "border-color:#FF0000;");
2381			}
2382			if (PoblacionFacturaCG == "n") {
2383				$('#txtPoblacionFactCG').attr("style", "border-color:#FF0000;");
2384			}
2385			if (PaisComboFacturaCG == "n") {
2386				$("#cmbPaisFacCG").attr("style", "border:2px solid #FF0000;");
2387			}
2388			if (ProvinciaFacturaComboCG == "n") {
2389				$("#ddlProvinceFactConfirmaDatosCG").attr("style", "border:2px solid #FF0000;");
2390			}
2391		}
2392	}
2393
2394	if (!document.getElementById("dvCheckAvisoLegal").hidden == true) {
2395		if (!$("#chkAceptoCondicionesEnvioCG").is(':checked') && ErrorDatosComunes == "false" && ErrorDatosFactura == "false" && ErrorDatosIdentificativos == "false") {
2396			$('#dvErrorValidacionCG').attr("style", "display:block");
2397			event.preventDefault();
2398			$('#lbl_error_validacionCG').removeClass("hidden").text(getIdioma("lbl00136"));
2399		}
2400	}
2401	else {
2402
2403		if (ErrorDatosComunes == "false" && ErrorDatosFactura == "false" && ErrorDatosIdentificativos == "false") {
2404			$('#dvErrorValidacionCG').attr("style", "display:none");
2405
2406			document.getElementById("dvCheckAvisoLegal").hidden = false;
2407
2408		}
2409	}
2410
2411}
2412
2413function ValidaCamposRegistroUsuarios(event) {
2414
2415	$('#dvErrorValidacionCG').attr("style", "display:none");
2416
2417
2418	ErrorDatosIdentificativos = "false";
2419
2420	if ($('#txtNombreCG').val()) {
2421
2422		$('#txtNombreCG').attr("style", "border-color:#4CAF50;");
2423		//ErrorDatosIdentificativos = "false";
2424	}
2425	else {
2426
2427		$('#txtNombreCG').attr("style", "border-color:#FF0000;");
2428		ErrorDatosIdentificativos = "true";
2429	}
2430
2431	if ($('#txtApellidosCG').val()) {
2432
2433		$('#txtApellidosCG').attr("style", "border-color:#4CAF50;");
2434		//ErrorDatosIdentificativos = "false";
2435
2436	}
2437	else {
2438
2439		$('#txtApellidosCG').attr("style", "border-color:#FF0000;");
2440		ErrorDatosIdentificativos = "true";
2441	}
2442
2443	if ($('#txtMailNewUserCG').val() && EmailCG == "s") {
2444
2445		$('#txtMailNewUserCG').attr("style", "border-color:#4CAF50;");
2446		//ErrorDatosIdentificativos = "false";
2447	}
2448	else {
2449
2450		$('#txtMailNewUserCG').attr("style", "border-color:#FF0000;");
2451		ErrorDatosIdentificativos = "true";
2452	}
2453
2454
2455	if ($('#txtPasswordNewUserCG').val()) {
2456
2457		$('#txtPasswordNewUserCG').attr("style", "border-color:#4CAF50;");
2458		//ErrorDatosIdentificativos = "false";
2459	}
2460	else {
2461
2462		$('#txtPasswordNewUserCG').attr("style", "border-color:#FF0000;");
2463		ErrorDatosIdentificativos = "true";
2464	}
2465
2466	if ($('#txtRepPasswordNewUserCG').val()) {
2467
2468		$('#txtRepPasswordNewUserCG').attr("style", "border-color:#4CAF50;");
2469		//ErrorDatosIdentificativos = "false";
2470	}
2471	else {
2472
2473		$('#txtRepPasswordNewUserCG').attr("style", "border-color:#FF0000;");
2474		ErrorDatosIdentificativos = "true";
2475	}
2476
2477	if (ErrorDatosIdentificativos == "true") {
2478
2479		event.preventDefault();
2480		$('#dvErrorValidacionCG').attr("style", "display:block");
2481		$('#lbl_error_validacionCG').removeClass("hidden").text(getIdioma("lbl00090"));
2482	}
2483
2484}
2485
2486
2487
2488function ValidaCamposClienteWeb(event) {
2489
2490
2491	$('#dvErrorValidacionCG').attr("style", "display:none");
2492
2493	var ErrorDatosIdentificativos = "false";
2494	var ErrorDatosComunes = "false";
2495	var ErrorDatosFactura = "false";
2496	var ErrorPuntoVenta = "false";
2497
2498
2499	// datos comunes
2500
2501	if ($('#txtNombreCG').val()) {
2502
2503		$('#txtNombreCG').attr("style", "border-color:#4CAF50;");
2504		//ErrorDatosIdentificativos = "false";
2505	}
2506	else {
2507
2508		$('#txtNombreCG').attr("style", "border-color:#FF0000;");
2509		ErrorDatosIdentificativos = "true";
2510	}
2511
2512	if ($('#txtApellidosCG').val()) {
2513
2514		$('#txtApellidosCG').attr("style", "border-color:#4CAF50;");
2515		//ErrorDatosIdentificativos = "false";
2516
2517	}
2518	else {
2519
2520		$('#txtApellidosCG').attr("style", "border-color:#FF0000;");
2521		ErrorDatosIdentificativos = "true";
2522	}
2523
2524	if ($('#txtMailNewUserCG').val()) {
2525
2526		$('#txtMailNewUserCG').attr("style", "border-color:#4CAF50;");
2527		//ErrorDatosIdentificativos = "false";
2528	}
2529	else {
2530
2531		$('#txtMailNewUserCG').attr("style", "border-color:#FF0000;");
2532		ErrorDatosIdentificativos = "true";
2533	}
2534
2535
2536	if ($('#txtPasswordNewUserCG').val()) {
2537
2538		$('#txtPasswordNewUserCG').attr("style", "border-color:#4CAF50;");
2539		//ErrorDatosIdentificativos = "false";
2540	}
2541	else {
2542
2543		$('#txtPasswordNewUserCG').attr("style", "border-color:#FF0000;");
2544		ErrorDatosIdentificativos = "true";
2545	}
2546
2547	if ($('#txtRepPasswordNewUserCG').val()) {
2548
2549		$('#txtRepPasswordNewUserCG').attr("style", "border-color:#4CAF50;");
2550		//ErrorDatosIdentificativos = "false";
2551	}
2552	else {
2553
2554		$('#txtRepPasswordNewUserCG').attr("style", "border-color:#FF0000;");
2555		ErrorDatosIdentificativos = "true";
2556	}
2557
2558
2559	if (JSON.parse(document.getElementById("hddConfirmacionEMail").value.toLowerCase())) {
2560
2561		if (document.getElementById("hddEmailAccountValidated").value == "s") {
2562
2563			$('#txtMailNewUserCG').attr("style", "border-color:#4CAF50;");
2564		}
2565		else {
2566
2567			$('#txtMailNewUserCG').attr("style", "border-color:#FF0000;");
2568			ErrorDatosIdentificativos = "true";
2569		}
2570	}
2571
2572
2573
2574
2575	// combos
2576
2577	if ($("#ddlProvinceConfirmaDatosCG :selected").val() == '0') {
2578
2579		$("#ddlProvinceConfirmaDatosCG").attr("style", "border: 1px solid #FF0000;");
2580		ErrorDatosComunes = "true";
2581	}
2582	else {
2583
2584		$("#ddlProvinceConfirmaDatosCG").attr("style", "border: 1px solid #4CAF50;");
2585
2586	}
2587
2588
2589	if ($("#ddlPaisCG :selected").val() == '0') {
2590
2591		$("#ddlPaisCG").attr("style", "border: 1px solid #FF0000;");
2592		ErrorDatosComunes = "true";
2593	}
2594	else {
2595
2596		$("#ddlPaisCG").attr("style", "border: 1px solid #4CAF50;");
2597
2598	}
2599
2600	if ($('#txtDomicilioCG').val()) {
2601
2602		$('#txtDomicilioCG').attr("style", "border-color:#4CAF50;");
2603
2604	}
2605	else {
2606
2607		$('#txtDomicilioCG').attr("style", "border-color:#FF0000;");
2608		ErrorDatosComunes = "true";
2609	}
2610
2611	if ($('#txtCP_CG').val() && localStorage.getItem("CodigoPostalCG") == "s") {
2612
2613		$('#txtCP_CG').attr("style", "border-color:#4CAF50;");
2614
2615	}
2616	else {
2617
2618		$('#txtCP_CG').attr("style", "border-color:#FF0000;");
2619		ErrorDatosComunes = "true";
2620	}
2621
2622	if ($('#txtPoblacionCG').val()) {
2623
2624		$('#txtPoblacionCG').attr("style", "border-color:#4CAF50;");
2625
2626
2627	}
2628	else {
2629
2630		$('#txtPoblacionCG').attr("style", "border-color:#FF0000;");
2631		ErrorDatosComunes = "true";
2632	}
2633
2634	if ($('#txtTelefonoCG').val()) {
2635
2636		$('#txtTelefonoCG').attr("style", "border-color:#4CAF50;");
2637
2638	}
2639	else {
2640
2641		$('#txtTelefonoCG').attr("style", "border-color:#FF0000;");
2642		ErrorDatosComunes = "true";
2643	}
2644
2645
2646	// datos factura
2647
2648	//si no existe nif con el cliente logado, es que no ha pedido factura
2649
2650	if ($("#chkDatosFacturaCG").is(':checked')) {
2651
2652
2653		if ($('#txtNIF_CG').val()) {
2654
2655			$('#panel_datos_facturacion').removeClass("hidden1").addClass("visible1");
2656			$('#chkfactura_hiddenCG').val("true");
2657			document.getElementById("chkDatosFacturaCG").checked = true;
2658
2659			$('#txtNIF_CG').attr("style", "border-color:#4CAF50;");
2660
2661		}
2662		else {
2663
2664			$('#txtNIF_CG').attr("style", "border-color:#FF0000;");
2665			ErrorDatosFactura = "true";
2666		}
2667
2668		if ($('#txtNombreFactCG').val()) {
2669
2670			$('#txtNombreFactCG').attr("style", "border-color:#4CAF50;");
2671
2672		}
2673		else {
2674
2675			$('#txtNombreFactCG').attr("style", "border-color:#FF0000;");
2676			ErrorDatosFactura = "true";
2677		}
2678
2679		if ($('#txtDomicilioFactCG').val()) {
2680
2681			$('#txtDomicilioFactCG').attr("style", "border-color:#4CAF50;");
2682
2683		}
2684		else {
2685
2686			$('#txtDomicilioFactCG').attr("style", "border-color:#FF0000;");
2687			ErrorDatosFactura = "true";
2688		}
2689
2690		if ($('#txtCPFactCG').val() && localStorage.getItem("CodigoPostalFacturaCG") == "s") {
2691
2692			$('#txtCPFactCG').attr("style", "border-color:#4CAF50;");
2693
2694		}
2695		else {
2696
2697			$('#txtCPFactCG').attr("style", "border-color:#FF0000;");
2698			ErrorDatosFactura = "true";
2699		}
2700
2701		if ($('#txtPoblacionFactCG').val()) {
2702
2703			$('#txtPoblacionFactCG').attr("style", "border-color:#4CAF50;");
2704
2705		}
2706		else {
2707
2708			$('#txtPoblacionFactCG').attr("style", "border-color:#FF0000;");
2709			ErrorDatosFactura = "true";
2710		}
2711
2712		if ($("#cmbPaisFacCG :selected").val() == '0') {
2713
2714			$("#cmbPaisFacCG").attr("style", "border: 1px solid #FF0000;");
2715			ErrorDatosFactura = "true";
2716		}
2717		else {
2718
2719			$("#cmbPaisFacCG").attr("style", "border: 1px solid #4CAF50;");
2720
2721		}
2722
2723		if ($("#ddlProvinceFactConfirmaDatosCG :selected").val() == '0') {
2724
2725			$("#ddlProvinceFactConfirmaDatosCG").attr("style", "border: 1px solid #FF0000;");
2726			ErrorDatosFactura = "true";
2727
2728		}
2729		else {
2730
2731			$("#ddlProvinceFactConfirmaDatosCG").attr("style", "border: 1px solid #4CAF50;");
2732
2733		}
2734
2735	}
2736
2737	if (document.getElementById("chkEntregaTienda").checked == true) {
2738
2739		if ($("#ddlTiendasDistribuidor :selected").val() == '0') {
2740
2741			$("#ddlTiendasDistribuidor").attr("style", "border: 1px solid #FF0000;");
2742			ErrorPuntoVenta = "true";
2743
2744		}
2745		else {
2746
2747			$("#ddlTiendasDistribuidor").attr("style", "border: 1px solid #4CAF50;");
2748
2749		}
2750	}
2751
2752
2753
2754
2755	if (ErrorDatosComunes == "true" || ErrorDatosFactura == "true"
2756		|| ErrorDatosIdentificativos == "true"
2757		|| ErrorPuntoVenta == "true") {
2758
2759		event.preventDefault();
2760		$('#dvErrorValidacionCG').attr("style", "display:block");
2761		$('#lbl_error_validacionCG').removeClass("hidden").text(getIdioma("lbl00090"));
2762	}
2763
2764
2765	if (!$("#chkAceptoCondicionesEnvioCG").is(':checked') && ErrorDatosComunes == "false"
2766		&& ErrorDatosFactura == "false"
2767		&& ErrorDatosIdentificativos == "false"
2768		&& ErrorPuntoVenta == "false") {
2769
2770		event.preventDefault();
2771
2772		document.getElementById("dvCheckAvisoLegal").hidden = false;
2773
2774		$('#dvErrorValidacionCG').attr("style", "display:block");
2775		$('#lbl_error_validacionCG').removeClass("hidden").text(getIdioma("lbl00136"));
2776	}
2777
2778
2779
2780}
2781
2782function validateCIF(cif) {
2783	//Quitamos el primer caracter y el ultimo digito
2784	var valueCif = cif.substr(1, cif.length - 2);
2785
2786	var suma = 0;
2787
2788	//Sumamos las cifras pares de la cadena
2789	for (i = 1; i < valueCif.length; i = i + 2) {
2790		suma = suma + parseInt(valueCif.substr(i, 1));
2791	}
2792
2793	var suma2 = 0;
2794
2795	//Sumamos las cifras impares de la cadena
2796	for (i = 0; i < valueCif.length; i = i + 2) {
2797		result = parseInt(valueCif.substr(i, 1)) * 2;
2798		if (String(result).length == 1) {
2799			// Un solo caracter
2800			suma2 = suma2 + parseInt(result);
2801		} else {
2802			// Dos caracteres. Los sumamos...
2803			suma2 = suma2 + parseInt(String(result).substr(0, 1)) + parseInt(String(result).substr(1, 1));
2804		}
2805	}
2806
2807	// Sumamos las dos sumas que hemos realizado
2808	suma = suma + suma2;
2809
2810	var unidad = String(suma).substr(1, 1)
2811	unidad = 10 - parseInt(unidad);
2812
2813	var primerCaracter = cif.substr(0, 1).toUpperCase();
2814
2815	if (primerCaracter.match(/^[FJKNPQRSUVW]$/)) {
2816		//Empieza por .... Comparamos la ultima letra
2817		if (String.fromCharCode(64 + unidad).toUpperCase() == cif.substr(cif.length - 1, 1).toUpperCase())
2818			return true;
2819	} else if (primerCaracter.match(/^[XYZ]$/)) {
2820		//Se valida como un dni
2821		var newcif;
2822		if (primerCaracter == "X")
2823			newcif = cif.substr(1);
2824		else if (primerCaracter == "Y")
2825			newcif = "1" + cif.substr(1);
2826		else if (primerCaracter == "Z")
2827			newcif = "2" + cif.substr(1);
2828		return validateDNI(newcif);
2829	} else if (primerCaracter.match(/^[ABCDEFGHLM]$/)) {
2830		//Se revisa que el ultimo valor coincida con el calculo
2831		if (unidad == 10)
2832			unidad = 0;
2833		if (cif.substr(cif.length - 1, 1) == String(unidad))
2834			return true;
2835	} else {
2836		//Se valida como un dni
2837		return validateDNI(cif);
2838	}
2839	return false;
2840};
2841
2842function validateDNI(dni) {
2843	var lockup = 'TRWAGMYFPDXBNJZSQVHLCKE';
2844	var valueDni = dni.substr(0, dni.length - 1);
2845	var letra = dni.substr(dni.length - 1, 1).toUpperCase();
2846
2847	if (lockup.charAt(valueDni % 23) == letra)
2848		return true;
2849	return false;
2850};
2851
2852
2853function getIdioma(idText) {
2854
2855
2856	var texto = "no text";
2857
2858	$.ajax({
2859
2860		type: 'POST',
2861		url: 'CestaGlobal.aspx/getIdiomaAJAX',
2862		data: "{idText:" + JSON.stringify(idText) + "}",
2863		contentType: "application/json; charset=utf-8",
2864		async: false,
2865		dataType: "json",
2866		success: function (result) {
2867
2868			if (result.d.length > 0) {
2869
2870				texto = result.d;
2871
2872			}
2873		},
2874		error: function (jqXHR, textStatus, errorThrown) {
2875			alert("textStatus: " + textStatus + "\n" + "jqXHR: " + jqXHR + "\n" + "errorThrown: " + errorThrown);
2876			// Handle errors here
2877			console.log("textStatus: " + textStatus + "\n" + "jqXHR: " + jqXHR + "\n" + "errorThrown: " + errorThrown);
2878		},
2879		complete: function (event, ui) {
2880			//alert("AJAX Complete");
2881		}
2882	});
2883
2884	return texto;
2885}
2886
2887
2888function ValidaDatosEnvio(event) {
2889
2890	if ($("#ddlProvinceConfirmaDatosCG :selected").val() == '0') {
2891
2892		$("#ddlProvinceConfirmaDatosCG").attr("style", "border:1px solid #FF0000;");
2893
2894		event.preventDefault();
2895	}
2896	else {
2897
2898		$("#ddlProvinceConfirmaDatosCG").attr("style", "border:1px solid #4CAF50;");
2899		ProvinciaComboCG = "s"
2900	}
2901}
2902
2903
2904
2905function cerrardvAccountValidationSuccess() {
2906
2907	document.getElementById("dvAccountValidationSuccess").setAttribute("class", "AccountEMailIdentityValidationSuccess hidden1");
2908}
2909
2910
2911function CPFacturaEvaluate() {
2912
2913		var input = $('#txtCPFactCG');
2914
2915		var element = $('#div_cp_fact')
2916		var re = /(^([0-9]{5,5})|^)$/;
2917		var is_name = input.val();
2918
2919		var isSpain = false;
2920
2921		if ($("#cmbPaisFacCG option:selected").text().toLowerCase().indexOf("españa") > -1) {
2922			isSpain = true;
2923		}
2924		else if ($("#cmbPaisFacCG option:selected").text().toLowerCase().indexOf("espanya") > -1) {
2925			isSpain = true;
2926		}
2927		else if ($("#cmbPaisFacCG option:selected").text().toLowerCase().indexOf("spain") > -1) {
2928			isSpain = true;
2929		}
2930
2931		var Evaluated = false;
2932
2933		if (isSpain && is_name.length == 5 && parseInt(is_name) >= 1000 && parseInt(is_name) <= 52999) {
2934
2935			Evaluated = true;
2936
2937			CodigoPostalFacturaCG = "s";
2938			input.attr("style", "border-color:#4CAF50;");
2939			localStorage.setItem("CodigoPostalFacturaCG", "s");
2940
2941			if (CodigoPostalFacturaCG == "s") {
2942
2943				$('#dvErrorValidacionCG').attr("style", "display:none");
2944				$('#lbl_error_validacionCG').addClass("hidden");
2945			}
2946
2947			if (NIFClienteCG == "s" && NombreFacturaCG == "s" && DomicilioFacturaCG == "s" && CodigoPostalFacturaCG == "s" && PoblacionFacturaCG == "s"
2948				&& PaisComboFacturaCG == "s" && ProvinciaFacturaComboCG == "s") {
2949
2950				$('#dvErrorValidacionCG').attr("style", "display:none");
2951				$('#lbl_error_validacionCG').addClass("hidden");
2952
2953				document.getElementById("dvCheckAvisoLegal").hidden = false;
2954			}
2955		}
2956		else {
2957
2958			input.attr("style", "border-color:#FF0000;")
2959			CodigoPostalFacturaCG = "n";
2960			localStorage.setItem("CodigoPostalFacturaCG", "n");
2961		}
2962
2963
2964		if (!isSpain && is_name) {
2965			CodigoPostalFacturaCG = "s";
2966			localStorage.setItem("CodigoPostalFacturaCG", "s");
2967			input.attr("style", "border-color:#4CAF50;");
2968
2969			if (CodigoPostalFacturaCG == "s") {
2970
2971				$('#dvErrorValidacionCG').attr("style", "display:none");
2972				$('#lbl_error_validacionCG').addClass("hidden");
2973			}
2974
2975			if (NIFClienteCG == "s" && NombreFacturaCG == "s" && DomicilioFacturaCG == "s" && CodigoPostalFacturaCG == "s" && PoblacionFacturaCG == "s"
2976				&& PaisComboFacturaCG == "s" && ProvinciaFacturaComboCG == "s") {
2977
2978				$('#dvErrorValidacionCG').attr("style", "display:none");
2979				$('#lbl_error_validacionCG').addClass("hidden");
2980
2981				document.getElementById("dvCheckAvisoLegal").hidden = false;
2982			}
2983		}
2984		else {
2985
2986			if (!Evaluated) {
2987
2988				input.attr("style", "border-color:#FF0000;")
2989				CodigoPostalFacturaCG = "n";
2990				localStorage.setItem("CodigoPostalFacturaCG", "n");
2991			}
2992		}
2993}
2994
2995
2996function CPEvaluate() {
2997
2998		var input = $('#txtCP_CG');
2999
3000
3001		var element = $('#div_cp')
3002		var re = /(^([0-9]{5,5})|^)$/;
3003		var is_name = input.val();
3004
3005		var inputVal = document.getElementById("txtCP_CG").value;
3006
3007		var isSpain = false;
3008
3009		if ($("#ddlPaisCG option:selected").text().toLowerCase().indexOf("españa") > -1) {
3010
3011			isSpain = true;
3012		}
3013		else if ($("#ddlPaisCG option:selected").text().toLowerCase().indexOf("espanya") > -1) {
3014
3015			isSpain = true;
3016		}
3017		else if ($("#ddlPaisCG option:selected").text().toLowerCase().indexOf("spain") > -1) {
3018
3019			isSpain = true;
3020		}
3021
3022		var Evaluated = false;
3023
3024		if (isSpain && inputVal.length == 5 && parseInt(inputVal) >= 1000 && parseInt(inputVal) <= 52999) {
3025
3026			Evaluated = true;
3027
3028			CodigoPostalCG = "s";
3029			localStorage.setItem("CodigoPostalCG", "s");
3030
3031
3032			input.attr("style", "border-color:#4CAF50;");
3033
3034			if (CodigoPostalCG == "s") {
3035
3036				$('#dvErrorValidacionCG').attr("style", "display:none");
3037				$('#lbl_error_validacionCG').addClass("hidden");
3038			}
3039
3040			if (DomicilioCG == "s" && CodigoPostalCG == "s" && PoblacionCG == "s" && TelefonoCG == "s"
3041				&& PaisComboCG == "s" && ProvinciaComboCG == "s") {
3042
3043				$('#dvErrorValidacionCG').attr("style", "display:none");
3044				$('#lbl_error_validacionCG').addClass("hidden");
3045
3046				document.getElementById("dvCheckAvisoLegal").hidden = false;
3047			}
3048		}
3049		else {
3050
3051			//alert("codigo invalido");
3052
3053			input.attr("style", "border-color:#FF0000;")
3054			CodigoPostalCG = "n";
3055			localStorage.setItem("CodigoPostalCG", "n");
3056		}
3057
3058
3059		if (!isSpain && is_name) {
3060
3061			CodigoPostalCG = "s";
3062			input.attr("style", "border-color:#4CAF50;");
3063			localStorage.setItem("CodigoPostalCG", "s");
3064
3065			if (CodigoPostalCG == "s") {
3066
3067				$('#dvErrorValidacionCG').attr("style", "display:none");
3068				$('#lbl_error_validacionCG').addClass("hidden");
3069			}
3070
3071			if (DomicilioCG == "s" && CodigoPostalCG == "s" && PoblacionCG == "s" && TelefonoCG == "s"
3072				&& PaisComboCG == "s" && ProvinciaComboCG == "s") {
3073
3074				$('#dvErrorValidacionCG').attr("style", "display:none");
3075				$('#lbl_error_validacionCG').addClass("hidden");
3076
3077				document.getElementById("dvCheckAvisoLegal").hidden = false;
3078			}
3079
3080		}
3081		else {
3082
3083			if (!Evaluated) {
3084				input.attr("style", "border-color:#FF0000;")
3085				CodigoPostalCG = "n";
3086				localStorage.setItem("CodigoPostalCG", "n");
3087			}
3088		}
3089}
3090

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.