1//messagebar.js initialized 2var reqOptionBar = new MessageBar(); 3reqOptionBar.initialize(); 4 5jQuery(function () { 6 //Quantity box 7 jQuery('.qty-input .qty-up').click(function () { 8 var qtyInput = jQuery(this).data('target'); 9 var incrementedVal = parseInt(jQuery(qtyInput).val()) + 1; 10 jQuery(qtyInput).val(incrementedVal); 11 }); 12 jQuery('.qty-input .qty-down').click(function () { 13 var qtyInput = jQuery(this).data('target'); 14 var incrementedVal = parseInt(jQuery(qtyInput).val()) - 1; 15 16 if (incrementedVal <= 1) incrementedVal = 1; 17 jQuery(qtyInput).val(incrementedVal); 18 }); 19 20 jQuery("#recurring_frequency").change(function () { 21 22 if (this.value == '') { 23 jQuery(".reward_redeem").show(); 24 jQuery(".ppcp_gp").show(); 25 jQuery(".ppcp_ap").show(); 26 } 27 else { 28 jQuery(".reward_redeem").hide(); 29 jQuery(".ppcp_gp").hide(); 30 jQuery(".ppcp_ap").hide(); 31 } 32 }) 33 34 initOptionsHelp(); 35 36 //Carousel for extra product images 37 jQuery(document).ready(function () { 38 jQuery('.flexslider:not(.product-carousel)').flexslider({ 39 animation: "slide", 40 animationLoop: true, 41 slideshow: false, 42 controlNav: false, 43 itemWidth: 50, 44 minItems: 4, 45 maxItems: 4, 46 itemMargin: 0, 47 prevText: "", 48 nextText: "" 49 }); 50 51 setTimeout(function () { 52 jQuery('#addl-images').addClass('addl-images-ready'); 53 window.dispatchEvent(new Event('resize')); 54 }, 100); 55 }); 56 57 58 //Responsive Tabs initialized 59 if (jQuery('#rTabs > ul > li').length > 0) { 60 jQuery('#rTabs').responsiveTabs({ 61 active: 0, 62 rotate: false, 63 startCollapsed: 'accordion', 64 collapsible: 'accordion', 65 setHash: false 66 }); 67 68 if (document.body.clientWidth < 767) { 69 jQuery('span.pipe').hide(); 70 jQuery('#rTabs').responsiveTabs('activate', 0); 71 } 72 if (document.body.clientWidth < 767) { 73 jQuery('span.pipe').hide(); 74 jQuery('#rTabs').responsiveTabs('activate', 0); 75 } 76 } 77 //Show realmedia on load if no product image is present 78 if (jQuery('#main-image').length <= 0) { 79 jQuery('#realmediaBlock').show(); 80 } 81 82 //Show/Hide realmedia 83 jQuery('.prod-thumb').on('touchstart click', function (e) { 84 var aThumb = jQuery(this).find('a'); 85 86 if (jQuery(aThumb).attr('id') == 'showRealMedia') { 87 88 if (jQuery(aThumb).attr('data-multi-video') == "True"){ 89 $('#modalVM').modal(); 90 $('#modalVM').on('shown.bs.modal', function (e) { 91 $('#VideoGallery')[0].contentWindow.loadVideoSlider(); 92 }) 93 } 94 else { 95 jQuery('#main-image').hide(); 96 jQuery('#realmediaBlock').show(); 97 } 98 } 99 else { 100 jQuery('#realmediaBlock').hide(); 101 jQuery('#main-image').show(); 102 103 var caption = jQuery(aThumb).attr('title'); 104 jQuery('#imagecaptiont').text(caption); 105 } 106 }); 107 108 //stop video on close 109 $("#modalVM").on('hidden.bs.modal', function (e) { 110 $('#VideoGallery')[0].contentWindow.reloadVideo(); 111 }); 112 113 //Go to reviews tab 114 jQuery('#review_count').click(function (e) { 115 e.preventDefault(); 116 jQuery('#reviewsTab a').click(); 117 118 if(jQuery('#tab-4').length > 0) { 119 jQuery('html, body').animate({ 120 scrollTop: jQuery("#tab-4").offset().top 121 }, 1000); 122 } 123 }); 124 125 //browsing history 126 if (typeof get_browsing_history !== "undefined") { 127 get_browsing_history(); 128 } 129}); 130 131 132//Product Tabs 133function viewTabs() { 134 jQuery('html, body').animate({ scrollTop: jQuery('#rTabs').position().top }, 'fast'); 135} 136 137/** 138* Old listing 139***********************/ 140function popup(filename, width, height) { 141 result = window.open(filename, "popped1", "width=" + width + ", height=" + height + ", location=no, menubar=no, status=no, toolbar=no, scrollbars=yes, resizable=no"); 142 if (result != null) html = "is not blocking"; 143 else alert("Your Browser is blocking popups which is preventing a Shift4Shop window to appear."); 144} 145 146function popupsimple(filename, width, height) { 147 var w = 480, h = 340; 148 149 if (document.all || document.layers) { 150 w = screen.availWidth; 151 h = screen.availHeight; 152 } 153 154 var leftPos = (w - width) / 2, topPos = (h - height) / 2;
155 result = window.open(filename, "popped1", "width=" + width + ", height=" + height + ",top=" + topPos + ",left=" + leftPos + ",location=no, menubar=no, status=no, toolbar=no, scrollbars=no, resizable=no"); 156 if (result != null) html = "is not blocking"; 157 else alert("Your Browser is blocking popups which is preventing a Shift4Shop window to appear."); 158} 159 160var stocknum = ''; 161 162function SearchAndReplace(Content, SearchFor, ReplaceWith) { 163 164 var tmpContent = Content; 165 var tmpBefore = new String(); 166 var tmpAfter = new String(); 167 var tmpOutput = new String(); 168 var intBefore = 0; 169 var intAfter = 0; 170 171 if (SearchFor.length == 0) 172 return; 173 174 175 while (tmpContent.toUpperCase().indexOf(SearchFor.toUpperCase()) > -1) { 176 177 // Get all content before the match 178 intBefore = tmpContent.toUpperCase().indexOf(SearchFor.toUpperCase()); 179 tmpBefore = tmpContent.substring(0, intBefore); 180 tmpOutput = tmpOutput + tmpBefore; 181 182 // Get the string to replace 183 tmpOutput = tmpOutput + ReplaceWith; 184 185 186 // Get the rest of the content after the match until 187 // the next match or the end of the content 188 intAfter = tmpContent.length - SearchFor.length + 1; 189 tmpContent = tmpContent.substring(intBefore + SearchFor.length); 190 191 } 192 193 return tmpOutput + tmpContent; 194 195} 196 197function Len(str) 198 /*** 199 IN: str - the string whose length we are interested in 200 201 RETVAL: The number of characters in the string 202 ***/ 203{ return String(str).length; } 204 205 206function Left(str, n) 207 /*** 208 IN: str - the string we are LEFTing 209 n - the number of characters we want to return 210 211 RETVAL: n characters from the left side of the string 212 ***/ { 213 if (n <= 0) // Invalid bound, return blank string 214 return ""; 215 else if (n > String(str).length) // Invalid bound, return 216 return str; // entire string 217 else // Valid bound, return appropriate substring 218 return String(str).substring(0, n); 219} 220 221 222function Right(str, n) 223 /*** 224 IN: str - the string we are RIGHTing 225 n - the number of characters we want to return 226 227 RETVAL: n characters from the right side of the string 228 ***/ { 229 if (n <= 0) // Invalid bound, return blank string 230 return ""; 231 else if (n > String(str).length) // Invalid bound, return 232 return str; // entire string 233 else { // Valid bound, return appropriate substring 234 var iLen = String(str).length; 235 return String(str).substring(iLen, iLen - n); 236 } 237} 238 239 240function Mid(str, start, len) { 241 // Make sure start and len are within proper bounds 242 if (start < 0 || len < 0) return ""; 243 244 var iEnd, iLen = String(str).length; 245 if (start + len > iLen) 246 iEnd = iLen; 247 else 248 iEnd = start + len; 249 250 return String(str).substring(start, iEnd); 251} 252 253function InStr(strSearch, charSearchFor) { 254 for (i = 0; i < Len(strSearch) ; i++) { 255 if (charSearchFor == Mid(strSearch, i, 1)) { 256 return i; 257 } 258 } 259 return -1; 260} 261 262function handleFileBackupAndRestore(action) { 263 if (!document.querySelector('input[type="file"]')) return; // Skip if no file inputs 264 265 window.fileBackup = window.fileBackup || {}; // Initialize if not set 266 267 document.querySelectorAll('input[type="file"]').forEach(input => { 268 if (action === "backup" && input.files.length > 0) { 269 window.fileBackup[input.name] = input.files; // Save file selection 270 } 271 else if (action === "restore" && window.fileBackup[input.name]) { 272 let dt = new DataTransfer(); 273 [...window.fileBackup[input.name]].forEach(file => dt.items.add(file)); 274 input.files = dt.files; // Restore file selection 275 } 276 }); 277} 278 279 280 281var listing_elemLenght = -1; 282 283function validateValues(what, alerting, form_id) { 284 var valid = true; 285 var fieldnamemod = new String(); 286 var fieldvaluemod = new String(); 287 var checkBoxes = false; 288 var checkboxChecked = false; 289 var price= 0; 290 var radioButtons = false; 291 var radioChecked = false; 292 var imagename= new Image; 293 var itemid; 294 var customTag; 295 var isValidateExecuted = false; 296 var intRewardsPointsOriginal = 0; 297 var intRewardsPointsBundleOption = 0; 298 var strRewardsButtonText = ''; 299 const product_status = jQuery('#availability_code').val();
300 var advanceoption_waitlist = jQuery("#allowadvancedoption_waitlist").val(); 301 var waitingListBlock = jQuery("#divWaitlist").size() > 0 ? jQuery("#divWaitlist, #waitingListBlock") : jQuery("#waitingListBlock"); 302 303 stocknum = ''; 304 305 handleFileBackupAndRestore("backup"); // Save file input before validation runs 306 307 if (what == null) return false; 308 309 if(what.std_price==null) { 310 //'Item has no options. 311 price = _3d_item.price; //raw item price 312 //check and show waiting list 313 if (product_status == "3") { 314 if (advanceoption_waitlist == "1") { 315 jQuery("#divWaitlist_AdvancedOptions").stop(true, true).show(); 316 } else { 317 jQuery(waitingListBlock).stop(true, true).show(); 318 } 319 } 320 recalculateRewardPoints(price); 321 } 322 else { 323 price =what.std_price.value; //document.add.std_price.value; 324 325 var isRewardProduct = (document.add.reward_product != undefined && document.add.reward_product.value > 0); 326 if (isRewardProduct) { 327 intRewardsPointsOriginal = eval(document.add.reward_product.value) 328 strRewardsButtonText = document.add.reward_text.value; 329 } 330 331 if (price == 0 && form_id != null && form_id != undefined) 332 return; 333 334 if (what.itemid != null) 335 itemid=what.itemid.value; 336 else 337 itemid=""; 338 339 listing_elemLenght = what.elements.length; 340 for (var i = 0, j = listing_elemLenght; i < j; i++) { 341 myType = what.elements[i].type; 342 343 // ISSUE-18167 Product review stars (type=radio) or Data Privacy Toolkit checkbox should not be considered as a product option type 344 if (what.elements[i].className === "rating-input" || what.elements[i].name === "privacy_accepted") { 345 myType = null; 346 } 347 348 try { 349 customTag = what.elements[i].getAttribute("customoption"); 350 } 351 catch (e) { customTag = null; } 352 353 if(myType != null && myType != undefined && customTag == null) { 354 fieldnamemod = what.elements[i].name; 355 if (fieldnamemod != '' && fieldnamemod != 'recipientselect' && fieldnamemod != 'reminder' && fieldnamemod != 'qty-0' && fieldnamemod != 'recurring_frequency' && fieldnamemod != 'item_id') { 356 var field_array; 357 358 // IMAGE dropdown's 359 //alert(fieldnamemod + fieldnamemod.indexOf("di_")); 360 if (fieldnamemod.indexOf("di_") > -1 || fieldnamemod.indexOf("mi_") > -1) { 361 // Have its own image per drop down 362 SetSrc(what, "img_"+fieldnamemod, GetValue(what, "image_"+what.elements[i].options[what.elements[i].selectedIndex].value, form_id), form_id); 363 //don't process the price, because it'll be considered below when the dropdown option is parsed. 364 } 365 366 if (myType == 'radio' && fieldnamemod != 'wishlist-optListType') { 367 radioButtons = true; 368 if (what.elements[i].checked) { 369 radioChecked = true; 370 percent = GetValue(what, "pricep_" + what.elements[i].value, form_id); 371 if (percent !== undefined) { 372 percentValue = eval(percent) / 100 * eval(price); 373 price = eval(price) + percentValue; 374 } 375 else { 376 price = eval(price) + eval(GetValue(what, "price_" + what.elements[i].value, form_id)); 377 } 378 itemid = (itemid) +GetValue(what, "OptID_"+ what.elements[i].value, form_id); 379 stocknum=stocknum +what.elements[i].value + "#"; 380 if(!isValidateExecuted && isRewardProduct && (eval(GetValue(what, "reward_" + what.elements[i].value)) != undefined)) 381 intRewardsPointsBundleOption = intRewardsPointsBundleOption + eval(GetValue(what, "reward_" + what.elements[i].value)); 382 } 383 recalculateRewardPoints(price); 384 } 385 if (myType == 'checkbox') { 386 checkBoxes = true; 387 if (what.elements[i].checked) { 388 if (fieldnamemod>"") 389 price=eval(price) +eval(GetValue(what, "price_" +fieldnamemod, form_id)); 390 itemid = (itemid) +GetValue(what, "OptID_" +fieldnamemod, form_id); 391 } 392 recalculateRewardPoints(price); 393 } 394 395 if (myType == 'hidden' || myType == 'password' || myType == 'text' || myType == 'textarea') 396 if (what.elements[i].value == what.elements[i].defaultValue) valid = false; 397 398 399 //Mixed Pack Recalculation 400 if (what.elements[i].getAttribute("data-feature_extra-price") != undefined && what.elements[i].getAttribute("data-feature_extra-price") != null) { 401 form_id = null; 402 if (!isNaN(what.elements[i].value)) { 403 mp_extra = (eval(what.elements[i].value) * eval(what.elements[i].getAttribute("data-feature_extra-price"))); 404 if (!isNaN(mp_extra)) 405 if (mp_extra > 0) 406 price = eval(price) + mp_extra; 407 } 408 } 409 410 411 if (myType == 'select-one' || myType == 'select-multiple') { 412 if (what.elements[i].name.indexOf("otf_") < 0 && what.elements[i].options[what.elements[i].selectedIndex].value > "") { 413 fieldvaluemod = what.elements[i].options[what.elements[i].selectedIndex].value; 414 stocknum = stocknum + fieldvaluemod + "#"; 415 percent = GetValue(what, "pricep_" + what.elements[i].options[what.elements[i].selectedIndex].value); 416 if (percent !== undefined) { 417 percentValue = eval(percent) / 100 * eval(price); 418 price = eval(price) + percentValue; 419 } 420 else { 421 price = eval(price) + eval(GetValue(what, "price_" + what.elements[i].options[what.elements[i].selectedIndex].value)); 422 } 423 itemid=itemid+ '' + GetValue(what, "OptID_" +what.elements[i].options[what.elements[i].selectedIndex].value);
424 if (!isValidateExecuted && isRewardProduct && (eval(GetValue(what, "reward_" +what.elements[i].value)) != undefined)) 425 intRewardsPointsBundleOption = intRewardsPointsBundleOption +eval(GetValue(what, "reward_" +what.elements[i].value)); 426 } 427 recalculateRewardPoints(price); 428 } 429 } 430 } 431 } 432 if (isRewardProduct) { 433 if (!isValidateExecuted) { 434 strRewardsButtonText = strRewardsButtonText.replace("[reward_redeem]", intRewardsPointsOriginal +intRewardsPointsBundleOption); 435 if (document.getElementById("btnRedeemText") != null) { 436 document.getElementById("btnRedeemText").innerHTML = strRewardsButtonText; 437 } 438 439 isValidateExecuted = true; 440 } 441 } 442 if ((checkBoxes && !checkboxChecked) || (radioButtons && !radioChecked)) valid = false; 443 444 setTimeout(() => handleFileBackupAndRestore("restore"), 100); // Restore file input with slight delay 445 446 447 changeprice(price, form_id); 448 changeid(itemid); 449 if (alerting==1) { 450 return check_stock(what, stocknum); 451 } 452 //return valid; 453 } 454} 455 456function recalculateRewardPoints(price) { 457 if (document.getElementById("customPoints") != null) { 458 var customPoints = parseFloat(document.getElementById("customPoints").value); 459 460 if (customPoints == 0) { 461 if (document.getElementById("pointsMultiplier").value != null) { 462 var pointsMultiplier = parseFloat(document.getElementById("pointsMultiplier").value); 463 var intPoints = Math.round((pointsMultiplier * price) * 100) / 100; 464 465 if (document.getElementById("productRewardDesc").value != null) { 466 var rewardItem = document.getElementById("productRewardDesc").value; 467 rewardItem = rewardItem.replace("[rewardsPointsValue]", intPoints); 468 469 if(document.getElementById("divRewardPoint")) { 470 if (document.getElementById("divRewardPoint").innerHTML != null) 471 document.getElementById("divRewardPoint").innerHTML = rewardItem; 472 } 473 } 474 } 475 } 476 } 477} 478 479 480 481function changeid(itemid) { 482 483 var txt = itemid; 484 if (typeof buildExtendedOffer === "function") { 485 var component = Extend.buttons.instance('#extend-offer') 486 487 if (component !== null && itemid !== "") 488 component.setActiveProduct(itemid) 489 else { 490 setTimeout(function () { 491 component = Extend.buttons.instance('#extend-offer'); 492 component.setActiveProduct(itemid); 493 }, 2000) 494 } 495 } 496 changecontent('product_id', txt); 497} 498 499 500function GetValue(formx, name, form_id) { 501 var element; 502 if (form_id != undefined && form_id != null) 503 element = jQuery("#add" + form_id + " input[name='" + name + "']"); 504 else 505 element = document.getElementsByName(name); 506 507 if (element != null && element != undefined && element.length > 0) 508 if (form_id != undefined && form_id != null) 509 return (element[0].value); 510 else 511 return (element.item(0).value); 512 513 var i; 514 for (i = 0; i < listing_elemLenght; i++) { 515 if (formx.elements[i].name == name) { 516 return formx.elements[i].value; 517} 518} 519} 520 521var listing_imgslength = -1; 522 523function SetSrc(formx, sname, sourcename, form_id) { 524 var element, imgs; 525 if (form_id != undefined && form_id != null) 526 element = jQuery("#add" + form_id + " input[name='" + sname + "']"); 527 else 528 element = document.getElementsByName(sname); 529 530 if (element != null && element != undefined && element.length > 0) { 531 if (element.length > 0) 532 element.item(0).src = sourcename; 533 return; 534 } 535 536 if (form_id != undefined && form_id != null) 537 imgs = jQuery("#add" + form_id + " img"); 538 else 539 imgs = document.getElementsByTagName('img'); 540 541 if (listing_imgslength == -1) 542 listing_imgslength = imgs.length; 543 544 for (i = 0; i < listing_imgslength; i++) { 545 if (imgs[i].name == sname) 546 imgs[i].src = sourcename; 547 } 548} 549 550 551function recalculate() { 552} 553 554 555function changecontent(fieldname, content1) { 556 var txt = content1; 557 558 if (document.getElementById) { 559 if (document.getElementById(fieldname) != null) { 560 document.getElementById(fieldname).innerHTML = txt; 561 document.getElementById(fieldname).style.visibility = 'visible'; 562 } 563 } 564 else if (document.all) { 565 if (document.all[fiendname] != null) { 566 document.all[fiendname].innerHTML = txt; 567 document.all[fieldname].style.visibility = 'visible'; 568 } 569 } 570 else if (document.layers) { 571 572 if (document.layers[fieldname] != null) { 573 document.layers[fieldname].document.open(); 574 document.layers[fieldname].document.write(txt); 575 document.layers[fieldname].document.close(); 576 document.layers[fieldname].visibility = 'show'; 577 } 578 } 579 580} 581 582 583function changegtin(gtin) { 584 var txt = gtin 585 changecontent('product_gtin', txt); 586} 587 588function changeprice(price, form_id) { 589 var txt = formatCurrency(price); 590 var metaPrice = price; 591 var currency_symbol_aux; 592 try { 593 if (currency_symbol != null && currency_symbol != undefined) 594 currency_symbol_aux = currency_symbol; 595 } 596 catch (err) { 597 currency_symbol_aux = "$" 598 } 599 600 var difference = 0; 601 if (document.getElementById("std_price_novat") != null) { 602 var price_novat = parseFloat(document.getElementById("std_price_novat").value); 603 var vattaxrate = parseFloat(document.getElementById("vat_tax_rate").value); 604 var price_vatformat = document.getElementById("vat_tax_price_format").value; 605 var priceAux = price; 606 if (vattaxrate >= 0) { 607 var priceAux = price_novat + (price_novat * (vattaxrate / 100)); 608 txt = price_vatformat; 609 txt = txt.replace("[price_vat]", formatCurrency(price)); 610 currency_symbol = ''; 611 // ---------------------------- 612 // Added this on 2/10/2014 to test - FM 613 difference = price - priceAux; //Find the option value and remove the VAT, so we can display the item amount without VAT 614 difference = difference / (1 + (vattaxrate / 100)); 615 price_novat = price_novat + difference; 616 metaPrice = metaPrice + difference 617 // ---------------------------- 618 currency_symbol = currency_symbol_aux; 619 txt = txt.replace("[price_novat]", formatCurrency(price_novat)); 620 txt = txt.replace("[currency]" + currency_symbol_aux, currency_symbol_aux); 621 txt = txt.replace("[currency]", currency_symbol_aux); 622 } 623 } 624 jQuery("[itemprop='price']").prop("content", metaPrice) 625 if (form_id != undefined && form_id != null) { 626 changecontent('price' + form_id, txt); 627 } else { 628 changecontent('price', txt); 629 } 630 recalculateRewardPoints(price); 631 recalculatePPPayLater(price); 632} 633function recalculatePPPayLater(price1) { 634 if (jQuery("#pp_message").length > 0 && jQuery("[itemprop='price']").length > 0) { 635 jQuery("#pp_message").attr("data-pp-amount", price1) 636 } 637} 638function formatCurrency(intNumber) { 639 640 var currencySymbol; //This variable gets the value of the currency_symbol variable declared on listing_x page template... 641 var decimalPlaces; //This variable gets the value of the prod_decimal_places variable declared on listing_x page template... 642 try { 643 currencySymbol = currency_symbol; 644 } 645 catch (err) { 646 currencySymbol = '$'; //If there's no variable declared, uses '$' as default. 647 } 648 try { 649 decimalPlaces = parseInt(prod_decimal_places); 650 } 651 catch (err) { 652 decimalPlaces = 2; //If there's no variable declared, uses '$' as default. 653 } 654 655 intNumber = parseFloat(intNumber); //Remove zeros on the right side 656 intNumber = intNumber.toString(); 657 658 if (decimalPlaces > 2) { 659 if (decimalPlaces - (intNumber.length - (intNumber.indexOf(".") + 1)) > 0) 660 decimalPlaces = intNumber.length - (intNumber.indexOf(".") + 1); 661 if (decimalPlaces < 2) 662 decimalPlaces = 2; 663 } 664 665 if (decimalPlaces > 0) 666 return formatNumberListing(intNumber, decimalPlaces, ',', '.', currencySymbol, '', '', ''); 667 else
668 return formatNumberListing(intNumber, decimalPlaces, '', '', currencySymbol, '', '', '') 669} 670 671function formatNumberListing(num, dec, thou, pnt, curr1, curr2, n1, n2) { var x = Math.round(num * Math.pow(10, dec)); if (x >= 0) n1 = n2 = ''; var y = ('' + Math.abs(x)).split(''); var z = y.length - dec; if (z < 0) z--; for (var i = z; i < 0; i++) y.unshift('0'); if (z < 0) z = 1; y.splice(z, 0, pnt); if (y[0] == pnt) y.unshift('0'); while (z > 3) { z -= 3; y.splice(z, 0, thou); } var r = curr1 + n1 + y.join('') + n2 + curr2; return r; } 672 673 674/** 675* Old functions 676***********************/ 677 678// Check stock 679function check_stock(what, partnum) { 680 var soption; 681 var i; 682 var product_availability = jQuery('#availability_itemprop').val(); 683 const product_status = jQuery('#availability_code').val(); 684 var backordermode = jQuery("#allowbackorder").val(); 685 var advanceoption_waitlist = jQuery("#allowadvancedoption_waitlist").val(); 686 687 var avail_instock = jQuery("#productAvailability-Instock").val(); 688 var avail_outofstock = jQuery("#productAvailability-Outofstock").val(); 689 var avail_backorder = jQuery("#productAvailability-Backorder").val(); 690 691 var catalogid = jQuery('#catalogid').val(); 692 var optionfound = 0; 693 694 var inventoryarray = window['inventoryarray' + catalogid]; 695 var idarray = window['idarray' + catalogid]; 696 var aopricearray = window['aopricearray' + catalogid]; 697 var gtinarray = window['gtinarray' + catalogid]; 698 699 var divAddToCart = jQuery("#divAddToCart").length > 0 700 ? jQuery("#divAddToCart, #paypal-button-container") 701 : jQuery(".addToCartBlock, #paypal-button-container"); 702 var waitingListBlock = jQuery("#divWaitlist").size() > 0 ? jQuery("#divWaitlist, #waitingListBlock") : jQuery("#waitingListBlock"); 703 704 var availabilityBar = new MessageBar(); 705 availabilityBar.initialize(); 706 707 // Mixed Pack 708 if (what.feature_type_id != null && what.feature_type_id != undefined) { 709 if (what.feature_type_id.length > 0) { 710 if (what.feature_type_id[0].value == 'MixedPack') { 711 for (var i = 0; i < what.feature_type_id.length; i++) { 712 data_feature_type_id = what.feature_type_id[i].getAttribute("data-feature_type_id"); 713 data_feature_type_min = parseInt(jQuery('#feature_type_min-' + data_feature_type_id).val()); 714 data_feature_type_max = parseInt(jQuery('#feature_type_max-' + data_feature_type_id).val()); 715 data_feature_type_sum = 0; 716 717 for (var z = 0; z < what.getElementsByClassName('qty-mixedpack-' + data_feature_type_id).length; z++) { 718 data_feature_type_sum += parseInt(what.getElementsByClassName('qty-mixedpack-' + data_feature_type_id)[z].value); 719 } 720 721 if ((data_feature_type_sum < data_feature_type_min || data_feature_type_sum > data_feature_type_max) && data_feature_type_sum > 0 && (document.activeElement.className.indexOf("mixedpack") < 0)) { 722 jQuery("#divAddToCart").slideUp(); 723 availabilityBar.alert('Error: Quantity must be between ' + data_feature_type_min + ' and ' + data_feature_type_max + '.'); 724 changecontent("availability", avail_instock); 725 return false; 726 } 727 } 728 } 729 } 730 else { 731 if (what.feature_type_id.value == 'MixedPack') { 732 data_feature_type_id = what.feature_type_id.getAttribute("data-feature_type_id"); 733 data_feature_type_min = parseInt(jQuery('#feature_type_min-' + data_feature_type_id).val()); 734 data_feature_type_max = parseInt(jQuery('#feature_type_max-' + data_feature_type_id).val()); 735 data_feature_type_sum = 0; 736 737 for (var z = 0; z < what.getElementsByClassName('qty-mixedpack-' + data_feature_type_id).length; z++) { 738 data_feature_type_sum += parseInt(what.getElementsByClassName('qty-mixedpack-' + data_feature_type_id)[z].value); 739 } 740 741 if ((data_feature_type_sum < data_feature_type_min || data_feature_type_sum > data_feature_type_max) && data_feature_type_sum > 0 && (document.activeElement.className.indexOf("mixedpack") < 0)) { 742 jQuery("#divAddToCart").slideUp(); 743 availabilityBar.alert('Error: Quantity must be between ' + data_feature_type_min + ' and ' + data_feature_type_max + '.'); 744 changecontent("availability", avail_instock); 745 return false; 746 } 747 } 748 } 749 }
750 ///////////////////////////////////////////////////////////////////////////////////// 751 752 753 if (typeof inventoryarray == 'undefined' || inventoryarray.length == 0) //if there is no advanced options, don't look for stock 754 { 755 //check and show waiting list 756 if (product_status == "3") { 757 if (advanceoption_waitlist == "1") { 758 jQuery("#divWaitlist_AdvancedOptions").stop(true, true).show(); 759 } else { 760 jQuery(waitingListBlock).stop(true, true).show(); 761 } 762 } 763 return true; 764 } else { 765 if (product_status == "-1") { 766 //console.log("Not for sale key"); 767 changecontent("availability", product_availability); 768 jQuery("#divWaitlist_AdvancedOptions").hide(); 769 jQuery(waitingListBlock).hide(); 770 divAddToCart.hide(); 771 } else { 772 for (i = 0; i < inventoryarray.length; i++) { 773 soption = inventoryarray[i]; 774 field_array = soption.split("-"); 775 //Dynamic Part for advanced options 776 if (typeof (idarray) != "undefined") { 777 soptionid = idarray[i]; 778 aoprice = aopricearray[i]; 779 aogtin = gtinarray[i]; 780 if (field_array[0] == partnum) { 781 if (soptionid != '') { 782 changeid(soptionid); 783 jQuery("#itemid_advancedoption").val(soptionid); 784 } 785 786 if (aoprice != '0') 787 changeprice(aoprice); 788 if (aogtin != '') 789 changegtin(aogtin); 790 } 791 } 792 793 if ((field_array[0] == partnum)) { 794 795 changecontent("product_inventory", field_array[1]); 796 797 if ( field_array[1] <= 0 || (eval(GetValue(what, "qty-0")) == undefined && advanceoption_waitlist == '1')) { 798 optionfound = 1; 799 if (backordermode == 1) { 800 changecontent("availability", avail_backorder); 801 return true; 802 } else { 803 changecontent("availability", avail_outofstock); 804 805 if (advanceoption_waitlist == "1") { 806 divAddToCart.stop(true, true).hide(); 807 availabilityBar.alert('The options you selected are not currently available.'); 808 jQuery("#divWaitlist_AdvancedOptions").stop(true, true).slideDown(); 809 return true; 810 } else { 811 divAddToCart.stop(true, true).hide(); 812 availabilityBar.alert('The options you selected are not currently available.'); 813 jQuery(waitingListBlock).stop(true, true).slideDown(); 814 return true; 815 } 816 817 //alert("The options you selected are not currently available."); 818 availabilityBar.alert('The options you selected are not currently available.'); 819 return false; 820 } 821 } else { 822 optionfound = 1; 823 changecontent("availability", avail_instock); 824 jQuery("#divWaitlist_AdvancedOptions").stop(true, true).hide(); 825 jQuery(waitingListBlock).stop(true, true).hide(); 826 divAddToCart.stop(true, true).slideDown(); 827 return true; 828 } 829 830 } else { 831 optionfound = 0; 832 changecontent("availability", product_availability); 833 switch(product_status) { 834 case "-1": 835 //console.log("Not for sale"); 836 jQuery("#divWaitlist_AdvancedOptions").stop(true, true).hide(); 837 jQuery(waitingListBlock).stop(true, true).hide(); 838 divAddToCart.stop(true, true).hide(); 839 break; 840 case "1": 841 //console.log("Out of Stock"); 842 jQuery("#divWaitlist_AdvancedOptions").stop(true, true).hide(); 843 jQuery(waitingListBlock).stop(true, true).hide(); 844 divAddToCart.stop(true, true).hide(); 845 break; 846 case "2": 847 //console.log("Back Order"); 848 jQuery("#divWaitlist_AdvancedOptions").stop(true, true).hide(); 849 jQuery(waitingListBlock).stop(true, true).hide(); 850 divAddToCart.stop(true, true).slideDown(); 851 break; 852 case "3": 853 //console.log("Waiting List"); 854 if (advanceoption_waitlist == "1") { 855 divAddToCart.stop(true, true).hide(); 856 availabilityBar.alert('The options you selected are not currently available.'); 857 jQuery("#divWaitlist_AdvancedOptions").stop(true, true).slideDown(); 858 } else { 859 divAddToCart.stop(true, true).hide(); 860 availabilityBar.alert('The options you selected are not currently available.'); 861 jQuery(waitingListBlock).stop(true, true).slideDown(); 862 } 863 break; 864 case "4": 865 //console.log("Pre Order"); 866 jQuery("#divWaitlist_AdvancedOptions").stop(true, true).hide(); 867 jQuery(waitingListBlock).stop(true, true).hide(); 868 divAddToCart.stop(true, true).slideDown(); 869 break; 870 case "9": 871 //console.log("In stock - Special Order status 9"); 872 jQuery("#divWaitlist_AdvancedOptions").stop(true, true).hide(); 873 jQuery(waitingListBlock).stop(true, true).hide(); 874 divAddToCart.stop(true, true).slideDown(); 875 break; 876 default:
877 //console.log("Default / In stock"); 878 jQuery("#divWaitlist_AdvancedOptions").stop(true, true).hide(); 879 jQuery(waitingListBlock).stop(true, true).hide(); 880 divAddToCart.stop(true, true).slideDown(); 881 break; 882 } 883 } 884 } 885 if (optionfound == "0") { 886 //options selected don't match any in array 887 return true; 888 } 889 } 890 } 891} 892 893 894/** 895* wishlist 896***********************/ 897jQuery('#wishlist-add').click(function () { 898 //jQuery('#wishlist-error').collapse('hide'); 899 900 var wishlist_optListType = jQuery('.wishlist-optListType:checked').val(); 901 var wishlist_drpLists = jQuery('#wishlist-drpLists').val(); 902 var wishlist_txtNewList = jQuery.trim(jQuery('#wishlist-txtNewList').val()); 903 904 if ((wishlist_optListType == "1" && wishlist_drpLists == "")) { 905 var text = GetLanguagItem('wishlist_multiple-addtolist-select-the-list'); 906 alert(text); 907 } 908 else if ((wishlist_optListType == "2" && wishlist_txtNewList == "")) { 909 var text = GetLanguagItem('wishlist_multiple-addtolist-enter-the-name-list'); 910 alert(text); 911 } 912 else { 913 try { 914 add_wishlistcustom(wishlist_optListType, wishlist_drpLists, wishlist_txtNewList); 915 } 916 catch (ex) { 917 add_wishlistcustom(wishlist_optListType, wishlist_drpLists, wishlist_txtNewList) 918 } 919 } 920}); 921function add_wishlist() { 922 923 var enabledMultipleWishList = jQuery('#Enabled_Multiple_WishList').val(); 924 var link_addtolist = jQuery('#link_addtolist').val(); 925 926 if(jQuery('body').hasClass('not-logged-in')) { 927 window.location.href = "/myaccount.asp?catalogid="+ jQuery('#catalogid').val(); 928 return; 929 } 930 931 if (enabledMultipleWishList == "1") { 932 jQuery('#wishlist-modal').modal('show'); 933 var src = link_addtolist; 934 } 935 else { 936 document.add.action = "add_cart.asp?action=addWishList"; 937 document.add.submit(); 938 } 939} 940function add_wishlistcustom(strListType, intListId, strListName) { 941 document.add.wishListCustomType.value = strListType; 942 document.add.wishListCustomId.value = intListId; 943 document.add.wishListCustomname.value = strListName; 944 document.add.action = "add_cart.asp?action=addWishList"; 945 document.add.submit(); 946} 947 948 949/** 950* Captcha reusable functions 951***********************/ 952function processCaptchaEexcute(modalID, callBack) { 953 954 if (jQuery('#' +modalID+ ' [name="g-recaptcha-response"]')) { 955 jQuery('#' +modalID+ ' .loading-overlay').show(); 956 var captchaId = parseInt(jQuery('#' +modalID+ ' .recaptchaRobot').data('widgetid')); 957 958 if(jQuery('#' +modalID+ ' .recaptchaRobot').data('size') == 'invisible') 959 grecaptcha.execute(captchaId); 960 961 setTimeout(function () { 962 window[callBack](); 963 }, 500); 964 } 965 else { 966 window[callBack](); 967 } 968} 969 970function refereshAllCaptchas() { 971 if(jQuery('.simple-captcha > .captcha > img').length > 0) { 972 var src = jQuery('.simple-captcha > .captcha > img').first().attr('src'); 973 src = src + '?timestamp=" + new Date().getTime()'; 974 jQuery('.simple-captcha > .captcha > img').each(function(index, element) { 975 jQuery(element).attr('src', src); 976 }); 977 978 jQuery('[name="ramdomWord"]').val(''); 979 } 980 981 if((jQuery('.recaptchaRobot').length > 0)) { 982 jQuery('.recaptchaRobot').each(function(index, element) { 983 var widgetId = jQuery(element).data('widgetid'); 984 var textarea = jQuery(element).find('textarea[name="g-recaptcha-response"]'); 985 grecaptcha.reset(widgetId); 986 jQuery(textarea).val(''); 987 }); 988 } 989} 990 991/** 992* add_giftregistry 993***********************/ 994function add_giftregistry() { 995 document.add.action = "add_cart.asp?action=addGiftRegistry"; 996 document.add.submit(); 997} 998 999/** 1000* email_friend 1001***********************/ 1002function recommendaFriendRequest() { 1003 1004 var name = jQuery.trim(jQuery('#visitorname').val()); 1005 var email = jQuery.trim(jQuery('#visitormail').val()); 1006 var friendName = jQuery.trim(jQuery('#friendname').val()); 1007 var friendEmail = jQuery.trim(jQuery('#friendmail').val()); 1008 var notes = jQuery.trim(jQuery('#recommendafriend-message').val()); 1009 var siteurl = jQuery('#product_url').val(); 1010 var ramdomWord = jQuery.trim(jQuery('#recommendafriend-modal input[name="ramdomWord"]').val()); 1011 var recaptcha_response_field = jQuery.trim(jQuery('#recommendafriend-modal input[name="recaptcha_response_field"]').val()); 1012 var recaptcha_challenge_field = jQuery.trim(jQuery('#recommendafriend-modal input[name="recaptcha_challenge_field"]').val()); 1013 var g_recaptcha_response = jQuery.trim(jQuery('#recommendafriend-modal [name="g-recaptcha-response"]').val()); 1014 1015 var valid = true; 1016 var friendValidationMsg = ""; 1017 1018 if (name == '') { friendValidationMsg += "Please enter your Your Name.. \n"; valid = false; } 1019 if (email == '' || !validateEmail(email)) { friendValidationMsg += "Please enter a valid email address. \n"; valid = false; } 1020 if (friendName == '') { friendValidationMsg += "Please enter your Friend's Name. \n"; valid = false; } 1021 if (friendEmail == '' || !validateEmail(friendEmail)) { friendValidationMsg += "Friend's Email: enter a valid email address. \n"; valid = false; } 1022 if (notes == '' || notes.length > 500) { friendValidationMsg += "Please enter your Note to friend:. Max length is 500. \n"; valid = false; } 1023 1024 if (jQuery("#gdpr_privacy_enforced").val() == "1") { 1025 if (!jQuery('#recommendafriend-modal input[name="privacy_accepted"]').is(':checked')) { 1026 friendValidationMsg += GetLanguagItem('gdpr_privacy-policy-validation-message') + "\n"; 1027 valid =false; 1028 } 1029 } 1030 1031 if (!valid) { 1032 jQuery('#recommendafriend-modal .loading-overlay').fadeOut(500); 1033 alert(friendValidationMsg); 1034 return; 1035 } 1036 else { 1037 1038 //Invisible captcha test 1039 if (jQuery('#recommendafriend-recaptchaRobot').data('size') == 'invisible') { 1040 if (jQuery('#recommendafriend-recaptchaRobot textarea').val() == '') { 1041 processCaptchaEexcute('recommendafriend-modal', 'recommendaFriendRequest_normal'); 1042 //console.log(jQuery('#recommendafriend-recaptchaRobot textarea').val()); 1043 return; 1044 } 1045 } 1046 1047 jQuery('#recommendafriend-modal .loading-overlay').show(); 1048 1049 jQuery.ajax({ 1050 method: "POST", 1051 url: '/recommendafriend.asp?action=ajaxSend', 1052 data: { 1053 catalogid: jQuery('#catalogid').val(), 1054 visitorname: name, 1055 visitormail: email, 1056 friendname: friendName, 1057 friendmail: friendEmail, 1058 message: notes, 1059 siteurl: siteurl + "/product.asp?itemid=" + jQuery('#catalogid').val(), 1060 ramdomWord: ramdomWord, 1061 recaptcha_response_field: recaptcha_response_field, 1062 recaptcha_challenge_field: recaptcha_challenge_field, 1063 'g-recaptcha-response': g_recaptcha_response 1064 }, 1065 success: function (data) { 1066 var response = JSON.parse(data); 1067 if (response.resCode != undefined && response.resCode == 1) { 1068 jQuery('#recommendafriend-modal .loading-overlay').hide(); 1069 jQuery('#recommendafriend-modal .modal-response').fadeIn(500); 1070 } 1071 else { 1072 alert(response.resMsg); 1073 } 1074 }, 1075 error: function () { 1076 alert('Something went wrong. Please try again later.'); 1077 }, 1078 complete: function () { 1079 jQuery('#recommendafriend-modal .loading-overlay').fadeOut(500); 1080 } 1081 }); 1082 } 1083} 1084 1085function recommendaFriendRequest_normal() {} 1086function recommendaFriendRequest_invisible() { 1087 recommendaFriendRequest(); 1088} 1089 1090jQuery('#recommendafriend_button').click(function () { 1091 //jQuery('.recommendafriend-error').hide(); 1092 //processCaptchaEexcute('recommendafriend-modal', 'recommendaFriendRequest'); 1093 recommendaFriendRequest(); 1094}); 1095function showRecFriend() { 1096 jQuery('#recommendafriend-modal').modal('show'); 1097} 1098/** 1099* waitinglist 1100***********************/ 1101jQuery(function () { 1102 if (jQuery('#waitinglist-phone').val() == '[phone]') jQuery('#waitinglist-phone').val(''); 1103 if (window.location.search.indexOf("waitinglist") != -1) { 1104 jQuery('#waitinglist-modal').modal('show'); 1105 } 1106}); 1107 1108 1109jQuery('#waitinglist-btn').click(function (e) { 1110 e.preventDefault(); 1111 jQuery('#waitinglist-modal').modal('show'); 1112}); 1113 1114jQuery('#AO-waitinglist-btn').click(function (e) { 1115 e.preventDefault(); 1116 jQuery('#AO_waitinglist-modal').modal('show'); 1117}); 1118 1119function sendWaitingListRequest() { 1120 var name = jQuery.trim(jQuery('#waitinglist-name').val()); 1121 var email = jQuery.trim(jQuery('#waitinglist-email').val()); 1122 var phone = jQuery.trim(jQuery('#waitinglist-phone').val()); 1123 var UsesAdvOpt = document.getElementById("UsesAO") 1124 var ramdomWord, recaptcha_response_field, recaptcha_challenge_field, g_recaptcha_response; 1125 1126 if (UsesAdvOpt && UsesAdvOpt.value == 1) { 1127 ramdomWord = jQuery.trim(jQuery('#AO_waitinglist-modal input[name="ramdomWord"]').val()); 1128 recaptcha_response_field = jQuery.trim(jQuery('#AO_waitinglist-modal input[name="recaptcha_response_field"]').val()); 1129 recaptcha_challenge_field = jQuery.trim(jQuery('#AO_waitinglist-modal input[name="recaptcha_challenge_field"]').val()); 1130 g_recaptcha_response = jQuery.trim(jQuery('#AO_waitinglist-modal [name="g-recaptcha-response"]').val()); 1131 } else { 1132 ramdomWord = jQuery.trim(jQuery('#waitinglist-modal input[name="ramdomWord"]').val()); 1133 recaptcha_response_field = jQuery.trim(jQuery('#waitinglist-modal input[name="recaptcha_response_field"]').val()); 1134 recaptcha_challenge_field = jQuery.trim(jQuery('#waitinglist-modal input[name="recaptcha_challenge_field"]').val()); 1135 g_recaptcha_response = jQuery.trim(jQuery('#waitinglist-modal [name="g-recaptcha-response"]').val()); 1136 } 1137 1138 var valid = true; 1139 var wlValidationMsg = ""; 1140 1141 if (name == '') { wlValidationMsg += "Please enter your Name. \n"; valid = false; } 1142 if (email == '' || !validateEmail(email)) { wlValidationMsg += "Please enter your Email. \n"; valid = false; } 1143 if (phone == '') { wlValidationMsg += "Please enter your Phone. \n"; valid = false; } 1144 1145 if (!valid) { 1146 jQuery('#waitinglist-modal .loading-overlay').fadeOut(500); 1147 alert(wlValidationMsg); 1148 return; 1149 } 1150 else { 1151 1152 if (UsesAdvOpt && UsesAdvOpt.value == 1) { 1153 //Invisible captcha test for Adv Options 1154 if (jQuery('#waitinglist-AdvancedOptions-recaptchaRobot').data('size') == 'invisible') { 1155 if (jQuery('#waitinglist-AdvancedOptions-recaptchaRobot textarea').val() == '') { 1156 processCaptchaEexcute('waitinglist-modal', 'waitinglist_normal'); 1157 return; 1158 } 1159 } 1160 } else { 1161 //Invisible captcha test
1162 if (jQuery('#waitinglist-recaptchaRobot').data('size') == 'invisible') { 1163 if (jQuery('#waitinglist-recaptchaRobot textarea').val() == '') { 1164 processCaptchaEexcute('waitinglist-modal', 'waitinglist_normal'); 1165 return; 1166 } 1167 } 1168 } 1169 1170 jQuery.ajax({ 1171 method: "POST", 1172 url: '/notify.asp?action=ajaxSend', 1173 data: { 1174 catalogid: jQuery('#catalogid').val(), 1175 itemid_advanced: jQuery("#itemid_advancedoption").val(), 1176 name: name, 1177 email: email, 1178 phone: phone, 1179 ramdomWord: ramdomWord, 1180 recaptcha_response_field: recaptcha_response_field, 1181 recaptcha_challenge_field: recaptcha_challenge_field, 1182 'g-recaptcha-response': g_recaptcha_response 1183 1184 }, 1185 success: function (data) { 1186 var response = JSON.parse(data); 1187 if (response.resCode != undefined) { 1188 if (response.resCode == 1) { 1189 jQuery('#waitinglist-response').text(response.resMsg); 1190 if (UsesAdvOpt && UsesAdvOpt.value == 1) { 1191 jQuery('#AO_waitinglist-modal .modal-response').fadeIn(500); 1192 } else { 1193 jQuery('#waitinglist-modal .modal-response').fadeIn(500); 1194 } 1195 refereshAllCaptchas(); 1196 } 1197 else { 1198 alert(response.resMsg); 1199 } 1200 } 1201 }, 1202 error: function () { 1203 alert('Something went wrong. Please try again later.'); 1204 }, 1205 complete: function () { 1206 jQuery('#waitinglist-modal .loading-overlay').fadeOut(500); 1207 } 1208 }); 1209 } 1210} 1211 1212function waitinglist_normal() {} 1213function waitinglist_invisible() { 1214 sendWaitingListRequest(); 1215} 1216 1217jQuery('#waitinglist_button').click(function () { 1218 sendWaitingListRequest(); 1219}); 1220/** 1221* make an offer 1222***********************/ 1223jQuery('#makeanoffer-btn').click(function () { 1224 jQuery('#makeanoffer-modal').modal('show'); 1225}); 1226 1227function sendMakeAnOfferRequest() { 1228 1229 var amount = jQuery.trim(jQuery('#makeanoffer-amount').val()); 1230 var name = jQuery.trim(jQuery('#makeanoffer-name').val()); 1231 var email = jQuery.trim(jQuery('#makeanoffer-email').val()); 1232 var comment = jQuery.trim(jQuery('#makeanoffer-comment').val()); 1233 var ramdomWord = jQuery.trim(jQuery('#makeanoffer-modal input[name="ramdomWord"]').val()); 1234 var recaptcha_response_field = jQuery.trim(jQuery('#makeanoffer-modal input[name="recaptcha_response_field"]').val()); 1235 var recaptcha_challenge_field = jQuery.trim(jQuery('#makeanoffer-modal input[name="recaptcha_challenge_field"]').val()); 1236 var g_recaptcha_response = jQuery.trim(jQuery('#makeanoffer-modal [name="g-recaptcha-response"]').val()); 1237 1238 var valid = true; 1239 var moValidationMsg = ""; 1240 1241 if (name == '') { moValidationMsg += "Please enter your Name. \n"; valid = false; } 1242 if (email == '' || !validateEmail(email)) { moValidationMsg += "Please enter your Email. \n"; valid = false; } 1243 if (amount == '') { moValidationMsg += "Please enter offer amount. \n"; valid = false; } 1244 1245 if (!valid) { 1246 alert(moValidationMsg); 1247 jQuery('#makeanoffer-modal .loading-overlay').hide(); 1248 return; 1249 } 1250 else { 1251 1252 //Invisible captcha test 1253 if(jQuery('#makeanoffer-recaptchaRobot').data('size') == 'invisible') { 1254 if(jQuery('#makeanoffer-recaptchaRobot textarea').val() == '') { 1255 processCaptchaEexcute('makeanoffer-modal', 'makeanoffer_normal'); 1256 return; 1257 } 1258 } 1259 jQuery('#makeanoffer-modal .loading-overlay').show(); 1260 1261 jQuery.ajax({ 1262 method: "POST", 1263 url: '/makeanoffer.asp?action=ajaxsend&catalogid=' +jQuery('#catalogid').val(), 1264 data: { 1265 catalogid: jQuery('#catalogid').val(), 1266 amount: amount, 1267 name: name, 1268 email: email, 1269 comment: comment, 1270 ramdomWord: ramdomWord, 1271 recaptcha_response_field: recaptcha_response_field, 1272 recaptcha_challenge_field: recaptcha_challenge_field, 1273 'g-recaptcha-response': g_recaptcha_response 1274 }, 1275 success: function (data) { 1276 var response = JSON.parse(data); 1277 if (response.resCode != undefined) { 1278 if (response.resCode == 1) { 1279 jQuery('#makeanoffer-response').text(response.resMsg); 1280 jQuery('#makeanoffer-modal .modal-response').fadeIn(500); 1281 } 1282 else { 1283 alert(response.resMsg); 1284 jQuery('#makeanoffer-error').collapse('show'); 1285 } 1286 } 1287 }, 1288 error: function () { 1289 alert('Something went wrong. Please try again later.'); 1290 }, 1291 complete: function () { 1292 jQuery('#makeanoffer-modal .loading-overlay').fadeOut(500); 1293 } 1294 }); 1295 } 1296} 1297 1298function makeanoffer_normal() {} 1299function makeanoffer_invisible() {
1300 sendMakeAnOfferRequest(); 1301} 1302 1303jQuery('#makeanoffer-submit').click(function () { 1304 sendMakeAnOfferRequest(); 1305}); 1306 1307/** 1308* Show/Hide 'Multipule Ship-To' Recipient field/note 1309***********************/ 1310function showAddName() { 1311 if (jQuery('.multipleShipToBlock .send-to select').val() == 'selectother') { 1312 jQuery('.multipleShipToBlock .add-name, .multipleShipToBlock .note').show(); 1313 } 1314 else { 1315 jQuery('.multipleShipToBlock .add-name, .multipleShipToBlock .note').hide(); 1316 } 1317} 1318 1319/** 1320* check_and_add 1321***********************/ 1322function ask_check_and_add(formx, IsAddToCart, replaceitemname) { 1323 if(confirm(replaceitemname + '\n\n' +GetLanguagItem('recurringorders_replace-confirm'))) 1324 check_and_add(formx, IsAddToCart); 1325 1326} 1327 1328function check_before_add(formx) { 1329 var reqOption = validateReqOption(formx); 1330 if (reqOption != null) { 1331 //alert("Please select all required options."); 1332 reqOptionBar.alert('Please select all required options.'); 1333 varx1 = '[name="' + reqOption.name + '"]'; 1334 jQuery(varx1).closest('.opt-regular').addClass('option-required'); 1335 return false; 1336 } 1337 1338 if (document.add.std_price != null) { 1339 return validateValues(formx, 1); 1340 } 1341 return true; 1342} 1343 1344function check_and_add(formx) { 1345 var reqOption = validateReqOption(formx); 1346 1347 var extendComponent; 1348 var extendproduct; 1349 var extendShowModal; 1350 1351 if (reqOption != null) { 1352 //alert("Please select all required options."); 1353 reqOptionBar.alert('Please select all required options.'); 1354 varx1 = '[name="' + reqOption.name + '"]'; 1355 jQuery(varx1).closest('.opt-regular').addClass('option-required'); 1356 return; 1357 } 1358 1359 if (document.add.std_price == null) { 1360 //document.add.submit(); 1361 if (typeof buildExtendedOffer !== "function") { 1362 document.add.submit(); 1363 } else { 1364 extendComponent = Extend.buttons.instance('#extend-offer'); 1365 if (extendComponent == null) { 1366 document.add.submit(); 1367 return; 1368 } 1369 extendproduct = extendComponent.getActiveProduct(); 1370 extendShowModal = jQuery("#extend_showModal").val(); 1371 if (extendproduct !== null) 1372 buildExtendedOffer(extendproduct.id, extendShowModal); 1373 } 1374 } 1375 else { 1376 var readytoadd = validateValues(formx, 1) 1377 if (readytoadd == true) { 1378 if (typeof buildExtendedOffer !== "function") { 1379 document.add.submit(); 1380 } else { 1381 extendComponent = Extend.buttons.instance('#extend-offer'); 1382 if (extendComponent == null) { 1383 document.add.submit(); 1384 return; 1385 } 1386 extendproduct = extendComponent.getActiveProduct(); 1387 extendShowModal = jQuery("#extend_showModal").val(); 1388 if (extendproduct !== null) 1389 buildExtendedOffer(extendproduct.id, extendShowModal); 1390 } 1391 } 1392 } 1393} 1394var currency_symbol = jQuery("#currency").val(); 1395var prod_decimal_places = jQuery("#prod_decimal_places").val(); 1396validateValues(document.add, 1); 1397 1398 1399/** 1400* Option Rules 1401***********************/ 1402function initOptionsHelp() { 1403 //Activate popover 1404 jQuery('[data-toggle="popover"]').popover(); 1405 1406 //Activate url 1407 jQuery('[data-toggle="link"]').click(function () { 1408 window.open(jQuery(this).data('content'), 'Help', 'height=320,width=480'); 1409 }); 1410} 1411function selectOption(objElement) { 1412 1413 var strElementName = ""; 1414 var strElementType = ""; 1415 var intHasRules = jQuery("#has_rules").val(); 1416 var specialAmountText = ''; 1417 var specialAmountValue = 0; 1418 1419 if (jQuery("#rangeInput")) { 1420 specialAmountText = jQuery(".range-slider__value").html(); 1421 specialAmountValue = jQuery("#rangeInput").val(); 1422 } 1423 else { 1424 specialAmountText = ''; 1425 specialAmountValue = 0; 1426 } 1427 1428 objElement = null; 1429 1430 if (intHasRules != "1") { 1431 return; 1432 } 1433 1434 add_overlay("divOptionsBlock", 1); 1435 var url = 'prod_options.asp?ajax=1&action=buildOptions&strElementType=' +escape(strElementType) + '&strElementName=' +escape(strElementName) + '&no-cache=' +Math.random(); 1436 1437 jQuery.ajax({ 1438 url: url, 1439 dataType: 'html', 1440 type: 'POST', 1441 data: jQuery(add).serialize(), 1442 cache: false, 1443 success: function (strResult) { 1444 //Keep the values for the text options 1445 var textCollection = jQuery("#divOptionsBlock").find("input:text,textarea"); 1446
1447 jQuery("#divOptionsBlock").html(strResult); 1448 initOptionsHelp(); 1449 1450 if (specialAmountValue !== undefined && specialAmountValue > 0) { 1451 if (jQuery("#rangeInput")) 1452 jQuery("#rangeInput").val(specialAmountValue); 1453 if (jQuery(".range-slider__value")) 1454 jQuery(".range-slider__value").html(specialAmountText); 1455 } 1456 1457 if (textCollection.length > 0) 1458 for (var i = 0; i < textCollection.length; i++) { 1459 jQuery("[name='" + textCollection[i].name + "']").val(textCollection[i].value); 1460 } 1461 1462 jQuery('#add input[type="radio"]:checked').each(function () { 1463 jQuery(this).next('div.radio-option').addClass('radio-selected'); 1464 jQuery(this).next('div.swatch-option').addClass('swatch-selected'); 1465 }); 1466 1467 // for custom templates check if the create_swatches function exist. If so, call function. 1468 if (typeof create_swatches === "function") { 1469 create_swatches(); 1470 } 1471 }, 1472 complete: afterOptionSelection, 1473 error: reportError 1474 }); 1475} 1476 1477function afterOptionSelection(req) { 1478 remove_overlay("divOptionsBlock"); 1479 return; 1480} 1481function getElementById_s(strId) { 1482 var obj = null; 1483 if (document.getElementById) { 1484 obj = get_Element(strId); 1485 } else if (document.all) { 1486 obj = document.all[strId]; 1487 } 1488 return obj; 1489} 1490 1491function remove_overlay(panel) { 1492 var objBody = getElementById_s('overlay_' +panel); 1493 if (objBody != null && objBody != 'null' && objBody != undefined && objBody != 'undefined') 1494 objBody.style.display = 'none'; 1495} 1496 1497function add_overlay(panel, loading) { 1498 var objBody = getElementById_s(panel); 1499 var objOverlay = document.createElement("div"); 1500 if (!objBody) return; 1501 objOverlay.setAttribute('id', 'overlay_' +panel); 1502 objOverlay.className = 'overlay'; 1503 objOverlay.style.position = 'absolute'; 1504 objOverlay.style.textAlign = 'center'; 1505 objOverlay.style.width = objBody.clientWidth + "px"; 1506 objOverlay.style.height = objBody.clientHeight + "px"; 1507 //alert(objOverlay.style.height); 1508 objBody.insertBefore(objOverlay, objBody.firstChild); 1509 objOverlay.style.display = 'block'; 1510 1511 if (loading == 1) { 1512 get_Element('overlay_' +panel).innerHTML = '<table border=0 width=100% height=100%><tr><td style="text-align: center;"><img src="assets/templates/common-html5/images/loading.gif"></td></tr></table>'; 1513 } 1514 else { 1515 get_Element('overlay_' +panel).innerHTML = '<table border=0 width=100% height=100%><tr><td align="center"></td></tr></table>'; 1516 } 1517} 1518 1519function get_Element(i) { 1520 return document.getElementById(i) || document.getElementsByName(i).item(0); 1521} 1522 1523function reportError(jqXHR, textStatus) { 1524 remove_overlay("divOptionsBlock"); 1525 1526 //jqXHR.responseText 1527 if (jqXHR.status > 0) 1528 alert("Error processing request " + jqXHR.status + " - " +textStatus); 1529} 1530 1531if (jQuery('#hdnHasDefaultSelected').length > 0 && jQuery('#hdnHasDefaultSelected').val() == "1") 1532 selectOption(null); 1533 1534function countChars(countfrom, displayto, countmax) { 1535 var str = document.getElementById(countfrom).value; 1536 var CountBreaks = str.split("\n").length -1; 1537 1538 document.getElementById(countfrom).maxLength = (Number(countmax) +Number(CountBreaks * 1)); 1539 var len = countmax -(document.getElementById(countfrom).value.length); 1540 if (len < 0) { 1541 document.getElementById(countfrom).value = str.substring(0, str.length -1) 1542 return false; 1543 } 1544 document.getElementById(displayto).innerHTML = len; 1545} 1546 1547jQuery(window).on("load", function () { 1548 jQuery('#get_quote-iframe').on("load", function () { 1549 if (jQuery('#get_quote-iframe').length > 0) { 1550 document.getElementById('get_quote-iframe').style.height = (document.getElementById('get_quote-iframe').contentWindow.document.body.scrollHeight +20) + 'px'; 1551 } 1552 }); 1553}); 1554 1555 1556/** 1557* Helpful rating 1558***********************/ 1559var qaUpdateBar = new MessageBar(); 1560qaUpdateBar.initialize(); 1561 1562function updateRevStats(id, spn, vote) { 1563 1564 var url = ''; 1565 var params = ''; 1566 1567 params = 'id=' + id; 1568 params += '&vote=' + vote; 1569 1570 url = 'reviewVote_ajax.asp?' + params + '&no-cache=' + Math.random(); 1571 1572 //window.location = url; 1573 1574 jQuery.ajax({ 1575 url: url, 1576 dataType: 'html', 1577 type: 'GET', 1578 cache: false, 1579 success: function (strResult) {
1580 if (strResult == '') { 1581 qaUpdateBar.alert(GetLanguagItem('productqa_helpful-notupdated')); 1582 } 1583 else { 1584 jQuery('#spnReview' + spn).html(strResult); 1585 qaUpdateBar.success(GetLanguagItem('productqa_update-helpful')); 1586 } 1587 1588 }, 1589 error: reportQAError 1590 }); 1591 1592} 1593 1594function updateQAStats(id, spn, vote) { 1595 1596 var url = ''; 1597 var params = ''; 1598 1599 params = 'id=' + id; 1600 params += '&vote=' + vote; 1601 1602 url = 'productqaVote_ajax.asp?' + params + '&no-cache=' + Math.random(); 1603 1604 //window.location = url; 1605 1606 jQuery.ajax({ 1607 url: url, 1608 dataType: 'html', 1609 type: 'GET', 1610 cache: false, 1611 success: function (strResult) { 1612 if (strResult == '') { 1613 qaUpdateBar.alert(GetLanguagItem('productqa_helpful-notupdated')); 1614 } 1615 else { 1616 jQuery('#spn' + spn).html(strResult); 1617 qaUpdateBar.success(GetLanguagItem('productqa_update-helpful')); 1618 } 1619 1620 }, 1621 error: reportQAError 1622 }); 1623 1624} 1625 1626function reportQAError(jqXHR, textStatus) { 1627 if (jqXHR.status > 0) { 1628 //alert("Error processing request, please try again."); 1629 qaUpdateBar.alert('Error processing request, please try again.'); 1630 //alert(jqXHR.responseText); 1631 //alert(jqXHR.status + " - " + jqXHR); 1632 } 1633} 1634 1635var OriginalImage = jQuery('#listing_main_image_link').attr('href') ?? ''; 1636function SelectSwatch_v2(id, caption, image_medium_w) { 1637 var imagepath = jQuery('#swatch-image-' + id).val(); 1638 var imagepath_large; 1639 if (imagepath == '') imagepath = OriginalImage; 1640 if (imagepath != '') { 1641 imagepath = Update_imagepath(imagepath, image_medium_w); 1642 imagepath_large = Base_imagepath(imagepath, image_medium_w); 1643 if (jQuery('#listing_main_image_link').length > 0) { 1644 if (jQuery(".MagicZoomPlus").length > 0) { 1645 jQuery('#listing_main_image_link').attr('href', imagepath_large); 1646 MagicZoom.update('listing_main_image_link', imagepath_large, imagepath); 1647 } 1648 } 1649 else { 1650 // If there is not a Main Image assigned to the product 1651 var altText = caption; 1652 jQuery('<div id="main-image" class="main-image text-center"><a href="' + imagepath_large + '" class="MagicZoomPlus" id="listing_main_image_link" data-options="zoomCaption: bottom;"><img src="' + imagepath +'" id="large" class="img-responsive" alt="' + altText + '"/></a></div>').insertBefore('#addl-images'); 1653 MagicZoom.start('listing_main_image_link'); 1654 } 1655 } 1656} 1657 1658function Update_imagepath(imagepath, image_medium_w) { 1659 if (imagepath.indexOf("/cdn-cgi/image/") >= 0) { 1660 if (imagepath.indexOf("width%3D") < 0 && imagepath.indexOf("quality%3D") > 0) { 1661 imagepath = imagepath.replace("quality%3D", "width%3D"+image_medium_w+"%2Cquality%3D"); 1662 } 1663 else { 1664 imagepath = 'thumbnail.asp?file=' + imagepath + '&maxx=' + image_medium_w + '&maxy=0'; 1665 } 1666 } 1667 return imagepath; 1668} 1669 1670function Base_imagepath(imagepath_large, image_medium_w) { 1671 if (imagepath_large.indexOf("width%3D") >= 0 && imagepath_large.indexOf("quality%3D") > 0) { 1672 imagepath_large = imagepath_large.replace("width%3D"+image_medium_w+"%2Cquality%3D", "quality%3D"); 1673 } else { 1674 imagepath_large = imagepath_large; 1675 } 1676 1677 return imagepath_large; 1678} 1679 1680function addKeyListenerToOptions() { 1681 document.querySelectorAll('.selectable-option').forEach(function (option) { 1682 option.addEventListener('keydown', function (e) { 1683 if (e.key === 'Enter' || e.keyCode === 13) { 1684 var optionId = (this.classList.contains('radio-option') ? 'radio-' : 'swatch-') + this.id; 1685 var optionInput = document.getElementById(optionId); 1686 if (optionInput) { 1687 optionInput.checked = true; 1688 validateValues(document.add, 1); 1689 selectOption(optionInput); 1690 if (this.classList.contains('swatch-option')) { 1691 SelectSwatch_v2(this.id, this.getAttribute('data-imagecaption'), this.getAttribute('data-image-medium-w')); 1692 } 1693 1694 e.preventDefault(); 1695 } 1696 } 1697 }); 1698 if (option.classList.contains('swatch-option')) { 1699 option.setAttribute('tabindex', '0'); 1700 } 1701 }); 1702} 1703addKeyListenerToOptions(); 1704// ISSUE-17162 - Moving the previous and next button handler to the frontend, 1705// Call the ajax.asp?action=previousnextbutton to get the HTML for the previous and next buttons 1706function PreviousNextButtonHandler(itemId, separator) { 1707 jQuery.ajax({ 1708 url: "../ajax.asp?action=previousnextbutton&itemid=" + itemId,
1709 type: 'GET', 1710 async: true, 1711 cache: false, 1712 success: function (htmlResult) { 1713 const buttons = htmlResult.split(separator); 1714 if (buttons.length > 0) { 1715 jQuery('#previous-product-button').html(buttons[0]); 1716 jQuery('#next-product-button').html(buttons[1]); 1717 } 1718 }, 1719 error: function (errObject, strResult) { 1720 console.error('Error: ', errObject); 1721 } 1722 }); 1723}
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.