var tumblrBadge=function(){var settings={userName:"laughingsquid",itemsToShow:10,itemToAddBadgeTo:"tumblr-badge",imageSize:250,shortPublishDate:true,timeToWait:2000};var head=document.getElementsByTagName("head")[0];var badgeContainer=document.getElementById(settings.itemToAddBadgeTo);if(head&&badgeContainer){var badgeJSON=document.createElement("script");badgeJSON.type="text/javascript";badgeJSON.src="http://"+ settings.userName+".tumblr.com/api/read/json?callback=tumblrBadge.listItems&num="+ settings.itemsToShow;head.appendChild(badgeJSON);var wait=setTimeout(function(){badgeJSON.onload=null;badgeJSON.parentNode.removeChild(badgeJSON);badgeJSON=null;},settings.timeToWait);listItems=function(json){var posts=json.posts,list=document.createElement("ul"),post,listItem,text,link,img,conversation,postLink;list.className="tumblr";for(var i=0,il=posts.length;i<il;i=i+1){post=posts[i];if(/regular|photo|conversation/.test(post.type)){listItem=document.createElement("li");text=post["regular-body"]||post["photo-caption"]||post["quote-source"]||post["link-text"]||post["link-url"]||"";if(post.type==="photo"){link=document.createElement("a");link.href=post.url;img=document.createElement("img");img.width=settings.imageSize;img.src=post["photo-url-"+ settings.imageSize];link.appendChild(img);listItem.appendChild(link);}
else if(post.type==="quote"){text=post["quote-text"]+"<em>"+ text+"</em>";}
else if(post.type==="link"){text='<a href="'+ post["link-url"]+'">'+ text+'</a>';}
else if(post.type==="conversation"){conversation=post["conversation-lines"];for(var j=0,jl=conversation.length;j<jl;j=j+1){text+=conversation[j].label+" "+ conversation[j].phrase+((j===(jl-1))?"":"<br>");}}
listItem.innerHTML+=text;postLink=document.createElement("a");postLink.className="tumblr-post-date";postLink.href=post.url;listItem.appendChild(postLink);list.appendChild(listItem);}}
badgeContainer.innerHTML="";badgeContainer.appendChild(list);};return{listItems:listItems};}}();
