Only eligible transactions made with a hotpoints Mastercard can be used for hotpoints Pay. In addition, there is a minimum number of hotpoints that must be earned before you are eligible to redeem your hotpoints for any reward or for hotpoints Pay. See the applicable Credit Card Conditions of Use for full details.
Westpac is not the supplier of the goods and services that can be redeemed with hotpoints and does not guarantee the obligations of the supplier or any goods and services supplied. Any goods or services that are provided by a third party supplier may be withdrawn at any time.
Only eligible transactions made with a hotpoints Mastercard can be used for hotpoints Pay. In addition, there is a minimum number of hotpoints that must be earned before you are eligible to redeem your hotpoints for any reward or for hotpoints Pay. See the applicable Credit Card Conditions of Use for full details.
Westpac is not the supplier of the goods and services that can be redeemed with hotpoints and does not guarantee the obligations of the supplier or any goods and services supplied. Any goods or services that are provided by a third party supplier may be withdrawn at any time.
Westpac is not the supplier of the goods and services that can be redeemed with hotpoints and does not guarantee the obligations of the supplier or any goods and services supplied. Any goods or services that are provided by a third party supplier may be withdrawn at any time.
Only eligible transactions made with a hotpoints Mastercard can be used for hotpoints Pay. In addition, there is a minimum number of hotpoints that must be earned before you are eligible to redeem your hotpoints for any reward or for hotpoints Pay. See the applicable Credit Card Conditions of Use for full details.
').insertBefore( '.footie' );
}else{
console.log('No, not on page '+i+' with '+pages_on[i], $(pages_on[i]).length);
}
}
};
var applyPointGiftStyling = function() {
console.log('Applying Point Gift Styling');
$('#rec_last_name').val('NA').addClass('disabled').css({ 'background-color': '#B4B7B9', 'color': '#949799'}).prop('readonly', true);
marker = $('
').insertBefore('#rec_last_name');
$('#rec_last_name').detach().attr('type', 'hidden').insertAfter(marker);
marker.remove();
/* I think it can only change from a password field if user triggers event*/
if($('#rec_last_name').attr('type')!='hidden'){
$('#rec_last_name').remove();
$('
').insertAfter('#rec_acc_num');
}
if($('#rec_last_name').attr('type')=='hidden'){
$("label[for='rec_last_name']").css("visibility", "hidden").css("display", "none");
}
if($('#rec_acc_num').attr('type')=='password'){
var item_val = $('#rec_acc_num').val();
var parent_ele = $('#rec_acc_num').parent();
$('#rec_acc_num').remove();
parent_ele.append('
');
}
};
var applyShoppingCartStyling = function() {
console.log('Applying Shopping Cart Styling');
$('form#shoppingCartForm .cart_list div.item_row > .row > .columns:nth-child(1)').addClass('thumbnail');
$('form#shoppingCartForm .cart_list div.item_row > .row > .columns:nth-child(2)').addClass('heading');
$('form#shoppingCartForm .cart_list div.item_row > .row > .columns:nth-child(3)').addClass('details');
$("#SPN_SHOPPINGCART form#shoppingCartForm .cart_list div.item_row > .row .thumbnail img").each(function(){
/*console.log('Found basket image: ', href);*/
var split = $(this).attr('src').split("/");
var filename = split.pop();
filename = filename.substr(1);
href = split.join("/");
/*console.log('Changed basket image: ', href+filename);*/
$(this).attr('src', href+'/'+filename);
});
$("#SPN_SHOPPINGCART form#shoppingCartForm .cart_list div.item_row > .row .details").each(function(){
var totalPointsHtml = $(this).find('.item-total-points').html();
$(this).find('span.quantity .button span').html('Remove from cart');
var removeButton = $(this).find('span.quantity').html();
/*console.log('Remove button HTML: ', removeButton);*/
$(this).parent('.row').find('.item-points').append(totalPointsHtml);
$(this).parent('.row').find('.item-points').append('
' + removeButton + '
');
var getName = $(this).parent('.row').find('span.name').html();
console.log(getName);
$(this).parent('.row').find('.thumbnail').append('
' + getName + '
');
});
var cartItemCount = document.getElementById("cart_item_count").value;
if(cartItemCount > 1){
$('#SPN_SHOPPINGCART form#shoppingCartForm #ajaxEventDiv').prepend('
' + cartItemCount + ' items in your cart
');
} else {
$('#SPN_SHOPPINGCART form#shoppingCartForm #ajaxEventDiv').prepend('
' + cartItemCount + ' item in your cart
');
}
$('#SPN_SHOPPINGCART input[aria-label="Quantity"]').each(function(){
var qnty = $(this).val();
var item_value = $(this).parent().parent().parent().find('> span:first-child span.points').html(); /* numberWithoutCommas() */
if(item_value){
$(this).parent().parent().parent().find('> span:first-child').after('
'+qnty+' '+numberWithCommas((numberWithoutCommas(item_value)*qnty))+' ');
}
});
$('#SPN_SHOPPINGCART .heading .total_points.points_amount, #SPN_SHOPPINGCART .heading .total_points.points_only').each(function(){
console.log('Found .total_points.points_amount: ', $(this).find('.amount').length);
if($(this).find('.amount').length == 0 || $(this).find('.amount').html() == '$0.00'){
$(this).css('visibility', 'hidden');
}
});
console.log('Points only nodes: ', $('#SPN_SHOPPINGCART .heading .total_points.points_only').length, $('#SPN_SHOPPINGCART .heading').length, $('#SPN_SHOPPINGCART .points_only').length);
/*$('#SPN_SHOPPINGCART .heading .total_points.points_only').each(function(){
console.log('Found .total_points.points_only: ', $(this).find('.amount').length);
if($(this).find('.amount').length == 0){
$(this).append('
$0.00 ');
}
});*/
applyTotalCheckoutFooter('SPN_SHOPPINGCART');
};
var applyCheckoutStyling = function() {
console.log('Applying Checkout Styling');
var firstNameText = document.getElementById("first_name_text").value;
var lastNameText = document.getElementById("last_name_text").value;
var phoneNum = document.getElementById("phone_number_new").value;
if(phoneNum == ""){
phoneNum = document.getElementById("phone_number").value;
}
var emailAddr = document.getElementById("email_address").value;
var pointsBalance = document.getElementById("available_point_balance").innerHTML;
var categoryNameText = document.getElementById("category_name_text").value;
var myDetailsData = '
My details. ' + firstNameText + ' ' + lastNameText + '
' + phoneNum + '
' + emailAddr +'
';
$('#SPN_CHECKOUT form#shoppingCartForm .cart_list:first').prepend(myDetailsData);
$('#SPN_CHECKOUT form#shoppingCartForm .bodyBolded').html('eCards and receipts for Click & Collect store collection will be sent to the email address provided within 1 business day');
$('#SPN_CHECKOUT #shoppingCartForm #ajaxEventDiv .cart_list .item_row .ship_to label:first-child span:first-child, #SPN_CHECKOUT #shoppingCartForm #ajaxEventDiv .cart_list .item_row .ship_to .item_ship.item_ship_to').html('Delivery address.'); /* This was added by ricky but think its having adverse effects */
$('#SPN_CHECKOUT form#shoppingCartForm #ajaxEventDiv .cart_list div.item_row').prepend('
Order details. ');
$("#SPN_CHECKOUT form#shoppingCartForm #ajaxEventDiv .cart_list div.item_row").each(function(){
var productCount = $(this).find('.item-totals .value').html();
$(this).find('.item-details span.name').prepend(productCount + ' x ');
if($(this).find('.item-total-points span.points_amount .amount').length) {
$(this).find('.item-totals').after('
Total amount to pay:
');
$(this).find('.item-total-points span.points_amount .amount').appendTo($(this).find('.items-pay-amount'));
}
for (i = 1; i <= 10; i++) {
/*console.log('Looking for: #div_item_mapping_info_'+i+'.');*/
if($('#div_item_mapping_info_'+i).length>0 && $.trim($('#div_item_mapping_info_'+i).html()).length>0){
console.log('Found non-empty: #div_item_mapping_info_'+i+'.');
if($('#div_item_mapping_info_'+i+' .edit_row').length==0 && $('#div_item_mapping_info_'+i+' #btn_add_map_info').length>0){
/* There is not a edit */
console.log('Found box which will need a line: #div_item_mapping_info_'+i+'.');
$('#div_item_mapping_info_'+i).addClass('add_line');
}
}
}
});
if($('.payment_information.row .error').length > 0){
var error = $('.payment_information.row .error').html().replace('The Card Number or the Expiration Date entered is not valid.','The card number or the expiration date entered is not valid.');
$('.payment_information.row .error').html(error);
}
applyTotalCheckoutFooter('SPN_CHECKOUT');
if($('select#card_brand').length > 0){
$('select#card_brand option').each(function( index ) {
if($(this).attr('value')!= 1){
$(this).remove();
}
});
}
};
var applySubCategoryStyling = function(calledFrom) {
console.log('Applying Sub Category Styling, Currently: ', $('#container_shop_category_title .shop_category_title').text(), '"'+calledFrom+'"');
if( $('section#shop_offers #sidebar').length){
var subCategoryLinks = $('section#shop_offers #sidebar #offers_categories > .sidebar_menu li.active.submenu:last ul').html();
var catName = $('#container_shop_category_title .shop_category_title').text();
var search_term = getSearchTermFromURL();
$('.shop.page_content .page_intro .row nav.sidebar_menu').remove();
removeBackButton();
if (subCategoryLinks != null){
console.log('There are subCategoryLinks. . . ', "'"+search_term+"'", "'"+$('#search_string').val()+"'");
if(catName!='Search Results.'){
// If not a search result
console.log('Not a search, so add sub category menu showing: ', subCategoryLinks);
$('.shop.page_content .page_intro .row #container_shop_category_title')
.after('');
}else{
// If a a search result remove the normal searches
ApplySearchAreaChanges();
}
}else{
console.log('No sub category links found.');
if(catName=='Search Results.'){
ApplySearchAreaChanges();
}
}
}
};
var getAllRewards = function() {
if(typeof show_all !== 'undefined'){
return {'id':show_all, 'link': root_url+'/shop/'+show_all+'?postaction=initActionShopCatalog&csrf_token='+getCSRFToken()};
}
return false;
};
var ApplySearchAreaChanges = function(catName) {
// If a a search result remove the normal searches
var all_rewards = getAllRewards();
console.log('Its a search and all rewards link exists, add back button to: ', all_rewards);
if(all_rewards){
// Remove the menu item
setTimeout(function(){
console.log('found h2 (title, span): ', $('h2.shop_category_title').length, $('h2.shop_category_title span').length);
//$('h2.shop_category_title span').remove();
// Sometimes the shop_category_title returns with a br on the end. as it appears after the . it is not returned in the code.
removeBackButton();
$('h2.shop_category_title').append('
Back to all rewards ');
//$('.shop.page_content .page_intro .row nav.sidebar_menu').remove(); // this appear to remove the menu after a search
},100);
}
};
var removeBackButton = function(catName) {
$('h2.shop_category_title .backcode').remove();
};
var applyTotalCheckoutFooter = function(div_id) {
/* Footer with total number */
var footerCartDetails = $('#'+div_id+' form#shoppingCartForm .cart_list footer.item_row');
var totoalPoints = footerCartDetails.find('.total .points').text();
var totoalAmount = footerCartDetails.find('.total .amount').text();
if(totoalAmount === ''){
totoalAmount = '$00.00';
}
console.log('Points: ' + totoalPoints + ' : ' + totoalAmount);
footerCartDetails.append('
Total hotpoints to be redeemed: '+ totoalPoints +'
'+(totoalAmount != '$00.00' ? '
Total you will pay: '+ totoalAmount +'
You can choose to pay as much as you like in dollars and save your hotpoints.
' : '')+'
hotpoints remaining: '+ numberWithCommas(availablePoints) +'
');
};
var applyEllipsizeTextBoxStyling = function() {
/* console.log('We have found '+$('.card_list .caption span').length+' products on this page to style'); */
$('.card_list .caption span').each(function(){
ellipsizeTextBox($(this));
});
searchForCSRFToken();
};
/* Apply modal changes here */
var applyModalStyle = function(style_id) {
console.log('Running applyModalStyle');
/* Modal for Redeem (/transaction-eraser) page */
$('.modal_default').addClass(style_id);
if(style_id == 'cacl_points_summary'){
var currency = $('.modal_default fieldset .value.currency').html();
var hotpoints = $('.modal_default fieldset label[for=pointsToRedeem] .value').html();
$('.modal_default fieldset label').css('display', 'none');
if($('.modal_default.cacl_points_summary .content h6').length>0){
console.log('Found the h6: ', $('.modal_default.cacl_points_summary .content h6').html());
var get_h6_text = $('.modal_default.cacl_points_summary .content h6').html().replace("To proceed with your order please read and accept our", "To proceed please read and accept our");
$('.modal_default.cacl_points_summary .content h6').html(get_h6_text);
}else{
console.log('The h6 is missing');
}
$( '
'+currency+' equals '+hotpoints+' hotpoints. You\'ll see the dollar value of the hotpoints redeemed back in your account within 2 business days.
' ).appendTo('.modal_default fieldset > .row:first-child');
$('.modal_default fieldset button span').html('Go back');
$('.modal_default fieldset button.primary span').html('Accept');
}
if(style_id == 'pt_cashback_summary'){
$('.modal_default header h3').html('Thank you!');
$('.modal_default .content p').addClass('pbody').html('Your hotpoints redemption is complete.');
$('.modal_default fieldset button.primary span').html('Close');
}
};
var commentSlider = {
'config' : {
'container' : $('#testimonial_wrapper')
},
'init' : function(config) {
console.log('Initialising testimonials');
if(config && typeof(config) == 'object') {
$.extend(commentSlider.config, config);
}
commentSlider.autoslide = true;
//wrapper
commentSlider.$container = commentSlider.config.container;
//all paragraph tags
commentSlider.$paragraphs = commentSlider.$container.
find('> div');
//all li tags
commentSlider.$dots = commentSlider.$container.
find('ul.dots-wrap > li');
//first li within ul.dots-wrap
commentSlider.$firstDot = commentSlider.$container.
find('ul.dots-wrap > li:first-child');
//first p tag within module wrapper
commentSlider.$firstParagraph = commentSlider.$container.
find('> div:first-child');
//setting first dot with .active class
commentSlider.$firstDot.addClass('active');
//setting first paragraph tag with .active class
commentSlider.$firstParagraph.addClass('activeText');
$('.testimonial_wrapper').on( "swipeleft", function(){ // show next image on swipe left
alert('Swipe left detected');
}).on( "swiperight", function(){ // show prev image on swipe right
alert('Swipe right detected');
});
//initializing functions and defining their parameters
commentSlider.currentItem(commentSlider.$paragraphs, commentSlider.$dots);
commentSlider.setActiveDot(commentSlider.$dots);
commentSlider.pauseOnHover(commentSlider.$container);
commentSlider.timer();
},
//timer function runs necesary functions every five seconds
'timer' : function() {
if(testimonialAutoSlider===true){
setInterval(function(){
commentSlider.moveToNextSlide(commentSlider.$dots);
}, 5000);
}
}, //timer function end
//grabs current numerical class of dot clicked
'dotNumber' : function($dot) {
var dotClassArray = [];
var dotClassList = dotClassArray.push($dot.attr('class'));
var splitArray = dotClassArray.toString().split(' ');
for(i = 0; i < splitArray.length; i++) {
if (splitArray[i] === "dot") {
splitArray.splice(i, 1);
var dotClickedNumber = splitArray[i];
commentSlider.paragraphNumber(dotClickedNumber, commentSlider.$paragraphs);
}
}
},//end dotNumber
'paragraphNumber' : function(dotClickedNumber, $paragraphs) {
$paragraphs.each(function() {
var $paragraph = $(this);
var paragraphClass = $paragraph.attr('class');
if(paragraphClass === dotClickedNumber) {
$paragraph.addClass('activeText');
$paragraph.siblings().removeClass('activeText').addClass('slideLeft');
setTimeout(function () {
$paragraph.siblings().removeClass('slideLeft');
}, 400);
}
});
},//end paragraphNumber
//currentItem function gives every paragraph and dot a numerical class
//based on their array position
'currentItem' : function($paragraphs, $dots) {
$paragraphs.each(function(i) {
var $paragraph = $(this);
$paragraph.addClass([] + i);
});
$dots.each(function(i) {
var $dot = $(this);
$dot.addClass([] + i);
});
},//end currentItem
//setActiveDot adds class active to whichever dot is clicked
'setActiveDot' : function($dots) {
$dots.each( function() {
var $dot = $(this);
$dot.on('click', function() {
if($dot.hasClass('active')) {
return false;
} else {
$dot.addClass('active');
$dot.siblings().removeClass('active');
}
commentSlider.dotNumber($dot);
});
});
},//end setActiveDot
//moveToNextSlide function works out the
'moveToNextSlide' : function($dots) {
if(commentSlider.autoslide === true){
var click_next = false;
$dots.each( function() {
// Get the active dot.
var $dot = $(this);
if(click_next == true){
//console.log('Next slide is '+$dot.attr('class'));
$dot.trigger('click');
click_next = false;
}else if($dot.hasClass('active')) {
//console.log('Active slide is '+$dot.attr('class'));
click_next = true;
}
});
if(click_next === true){
//console.log('Must have been last slide, move to first');
var $dot = commentSlider.$firstDot;
$dot.trigger('click');
}
click_next = false;
}
},
//moveToNextSlide function works out the
'pauseOnHover' : function($slider) {
$slider.on('mouseover', function() {
commentSlider.autoslide = false;
//console.log('Paused auto slide');
}).on('mouseleave', function() {
commentSlider.autoslide = true;
//console.log('resume auto slide');
});
}
};
//initializes the entire thing by calling the init function
$(document).ready(commentSlider.init);
/* Incase its not avalable (i.e. ir.js is not included on a page) We define our own. */
if (typeof getCSRFToken === "undefined"){
var getCSRFToken = function() {
if ($('#csrf_token_keeper').length>0) {
return $('#csrf_token_keeper').val();
}else{ /*if($('a.tab-class:first-child').length > 0 && $('a.tab-class:first-child').attr('href').indexOf("?csrf_token=") !== -1){
return $('a.tab-class:first-child').attr('href').substr($('a.tab-class:first-child').attr('href').indexOf("?csrf_token="));*/
return window.location.href.substr(window.location.href.indexOf("?csrf_token="));
}
};
}
var numberWithCommas = function(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
};
var numberWithoutCommas = function(x) {
return parseInt(x.replace(/\,/g,''),10);
};
var ellipsizeTextBox = function(id, not_parent) {
var not_parent = typeof not_parent === 'undefined' || not_parent === false ? false : true;
var el = typeof id == 'string' ? $(id) : id;
var wordArray = el.html().split(' ');
if(not_parent){
while(el.prop("scrollHeight") > el.prop("offsetHeight")) {
/*console.log(el.parent().prop("scrollHeight")+ ' > '+el.parent().prop("offsetHeight"), wordArray.join(' ') + '...'); */
wordArray.pop();
el.html(wordArray.join(' ') + '...');
}
}else{
while(el.parent().prop("scrollHeight") > el.parent().prop("offsetHeight")) {
/*console.log(el.parent().prop("scrollHeight")+ ' > '+el.parent().prop("offsetHeight"), wordArray.join(' ') + '...'); */
wordArray.pop();
el.html(wordArray.join(' ') + '...');
}
}
};
var showOnLoad = function() {
console.log('body has loaded show hidden items: ');
var show_on_load = []; /* for items not tagged with below style */
$('.show_on_load').removeClass('show_on_load');
for (var i = 0; i < show_on_load.length; i++) {
var val = show_on_load[i];
console.log('showing: ', val);
$(val).attr('style', function(i,s) { return (s || '') + 'visibility: visible !important;' });
}
};
var highlightActiveMenus = function() {
if($('.header_top_row ul.top-h-menu > li a').length){
console.log('Found '+$('.header_top_row ul.top-h-menu > li a').length+' menu items.');
}else{
console.log('NO MENU ITEMS FOUND.');
}
$('.header_top_row ul.top-h-menu > li a').each(function(){
var links_to = '';
if($(this).attr('onclick') && $(this).attr('onclick').indexOf('naviagateHeaderMenu')!== -1){
links_to = removeNaviagateHeaderMenu($(this).attr('onclick'));
console.log($(this).html()+' USES naviagateHeaderMenu', links_to);
}else if($(this).attr('href') && $(this).attr('href').length && $(this).attr('href') == '#'){
links_to = getUrlFromHref($(this).attr('href'));
console.log($(this).html()+' USES href', links_to);
}else{
console.log($(this).html()+' USES unknown.');
}
/*if(var links_to == window.location.href){
}*/
console.log(window.location.href, ' -> ', links_to);
});
};
/* As the Products menu is on every page we need these functions if not loaded */
if (typeof doAjaxCall10085 === "undefined"){
var doAjaxCall10085 = function(ajaxevt, code) {
showLoader();
var sortSelectId = 'selsort';
var orderByParam = '';
if (document.getElementById(sortSelectId)) {
var orderBy = sessionStorage.getItem('orderBy') || $('#' + sortSelectId).children("option:selected").val();
orderByParam = '&orderby=' + orderBy;
};
readTextWithPost('/rewards/AjaxDataServlet/','ajaxEvent='+ajaxevt+'&ajaxData='+code+orderByParam ,AjaxCallBack10085, -1, -1);
};
var AjaxCallBack10085 = function( ajaxdata ) {
if (ajaxdata) document.getElementById('shop_offers').innerHTML = ajaxdata;
$.post('/rewards/SessionObject', function(data, status) {
var pageContent = document.getElementById('page_content');
if (data.selectedCategory.backgroundImage === "" || data.selectedCategory.backgroundImage === null) {
pageContent.style = "background-image: none;";
document.getElementByClassName('shop_category_title').style.display = 'none !important;';
}
else {
pageContent.style = "background-image: url('/rewards/ImageDisplayServlet?file=" +
data.selectedCategory.backgroundImage + " '); background-repeat: no-repeat;";
}
});
new SURPREENDA.SideBar();
BreadCrumbAjaxCall10085('refreshBreadCrumb');
refreshShopCategoryTitle();
if (typeof refreshStyles === 'function') refreshStyles();
var sortSelectId = 'selsort';
// Select the proper value in the sort order select.
// 'orderBy' is saved in sessionStorage in the doSort function.
var orderBy = sessionStorage.getItem('orderBy') || 'orderByPointsAsc';
document.getElementById(sortSelectId).value = orderBy;
// Update the jQuery chosen component for the sort order
// to select the same value that is selected
// in the select element that it hides.
$('#' + sortSelectId).trigger('chosen:updated');
if (setFocusOnProducts) {
// on load, don't set the focus to products
focusProducts();
} else {
setFocusOnProducts = true;
}
sessionActivityHappened();
hideLoader();
};
}
if (typeof getAjaxData === "undefined"){
console.log('Defining own version of getAjaxData');
var getAjaxData = function(ajaxevent, rewardMatrixItemId) {
console.log('Running own version of getAjaxData');
/* added as mobile wishlist errors */
if(typeof rewardMatrixItemId === 'undefined'){
console.log('Usual version being used', typeof getAjaxData);
ajaxdata = '&item_id='+document.getElementById("item_id").value ;
if (ajaxevent == 'getNextItem' || ajaxevent == 'getPrevItem') {
var itemIndex = document.getElementById("item_index").value;
ajaxdata=ajaxdata+'&item_index='+ itemIndex;
}
else if (ajaxevent == 'AddPPItemAction' || ajaxevent == 'AddItemAction') {
var qty = document.getElementById("qty").value;
ajaxdata = ajaxdata + '&qty='+ qty;
/* The below 3 items were commented out. */
if(typeof $('#txtPointsDonate').val() == 'undefined'){
var pointAmount = 1;
var payAmount = 0;
ajaxdata = ajaxdata + '&point_amount='+ pointAmount + '&pay_amount='+ payAmount;
}
} else if (ajaxevent == 'catAddTravelItemAction') {
ajaxdata = ajaxdata + '&qty=1';
} else if (ajaxevent == 'AddRecurItem'){
var itemFreq = document.getElementById("itemFreq").value;
ajaxdata = ajaxdata + '&itemFreq='+ itemFreq;
}
console.log('Running custom general getAjaxData function, appending: ', ajaxdata);
return additionalRewardOptionParameters(ajaxdata);
}else{
console.log('Passed in rewardMatrixItemId: '+rewardMatrixItemId+' version being used');
var qty = 1;
var ajaxdata = '&item_id='+rewardMatrixItemId ;
if (ajaxevent == 'AddPPItemAction' || ajaxevent == 'AddItemAction' || ajaxevent == 'catAddTravelItemAction') {
ajaxdata = ajaxdata + '&qty='+ qty;
} else if (ajaxevent == 'AddRecurItem'){
var itemFreq = document.getElementById("itemFreq").value;
ajaxdata = ajaxdata + '&itemFreq='+ itemFreq;
}
return ajaxdata;
}
};
}else{
console.log('getAjaxData does not need defining');
}
if (typeof additionalRewardOptionParameters === "undefined"){
var additionalRewardOptionParameters = function(ajaxdata) {
console.log('Running custom additionalRewardOptionParameters, using: ', ajaxdata);
var itemRewardOption = $('input[name=gc_reward_option]').val();
var selectedRewardOptionInput = $('input[name=selected_reward_option]').val();
if (itemRewardOption !== null && itemRewardOption === 'BOTH') {
ajaxdata = ajaxdata + '&ro=' + selectedRewardOptionInput;
} else if(itemRewardOption !== null && itemRewardOption === 'PHYSICAL') {
ajaxdata = ajaxdata + '&ro=' + selectedRewardOptionInput;
} else if(itemRewardOption !== null && itemRewardOption === 'VIRTUAL') {
ajaxdata = ajaxdata + '&ro=' + selectedRewardOptionInput;
}
return ajaxdata;
};
}else{
console.log('additionalRewardOptionParameters does not need defining');
}
/*console.log('addVPPToCart is being overridden to test mobile issue');
function addVPPToCart(ajaxevt, rewardMatrixItemId, pointAmount, payAmount){
console.log('addVPPToCart triggered.');
var ajaxdata = getAjaxData(ajaxevt, rewardMatrixItemId, pointAmount, payAmount);
ajaxdata = ajaxdata + '&point_amount='+ pointAmount + '&pay_amount='+ payAmount;
showLoader();
readTextWithPost('/rewards/AjaxDataServlet/', 'ajaxEvent='+ajaxevt+'&ajaxData='+ajaxdata, function(ajaxdata){});
}*/
/* Hotpoint Pay */
var applyTransactionAccordion = function() {
if($('#tetable').length>0){
console.log('Found tetable');
setTimeout(function(){
if($('#tetable ul li').length>0){console.log('Found '+$('#tetable ul li').length+' li tags in table');}
$('#tetable ul li').each(function(){
if($(this).attr('data-dtr-index') == 3){
if($.trim($(this).find('.dtr-data').text()).length==0){
console.log('Found a hotpoints_to_redeem node: ', $(this).find('#amt').val(), $(this).find('#rate').val(), $(this).find('#amt').val()/$(this).find('#rate').val());
var hotpoints_to_redeem = $(this).find('#amt').val()/$(this).find('#rate').val();
$(this).find('.dtr-data').prepend(hotpoints_to_redeem.toFixed(2));
}
}
});
}, 100);
}
};
/*var updateTables = function() {
if (($(window).width() < 767) && !switched ){
switched = true;
$("table.responsive").each(function(i, element) {
splitTable($(element));
});
applyTransactionAccordion();
return true;
}
else if (switched && ($(window).width() > 767)) {
switched = false;
$("table.responsive").each(function(i, element) {
unsplitTable($(element));
});
}
};*/
if (typeof addByEvtDetail === "undefined"){
console.log('Defining own addByEvtDetail function');
var addByEvtDetail = function(ajaxevt, rmids, qtys) {
var element = document.getElementById('postaction');
if (typeof(element) != 'undefined' && element != null) {
document.getElementById("postaction").value = ajaxevt;
}
if (ajaxevt == 'AddItemAction'){
var showEMailPopUp = false;
if(!showEMailPopUp) {
var cartHasItems = typeof document.getElementById("cartHasItems") == 'undefined' || document.getElementById("cartHasItems") == null || document.getElementById("cartHasItems").value == null ? 'false' : document.getElementById("cartHasItems").value;
if (typeof document.getElementById("supportRecurRedeem") != 'undefined' && document.getElementById("supportRecurRedeem") != null && document.getElementById("supportRecurRedeem").value == 'true') {
var cartHasRecurItem = document.getElementById("cartHasRecurItem").value;
var itemRecurRedeem = document.getElementById("itemRecurRedeem");
if (itemRecurRedeem && itemRecurRedeem.checked) {
ajaxevt = 'AddRecurItem';
document.getElementById("postaction").value = ajaxevt;
if (cartHasItems == 'true') {
var modal = new SURPREENDA.Modal({ el : '#tpl_lightbox_has_recur_item' , defaults : { width: 350 } });
$("form#form_recur_item fieldset p").text('Your shopping cart contains item(s) that will be cleared before this recurring item is added.');
document.getElementById("originalAction").value = ajaxevt;
} else {
doAjaxCall10088( ajaxevt, rmids, qtys );
}
} else {
if (cartHasRecurItem == 'true') {
var modal = new SURPREENDA.Modal({ el : '#tpl_lightbox_has_recur_item' , defaults : { width: 350 } });
$("form#form_recur_item fieldset p").text('Your shopping cart contains a recurring item that will be cleared before this item is added.');
document.getElementById("originalAction").value = ajaxevt;
} else {
doAjaxCall10088( ajaxevt, rmids, qtys );
}
}
} else {
doAjaxCall10088( ajaxevt, rmids, qtys );
}
}
}
};
}else{
console.log('addByEvtDetail does not need defining');
}
if (typeof doAjaxCall10088 === "undefined"){
var doAjaxCall10088 = function( ajaxevt , rmids, qtys) {
console.log('Using Own version of doAjaxCall10088 function.', ajaxevt);
if (rmids == null) {
ajaxdata = getAjaxData(ajaxevt);
} else {
ajaxdata = getAjaxDataForConsolidated(ajaxevt, rmids, qtys);
}
showLoader();
readTextWithPost('/rewards/AjaxDataServlet/', 'ajaxEvent='+ajaxevt+'&ajaxData='+ajaxdata, AjaxCallBack10088);
};
var AjaxCallBack10088 = function( ajaxdata ) {
console.log('Using Own version of AjaxCallBack10088 function.', ajaxdata);
var action = '';
if(typeof document.getElementById("postaction") != 'undefined' && document.getElementById("postaction") != null){
var action = document.getElementById("postaction").value;
}
console.log(ajaxdata);
document.getElementById("form_10088").innerHTML = ajaxdata;
if (action == 'AddPPItemAction' || action == 'AddItemAction' || action == 'AddRecurItem') {
if (document.getElementById("errorMsg") !==null && document.getElementById("errorMsg").value != ''){
document.getElementById("qty").value = document.getElementById("selqty").value;
}
} else if (action == 'catAddTravelItemAction') {
if (document.getElementById("errorMsg") !==null && document.getElementById("errorMsg").value != ''){
doSubmitTravelItem();
}
}
};
}else{
console.log('doAjaxCall10088 & AjaxCallBack10088 does not need defining');
}
var myEle2 = document.getElementById("SPN_CHECKOUT");
console.log('myEle2: ', myEle2);
if(myEle2 != null){
console.log('SPN_CHECKOUT exists so Defining AjaxCallBack10106');
var AjaxCallBack10106 = function( ajaxdata ) {
console.log('Using Overriden version of AjaxCallBack10106 function.');
$.fancybox.hideActivity();
document.getElementById('ajaxEventDiv').innerHTML = ajaxdata;
showPopup();
updateState();
disableSecondaryShippingOnLoad();
if(document.getElementById('initiate-authentication-script') != null){
initAuthResponseExists = true;
eval(document.getElementById('initiate-authentication-script').text);
}
/*console.log('Before');
setTimeout(function () {
if(document.getElementById('threedsFrictionLessRedirect') != null){console.log('Friction');
document.getElementById('threedsFrictionLessRedirect').setAttribute("style","height: 100hv");
}
if(document.getElementById('challengeFrame') != null){ console.log('IFrame');
document.getElementById('challengeFrame').setAttribute("style","height: 100%;width: 100%");
}
}, 2000);*/
/* applyTotalCheckoutFooter('SPN_CHECKOUT'); */
applyCheckoutStyling();
$.fancybox.hideActivity();
if($('#fancybox-loading').css('display')=='block'){
$('#fancybox-loading').hide();
}
};
}else{
console.log('AjaxCallBack10106 does not need defining');
}
var BreadCrumbAjaxCallBack10085 = function( ajaxdata ) {
document.getElementById('breadcrumb').innerHTML = ajaxdata;
processCrumbtrail();
};
var processCrumbtrail = function() {
if($('#breadcrumb').length) {
$( "ul#breadcrumb li" ).each(function( index ) {
var bst = $(this).html();
if(bst.indexOf(">")){
bst = bst.replace(/>/g, '/');
$(this).html(bst);
}
/*console.log('Found crumbtrail element: ', $.trim($( this ).text()), $.trim($( this ).find( "a" ).text()));*/
if($.trim($( this ).find( "a" ).text()) == 'Shop the Catalog'){
$( this ).remove();
}
});
}
};
var removeNaviagateHeaderMenu = function(link_str) {
var split = link_str.split("naviagateHeaderMenu(");
var split2 = split[1].indexOf("?") !== -1 ? split[1].split("?") : split[1].split(",");
var url_to_return = split2[0];
return url_to_return;
};
var getUrlFromHref = function(link_str) {
var url_to_return = link_str.substr(0, link_str.indexOf("?"));
return url_to_return;
};
console.log('defining own refreshShopCategoryTitle function');
var refreshShopCategoryTitle = function() {
function done(result) {
console.log('refreshShopCategoryTitle Done Called');
var shopCategoryContainer = document.getElementById('container_shop_category_title');
if (shopCategoryContainer) {
shopCategoryContainer.innerHTML = result;
if($('#container_shop_category_title .shop_category_title').length>0){
$('#container_shop_category_title .shop_category_title').html($.trim($('#container_shop_category_title .shop_category_title').html())+'.');
console.log('refreshShopCategoryTitle changed title to '+$.trim($('#container_shop_category_title .shop_category_title').html()));
applySubCategoryStyling('refreshShopCategoryTitle');
}
refreshRewardsByPointsBalanceTitle();
}
}
console.log('refreshShopCategoryTitle Called, Currently: ', document.getElementById('container_shop_category_title').innerHTML);
readTextWithPost('/rewards/AjaxDataServlet/','ajaxEvent=refreshShopCategoryTitle', done, -1, -1);
};
var applyCSRFToken = function(csrf_link) {
bm_csrf_tkn = getCSRFToken();
if(bm_csrf_tkn !== 'undefined' && bm_csrf_tkn.length>0){
return csrf_link.indexOf("?") === -1 ? csrf_link+'?csrf_token='+bm_csrf_tkn : csrf_link+'&csrf_token='+bm_csrf_tkn
}
return;
};
var searchForCSRFToken = function() {
if(typeof bm_csrf_tkn !== 'undefined' && bm_csrf_tkn.length>0){
/*console.log('Found csrf links to replace: ', $( "a.csrfadd" ).length);*/
$( "a.csrfadd" ).each(function( index ) {
if($( this ).attr('href').indexOf("csrf_token=") === -1){
$( this ).attr('href', applyCSRFToken($( this ).attr('href')));
}
if(typeof $( this ).attr('data-add-anchor') != 'undefined' && $( this ).attr('data-add-anchor').length>0){
$( this ).attr('href', $( this ).attr('href')+'#'+$( this ).attr('data-add-anchor'));
}
});
/* If we want to add to buttons or forms add additional code here */
}
};
var stickyMenu = function(triggeredOnResize) {
scroll_top = $(document).scrollTop();
var compare_with = isMobile() ? menu_top_mobile : menu_top;
var tag = isMobile() ? '.header_nav_row' : '.header_top_row';
var tag_rev = isMobile() ? '.header_top_row' : '.header_nav_row';
//