(function() { var Base64 = { // private property _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", // public method for decoding decode: function(input) { var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); while (i < input.length) { enc1 = this._keyStr.indexOf(input.charAt(i++)); enc2 = this._keyStr.indexOf(input.charAt(i++)); enc3 = this._keyStr.indexOf(input.charAt(i++)); enc4 = this._keyStr.indexOf(input.charAt(i++)); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; output = output + String.fromCharCode(chr1); if (enc3 != 64) { output = output + String.fromCharCode(chr2); } if (enc4 != 64) { output = output + String.fromCharCode(chr3); } } output = Base64._utf8_decode(output); return output; }, // private method for UTF-8 decoding _utf8_decode: function(utftext) { var string = ""; var i = 0; var c = c1 = c2 = 0; while (i < utftext.length) { c = utftext.charCodeAt(i); if (c < 128) { string += String.fromCharCode(c); i++; } else if ((c > 191) && (c < 224)) { c2 = utftext.charCodeAt(i + 1); string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); i += 2; } else { c2 = utftext.charCodeAt(i + 1); c3 = utftext.charCodeAt(i + 2); string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); i += 3; } } return string; } } function old_button_support(params){ old_button_colors = ['orange', 'teal', 'yellow'] old_button_size = ['mini'] params_array = params.split(",") if (old_button_colors.indexOf(params_array[2]) != -1){ params_array[2] = 'blue' } if (old_button_size.indexOf(params_array[1]) != -1){ params_array[1] = 'simple' } params = params_array.join(",") return params; } // allows multiple scripts to be executed, because scripts are loaded in order // the last script found should always be the script we're dealing with. var scripts = document.getElementsByTagName("script"); var scriptId = scripts.length var script = null; var showButton = true; var length = scripts.length; while(length--) { script = scripts[length] if(script.id == "chimp-button-script") { if(script.getAttribute("data-hide-button") == "true") { showButton = false; } if(script.getAttribute("data-script-id")) { scriptId = script.getAttribute("data-script-id"); } break; } } var path = script.src.split("/"); var protocol = path[0]; var host = path[2]; var origin = protocol + "//" + host; var parent_url = window.top.location.href; // the following allows us to pass in encoded or unencoded parameterts, essentially // if the parameter string doesn't end with ",unencoded" then we assume it's a base // 64 encoded string. var params = decodeURIComponent(script.src.split("?")[1]); var unencoded = ",unencoded" if(params.indexOf(unencoded, params.length - unencoded.length) == -1) { params = Base64.decode(params); params = old_button_support(params); } else { // remove the unencoded string from the params params = params.substring(0, params.length - unencoded.length) params = old_button_support(params); } var splitParams = params.split(",") var objectId = splitParams[0]; // can't extract parameters via window.location.search var size = splitParams[1]; var color = splitParams[2]; var name = splitParams[3]; var type = "beneficiary"; if(splitParams.length > 4) { type = splitParams[4]; type = type.toLowerCase(); } var production = (["chimp.net", "my.charitableimpact.com", "www.charitableimpact.com"].indexOf(host) != -1 ? "true" : "false") var button = protocol + "//" + host + "/widget/button-" + color + "-" + size + ".html?" + type + "=" + objectId + "&scriptId=" + scriptId + "&name=" + encodeURIComponent(name) + "&production=" + production; // absolute path of button based on where this script was loaded var form = protocol + "//" + host + "/widget/form.html?" + type + "=" + objectId + "&name=" + encodeURIComponent(name) + "&scriptId=" + scriptId + "&parentUrl=" + encodeURIComponent(parent_url) + "&production=" + production; var width = "275px;"; var height = "106px;"; if(size == "mini") { width = "207px"; height = "82px"; } button = button.replace(/'/g, "'").replace(/"/g, """); form = form.replace(/'/g, "'").replace(/"/g, """); if( document.getElementById('charitableimpact_widget_button') ) { var iframe_1 = ""; if(showButton) { iframe_1 += "