var GLOBAL_givingListChanged = false; function activateHoverClass(id) { if (!$('#' + id).hasClass('clicked')) { $('#' + id).addClass('ui-state-hover'); } } function deactivateHoverClass(id) { if (!$('#' + id).hasClass('clicked')) { $('#' + id).removeClass('ui-state-hover'); } } function adjustSponsorshipButton(addToList, id, btnclass, code) { var displayText = ''; if (code == 'child' || code == 'Child') { displayText = "Sponsor Me Now" } else if (code == 'national worker' || code == 'National Worker') { displayText = "Sponsor Me Now" } else displayText = "Support Now"; if (addToList) { $('#clist-sponsor-now-detail' + id + ' .ui-button-text div').html('In Your Giving Cart') $('#clist-sponsor-now-detail' + id + ' .ui-button-icon-primary').removeClass(btnclass); $('#clist-sponsor-now-detail' + id + ' .ui-button-icon-primary').addClass('ui-icon-cart'); } else { $('#clist-sponsor-now-detail' + id + ' .ui-button-text div').html(displayText) $('#clist-sponsor-now-detail' + id + ' .ui-button-icon-primary').removeClass('ui-icon-cart'); $('#clist-sponsor-now-detail' + id + ' .ui-button-icon-primary').addClass(btnclass); } } function clickHoverClass(id, cname, uiSponsorButtonClass, code, constituentid, goImmediatelyToDonate) { var totalCauses = 0; GLOBAL_givingListChanged = true; var blnSuccess = false; if ($('#addremove' + id).hasClass('clicked')) { window.location = 'https://www.amginternational.org/main/fs/index.cfm?do=donate'; throw new Error("We need to abort and go directly to basket per AMG Admin."); dataString = "CFID=19510260&CFTOKEN=1c78b44e4714cf2d-7059F450-D222-DD0F-667DC5072DFDB52B&jsessionid=E990F7144FA24F15DCFEEE72B0C89A74.cfusion&action=remove&id=" + id; $.ajax({ type: "POST", url: "../ajax/ajax-giving-list.cfm?" + dataString, beforeSend: function() {$("#loadingoverlay" + id).show()}, data: dataString, success: function(data){ var parsedResponse = JSON.parse(data); if (parsedResponse.Error != "true") { $('#give-action' + id).removeClass('ui-icon-minusthick').addClass('ui-icon-plusthick'); $('#addremove' + id).prop("title", "Click this button to add " + cname + " to your giving list.") totalCauses = parseInt($('#causes-chosen').text()); $('#causes-chosen').text(totalCauses - 1); $('#overlay' + id).fadeTo('slow', 1.0); $('#give-amount-' + id).addClass("dont-count"); var totalDesignatedFunds = 0; $.each($('.giving-list-amount'), function(index){ if (!$('.giving-list-amount').eq(index).hasClass("dont-count")) totalDesignatedFunds += parseFloat($('.giving-list-amount').eq(index).text()) }); $('.giving-summary-fund-designation').text(" $" + totalDesignatedFunds.toFixed(2)); $('#addremove' + id).toggleClass('clicked'); blnSuccess = true; } else { $('#error-notification-modal').dialog('option', 'title', 'Unable To Remove ' + cname + ' From Your Giving Cart'); $('#error-notification-modal').dialog('option', 'width', '450px'); $('#error-notification-modal').html("

We apologize for the inconvenience, however, we were unable to remove " + cname + " to your giving cart at this time.

Please try adding " + cname + " at a later time.

Thank you for your understanding."); $('#error-notification-modal').dialog('open'); } }, error: function(data) { $('#error-notification-modal').dialog('option', 'title', 'Unable To Access Your Giving Cart'); $('#error-notification-modal').dialog('option', 'width', '300px'); $('#error-notification-modal').html("

We apologize for the inconvenience, however, we were unable to remove " + cname + " to your giving cart.

This is a technical issue and technical support has been notified.

Please try adding your choice again soon."); $('#error-notification-modal').dialog('open'); }, complete: function() { $("#loadingoverlay" + id).hide(); } }); } else { dataString = "CFID=19510260&CFTOKEN=1c78b44e4714cf2d-7059F450-D222-DD0F-667DC5072DFDB52B&jsessionid=E990F7144FA24F15DCFEEE72B0C89A74.cfusion&action=add&id=" + id + "&constituentid=" + constituentid; $.ajax({ type: "POST", url: "../ajax/ajax-giving-list.cfm?" + dataString, beforeSend: function() {$("#loadingoverlay" + id).show()}, data: dataString, success: function(data){ var parsedResponse = JSON.parse(data); if (parsedResponse.Error != "true") { totalCauses = parseInt($('#causes-chosen').text()); $('#causes-chosen').text(totalCauses + 1); $('#overlay' + id).fadeTo('slow', 0.0); $('#give-amount-' + id).removeClass("dont-count"); var totalDesignatedFunds = 0; $.each($('.giving-list-amount'), function(index){ if (!$('.giving-list-amount').eq(index).hasClass("dont-count")) totalDesignatedFunds += parseFloat($('.giving-list-amount').eq(index).text()) }); $('.giving-summary-fund-designation').text(" $" + totalDesignatedFunds.toFixed(2)); $('#give-action' + id).removeClass('ui-icon-plusthick').addClass('ui-icon-minusthick'); $('#addremove' + id).prop("title", cname + " is currently on your giving list. Click this button to remove " + cname + ".") $('#addremove' + id).toggleClass('clicked'); blnSuccess = true; window.location = 'https://www.amginternational.org/main/fs/index.cfm?do=donate'; } else { $('#error-notification-modal').dialog('option', 'title', 'Unable To Add ' + cname + ' To Your Giving Cart'); $('#error-notification-modal').dialog('option', 'width', '450px'); $('#error-notification-modal').html(parsedResponse.Error_Message); $('#error-notification-modal').dialog('open'); } }, error: function(data) { $('#error-notification-modal').dialog('option', 'title', 'Unable To Access Your Giving Cart'); $('#error-notification-modal').dialog('option', 'width', '300px'); $('#error-notification-modal').html("

We apologize for the inconvenience, however, we were unable to add " + cname + " to your giving cart.

This is a technical issue and technical support has been notified.

Please try adding your choice again soon."); $('#error-notification-modal').dialog('open'); }, complete: function() { $("#loadingoverlay" + id).hide(); } }); } } function popDialog(id, reload, iframeid) { if (id == 'giving-list-dialog') { window.location = 'https://www.amginternational.org/main/fs/index.cfm?do=donate'; throw new Error("We need to abort and go directly to basket per AMG Admin."); } if (reload) { $('#' + iframeid).hide(); $('#giving-list-loader').show('fade',{},400); $('#' + iframeid).prop("src","inc/inc-forms-menu-user-mini.cfm?find=giving_list"); $('#' + id).dialog('open'); $("#" + iframeid).load(function (){ $('#giving-list-loader').hide('fade', {}, 800, function() {$('#' + iframeid).show('fade');}); }); } else $('#' + id).dialog('open'); } function howManyOnList() { return $('.cart-item').length; } function removeConstituentDesignateFundsPage(id, cname, code, constituentid, action) { var totalCauses = 0; var blnSuccess = false; $('.completion-my-donation-btn').attr('disabled', true).addClass('disabled'); $('#loading-cart-contents').text('Saving...'); $('#loading-cart-contents').show(); dataString = "CFID=19510260&CFTOKEN=1c78b44e4714cf2d-7059F450-D222-DD0F-667DC5072DFDB52B&jsessionid=E990F7144FA24F15DCFEEE72B0C89A74.cfusion&action=remove&id=" + id; var content = ''; $.ajax({ type: "POST", url: "../ajax/ajax-giving-list.cfm?" + dataString, beforeSend: function() {$("#loadingoverlay" + id).show();$('#submit-button').prop('disabled', true);}, data: dataString, success: function(data){ var parsedResponse = JSON.parse(data); if (parsedResponse.Error != "true") { blnSuccess = true; $("#loadingoverlay" + id).hide(); $('#loading-cart-contents').text('Saved.'); $('#cart-wrapper' + id).hide('blind', {}, 500, function() { $('#cart-wrapper' + id).remove(); if (howManyOnList() == 0) { urgentValue = parseFloat($('#cid10000000').val()); specialValue = parseFloat($('#cid10000003').val()); if ($('#cart-wrapper10000000').is(":hidden")) $('#cart-wrapper10000000').show('blind'); if ($('#cart-wrapper10000003').is(":hidden")) $('#cart-wrapper10000003').show('blind'); if ($('#general-giving-left').is(":hidden")) $('#general-giving-left').show('blind'); if ($('#general-header').is(":hidden")) { $('#general-header').show('blind'); } } adjustSummaryFigures(); }); } else { $('#error-notification-modal').dialog('option', 'title', 'Unable To Remove ' + cname + ' From Your Giving Cart'); $('#error-notification-modal').dialog('option', 'width', '450px'); $('#error-notification-modal').html("

We apologize for the inconvenience, however, we were unable to remove " + cname + " to your giving cart at this time.

Please try adding " + cname + " at a later time.

Thank you for your understanding."); $('#error-notification-modal').dialog('open'); } }, error: function(data) { $('#error-notification-modal').dialog('option', 'title', 'Unable To Access Your Giving Cart'); $('#error-notification-modal').dialog('option', 'width', '300px'); $('#error-notification-modal').html("

We apologize for the inconvenience, however, we were unable to remove " + cname + " to your giving cart.

This is a technical issue and technical support has been notified.

Please try adding your choice again soon."); $('#error-notification-modal').dialog('open'); }, complete: function() { $('#loading-cart-contents').hide(); GLOBAL_givingListChanged = true; } }); } function addConstituentDesignateFundsPage(id, cname, code, constituentid, action) { var totalCauses = 0; var blnSuccess = false; $('.completion-my-donation-btn').attr('disabled', true).addClass('disabled'); var GivingListNumber = howManyOnList(); dataString = "CFID=19510260&CFTOKEN=1c78b44e4714cf2d-7059F450-D222-DD0F-667DC5072DFDB52B&jsessionid=E990F7144FA24F15DCFEEE72B0C89A74.cfusion&action=add&id=" + id + "&constituentid=" + constituentid; if (GivingListNumber >= 10) { $('#error-notification-modal').dialog('option', 'title', 'Your Giving Cart Is Full'); $('#error-notification-modal').dialog('option', 'width', '300px'); $('#error-notification-modal').html("

You can have up to 10 causes in your Giving Cart at one time.

In order to add more causes, you can either remove an opportunity from your Giving Cart or Complete Your Donation.

AMG International."); $('#error-notification-modal').dialog('open'); } else { $.ajax({ type: "POST", url: "ajax/ajax-giving-list.cfm?" + dataString, beforeSend: function() { if (GivingListNumber >= 10) throw 10001; $("#checkoutaddbtn" + id).val('Adding...').prop("disabled",true); $('#loading-cart-contentsdirected').text('Saving...'); $('#loading-cart-contentsdirected').show(); }, data: dataString, success: function(data){ var parsedResponse = data if (parsedResponse.Error != "true") { blnSuccess = true; $("#loadingoverlay" + id).hide(); $('#loading-cart-contentsdirected').text('Saved'); $("#checkoutaddbtn" + id).val('Added'); $("#crosssell" + id).hide('drop',{},500, function() { $("#crosssell" + id).remove(); var numberToLoad = 3 - $('#crossSellCheckoutUL li').length; loadMoreCrossSell(numberToLoad); }); reloadCheckoutCartList() } else { $('#error-notification-modal').dialog('option', 'title', 'Unable To Remove ' + cname + ' From Your Giving Cart'); $('#error-notification-modal').dialog('option', 'width', '450px'); $('#error-notification-modal').html("

We apologize for the inconvenience, however, we were unable to add " + cname + " to your giving cart at this time.

Please try adding " + cname + " at a later time.

Thank you for your understanding."); $('#error-notification-modal').dialog('open'); } }, error: function(data) { $('#error-notification-modal').dialog('option', 'title', 'Unable To Access Your Giving Cart'); $('#error-notification-modal').dialog('option', 'width', '300px'); $('#error-notification-modal').html("

We apologize for the inconvenience, however, we were unable to add " + cname + " to your giving cart.

This is a technical issue and technical support has been notified.

Please try adding your choice again soon."); $('#error-notification-modal').dialog('open'); $("#checkoutaddbtn" + id).val('Add Now').prop("disabled",false); }, complete: function() { GLOBAL_givingListChanged = true; $('#loading-cart-contentsdirected').text(''); } }); } } function reloadCheckoutCartList() { $('#loading-cart-contents').text('Loading...'); $('#loading-cart-contents').show(); var jqxhr = $.get( "inc/inc-donate-with-cart-section-giving-cart-list-contents.cfm?CFID=19510260&CFTOKEN=1c78b44e4714cf2d-7059F450-D222-DD0F-667DC5072DFDB52B&jsessionid=E990F7144FA24F15DCFEEE72B0C89A74.cfusion", function(data) { $( "#cart-wrapper" ).hide('drop', {}, 500, function() { $( "#cart-wrapper" ).html( data ); $('#loading-cart-contents').show(); $('#loading-cart-contents').text('Loaded.'); $( "#cart-wrapper" ).show('drop',{direction: "right"}, 500, function() { $('#loading-cart-contents').hide('fade', {}, 500); if (howManyOnList() > 0) { urgentValue = parseFloat($('#cid10000000').val()); specialValue = parseFloat($('#cid10000003').val()); if (urgentValue == 0 && !$('#cart-wrapper10000000').is(":hidden")) $('#cart-wrapper10000000').hide('blind'); if (specialValue == 0 && !$('#cart-wrapper1000003').is(":hidden")) $('#cart-wrapper10000003').hide('blind'); if (specialValue == 0 && urgentValue == 0 && !$('#general-giving-left').is(":hidden")) $('#general-giving-left').hide('blind'); } adjustSummaryFigures(); }); }); }) .done(function() { }) .fail(function() { $('#error-notification-modal').dialog('option', 'title', 'Unable To Load Your Giving Cart'); $('#error-notification-modal').dialog('option', 'width', '300px'); $('#error-notification-modal').html("

We apologize for the inconvenience, however, we were unable to load your giving cart.

This is a technical issue and technical support has been notified.

Please try again soon."); $('#error-notification-modal').dialog('open'); }); } function loadMoreCrossSell(size) { var currentCrossSell = ''; $.each($('.hiddenCrossSell'), function(index){ currentCrossSell = $('.hiddenCrossSell').eq(index).val() + ',' + currentCrossSell; }); var jqxhr = $.get( "inc/inc-donate-with-cart-cross-sell-list-contents.cfm?CFID=19510260&CFTOKEN=1c78b44e4714cf2d-7059F450-D222-DD0F-667DC5072DFDB52B&jsessionid=E990F7144FA24F15DCFEEE72B0C89A74.cfusion&size=" + size + '¤tcrosssell=' + currentCrossSell, function(data) { $('#crossSellCheckoutUL').append(data); }) .done(function() { }) .fail(function() { $('#error-notification-modal').dialog('option', 'title', 'Unable To Load Your Giving Cart'); $('#error-notification-modal').dialog('option', 'width', '300px'); $('#error-notification-modal').html("

We apologize for the inconvenience, however, we were unable to load your giving cart.

This is a technical issue and technical support has been notified.

Please try again soon."); $('#error-notification-modal').dialog('open'); }); } function updateCartItem(id,cart,showModeMessage) { var totalCauses = 0; var blnSuccess = false; var mode = $('#mode' + id).val() var center = $('#center' + id).val(); var code = $('#code' + id).val(); var amount = 0; var dropdownamount = parseFloat($('#cid_s' + id).val()); var inputamount = parseFloat(stripCharsInBag($('#cid' + id).val(),"$,")); var additionalamount = parseFloat(stripCharsInBag($('#amount-additional' + id).val(), "$,")); var specialgift = $('#specialgift' + id).val(); var specialgift_other = $('#specialgift_other' + id).val(); switch (mode) { case 'Single' : modeamountid = 'amount-single' + id; break; case 'Per Month' : modeamountid = 'amount-monthly' + id; if ($('#mode-change-message').is(":hidden") && showModeMessage) { $('#mode-change-message').show('blind', {}, 500); } break; case 'Per Year' : modeamountid = 'amount-annually' + id; if ($('#mode-change-message').is(":hidden") && showModeMessage) { $('#mode-change-message').show('blind', {}, 500); } break; } switch (dropdownamount) { case 0: // we are dealing with an input box amount = inputamount; break; default: // we are dealing with a drop-down menu amount = dropdownamount; } dataString = "CFID=19510260&CFTOKEN=1c78b44e4714cf2d-7059F450-D222-DD0F-667DC5072DFDB52B&jsessionid=E990F7144FA24F15DCFEEE72B0C89A74.cfusion&action=update&id=" + id + "&amount=" + amount + "&additionalamount=" + additionalamount + "&mode=" + mode + "&specialgift=" + specialgift + "&specialgift_other=" + specialgift_other + "&cart=" + cart; var addOnID = ''; if (id == 10000001) { addOnID = 10000001; } $.ajax({ type: "POST", url: "ajax/ajax-giving-list.cfm?" + dataString, beforeSend: function() { $('#loading-cart-contents' + cart + addOnID).text('Saving...'); $('#loading-cart-contents' + cart + addOnID).show(); }, data: dataString, success: function(data){ var parsedResponse = data if (parsedResponse.Error != "true") { blnSuccess = true; $('#loading-cart-contents' + cart + addOnID).text('Saved.'); $('#loading-cart-contents' + cart + addOnID).hide('fade',{},800); } else { $('#error-notification-modal').dialog('option', 'title', 'Unable To Remove ' + cname + ' From Your Giving Cart'); $('#error-notification-modal').dialog('option', 'width', '450px'); $('#error-notification-modal').html("

We apologize for the inconvenience, however, we were unable to remove " + cname + " to your giving cart at this time.

Please try adding " + cname + " at a later time.

Thank you for your understanding."); $('#error-notification-modal').dialog('open'); } }, error: function(data) { $('#error-notification-modal').dialog('option', 'title', 'Unable To Access Your Giving Cart'); $('#error-notification-modal').dialog('option', 'width', '300px'); $('#error-notification-modal').html("

We apologize for the inconvenience, however, we were unable to remove " + cname + " to your giving cart.

This is a technical issue and technical support has been notified.

Please try adding your choice again soon."); $('#error-notification-modal').dialog('open'); }, complete: function() { } }); }