/** @constructor */function Http(a){this.prefix=a||"cache"}function Cookie(a){this.doc=a||document}function Bysshe(a){this.cookie=a}Bysshe.prototype.getUserId=function(){this.cookie.get("userid")||this.cookie.set("userid",(Math.random()+Math.pow(10,-9)).toString().substr(2,8),15768e4);return this.cookie.get("userid")},Bysshe.prototype.getSessionId=function(){this.cookie.get("sessionid")?this.cookie.set("sessionid",this.cookie.get("sessionid"),1800):this.cookie.set("sessionid",(Math.random()+Math.pow(10,-9)).toString().substr(2,8).toString(16),1800);return this.cookie.get("sessionid")},Bysshe.prototype.setPathnameData=function(a,b,c){var d=this.cookie.getObj("bysshe",{});d[a]={t0:b,region:c},this.cookie.setObj("bysshe",d,30)},Bysshe.prototype.getPathnameData=function(a){var b=this.cookie.getObj("bysshe",{});return b[a]?b[a]:{t0:null,region:null}},Bysshe.prototype.resetPathnameData=function(a){var b=this.cookie.getObj("bysshe",{});delete b[a];return this.cookie.setObj("bysshe",b,30)},Bysshe.prototype.getLocation=function(){var a={latitude:null,longitude:null,city:null,country:null};if(typeof google!="undefined"&&google.loader.ClientLocation){var b=google.loader.ClientLocation;a.latitude=b.latitude,a.longitude=b.longitude,a.city=b.address.city,a.country=b.address.country}return a},Bysshe.prototype.getInfo=function(){var a=this.getLocation(),b=this.getPathnameData(document.location.pathname),c=b.t0,d=window.t1,e=new Date;return{url:document.URL,title:document.title,referrer:document.referrer,status:document.status?document.status:200,userid:this.getUserId(),sessionid:this.getSessionId(),localtime:e.getTime()-e.getTimezoneOffset()*60*1e3,width:$(document.body).getWidth(),region:b.region,loadtime0:c?e.getTime()-c:null,loadtime1:d?e.getTime()-d:null,latitude:a.latitude,longitude:a.longitude,city:a.city,country:a.country}},Cookie.prototype.set=function(a,b,c,d){d||(d="/"),this.doc.cookie=a+"="+encodeURIComponent(b)+"; max-age="+c+"; path="+d},Cookie.prototype.setObj=function(a,b,c,d){this.set(a,Object.toJSON(b),c,d)},Cookie.prototype.get=function(a,b){var c=this.doc.cookie,d=c.indexOf(a+"=");if(d!=-1){var e=d+a.length+1,f=c.indexOf(";",e);f==-1&&(f=c.length);var g=c.substring(e,f);return decodeURIComponent(g)}return b},Cookie.prototype.getObj=function(a,b){var c=this.get(a);return c?c.evalJSON():b},Http.prototype._hasLocalStorage=function(){try{return"localStorage"in window&&window.localStorage!==null}catch(a){return!1}},Http.prototype._request=function(a,b){var c="callback"+(Math.random()+Math.pow(10,-9)).toString().substr(2,8);window[c]=function(){b.apply(null,arguments);var a=document.getElementById(c);a.parentNode.removeChild(a),delete window[c]};var d=document.createElement("script");d.type="text/javascript",d.async=!0,d.id=c,d.src=a.url.replace(/\{callback\}/,c);var e=document.getElementsByTagName("script")[0];e.parentNode.insertBefore(d,e)},Http.prototype.request=function(a,b,c){var d={url:a,maxAge:c||300};if(this._hasLocalStorage()){var e="cache."+a,f=window.localStorage[e]&&JSON.parse(window.localStorage[e]);if(f){var g=(new Date).getTime();if(g-f.date<d.maxAge*1e3){b.apply(null,f.body);return}delete window.localStorage[e]}this._request(d,function(){try{window.localStorage[e]=JSON.stringify({date:(new Date).getTime(),body:Array.prototype.slice.call(arguments)})}catch(a){}b.apply(null,arguments)})}else this._request(d,b)},document.observe("dom:loaded",function(){var a=new Bysshe(new Cookie(document));document.observe("click",function(b){var c=b.element();c.tagName.toLowerCase()!="a"&&(c=c.up("a"));if(!!c){var d=c.pathname;while(c.id===""&&c!=document.body)c=c.parentNode;a.setPathnameData(d,(new Date).getTime(),c.id)}}),new Ajax.Request("/api/visit/",{method:"POST",parameters:a.getInfo(),onSuccess:function(a){var b=new Template(["<h2>Stats</h2>",'<ul class="flat">',"<li>Views last month: <strong>#{hits}</strong></li>","<li>Last viewed: #{last_hit}</li>",'<li><img src="#{sparkline.url}" width="#{sparkline.width}" height="#{sparkline.height}" alt="Hits over last 28 days" title="Hits over last 28 days" id="sparkline"/></li>',"</ul>"].join("\n"));a.responseJSON.last_hit=a.responseJSON.last_hit.replace(/^(\d+)/,"<strong>$1</strong>"),$("stats")&&$("stats").update(b.evaluate(a.responseJSON))}})}),document.observe("dom:loaded",function(){if(!!$("twitter")&&!!$("stats")){var a=function(a){function e(a){a.text=a.text.replace(/https?:\/\/\S+[\w\/]/g,function(a){return a.link(a)}),a.text=a.text.replace(/[@#]\w+/g,function(a){return a[0]=="@"?a.link("http://twitter.com/#!/"+a.substr(1)):a.link("http://search.twitter.com/search?q=%23"+a.substr(1))});return a}function d(a){return!a.in_reply_to_status_id}var b=new Template(['<h2>Twitter <a href="http://twitter.com/ithinkihaveacat"><img src="https://si0.twimg.com/images/dev/cms/intents/bird/bird_blue/bird_16_blue.png" width="16" height="16"/></a></h2>',"#{tweets}"].join("\n")),c=new Template(['<p>#{text}&#160;<a href="https://twitter.com/intent/tweet?in_reply_to=#{id_str}"><img title="Reply" src="https://si0.twimg.com/images/dev/cms/intents/icons/reply.png" style="position: absolute" width="16" height="16"/></a></p>'].join("\n"));$("twitter").update(b.evaluate({tweets:$A(a).filter(d).map(e).map(function(a){return c.evaluate(a)}).slice(0,5).join("\n")})),$("twitter").show(),$("stats").show(),$("elsewhere").show()},b=new Http;b.request("https://api.twitter.com/1/statuses/user_timeline.json?screen_name=ithinkihaveacat&trim_user=1&callback={callback}",a)}}),document.observe("dom:loaded",function(){$(document.body).hasClassName("album")&&function(){var a=$(document.body);a.insert({bottom:['<div class="resizer" style="display: none">',"<p>Hey! Resize me to get bigger pics!</p>","</div>"].join("\n")});var b=$$(".resizer")[0];new PeriodicalExecuter(function(){screen.width>1256&&a.getWidth()<1256?b.show():b.hide()},.4)}()})
