if(typeof(BitlyApi)=="undefined"){var BitlyApi={}}if(typeof(BitlyCB)=="undefined"){var BitlyCB={}}BitlyApi.loadScript=function(b){var a=document.createElement("script");a.setAttribute("language","javascript");a.setAttribute("type","text/javascript");a.setAttribute("src",b);document.body.appendChild(a)};BitlyApi.loadCss=function(a){var b=document.createElement("link");b.setAttribute("type","text/css");b.setAttribute("href",a);b.setAttribute("rel","stylesheet");b.setAttribute("media","screen");try{document.getElementsByTagName("head")[0].appendChild(b)}catch(c){document.body.appendChild(b)}};BitlyApi.call=function(f,e,b){var c="http://api.bit.ly/"+f;if(location.protocol.indexOf("https")==0){c="https://api-ssl.bitly.com/"+f}var d=[];if(b){d.push("callback="+b)}for(var a in e){d.push(a+"="+encodeURIComponent(e[a]))}c+="?"+d.join("&");BitlyApi.loadScript(c)};var BitlyApiClient=function(b,c,a){this.login=b||"ignitiondemo";this.apiKey=c||"R_d73761d72f399d10ef7632db3e1cb609";this.version=a||"2.0.1"};BitlyApiClient.prototype.googleVisRequired="This method requires the google visualization api. Please include javascript from: http://www.google.com/jsapi. More info: http://code.google.com/apis/visualization/documentation/index.html";BitlyApiClient.prototype.availableModules=["stats"];BitlyApiClient.prototype.loadingModules={};BitlyApiClient.prototype.moduleLoaded=function(module_name,callback_method_name){BitlyApiClient.prototype.loadingModules[module_name]=true;for(var mod in BitlyApiClient.prototype.loadingModules){if(!BitlyApiClient.prototype.loadingModules[mod]){return false}}eval(callback_method_name+"();")};BitlyApiClient.prototype.loadModules=function(a,d){for(var f=0;f<a.length;f++){BitlyApiClient.prototype.loadingModules[a[f]]=false}for(var f=0;f<a.length;f++){var c=a[f];var b="module_"+c+"_loaded";BitlyCB[b]=function(){BitlyApiClient.prototype.moduleLoaded(c,d)};var g="http://bit.ly/app/modules/"+c+".js?callback=BitlyCB."+b;try{BitlyApi.loadScript(g)}catch(h){BitlyClient.addPageLoadEvent(function(){BitlyApi.loadScript(g)})}}try{BitlyApi.loadCss("http://bit.ly/static/css/javascript-modules.css")}catch(h){BitlyClient.addPageLoadEvent(function(){BitlyApi.loadCss("http://bit.ly/static/css/javascript-modules.css")})}};BitlyApiClient.prototype.addPageLoadEvent=function(a){var b=window.onload;if(typeof window.onload!="function"){window.onload=a}else{window.onload=function(){b();a()}}};BitlyApiClient.prototype.extractBitlyHash=function(b){if(b==null){return null}else{var a=b.match(/\/([^\/]+)$/);if(a){return a[1]}else{return b}}};BitlyApiClient.prototype.createElement=function(d,b){var c=document.createElement(d);for(var a in b){if(a=="text"){c.appendChild(document.createTextNode(b[a]))}else{this.setAttribute(c,a,b[a])}}return c};BitlyApiClient.prototype.setAttribute=function(b,a,c){if(a=="class"){b.setAttribute("className",c)}return b.setAttribute(a,c)};BitlyApiClient.prototype.listen=function(c,d,b){if(c.addEventListener){c.addEventListener(d,b,false)}else{if(c.attachEvent){var a=c.attachEvent("on"+d,b);return a}}};BitlyApiClient.prototype.targ=function(b){var a;if(!b){var b=window.event}if(b.target){a=b.target}else{if(b.srcElement){a=b.srcElement}}if(a.nodeType==3){a=a.parentNode}return a};BitlyApiClient.prototype.toggle=function(a){var b;if(typeof(a)=="string"){b=document.getElementById(a);if(typeof(b)==undefined){throw"toggle: No DOM element with id: "+a;return}}else{b=a}if(b.style.display=="none"){b.style.display=""}else{b.style.display="none"}};BitlyApiClient.prototype.call=function(c,b,a){b.version=this.version;b.login=this.login;b.apiKey=this.apiKey;return BitlyApi.call(c,b,a)};BitlyApiClient.prototype.shorten=function(b,a){return this.call("shorten",{longUrl:b},a)};BitlyApiClient.prototype.expand=function(b,a){return this.call("expand",{shortUrl:b},a)};BitlyApiClient.prototype.info=function(e,c){var a=e.split(",");var b=[];for(var d=0;d<a.length&&d<1;d++){b.push(this.extractBitlyHash(a[d]))}return this.call("info",{hash:b.join(",")},c)};BitlyApiClient.prototype.stats=function(b,a){b=this.extractBitlyHash(b);return this.call("stats",{hash:b},a)};BitlyApiClient.prototype.shortenTest=function(){this.shorten(document.location,"shortenTestCB")};function shortenTestCB(c){var a;for(var b in c.results){a=c.results[b];a.longUrl=b;break}alert(a.longUrl+" shortened to "+a.shortUrl)}BitlyApiClient.prototype.expandTest=function(){this.expand("http://bit.ly/3j4ir4","expandTestCB")};function expandTestCB(c){var a;for(var b in c.results){a=c.results[b];a.hash=b;break}alert(a.hash+" expanded to "+a.longUrl)}BitlyApiClient.prototype.infoTest=function(){this.info("http://bit.ly/3j4ir4","infoTestCB")};function infoTestCB(b){var c;for(var a in b.results){c=b.results[a];break}alert("got info for "+c.hash+". eg., longUrl is "+c.longUrl+", title is "+c.htmlTitle)}BitlyApiClient.prototype.statsTest=function(){this.stats("http://bit.ly/3j4ir4","statsTestCB")};function statsTestCB(b){var a=b.results;alert("stats for "+a.hash+". "+a.clicks+" clicks")}var BitlyClient=new BitlyApiClient();
