var Mustache=function(){var g={},m=function(){};m.prototype={otag:"{{",ctag:"}}",pragmas:{},buffer:[],pragmas_implemented:{"IMPLICIT-ITERATOR":true},context:{},render:function(a,b,c,d){if(!d)this.context=b,this.buffer=[];if(!this.includes("",a))if(d)return a;else{this.send(a);return}var a=this.render_pragmas(a),e=this.render_section(a,b,c);e===false&&(e=this.render_tags(a,b,c,d));if(d)return e;else this.sendLines(e)},send:function(a){a!==""&&this.buffer.push(a)},sendLines:function(a){if(a)for(var a=
a.split("\n"),b=0;b<a.length;b++)this.send(a[b])},render_pragmas:function(a){if(!this.includes("%",a))return a;var b=this,c=this.getCachedRegex("render_pragmas",function(a,b){return RegExp(a+"%([\\w-]+) ?([\\w]+=[\\w]+)?"+b,"g")});return a.replace(c,function(a,c,h){if(!b.pragmas_implemented[c])throw{message:"This implementation of mustache doesn't understand the '"+c+"' pragma"};b.pragmas[c]={};h&&(a=h.split("="),b.pragmas[c][a[0]]=a[1]);return""})},render_partial:function(a,b,c){a=this.trim(a);if(!c||
c[a]===void 0)throw{message:"unknown_partial '"+a+"'"};return typeof b[a]!="object"?this.render(c[a],b,c,true):this.render(c[a],b[a],c,true)},render_section:function(a,b,c){if(!this.includes("#",a)&&!this.includes("^",a))return false;var d=this,e=this.getCachedRegex("render_section",function(a,b){return RegExp("^([\\s\\S]*?)"+a+"(\\^|\\#)\\s*(.+)\\s*"+b+"\n*([\\s\\S]*?)"+a+"\\/\\s*\\3\\s*"+b+"\\s*([\\s\\S]*)$","g")});return a.replace(e,function(a,e,j,f,i,k){var a=e?d.render_tags(e,b,c,true):"",k=
k?d.render(k,b,c,true):"",l,f=d.find(f,b);j==="^"?l=!f||d.is_array(f)&&f.length===0?d.render(i,b,c,true):"":j==="#"&&(l=d.is_array(f)?d.map(f,function(a){return d.render(i,d.create_context(a),c,true)}).join(""):d.is_object(f)?d.render(i,d.create_context(f),c,true):typeof f==="function"?f.call(b,i,function(a){return d.render(a,b,c,true)}):f?d.render(i,b,c,true):"");return a+l+k})},render_tags:function(a,b,c,d){for(var e=this,h=function(){return e.getCachedRegex("render_tags",function(a,b){return RegExp(a+
"(=|!|>|\\{|%)?([^\\/#\\^]+?)\\1?"+b+"+","g")})},g=h(),j=function(a,d,f){switch(d){case "!":return"";case "=":return e.set_delimiters(f),g=h(),"";case ">":return e.render_partial(f,b,c);case "{":return e.find(f,b);default:return e.escape(e.find(f,b))}},a=a.split("\n"),f=0;f<a.length;f++)a[f]=a[f].replace(g,j,this),d||this.send(a[f]);if(d)return a.join("\n")},set_delimiters:function(a){a=a.split(" ");this.otag=this.escape_regex(a[0]);this.ctag=this.escape_regex(a[1])},escape_regex:function(a){if(!arguments.callee.sRE)arguments.callee.sRE=
RegExp("(\\/|\\.|\\*|\\+|\\?|\\||\\(|\\)|\\[|\\]|\\{|\\}|\\\\)","g");return a.replace(arguments.callee.sRE,"\\$1")},find:function(a,b){function c(a){return a===false||a===0||a}var a=this.trim(a),d;a.match(/([a-z_]+)\./ig)?d=c(this.walk_context(a,b)):c(b[a])?d=b[a]:c(this.context[a])&&(d=this.context[a]);return typeof d==="function"?d.apply(b):d!==void 0?d:""},walk_context:function(a,b){for(var c=a.split("."),d=b[c[0]]!=void 0?b:this.context,e=d[c.shift()];e!=void 0&&c.length>0;)d=e,e=e[c.shift()];
return typeof e==="function"?e.apply(d):e},includes:function(a,b){return b.indexOf(this.otag+a)!=-1},escape:function(a){return String(a===null?"":a).replace(/&(?!\w+;)|["'<>\\]/g,function(a){switch(a){case "&":return"&amp;";case '"':return"&quot;";case "'":return"&#39;";case "<":return"&lt;";case ">":return"&gt;";default:return a}})},create_context:function(a){if(this.is_object(a))return a;else{var b=".";if(this.pragmas["IMPLICIT-ITERATOR"])b=this.pragmas["IMPLICIT-ITERATOR"].iterator;var c={};c[b]=
a;return c}},is_object:function(a){return a&&typeof a=="object"},is_array:function(a){return Object.prototype.toString.call(a)==="[object Array]"},trim:function(a){return a.replace(/^\s*|\s*$/g,"")},map:function(a,b){if(typeof a.map=="function")return a.map(b);else{for(var c=[],d=a.length,e=0;e<d;e++)c.push(b(a[e]));return c}},getCachedRegex:function(a,b){var c=g[this.otag];c||(c=g[this.otag]={});var d=c[this.ctag];d||(d=c[this.ctag]={});(c=d[a])||(c=d[a]=b(this.otag,this.ctag));return c}};return{name:"mustache.js",
version:"0.4.0-dev",to_html:function(a,b,c,d){var e=new m;if(d)e.send=d;e.render(a,b||{},c);if(!d)return e.buffer.join("\n")}}}();

templates={"Last.Fm":'<div class="lastfm" ><h1>{{song}}</h1><h2>{{artist}}<h2><h3>{{album}}</h3><img src="{{cover}}"></div>',Tumblr:'<div class="tumblr"><h1>My lastest posts:</h1><ul> <li><a href="{{url1}}"> {{post1}} </a></li><li><a href="{{url2}}"> {{post2}} </a></li></ul><p>read more on my <a href="http://blog.martianwabbit.com">blog.</a></p></div>',Twitter:'<div class="twitter"><blockquote>{{status}}</blockquote><cite>- <a href="http://www.twitter.com/seich"> @Seich </a></div>',Forrst:'<div class="forrst"><p>My last post was a <b>{{type}}</b> titled:</p><h1><a href="{{url}}">{{title}}</h1><p>I am <a href="http://forrst.me/seich">Seich</a> on <a href="http://www.forrst.com">forrst</a>. </p></div>',
Github:'<div class="github"><h1>Some of my repositories:</h1><ul>{{#repositories}}<li><a href="{{url}}">{{name}}</a> ({{language}})</li>{{/repositories}}</ul><p>I am <a href="http://github.com/seich">Seich</a> on <a href="http://www.github.com">Github</a>. </p></div>'};
dataUrls={"Last.Fm":"http://ws.audioscrobbler.com/2.0/user/seichleon/recenttracks.xml",Tumblr:"https://query.yahooapis.com/v1/public/yql?q=select%20posts.post.url%2C%20posts.post.regular-title%20from%20xml%20where%20url%3D%22http%3A%2F%2Fblog.martianwabbit.com%2Fapi%2Fread%3Fnum%3D3%22&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys",Twitter:"https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20twitter.user.status%20where%20screen_name%3D'seich'&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys",
Forrst:"https://query.yahooapis.com/v1/public/yql?q=select%20resp.post_type%2C%20resp.post_url%2C%20resp.title%20from%20json%20where%20url%3D'https%3A%2F%2Fforrst.com%2Fapi%2Fv2%2Fusers%2Fposts%3Fusername%3Dseich'&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys",Github:"http://query.yahooapis.com/v1/public/yql/seich/getGithubRepos?format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys"};
$(function(){bioBubble={e:$("#bio"),loadFeed:function(a){bioBubble.html('<div class="loading"><img src="images/loader.gif" alt="loading"><p>Loading</p></div>');bioBubble.loadData(a)},originalHtml:$("#bio").html(),html:function(a){bioBubble.e.children("div").fadeOut("fast",function(){$(this).parent().html(a).fadeIn()})},reset:function(){bioBubble.html(bioBubble.originalHtml)},loadData:function(a){$.ajax({url:dataUrls[a],type:"GET",dataType:a=="Last.Fm"?"xml":"json",success:function(b){switch(a){case "Last.Fm":latestTrack=
$(b).find("recenttracks track").first();dt={artist:latestTrack.find("artist").text(),song:latestTrack.find("name").text(),album:latestTrack.find("album").text(),cover:latestTrack.find('image[size="medium"]').text()};break;case "Tumblr":lastestPosts=b.query.results.tumblr;dt={post1:lastestPosts[0].posts.post["regular-title"],url1:lastestPosts[0].posts.post.url,post2:lastestPosts[1].posts.post["regular-title"],url2:lastestPosts[1].posts.post.url,post3:lastestPosts[2].posts.post["regular-title"],url3:lastestPosts[2].posts.post.url};
break;case "Twitter":dt={status:b.query.results.status.text};break;case "Forrst":post=b.query.results.json[0].resp;dt={type:post.post_type,title:post.title,url:post.post_url};break;case "Github":dt={repositories:[]};for(i=0;i<5;i++)dt.repositories.push({name:b.query.results.repositories.repository[i].name,url:b.query.results.repositories.repository[i].url,language:b.query.results.repositories.repository[i].language})}bioBubble.html(Mustache.to_html(templates[a],dt))},error:function(){bioBubble.html("There was an error loading the "+
a+" feed.")}})}};socialBubbles={e:$("#social-bubbles li"),init:function(){socialBubbles.place();socialBubbles.e.each(function(a){$(this).hover(function(){$(this).stop().animate({left:a<3?"+=10":"-=10"},"normal")},function(){$(this).animate({left:socialBubbles.left(a,this),top:socialBubbles.top(a,this)},"fast")})});socialBubbles.e.not("#x").click(function(a){a=$(this);x=$("#x");a.fadeTo("normal",1);a.siblings().not("#x").stop().fadeTo("normal",0.5);x.fadeTo("normal",1);bioBubble.loadFeed(a.children("img").attr("alt"))});
$("#x").click(function(){x=$(this);x.fadeOut();x.siblings().fadeTo("normal",1);bioBubble.reset()})},place:function(){socialBubbles.e.each(function(a,b){$(this).animate({left:socialBubbles.left(a,b),top:socialBubbles.top(a,b)}).css({"background-image":a>=3?"url(images/bubble-social-i.png)":null,padding:a>=3?"14px 0 0 25px":null})})},left:function(a,b){return a<3?bioBubble.e.offset().left-$(b).width()-45:bioBubble.e.offset().left+bioBubble.e.width()+20},top:function(a,b){return a<3?bioBubble.e.offset().top+
$(b).height()*a+a*15+10:bioBubble.e.offset().top+$(b).height()*(a-3)+(a-3)*15+10}};stackBubbles={init:function(){e=stackBubbles.main.e;$("ul#bubbles li").each(function(){$(this).hover(function(){bubble=$(this);bubble.siblings().stop().fadeTo("normal",0.5).parent().fadeTo("normal",1);stackBubbles.mini.show(bubble)},function(){bubble=$(this);bubble.siblings().stop().fadeTo("normal",1).parent().fadeTo("normal",1);stackBubbles.main.hide()})})},main:{e:$("#details-bubble"),show:function(a){e=stackBubbles.main.e;
ePos=e.position();eOff=e.offset();e.find("h1").html(a.children("img").attr("alt"));left=stackBubbles.main.left(a);e.css({left:left}).css("top",stackBubbles.main.top(a)).stop().show().fadeTo("normal",1);stackBubbles.main.e.find("span").css("width",0);e.find("span").stop().animate({width:a.children("img").attr("data-percentage")},{duration:2E3,step:function(){e=$(this);w=e.width();w>0&&w<=60?e.css("background","#a30000"):w>60&&w<=120?e.css("background","#ffbb00"):w>120&&w<=180?e.css("background","#00a5af"):
w>180&&w<=200&&e.css("background","#72ff00")}})},hide:function(){stackBubbles.mini.e.stop().fadeTo("normal",0).hide();stackBubbles.main.e.stop().fadeTo("normal",0).hide();stackBubbles.main.e.children("h1").html("")},left:function(a){e=stackBubbles.main.e;return a.offset().left+e.width()+43>$(window).width()?$(window).width()-e.width()-20:a.offset().left-a.width()-e.width()<$(window).width()?a.offset().left-a.width()+e.width()/3+43:a.offset().left-a.width()+43},top:function(a){e=stackBubbles.main.e;
return a.offset().top-a.height()*1.8}},mini:{e:$("img#mini-bubble"),show:function(a){e=stackBubbles.mini.e;stackBubbles.mini.place(a);stackBubbles.main.show(a)},place:function(a){e=stackBubbles.mini.e;e.stop().show().fadeTo("normal",1);e.css({top:a.offset().top-a.height()/3,left:a.offset().left+stackBubbles.main.e.width()<$(window).width()?stackBubbles.main.left(a)+60:stackBubbles.main.left(a)+a.width()+20})}}};stackBubbles.init();socialBubbles.init()});$(window).resize(function(){socialBubbles.place()});
