PageSourceSearch

https://www.discountschoolsupply.com/_ui/responsive/common/js/acc.checkout.js?v=S530

js discountschoolsupply.com collected 2026-09-25 18:18:11 UTC 54,034 bytes, 1,469 lines download raw bytes

1var paymentId='';
2var addressId='';
3var billToAddr = null;
4ACC.checkout = {
5
6	_autoload: [
7		"bindCheckO",
8		"bindForms",
9		"bindSavedPayments",
10		"bindselectedPayments",
11		"bindAddCard",
12		"bindCancelCard",
13		"bindEditCard",
14		"bindAddAddressCard",
15		"bindEditAddressCard",
16		"bindSelectAddresses",
17		"bindSuggestedForms",
18		"bindTaxExemptInfo",
19		"bindGiftCertificates",
20		"bindPlaceOrderForm",
21		"bindCreateAccountPopup"
22	],
23
24	bindForms:function(){
25
26        $(document).on("click","#submitBtn",function(e){
27            e.preventDefault();
28             $('#grantOrderForm').submit();
29        })
30
31		$(document).on("click","#deliveryMethodSubmit,#deliveryMethodSubmit_mobile",function(e){
32			e.preventDefault();
33			$('#selectDeliveryMethodForm').submit();
34		})
35		$(document).on("click","#deliveryinstruction",function(e){
36        			if($(this).is(':checked')){
37                        $('#deliveryinstruction-input').show();
38        			}else{
39        			    $('#deliveryinstruction-input').hide();
40                        $('#commentsLine1').val("");
41                        $('[id^=commentsplacement]').prop('checked', false);
42        			}
43        		})
44                $(document).on("click","#saveddeliveryinstruction",function(e){
45                        if($(this).is(':checked')){
46                              $('#saveddeliveryinstruction-input').show();
47                        }else{
48                            $('#saveddeliveryinstruction-input').hide();
49                            $('#savedComment').val("");
50                            $('[id^=savedCommentsPlacement]').prop('checked', false);
51                        }
52                })
53
54        		$(document).on("click","input[name='customerType']",function(e){
55                    if($(this).val() === "ORGANIZATION"){
56                        $('.js-organization-inputs').show();
57                    }else{
58                        $('.js-organization-inputs').hide();
59                    }
60                })
61
62
63	},
64	bindSuggestedForms:function(){
65	$('.js-edit-entered-address').click(function(e)
66	{
67		ACC.colorbox.close();
68	});
69
70	$('.use-entered-address').click(function(e)
71	{
72		$(this).addClass("active")
73		if($('#qasaddress').val() != "" && $('#qasaddress').val() == "true"){
74			$(".use-entered-address,.use-corrected-address,.js-edit-entered-address").css( 'pointer-events', 'none' );
75			 $('#silentOrderPostForm').submit();
76
77		}else{
78		    $( "input[name='enteredAddressUsed']" ).val(true);
79			$('#addressForm').submit();
80		}
81
82	});
83
84	$('.use-corrected-address').click(function(e)
85	{
86
87		if($('#qasaddress').val() != "" && $('#qasaddress').val() == "true"){
88			$( "input[name='billTo_street1']" ).val($('#suggestedLine1').val());
89			$( "input[name='billTo_street2']" ).val($('#suggestedLine2').val());
90			$( "input[name='billTo_city']" ).val($('#suggestedCity').val());
91			$( "select[name='billTo_state']" ).val($('#suggestedBillState').val());
92			$( "input[name='billTo_postalCode']" ).val($('#suggestedZipCode').val());
93			$(".use-entered-address,.use-corrected-address,.js-edit-entered-address").css( 'pointer-events', 'none' );
94			$(this).addClass("active")
95			 $('#silentOrderPostForm').submit();
96		}else{
97			$( "input[name='line1']" ).val($('#suggestedLine1').val());
98			$( "input[name='line2']" ).val($('#suggestedLine2').val());
99			$( "input[name='townCity']" ).val($('#suggestedCity').val());
100			$( "select[name='regionIso']" ).val($('#suggestedState').val());
101			$( "input[name='postcode']" ).val($('#suggestedZipCode').val());
102			$( "input[name='deliveryPointBarcode']" ).val($('#deliveryPointBarcode').val());
103            $( "input[name='checkDigit']" ).val($('#checkDigit').val());
104			$( "input[name='correctedAddressUsed']" ).val(true);
105
106			$('#addressForm').submit();
107		}
108	});
109
110	},
111
112    /**
113     * Applies the QAS-corrected address straight to the form fields and submits - exactly what
114     * the ".use-corrected-address" click handler above does - but driven off the raw ajax
115     * response instead of a click. Used when /qas/verify decided the entered and corrected
116     * addresses are close enough (cosmetic-only or ZIP+4-only difference) that the popup should
117     * never be shown at all.
118     */
119    applyCorrectedAddress:function($response)
120    {
121       if($('#qasaddress').val() != "" && $('#qasaddress').val() == "true"){
122          $( "input[name='billTo_street1']" ).val($response.find('#suggestedLine1').val());
123          $( "input[name='billTo_street2']" ).val($response.find('#suggestedLine2').val());
124          $( "input[name='billTo_city']" ).val($response.find('#suggestedCity').val());
125          $( "select[name='billTo_state']" ).val($response.find('#suggestedBillState').val());
126          $( "input[name='billTo_postalCode']" ).val($response.find('#suggestedZipCode').val());
127          $('#silentOrderPostForm').submit();
128       }else{
129          $( "input[name='line1']" ).val($response.find('#suggestedLine1').val());
130          $( "input[name='line2']" ).val($response.find('#suggestedLine2').val());
131          $( "input[name='townCity']" ).val($response.find('#suggestedCity').val());
132          $( "select[name='regionIso']" ).val($response.find('#suggestedState').val());
133          $( "input[name='postcode']" ).val($response.find('#suggestedZipCode').val());
134          $( "input[name='deliveryPointBarcode']" ).val($response.find('#deliveryPointBarcode').val());
135          $( "input[name='checkDigit']" ).val($response.find('#checkDigit').val());
136          $( "input[name='correctedAddressUsed']" ).val(true);
137          $('#addressForm').submit();
138       }
139    },
140	bindTaxExemptInfo:function()
141	{
142
143		var taxExemptCheckbox = $('[id^="taxExemptCheckboxCart"]');
144		taxExemptCheckbox.click(function () {
145			var taxExemptCheckboxVal = $(this).is(":checked");
146			$.ajax({
147				url: ACC.config.encodedContextPath +'/checkout/taxexemptconsent?taxexemptcheck='+taxExemptCheckboxVal,
148				type: 'POST',
149				async: true,
150				success: function (data) {
151				$(".js-tax-exempt-checkbox").prop('checked', taxExemptCheckboxVal);
152					console.log("Success");
153				},
154				error: function (error) {
155					console.log("Failure");
156				}
157			});
158
159		});
160
161
162	},
163	bindAddAddressCard:function(){
164	$('#school_business1').click(function(e){
165	    if($(this).is(':checked')){
166             $("input[name='addressType']").val("BUSINESS");
167        }else{
168              $("input[name='addressType']").val("RESIDENTIAL");
169        }
170	})
171	$('.js-addaddress').click(function(e)
172	{
173		e.preventDefault();
174		$('.add-edit-address-text').html(messages.newShippAddress);
175		$('.js-shippingaddress-list').hide();
176		$(".js-customeraddress-section").removeClass("hidden").show();
177		$(".cancel-address-holder").removeClass("hidden").show();
178		$(".save-in-addressbook").removeClass("hidden").show();
179		$(".cancel-add-text").removeClass("hidden").show();
180		var addressId=$('.add_edit_delivery_address_id').val();
181		ACC.checkout.addressId=addressId;
182		$('.add_edit_delivery_address_id').val('');
183
184		$('.editAddress').val("false");
185		$( "input[name='editAddress']" ).val("false");
186		$("input:checkbox[name='school_business1'][value=true]").prop('checked', false);
187		$("input[name='addressType']").val("RESIDENTIAL");
188		$( "input[name='company']" ).val("");
189		$( "input[name='firstName']" ).val("");
190		$( "input[name='lastName']" ).val("");
191		$( "input[name='line1']" ).val("");
192		$( "input[name='line2']" ).val("");
193		$( "input[name='townCity']" ).val("");
194		$( "select[name='regionIso']" ).val("");
195		$( "input[name='postcode']" ).val("");
196		$( "input[name='phone']" ).val("");
197		$('#commentsLine1').val("");
198        $('[id^=commentsplacement]').prop('checked', false);
199        $('[id=deliveryinstruction').prop('checked', false);
200        $('#deliveryinstruction-input').hide();
201        $('[id=taxExemptCheckboxCart1]').prop('checked', false);
202        $('[id=saveAddressInMyAddressBook]').prop('checked', false);	});
203	},
204
205	bindEditAddressCard:function(){
206	$('.js-editaddress').click(function(e)
207	{
208
209		e.preventDefault();
210		$('.add-edit-address-text').html(messages.editShippAddress);
211		$('.js-shippingaddress-list').hide();
212		$(".js-customeraddress-section").removeClass("hidden").show();
213		$(".cancel-address-holder").removeClass("hidden").show();
214		$(".save-in-addressbook").removeClass("hidden").show();
215		$(".cancel-edit-text").removeClass("hidden").show();
216		var addressId=$('.add_edit_delivery_address_id').val();
217		ACC.checkout.addressId=addressId;
218		var orderCode ='';
219		if($('#orderCode').val() != "" && $('#orderCode').val() != undefined){
220			orderCode =$('#orderCode').val();
221		}
222		var options = {'addressId':addressId, 'orderCode': orderCode};
223		$.ajax({
224			url: ACC.config.encodedContextPath + '/checkout/multi/delivery-address/deliveryAddress',
225			async: true,
226			data: options,
227			dataType: "json",
228		}).done(function (data)
229		{
230			$('.editAddress').val("true");
231			$( "input[name='editAddress']" ).val("true");
232            var addressType = data.addressType;
233            if(addressType == 'BUSINESS'){
234            	$("input:checkbox[name='school_business1'][value=true]").prop('checked', true);
235                $( "input[name='company']" ).val(data.company);
236            }else{
237                $("input:checkbox[name='school_business1'][value=true]").prop('checked', false);
238                $( "input[name='company']" ).val(data.company);
239            }
240            $( "input[name='addressType']" ).val(addressType);
241			$( "input[name='firstName']" ).val(data.firstName);
242			$( "input[name='lastName']" ).val(data.lastName);
243			$( "input[name='line1']" ).val(data.street);
244			$( "input[name='line2']" ).val(data.street2);
245			$( "input[name='townCity']" ).val(data.city);
246			$( "select[name='regionIso']" ).val(data.state);
247			$( "input[name='postcode']" ).val(data.zipcode);
248			$( "input[name='phone']" ).val(data.phone);
249			if(data.comments1!=undefined && data.comments1!=null && data.comments1.trim().length>0){
250                $('#deliveryinstruction-input').show();
251                $( "input:checkbox[name='deliveryinstruction']").prop('checked', true);
252                $( "input[name='comments1']" ).val(data.comments1.trim());
253                if(data.PACKING_SLIP!=undefined && data.PACKING_SLIP!=null){
254                    $("#commentsplacement0").prop('checked', true);
255                }
256                if(data.SHIPPING_LABEL!=undefined && data.SHIPPING_LABEL!=null){
257                    $("#commentsplacement1").prop('checked', true);
258                }
259                if(data.INVOICE!=undefined && data.INVOICE!=null){
260                    $("#commentsplacement2").prop('checked', true);
261                }
262            }
263            if(data.visibleInAddressBook!=undefined && data.visibleInAddressBook!=null && data.visibleInAddressBook=="true"){
264                $('[id=saveAddressInMyAddressBook]').prop('checked', true);
265            }else{
266                $('[id=saveAddressInMyAddressBook]').prop('checked', false);
267            }
268            if(data.taxExemptConsent=="true"){
269                $('[id=taxExemptCheckboxCart1]').prop('checked', true);
270            }else{
271                $('[id=taxExemptCheckboxCart1]').prop('checked', false);
272            }
273		});
274
275	});
276	},
277	bindSelectAddresses:function(){
278		var deliveryInfo = document.getElementById ("deliveryAddressDropDown");
279		if(deliveryInfo !=undefined && deliveryInfo.options [deliveryInfo.selectedIndex] != undefined){
280			var addressId = deliveryInfo.options [deliveryInfo.selectedIndex].value;
281			$('.add_edit_delivery_address_id').val(addressId);
282		}
283
284		$('#deliveryAddressDropDown').change(function(e){
285			e.preventDefault();
286			var e = document.getElementById ("deliveryAddressDropDown");
287			var addressId = e.options [e.selectedIndex].value;
288			$('.add_edit_delivery_address_id').val(addressId);
289			var orderCode ='';
290			if($('#orderCode').val() != "" && $('#orderCode').val() != undefined){
291				orderCode =$('#orderCode').val();
292			}
293			var options = {'addressId':addressId, 'orderCode': orderCode};
294			$.ajax({
295				url: ACC.config.encodedContextPath + '/checkout/multi/delivery-address/deliveryAddress',
296				async: true,
297				data: options,
298				dataType: "json",
299			}).done(function (data)
300			{
301				$('.editAddress').val("false");
302				$( "input[name='editAddress']" ).val("false");
303				$( "input[name='firstName']" ).val(data.firstName);
304				$( "input[name='lastName']" ).val(data.lastName);
305				$( "input[name='line1']" ).val(data.street);
306				$( "input[name='line2']" ).val(data.street2);
307				$( "input[name='townCity']" ).val(data.city);
308				$( "select[name='regionIso']" ).val(data.state);
309				$( "input[name='postcode']" ).val(data.zipcode);
310				$( "input[name='phone']" ).val(data.phone);
311
312				$( "input[name='companyName']" ).val(data.company);
313                var addressType = data.addressType;
314                if(!addressType){
315                    addressType = 'RESIDENTIAL';
316                }
317                /* Removed as part of new checkout flow
318                if(addressType == 'RESIDENTIAL'){
319                    var residentialEle = document.getElementById("RESIDENTIAL");
320                    if(residentialEle!=null){
321                    residentialEle.checked = true;
322                    $("#address-company-div").addClass("hidden");
323                    }
324                }else{
325                    var businessEle = document.getElementById("BUSINESS");
326                    if(businessEle!=null){
327                    document.getElementById("BUSINESS").checked = true;
328                    $("#address-company-div").removeClass("hidden");
329                }*/
330                if(addressType == 'BUSINESS' && data.company != null){
331                    var selectedAddress = '<div class="address-holder data-holder">'+data.company+"<br>"+'<span class="bold">'+data.firstName+" "+data.lastName+"</span><br><br>"+data.street+","+data.street2+"<br>"+data.city+","+data.stateDisplay+" "+data.zipcode+"<br><br>"+data.phone+'</div>';
332                }else{
333                   	var selectedAddress = '<div class="address-holder data-holder"><span class="bold">'+data.firstName+" "+data.lastName+"</span><br><br>"+data.street+","+data.street2+"<br>"+data.city+","+data.stateDisplay+" "+data.zipcode+"<br><br>"+data.phone+'</div>';
334                }
335                $(".ship-to-address").html(selectedAddress);
336			});
337
338		});
339	},
340	bindselectedPayments:function(){
341		var info = document.getElementById ("paymentInfo");
342		if(info !=undefined && info.options [info.selectedIndex] != undefined){
343			var paymentId = info.options [info.selectedIndex].value;
344			$('#selectedPaymentMethodId').val(paymentId);
345		}
346		$('#paymentInfo').change(function(e){
347			e.preventDefault();
348			var e = document.getElementById ("paymentInfo");
349			var paymentId = e.options [e.selectedIndex].value;
350			$('#selectedPaymentMethodId').val(paymentId);
351			ACC.checkout.paymentId=paymentId;
352			var options = {'paymentId':paymentId};
353			$.ajax({
354				url: ACC.config.encodedContextPath + '/checkout/multi/sop/getBillingAddress',
355				async: true,
356				data: options,
357				dataType: "json",
358			}).done(function (data)
359				{
360					var selectedAddress = data.street+","+data.street2+"<br>"+data.city+","+data.state+" "+data.zipcode;
361					$("#selectedBillingAddress").html(selectedAddress);
362					$("#billingAddress").hide();
363				});
364		});
365	},
366
367	bindAddCard:function(){
368	$('.js-addcard').click(function(e)
369		{
370			e.preventDefault();
371			$('.add-edit-card-text').html(messages.newCreditCard);
372			$('.js-savedcards-list').hide();
373			$('#getSavedCards').hide();
374			$(".js-newcard-section").removeClass("hidden").show();
375			ACC.checkout.paymentId=$('#selectedPaymentMethodId').val();
376			$('#selectedPaymentMethodId').val('');
377            $('.edit_billTo').hide();
378            ACC.silentorderpost.enableAddressForm();
379            $('.useShipAddress').removeClass("hidden").show();
380            $("#samebillingAddress").hide();
381            $("#billingAddress").show();
382            $('#billingAddressForm').show();
383            $('input:radio[id=useDeliveryAddress]').prop('checked', false);
384            $('input:radio[id=useDeliveryAddress2]').prop('checked', true);
385            $( "input[name='qasaddress']" ).val("true");
386
387		});
388
389	},
390	bindEditCard:function(){
391		$('.js-editcard').click(function(e)
392		{
393			var paymentId=$('#selectedPaymentMethodId').val();
394			ACC.checkout.paymentId=paymentId;
395			var options = {'paymentId':paymentId};
396			e.preventDefault();
397			$('.add-edit-card-text').html(messages.editCreditCard);
398			$('.js-savedcards-list').hide();
399			$('#getSavedCards').hide();
400			$(".js-newcard-section").removeClass("hidden").show();
401			$.ajax({
402				url: ACC.config.encodedContextPath + '/checkout/multi/payment-type/editCardForm',
403				async: true,
404				data: options,
405				dataType: "json",
406			}).done(function (data)
407			{
408				$(".checkbox label[for='savePaymentMethod']" ).hide();
409				$(".checkbox label[for='useDeliveryAddress']" ).hide();
410				$('.useShipAddress').removeClass("hidden").show();
411
412                $('input:radio[id=useDeliveryAddress]').prop('checked', false);
413                $('input:radio[id=useDeliveryAddress2]').prop('checked', true);
414                $("#samebillingAddress").hide();
415				$('#billingAddressForm').show();
416				 $( "input[name='qasaddress']" ).val("true");
417
418				ACC.silentorderpost.enableAddressForm();
419				$( "input[name='editCardFlag']" ).val("true");
420				$( "input[name='card_nameOnCard']" ).val(data.cardName);
421				$( "select[name='card_cardType']" ).val(data.cardType);
422				$( "input[name='card_accountNumber']" ).val(data.cardNum);
423				$( "select[name='card_expirationMonth']" ).val(data.expMonth);
424				$( "select[name='card_expirationYear']" ).val(data.expYear);
425				$( "input[name='billTo_street1']" ).val(data.street);
426				$( "input[name='billTo_street2']" ).val(data.street2);
427				$( "input[name='billTo_city']" ).val(data.city);
428				$( "select[name='billTo_state']" ).val(data.state);
429				$( "input[name='billTo_postalCode']" ).val(data.zipcode);
430				$( "input[name='billTo_firstName']" ).val(data.firstName);
431				$( "input[name='billTo_lastName']" ).val(data.lastName);
432				$( "input[name='billTo_phoneNumber']" ).val(data.phone);
433				$('.edit_billTo').hide();
434				$('.js-billTo-cancelcard').hide();
435
436				//new stuff
437				var editCardInfoHolder = $('#editCardInformationData');
438				var billingAddressForm = $('#billingAddressForm');
439				var actualCardTypeName = $('#card_cardType').find('option:selected').text();
440				var editInfoHtml = '<span class="editCardInfoHolder">'+data.cardName+'<br/>'+actualCardTypeName+' '+data.cardNum+'</span>';
441				$('.cc-form-name-on-card-row').hide();
442				$('.cc-form-card-number-column').hide();
443				editCardInfoHolder.html(editInfoHtml).show();
444				billingAddressForm.addClass('no-indent');
445
446
447				if($('#edit_bill_address_flag').val() =="false"){
448					$( "input[name='billTo_street1']" ).attr("disabled", true);
449					$( "input[name='billTo_street2']" ).attr("disabled", true);
450					$( "input[name='billTo_city']" ).attr("disabled", true);
451					$( "select[name='billTo_state']" ).attr("disabled", true);
452					$( "input[name='billTo_postalCode']" ).attr("disabled", true);
453				}
454
455			});
456
457
458		});
459
460	},
461	bindCancelCard:function(){
462
463
464		$('.js-cancelcard').click(function(e)
465		{
466			e.preventDefault();
467			$(".js-newcard-section").hide();
468			$('.js-savedcards-list').show();
469			$('#getSavedCards').show();
470			$('#selectedPaymentMethodId').val('');
471			$( "input[name='editCardFlag']" ).val('');
472			$( "input[name='card_nameOnCard']" ).val('');
473			$( "select[name='card_cardType']" ).val('');
474			$( "input[name='card_accountNumber']" ).val('');
475			$( "select[name='card_expirationMonth']" ).val('');
476			$( "select[name='card_expirationYear']" ).val('');
477			$( "input[name='billTo_street1']" ).val('');
478            $( "input[name='billTo_street2']" ).val('');
479            $( "input[name='billTo_city']" ).val('');
480            $( "select[name='billTo_state']" ).val('');
481            $( "input[name='billTo_postalCode']" ).val('');
482            $( "input[name='billTo_firstName']" ).val('');
483            $( "input[name='billTo_lastName']" ).val('');
484            $( "input[name='billTo_phoneNumber']" ).val('');
485
486
487			$("#samebillingAddress").show();
488			ACC.silentorderpost.disableAddressForm();
489			$('#selectedPaymentMethodId').val(ACC.checkout.paymentId);
490			$(".checkbox label[for='useDeliveryAddress']" ).show();
491			$(".checkbox label[for='savePaymentMethod']" ).show();
492			$('label.error').hide();
493			$( "input[name='qasaddress']" ).val("false");
494			$('.useShipAddress').hide();
495			$('.edit_billTo').show();
496			ACC.checkout.bindselectedPayments();
497			$('.js-billTo-cancelcard').removeClass("hidden").show();
498
499			//new
500			var editCardInfoHolder = $('#editCardInformationData');
501			var billingAddressForm = $('#billingAddressForm');
502			$('.cc-form-name-on-card-row').show();
503			$('.cc-form-card-number-column').show();
504			editCardInfoHolder.html('').hide();
505			billingAddressForm.removeClass('no-indent');
506
507
508			if($('#edit_bill_address_flag').val() =="false"){
509				$( "input[name='billTo_street1']" ).attr("disabled", false);
510				$( "input[name='billTo_street2']" ).attr("disabled", false);
511				$( "input[name='billTo_city']" ).attr("disabled", false);
512				$( "select[name='billTo_state']" ).attr("disabled", false);
513				$( "input[name='billTo_postalCode']" ).attr("disabled", false);
514			}
515		});
516
517	},
518	bindSavedPayments:function(){
519		$(document).on("click",".js-saved-payments",function(e){
520			e.preventDefault();
521
522			var title = $("#savedpaymentstitle").html();
523
524			$.colorbox({
525				href: "#savedpaymentsbody",
526				inline:true,
527				maxWidth:"100%",
528				opacity:0.7,
529				//width:"320px",
530				title: title,
531				close:'<span class="glyphicon glyphicon-remove"></span>',
532				onComplete: function(){
533				}
534			});
535		})
536	},
537
538	bindCheckO: function ()
539	{
540		var cartEntriesError = false;
541
542		// Alternative checkout flows options
543		$('.doFlowSelectedChange').change(function ()
544		{
545			if ('multistep-pci' == $('#selectAltCheckoutFlow').val())
546			{
547				$('#selectPciOption').show();
548			}
549			else
550			{
551				$('#selectPciOption').hide();
552
553			}
554		});
555
556
557
558		$('.js-continue-shopping-button').click(function ()
559		{
560			var checkoutUrl = $(this).data("continueShoppingUrl");
561			window.location = checkoutUrl;
562		});
563
564		$('.js-create-quote-button').click(function ()
565		{
566			$(this).prop("disabled", true);
567			var createQuoteUrl = $(this).data("createQuoteUrl");
568			window.location = createQuoteUrl;
569		});
570
571
572		$('.expressCheckoutButton').click(function()
573				{
574					document.getElementById("expressCheckoutCheckbox").checked = true;
575		});
576
577		$('.js-continue-checkout-button').click(function ()
578		{
579			var checkoutUrl = $(this).data("checkoutUrl");
580
581			cartEntriesError = ACC.pickupinstore.validatePickupinStoreCartEntires();
582			if (!cartEntriesError)
583			{
584				var expressCheckoutObject = $('.express-checkout-checkbox');
585				if(expressCheckoutObject.is(":checked"))
586				{
587					window.location = expressCheckoutObject.data("expressCheckoutUrl");
588				}
589				else
590				{
591					var flow = $('#selectAltCheckoutFlow').val();
592					if ( flow == undefined || flow == '' || flow == 'select-checkout')
593					{
594						// No alternate flow specified, fallback to default behaviour
595						window.location = checkoutUrl;
596					}
597					else
598					{
599						// Fix multistep-pci flow
600						if ('multistep-pci' == flow)
601						{
602						flow = 'multistep';
603						}
604						var pci = $('#selectPciOption').val();
605
606						// Build up the redirect URL
607						var redirectUrl = checkoutUrl + '/select-flow?flow=' + flow + '&pci=' + pci;
608						window.location = redirectUrl;
609					}
610				}
611			}
612			return false;
613		});
614
615        $("#silentOrderPostForm").submit(function(e) {
616            $('input[type="hidden"][id^="billTo_firstname"]').prop('disabled', true);
617            $('input[type="hidden"][id^="billTo_lastname"]').prop('disabled', true);
618            $('input[type="hidden"][id^="billTo_street1"]').prop('disabled', true);
619            $('input[type="hidden"][id^="billTo_street2"]').prop('disabled', true);
620            $('input[type="hidden"][id^="billTo_city"]').prop('disabled', true);
621            $('input[type="hidden"][id^="billTo_state"]').prop('disabled', true);
622            $('input[type="hidden"][id^="billTo_postalCode"]').prop('disabled', true);
623        });
624
625	},
626
627	bindGiftCertificates: function () {
628        var $gcForm = $(".js-gift-certificate-add-form");
629
630        $('.js-gift-certificate-toggle').click(function(e) {
631		    e.preventDefault();
632
633		    $gcForm.find("#gcNumber").val('');
634		    $gcForm.find("label.error").remove();
635            $(".js-gift-certificate-payment").toggleClass("active");
636        });
637
638        $gcForm.on('submit',function(e) {
639            $gcForm.validate({
640                rules: {
641                    gcNumber : {
642                        required: true
643                    }
644                },
645                messages: {
646                    gcNumber : {
647                        required: messages.gcNumber
648                    }
649                }
650            });
651        });
652
653        $gcForm.find('#gcNumber').on('keyup change',function(e) {
654            var value = $(this).val(),
655                $cta = $gcForm.find('button[type=submit]');
656
657            if($.trim(value) == '') {
658                $cta.attr("disabled", true);
659            } else {
660                $cta.attr("disabled", false);
661            }
662        });
663
664        $('.js-gift-certificate-remove').click(function(e) {
665            e.preventDefault();
666
667            var form = $("#js-gift-certificate-remove-form"),
668                gcNumber = $(this).attr("data-id");
669
670            form.find("#input-gc-remove").val(gcNumber);
671            form.submit();
672        });
673	},
674
675	bindPlaceOrderForm: function () {
676	    $('.js-placeorder-form').submit(function(e) {
677            ACC.global.showLoadingScreen();
678        });
679	},
680
681	bindCreateAccountPopup:function(){
682	            // Ajax call to create WW guest user at cart page
683	            $(document).on("click", "#guest-account-create", function(e){
684                    $.ajax({
685                       url:window.location.href+"/wwGuestLogin/?email="+($("#signinEmailGuest").val()),
686                       type:"POST",
687                       success:function(data){
688                        if(data === "success"){
689                            window.location = "/checkout/multi";
690                        }else if(data === "failed"){
691                            $("#guest-error").text("please try again");
692                        }else{
693                            $("#guest-error").text(data);
694                        }
695                        }
696                    });
697                });
698    		    $(document).on("click", "#create-account-guest", function(e){
699
700            	$.ajax({
701            	   url:ACC.config.encodedContextPath+"/register/checkout/cu
701stomer",
702            	   type:"GET",
703            	   success:function(data){
704                    $('#guest-login-modal').modal("hide");
705                    $('#create-account-modal').html(data);
706                    setTimeout(function(){
707                        $('#create-account-modal').modal("show");
708
709                     }, 500);
710                     bindEventsForModal();
711            	    }
712            	  })
713            	});
714            	$(document).on("click", ".js-create-account-btn", function(event){
715            	event.preventDefault();
716            	$('.js-create-account-btn').prop('disabled', true);
717            	$.ajax({
718            	url: $('#excelligenceRegisterForm').attr("action"),
719            	type:"POST",
720            	data:$('#excelligenceRegisterForm').serialize(),
721            	success: function(data){
722                    var _isError = $(data).find('#guest-create-section #excelligenceRegisterForm .form-group').hasClass('has-error');
723                      if(_isError){
724                        $('#create-account-modal').html(data);
725                        $('#create-account-modal').modal("show");
726                        $('.js-create-account-btn').prop('disabled', false);
727                     	bindEventsForModal();
728                      } else {
729                        window.location.href=window.location.href;
730                      }
731            	},
732            	error:function(){
733            	   window.location.href=window.location.href;
734            	}
735              })
736            });
737        }
738};
739
740$(document).ready(function (){
741    //myAccessStuff(radioButton,'COURIER');
742	if($('#edit_bill_address_flag').val() =="false" || $('#default_BillTo').val() =="true"){
743		ACC.silentorderpost.disableAddressForm();
744	}
745	$('.js-edit-billToAddress').click(function(e){
746        e.preventDefault();
747    });
748	$('input#card_accountNumber').keyup(function(){
749	    var cc_value = $(this).val().charAt(0),
750	        cc_mapping = [
751	            { validator: ['4'], id: '001' },
752	            { validator: ['2', '5'], id: '002' },
753	            { validator: ['3'], id: '003' },
754	            { validator: ['6'], id: '004' }
755	        ],
756	        cc_type = '001';
757
758	    $.each(cc_mapping, function(x, type){
759	        $.each(type.validator, function(x, id){
760	            if(id == cc_value) {
761	                cc_type = type.id;
762	            }
763	        });
764	    });
765
766	    $('select#card_cardType').val(cc_type);
767	});
768
769
770	$('.js-billTo-cancelcard').click(function(e){
771		e.preventDefault();
772		$('.useShipAddress').hide();
773		$('.edit_billTo').show();
774
775		$('#billTo_street1').val(ACC.checkout.billToAddr['street1']);
776		$('#billTo_street2').val(ACC.checkout.billToAddr['street2']);
777		$('#billTo_city').val(ACC.checkout.billToAddr['city']);
778		$('#billTo_state').val(ACC.checkout.billToAddr['state']);
779		$('#billTo_postalCode').val(ACC.checkout.billToAddr['zipCode']);
780		$( "input[name='qasaddress']" ).val("");
781		ACC.silentorderpost.disableAddressForm();
782
783	});
784
785	$('#comment-section-yes').click(function(){
786		$('.comments-section').removeClass("hidden").show();
787		$('#comment-section-no').prop("checked", false);
788	});
789
790	$('#comment-section-no').click(function(){
791		$('.comments-section').hide();
792		$('#comment-section-yes').prop("checked", false);
793	});
794
795	$('.js-canceladdress').click(function(e)
796	{
797		e.preventDefault();
798		//document.location.reload();
799		//window.location.href=window.location.href;
800		$(".js-customeraddress-section").hide();
801		$(".save-in-addressbook").hide();
802		$('.js-shippingaddress-list').removeClass("hidden").show();
803		$( "input[name='firstName']" ).val('');
804		$( "input[name='lastName']" ).val('');
805		$( "input[name='line1']" ).val('');
806		$( "input[name='line2']" ).val('');
807		$( "input[name='townCity']" ).val('');
808		$( "select[name='regionIso']" ).val('');
809		$( "input[name='postcode']" ).val('');
810		$( "input[name='phone']" ).val('');
811		$(".cancel-address-holder").hide();
812		$(".cancel-add-text,.cancel-edit-text").hide();
813		$('.add_edit_delivery_address_id').val(ACC.checkout.addressId);
814		$('.ajax-global-error-message').hide();
815		$('.add-edit-address-text').html("");
816		$('label.error').hide();
817		$('.editAddress').val("false");
818	});
819
820	$('#addressSubmit,#addressSubmit_mobile').on('click',function(){
821		var billingAddress = $("#qasBillAddress").val();
822		$('#addressSubmit,#addressSubmit_mobile').validate();
823		if($('.add_edit_delivery_address_id').val() != "" && $('.editAddress').val() == "false"){
824                $("#addressForm :input[name='comments1']").val($("#savedComment").val());
825                $("#addressForm :input[name='deliveryinstruction']").prop('checked',$('#saveddeliveryinstruction').checked);
826                $("input.placementTypes[type=checkbox]").each(function() {
827                     $("#addressForm :input[name='placementTypes'][value="+$(this).val()+"]").prop('checked', this.checked);
828                });
829                $("#addressForm .accountingCodeVal").val($(".accountingCodesRadio input[type='radio']:checked").val());
830                $('#addressForm').submit();
831		}else{
832		if($('#addressForm').valid()){
833		$(".dss-loader").show();
834        $(".overlay").show();
835		var addressString = encodeURIComponent(ACC.address.getAddressQasString());
836		$.ajax({
837             url: ACC.config.encodedContextPath + '/qas/verify?addressString='+addressString+'&billingAddress='+billingAddress,
838             type: 'GET',
839             success: function (response) {
840             var $response = $(response);
841             var poBoxError = $response.find('#isPoBoxError').val()==='true';
842            	              var skipConfirmationPrompt = $response.find('#skipConfirmationPrompt').val()==='true';
843                                  if(!poBoxError && skipConfirmationPrompt){
844                                     $(".dss-loader,.overlay").hide();
845                                     $('.ajax-global-error-message').hide();
846                                     ACC.checkout.applyCorrectedAddress($response);
847                                  }else if(!poBoxError){
848            		 $('.ajax-global-error-message').hide();
849            		 var addressString = encodeURIComponent(ACC.address.getAddressQasString());
850            		 ACC.colorbox.open(messages.verificationMessage,{
851                          html:response,
852                          maxWidth:"100%",
853                          className:"suggested-address",
854                          width:"700px",
855                          height:"100%",
856                          top:"10%",
857                          onComplete: function(){
858                          $(".dss-loader,.overlay").hide();
859                          	setTimeout(function(){
860                          		 _autoload : [   ]
861
862                          	}, 800);
863                          	ACC.colorbox.resize();
864                          	ACC.checkout.bindSuggestedForms();
865            		        ACC.colorbox.resize();
866                          }
867                      });
868            	 }else if(poBoxError){
869            	     $(".dss-loader,.overlay").hide();
870            		 $('.ajax-global-error-message').removeClass("hidden").show();
871            		 $('.ajax-global-error-message').html('<div class="alert alert-danger alert-dismissable getAccAlert">'+messages.upsMessage+'</div>');
872            	 }else{
873            		 $(".dss-loader,.overlay").hide();
874            	        $('.ajax-global-error-message').removeClass("hidden").show();
875                        $('.ajax-global-error-message').html('<div class="alert alert-danger alert-dismissable getAccAlert">'+messages.invalidManualAddress+'</div>');
876
877            		 //$('#addressForm').submit();
878            	 }
879             },
880             error: function (jqXHR, textStatus, errorThrown) {
881               $(".dss-loader,.overlay").show();
882               setTimeout(function() { $(".dss-loader,.overlay").hide(); }, 1000);
883               $('.ajax-global-error-message').removeClass("hidden").show();
884               $('.ajax-global-error-message').html('<div class="alert alert-danger alert-dismissable getAccAlert">'+messages.invalidManualAddress+'</div>');
885               // log the error to the console
886                 console.log("The following error occured: " + textStatus, errorThrown);
887             }
888         });
889
890		}else{
891		     $(".dss-loader,.overlay").show();
892             setTimeout(function() { $(".dss-loader,.overlay").hide(); }, 1000);
893			 $('.ajax-global-error-message').removeClass("hidden").show();
894    		 $('.ajax-global-error-message').html('<div class="alert alert-danger alert-dismissable getAccAlert">'+messages.errorMessage+'</div>');
895		}
896		}
897
898	});
899
900    const maximumLength = parseInt($("#maxLength").val(), 10);
901	$("#addressForm").validate({
902		rules: {
903		    company : {
904                required: '#school_business1:checked'
905            },
906			firstName : {
907				required: true
908			},
909			lastName: {
910				required: true
911			},
912			line1 : {
913				required: true,
914				maxlength: maximumLength
915            },
916            line2 : {
917                maxlength: maximumLength
918            },
919			townCity : {
920				required: true
921			},
922			regionIso : {
923				required: true
924			},
925			postcode : {
926				required: true
927			},
928			phone: {
929				required: true
930			},
931            email: {
932                required: true,
933                email: true
934            }
935		},
936		messages: {
937			company : {
938               	required: messages.company
939            },
940			firstName : {
941				required: messages.firstName
942			},
943			lastName : {
944				required: messages.lastName
945			},
946			line1 : {
947				required: messages.street,
948				maxlength: "The address length should not exceed " + maximumLength+  " characters."
949            },
950            line2 : {
951                maxlength: "The address length should not exceed " + maximumLength+  " characters."
952            },
953			townCity : {
954				required: messages.city
955			},
956			postcode : {
957				required: messages.zipCode
958			},
959			regionIso : {
960				required: messages.state
961			},
962			phone: {
963				required: messages.phone
964			},
965            email: {
966                required: messages.email
967            }
968		}
969
970	});
971
972	$("#addressTypeForm").validate({
973            		rules: {
974            		    companyName : {
975                            required: true
976                        }
977                    },
978                    messages: {
979                    	companyName : {
980                           	required: messages.company
981                        }
982                    }
983            });
984	$('.submit_silentOrderPostForm').on('click',function(){
985	var progressBtn = $(this);
986	function progressBar(){
987		if (!progressBtn.hasClass("progress-active")) {
988			progressBtn.addClass("progress-active");
989			progressBtn.css( 'pointer-events', 'none' );
990		}
991	}
992
993	const maximumLength = parseInt($("#maxLength").val(), 10);
994	$("#silentOrderPostForm").validate({
995		rules: {
996			card_cardType : {
997				required: true
998			},
999			card_nameOnCard: {
1000				required: true
1001			},
1002			card_accountNumber :{
1003				required: true,
1004				invalidNum:true
1005			},
1006			card_expirationMonth : {
1007				required: true,
1008				expDate: true
1009
1010			},
1011			card_expirationYear : {
1012				required: true,
1013				expDate: true
1014			},
1015			card_cvNumber : {
1016				required: true
1017			},
1018			billTo_firstName : {
1019				required: true
1020			},
1021			billTo_lastName : {
1022                required: true
1023            },
1024			billTo_street1 : {
1025				required: true,
1026				maxlength: maximumLength
1027			},
1028			billTo_street2 : {
1029                maxlength: maximumLength
1030            },
1031			billTo_city : {
1032				required: true
1033			},
1034			billTo_postalCode : {
1035				required: true
1036			},
1037			billTo_state : {
1038				required: true
1039			},
1040			purchaseOrderNumber : {
1041				required: true
1042			}
1043		},
1044		messages: {
1045
1046			card_cardType : {
1047				required: messages.cardType
1048			},
1049			card_nameOnCard : {
1050				required: messages.cardName
1051			},
1052			card_cardNumber :{
1053				required: messages.cardNumber,
1054				invalidNum: messages.invalidCardNumber
1055			},
1056			card_expirationMonth : {
1057				required: messages.expirationMonth,
1058				expDate: messages.expDate
1059			},
1060			card_expirationYear : {
1061				required: messages.expirationYear,
1062				expDate: messages.expDate
1063			},
1064			card_cvNumber : {
1065				required: messages.cvNumber
1066			},
1067			billTo_street1 : {
1068                required: messages.street,
1069                maxlength: "The address length should not exceed " + maximumLength + " characters."
1070            },
1071            billTo_street2 : {
1072                maxlength: "The address length should not exceed " + maximumLength + " characters."
1073            },
1074			billTo_city : {
1075				required: messages.city
1076			},
1077			billTo_postalCode : {
1078				required: messages.zipCode
1079			},
1080			billTo_state : {
1081				required: messages.state
1082			},
1083			purchaseOrderNumber:{
1084				required: messages.poNumber
1085			},
1086			billTo_lastName:{
1087                required: messages.billToLastName
1088            }
1089		}
1090
1091	});
1092	function preventKeypress(){
1093		$('#silentOrderPostForm').on('keypress',function(event) {
1094			event.preventDefault();
1095			return false;
1096		});
1097	}
1098	function checkDate(){
1099		var Current = new Date();
1100		var expiryYear="20"+$('#ExpiryYear').val();
1101		var Selected = new Date(
1102		    expiryYear,
1103		    $('#ExpiryMonth').val()
1104		);
1105		if(Selected > Current){
1106			return true;
1107		}
1108	}
1109	function checkMod10()
1110	{
1111	  var input=$('#card_accountNumber').val();
1112	  var sum = 0;
1113	  var numdigits = input.length;
1114	  var parity = numdigits % 2;
1115	  for(var i=0; i < numdigits; i++) {
1116	    var digit = parseInt(input.charAt(i))
1117	    if(i % 2 == parity) digit *= 2;
1118	    if(digit > 9) digit -= 9;
1119	    sum += digit;
1120	  }
1121	  return (sum % 10) == 0;
1122	}
1123	$.validator.addMethod("expDate", function (value, element) {
1124        return this.optional(element) || checkDate();
1125    }, messages.expDate);
1126	$.validator.addMethod("invalidNum", function (value, element) {
1127        return this.optional(element) || checkMod10();
1128    }, messages.invalidCardNumber);
1129	if($('#silentOrderPostForm').valid()){
1130		var paymentType = $("input[type='radio'][name='paymentType']:checked").val();
1131		if(paymentType !== 'PAYPAL' && $('#qasaddress').val() != "" && $('#qasaddress').val() == "true"){
1132		var addressString = encodeURIComponent(ACC.address.getBillingAddressQasString());
1133		$.ajax({
1134			 url: ACC.config.encodedContextPath + '/qas/verify?addressString='+addressString+'&billingAddress=true',
1135             type: 'GET',
1136             success: function (response) {
1137                 var $response = $(response);
1138                 var poBoxError = $response.find('#isPoBoxError').val()==='true';
1139                 var skipConfirmationPrompt = $response.find('#skipConfirmationPrompt').val()==='true';
1140                 if(!poBoxError && skipConfirmationPrompt){
1141                    $('.ajax-global-error-message').hide();
1142                    preventKeypress();
1143                    ACC.checkout.applyCorrectedAddress($response);
1144                 }else if(!poBoxError){            		 $('.ajax-global-error-message').hide();
1145            		 var addressString = encodeURIComponent(ACC.address.getBillingAddressQasString());
1146            		 ACC.colorbox.open(messages.verificationMessage,{
1147                          html:response,
1148                          maxWidth:"100%",
1149                          className:"suggested-address",
1150                          width:"700px",
1151                          height:"100%",
1152                          top:"10%",
1153                          onComplete: function(){
1154                          	setTimeout(function(){
1155                          		 _autoload : [   ]
1156
1157                          	}, 800);
1158                          	ACC.colorbox.resize();
1159                          	ACC.checkout.bindSuggestedForms();
1160            		        ACC.colorbox.resize();
1161                          },
1162						  onCleanup: function(){
1163							if( $('.use-entered-address').hasClass("active") || $('.use-corrected-address').hasClass("active")) {
1164							preventKeypress();
1165							} else if (progressBtn.hasClass("progress-active")) {
1166								progressBtn.removeClass("progress-active");
1167								progressBtn.css( 'pointer-events', 'auto' );
1168							}
1169						  }
1170                      });
1171            	 }else if (poBoxError){
1172            		 $('.ajax-global-error-message').removeClass("hidden").show();
1173            		 $('.ajax-global-error-message').html('<div class="alert alert-danger alert-dismissable getAccAlert">'+messages.upsMessage+'</div>');
1174            	 }else{
1175					 preventKeypress();
1176            		 $('#silentOrderPostForm').submit();
1177            	 }
1178             },
1179             error: function (jqXHR, textStatus, errorThrown) {
1180                 // log the error to the console
1181                 console.log("The following error occured: " + textStatus, errorThrown);
1182             }
1183         });
1184		}else{
1185			preventKeypress();
1186			$('#silentOrderPostForm').submit();
1187		}
1188		progressBar();
1189	}
1190	});
1191
1192	$('#PaymentTypeSelection_CARD').attr( 'checked', 'checked' );
1193	$('#creditCardForm').removeClass("hide");
1194	$('#creditCardForm').show();
1195	$("#PaymentTypeSelection_ACCOUNT").removeAttr('checked');
1196
1197		$('#PaymentTypeSelection_CARD').on('change',function(){
1198			$("#PaymentTypeSelection_ACCOUNT").removeAttr('checked');
1199			$('#creditCardForm').removeClass("hide");
1200			$('#PaymentTypeSelection_PAYPAL').removeAttr('checked');
1201			$('#PaymentTypeSelection_CARD').attr( 'checked', 'checked' );
1202			$('#creditCardForm').show();
1203			$('#getSavedCards').show();
1204			$('.js-savedcards-list').show();
1205			$('.submit_silentOrderPostForm').show();
1206			$('.accountPaymentDetails').hide();
1207		});
1208
1209		$('#PaymentTypeSelection_PAYPAL').on('change',function(){
1210			$("#PaymentTypeSelection_ACCOUNT").removeAttr('checked');
1211			$('#PaymentTypeSelection_PAYPAL').attr( 'checked', 'checked' );
1212			$('#creditCardForm').hide();
1213			$('.js-savedcards-list').hide();
1214			$('#getSavedCards').hide();
1215			$('.js-newcard-section').hide();
1216			$('.submit_silentOrderPostForm').show();
1217			$('.accountPaymentDetails').hide();
1218		});
1219
1220		$('#PaymentTypeSelection_ACCOUNT').on('change',function(){
1221			$("#PaymentTypeSelection_ACCOUNT").attr( 'checked', 'checked' );
1222			$('#PaymentTypeSelection_PAYPAL').removeAttr('checked');
1223			$('#PaymentTypeSelection_CARD').removeAttr('checked');
1224			$('#creditCardForm').hide();
1225			$('.js-savedcards-list').hide();
1226			$('.js-newcard-section').hide();
1227			$('#getSavedCards').hide();
1228			$(".accountPaymentDetails").removeClass("hidden").show();
1229			$('.submit_silentOrderPostForm').show();
1230		});
1231        $("#guest-login-btn,#ww-guest-login-btn").click(function(e) {
1232           $("#guest-login-modal").modal("show");
1233        });
1234
1235       $('#signinSubmit').on('click',function(){
1236           if($('#checkoutSigninForm').valid()){
1237               var $form = $(document).find('#checkoutSigninForm');
1238               var signinEmail = $('#signinEmail').val();
1239               var signinPassword = $('#signinPassword').val();
1240               var data = {'j_username': signinEmail, 'j_password': signinPassword}
1241               $.ajax({
1242                    url: $form.attr("action"),
1243                    data: data,
1244                    type: 'POST',
1245                    success: function (response) {
1246                        if(response == "true"){
1247                           $("#checkoutSigninFormError").show().delay(2500).fadeOut();
1248                        }else{
1249                           window.location.href=window.location.href;
1250                        }
1251                     }
1252                });
1253           }
1254        });
1255        $("#checkoutSigninForm").validate({
1256            rules: {
1257                signinEmail : {
1258                    required: true
1259                },
1260                signinPassword: {
1261                    required: true
1262                }
1263            },
1264            messages: {
1265                signinEmail : {
1266                    required: messages.signinemail
1267                },
1268                signinPassword : {
1269                    required: messages.signinpassword
1270                }
1271            }
1272        });
1273});
1274
1275function submitOhrGcRemoveForm(gcNumber,orderCode){
1276	$("#input-gc-remove").val(gcNumber);
1277	$("#input-orderCode-remove").val(orderCode);
1278	$("#js-gift-certificate-remove-form").submit();
1279}
1280
1281if($('input#standard-shipping').is(':checked')){
1282        $('.specialServices').removeClass('specialServices-hide');
1283    }else{
1284         $('.specialServices').addClass('specialServices-hide');
1285         }
1286
1287$('#selectDeliveryMethodForm label').on('click', function(){
1288    $(this).find('input').attr('checked','checked');
1289    if($('input#standard-shipping').is(':checked')){
1290        $('.specialServices').removeClass('specialServices-hide');
1291    }
1292    else{
1293    $('.specialServices').addClass('specialServices-hide');
1294    $('.specialServices label input').val('');
1295    }
1296});
1297$(function() {
1298    $('body').on('keydown', '#companyName', function(e) {
1299    console.log(this.value);
1300    if (e.which === 32 && e.target.selectionStart === 0) {
1301        return false;
1302        }
1303    });
1304});
1305
1306function bindEventsForModal(){
1307     ACC.global.passwordStrength();
1308     ACC.global.bindPasswordToggle();
1309}
1310
1311function myAccessStuff(radioButton, serviceType, liftgateSuggested,liftgateconsent,liftgateRequired) {
1312		var lifCodes= $('#js-lift-gate').val();
1313		var insideCode= $('#js-inside-service').val();
1314        if($(radioButton).hasClass( "accessRadioSelected" )){
1315            if(liftgateSuggested== true && liftgateconsent == false && liftgateRequired != true) {
1316                $('#special-shiping-modal').modal('show');
1317            }else {
1318                $('input[name="delivery_service"]').each(function(i, inputObj) {
1319                    inp = $( inputObj).get(0);
1320                    if(liftgateRequired == true){
1321                        if($("#inside").hasClass("accessRadioSelected") == true){
1322                            $('input[name="delivery_service"]').each(function(i, inputObj) {
1323                                inp = $(inputObj).get(0);
1324                                if (lifCodes.includes(inp.id) == true) {
1325                                    $(inp).prop('checked', true);
1326                                }
1327                            });
1328                        }else{
1329                            $('input[name="delivery_service"]').each(function(i, inputObj) {
1330                                inp = $(inputObj).get(0);
1331                                if (insideCode.includes(inp.id) == true) {
1332                                    $(inp).prop('checked', true);
1333                                }
1334                            });
1335                        }
1336
1337                    }else{
1338                        if(inp.id.startsWith('RESIDENTIAL')|| inp.id.startsWith('COURIER')){
1339                            $(inp).prop('checked', true);
1340                        }
1341                    }
1342                });
1343                 $(radioButton).prop('checked', false);
1344                 $(radioButton).removeClass( "accessRadioSelected");
1345								 var defaultDeliveryType = $("#deliveryType").attr("defaultDeliveryType");
1346								if(defaultDeliveryType === "INSIDE") {
1347									$(".specialShipping-insidegate").addClass("d-block");
1348								}
1349								if(defaultDeliveryType === "LIFT") {
1350									$(".specialShipping-liftgate").addClass("d-block");
1351								}
1352            }
1353        }else{
1354            $(radioButton).addClass( "accessRadioSelected");
1355            if(serviceType == 'lift'){
1356                $('#inside').removeClass('accessRadioSelected');
1357                $("#inside").prop('checked', false);
1358								var defaultDeliveryType = $("#deliveryType").attr("defaultDeliveryType");
1359								if(defaultDeliveryType === "LIFT") {
1360									$(".specialShipping-liftgate").removeClass("d-block");
1361								}
1362								if(defaultDeliveryType === "INSIDE") {
1363									$(".specialShipping-insidegate").addClass("d-block");
1364								}
1365                $('input[name="delivery_service"]').each(function(i, inputObj) {
1366                    inp = $( inputObj).get(0);
1367                    if (lifCodes.includes(inp.id)==true) {
1368                        $(inp).prop('checked', true);
1369                        if(liftgateconsent == true){
1370                            $(".specialShipping-liftgate").addClass("d-none");
1371                        }
1372                    }
1373                });
1374            }else if(serviceType == 'inside'){
1375                $('#lift').removeClass('accessRadioSelected');
1376                $("#lift").prop('checked', false);
1377								var defaultDeliveryType = $("#deliveryType").attr("defaultDeliveryType");
1378								if(defaultDeliveryType === "INSIDE") {
1379									$(".specialShipping-insidegate").removeClass("d-block");
1380								}
1381								if(defaultDeliveryType === "LIFT") {
1382									$(".specialShipping-liftgate").addClass("d-block");
1383								}
1384                $('input[name="delivery_service"]').each(function(i, inputObj) {
1385                    inp = $( inputObj).get(0);
1386                    if (insideCode.includes(inp.id)== true) {
1387                        $(inp).prop('checked', true);
1388                        if(liftgateconsent == true){
1389                            $(".specialShipping-liftgate").addClass("d-none");
1390                        }
1391                    }
1392                });
1393            }
1394        }
1395}
1396
1397function liftgate(){
1398	var currentUrl = window.location.href
1399		currentUrlItem = '/choose';
1400		newUrl = "/accessorialterms?liftgateExempt=true"
1401		window.location.href= currentUrl.replace(currentUrlItem,newUrl);
1402}
1403
1404
1405$(document).ready(function() {
1406	var defaultDeliveryType = $("#deliveryType").attr("defaultDeliveryType");
1407
1408	function hideSpecialShippingOptions() {
1409			$(".specialShipping-liftgate").removeClass("d-block");
1410			$(".specialShipping-insidegate").removeClass("d-block");
1411	}
1412
1413	function selectDeliveryType(type) {
1414			$('#lift').removeClass('accessRadioSelected').prop('checked', false);
1415			$('#inside').removeClass('accessRadioSelected').prop('checked', false);
1416
1417			if (type === "LIFT") {
1418					$('#lift').addClass('accessRadioSelected').prop('checked', true);
1419			} else if (type === "INSIDE") {
1420					$('#inside').addClass('accessRadioSelected').prop('checked', true);
1421			}
1422	}
1423
1424	if (defaultDeliveryType === "LIFT" || defaultDeliveryType === "INSIDE") {
1425			selectDeliveryType(defaultDeliveryType);
1426			hideSpecialShippingOptions();
1427	} else if (defaultDeliveryType === "") {
1428			hideSpecialShippingOptions();
1429	}
1430
1431	$('input[name="delivery_service"]').each(function(i, inputObj) {
1432			var lifCodes = $('#js-lift-gate').val();
1433			var serviceType2 = $('#service-charge-2').val();
1434			var serviceType3 = $('#service-charge-3').val();
1435			var liftgatereq = $('#js-liftgateRequired').val();
1436
1437			$("#liftgateServiceVal").text(serviceType3);
1438			$("#insideServiceVal").text(serviceType2);
1439
1440			var insideCode = $('#js-inside-service').val();
1441			if (liftgatereq === "true") {
1442					$(".specialShipping-liftgate").addClass("d-none");
1443			}
1444
1445			if ($(this).is(':checked')) {
1446					var $this = $(inputObj).get(0);
1447
1448					if (insideCode.includes($this.id)) {
1449							selectDeliveryType("INSIDE");
1450					} else if (lifCodes.includes($this.id)) {
1451							selectDeliveryType("LIFT");
1452					} else {
1453							$('input[name="radio"]').each(function(i, inputObj) {
1454									var inp = $(inputObj).get(0);
1455									if (inp.id === 'RESIDENTIAL' || inp.id === 'COURIER') {
1456											$(inp).prop('checked', true);
1457									}
1458							});
1459					}
1460			}
1461	});
1462});
1463
1464$('.js-modal-input-radio').on('click', function () {
1465	if($(this).is(':checked') ) {
1466		$(".js-special-shipping-btn").removeClass('disabled')
1467	}
1468});
1469

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.