( function() {
                        var sendCookie = function() {
                            var cookieId = Bloomerang.Util.getCookie('bloomerangConstituent');       
                            var accountId = Bloomerang.Util.getQueryStringValue('blm_aid');                 

                            var success = function(result) { 
                                if(result.IsSuccess) {
                                    document.cookie = 'bloomerangConstituent=' + result.CookieId + '; expires=' + new Date('2038/01/01').toUTCString() + '; path=/';
                                    var secureDonationLink = jQuery('#bloomerangSecureDonationLink');
                                    if(secureDonationLink.length > 0 && secureDonationLink.attr('href').indexOf('BloomerangCookieId') == -1) {
                                        secureDonationLink.attr('href', secureDonationLink.attr('href') + '&BloomerangCookieId=' + result.CookieId);
                                    }
                                }
                            };

                            var visit = { CookieId: cookieId, 
                                AccountId: accountId,
                                Url: window.location.href, 
                                Referrer: document.referrer };

                            Bloomerang.useKey('pub_3e8531cc-cfc0-11ed-ba02-0229dc8379ef');

                            Bloomerang.Api._post('v1/WebsiteVisit/', visit, success);
                        };
                var startBloomerangLoad = function() {
                    if (window.bloomerangLoadStarted == undefined) {
                        window.bloomerangLoadStarted = true;
                        var script = document.createElement('script');
                        script.type = 'text/javascript';
                        script.src = 'https://crm.bloomerang.co/Content/Scripts/Api/Bloomerang-v2.js?nocache=1734641697';
                        document.getElementsByTagName('head')[0].appendChild(script);
                        waitForBloomerangLoad(sendCookie);
                    }
                    else {
                        waitForBloomerangLoad(sendCookie);
                    }
                };

                var waitForBloomerangLoad = function(callback) {
                    if (typeof(Bloomerang) === 'undefined' || !Bloomerang._isReady) {
                        setTimeout(function () { waitForBloomerangLoad(callback) }, 500);
                    }
                    else {
                        if (true) {
                            callback();
                        } else {
                            window.bloomerangLoadStarted = undefined;
                            Bloomerang = undefined; // The version of Blomerang.js is not what we want. So blow it away and reload.
                            startBloomerangLoad();
                        }
                    }
                };

                startBloomerangLoad();})();