BLOBBR=window.BLOBBR||{};(function(){if(BLOBBR&&BLOBBR.widget){return}var c="http://blobbr.com",g="http://api.blobbr.com",b="BLOBBR",k="jsonp",f="blobbr",l="-widget",a=0,h=false;
document.write('<style type="text/css">.'+f+l+" { display: none; }</style>");var e={loading:false,loaded:false,load:function(){if(!this.loaded&&!this.loading){this.loading=true;
var m=document.createElement("link");m.href=c+"/lib/widgets/v1/dropps/"+(h?"full":"min")+".css";m.rel="stylesheet";m.type="text/css";document.getElementsByTagName("head")[0].appendChild(m);
this.loaded=true;this.loading=false}}};var j={bind:function(n,m,o){if(m.addEventListener){m.addEventListener(n,o,false)}else{if(m.attachEvent){m.attachEvent("on"+n,o)
}}},addClass:function(o,p){var n=this.getClasses(o),q=false;for(var m=0;m<n.length;m++){if(n[m]==p){q=true;break}}if(!q){o.className=(o.className?o.className+" ":"")+p
}},removeClass:function(o,p){var n=this.getClasses(o),q="";for(var m=0;m<n.length;m++){if(n[m]!=p){q+=(n[m]+" ")}}o.className=q.substring(0,q.length-1)
},getClasses:function(m){return m.className?m.className.split(" "):[]}};var i=function(s){var p;var r=s.replace(/-/,"/").replace(/-/,"/");r=r.replace(/T/," ").replace(/Z/," UTC");
r=r.replace(/([\+-]\d\d)\:?(\d\d)/," $1$2");var n=new Date(r);var q=new Date();var u=Math.floor((q.getTime()-n.getTime())/1000);var t=Math.floor(u/3600);
if(t>=0&&t<24){if(!t){var o=Math.floor(u/60);if(!o){if(u==0){p="just now"}else{p=u+" sec"+(u>1?"s":"")+" ago"}}else{p=o+" min"+(o>1?"s":"")+" ago"}}else{p=t+" hr"+(t>1?"s":"")+" ago"
}}else{if(t<168){var v=Math.floor(t/24);p=v+" day"+(v>1?"s":"")+" ago"}else{var m=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"];
p="on "+m[n.getMonth()]+" "+n.getDate();if(n.getFullYear()!=q.getFullYear()){p+=", "+n.getFullYear()}}}return p};var d=function(){};BLOBBR.widget=d;d.prototype.init=function(m){e.load();
this.config=m||{};this.counter=++a;this.id=f+l+this.counter;this.data=null;this.num=null;this.nodes={};document.write('<div id="'+this.id+'"></div>');this.parent=document.getElementById(this.id);
this.parent.className=f+l;this.load(this.url())};d.prototype.url=function(){var m=g+"/api/dropps/include=blobb,answers/filter/";if(this.config.unique){m+="unique=blobbid/"
}if(this.config.widget){m+="by=combo/username="+this.config.username+"/widget="+this.config.widget+"/username,widget"}else{if(this.config.blobbid){m+="by=combo/username="+this.config.username+"/blobb="+this.config.blobbid+"/username,blobb"
}else{if(this.config.blobbs&&this.config.blobbs.length){m+="by=combo/username="+this.config.username+"/blobbs="+this.config.blobbs.join(",")+"/username,blobbs"
}else{m+="by=username/"+this.config.username}}}m+=".jsonp?callback="+b+"."+k+this.counter;if(this.config.count){m+="&num="+this.config.count}return m};
d.prototype.clear=function(){var m;while(m=this.parent.firstChild){this.parent.removeChild(m)}};d.prototype.resize=function(){if(this.config.width){this.parent.style.width=this.config.width+"px"
}if(this.config.height){this.parent.style.height=this.config.height+"px"}};d.prototype.scale=function(s,o,n){var r=n.font.max;s.style.fontSize=s.style.lineHeight=r+"px";
o.style.paddingTop=o.style.paddingBottom=0;while(o.offsetHeight>n.height.min&&r>n.font.min){s.style.fontSize=s.style.lineHeight=--r+"px"}var q=0;while(o.offsetHeight>=(r*2)&&r>n.font.min){s.style.fontSize=s.style.lineHeight=--r+"px";
if(++q>2){break}}var m=Math.max(o.offsetHeight,n.height.min);var p=Math.floor((m-o.offsetHeight)/2);if(n.height.pad&&p<n.height.pad){m+=((n.height.pad-p)*2);
p=n.height.pad}s.style.height=m+"px";o.style.paddingTop=p+"px";o.style.paddingBottom=p+"px";o.className+=" "+f+"-scaled";o.className=o.className.replace(/^\s+|\s+$/g,"")
};d.prototype.overflow=function(){if(this.nodes.content.scrollHeight!=this.nodes.content.offsetHeight){var p=this.nodes.content.childNodes;for(var o=0;
o<p.length;o++){var n=p[o].childNodes;for(var m=0;m<n.length;m++){if(new RegExp(f+"-scaled").test(n[m].className)){p[o].style.height=n[m].offsetHeight+"px"
}}}}};d.prototype.load=function(o){this.loading();var n=this;var m=document.createElement("script");m.onload=m.onreadystatechange=function(){if(n.loaded(m)){m.onload=m.onreadystatechange=null
}};m.onerror=function(){n.error("request error")};m.setAttribute("type","text/javascript");m.setAttribute("src",o);document.getElementsByTagName("head")[0].appendChild(m)
};d.prototype.loading=function(){this.clear();this.resize();var m=document.createElement("div");m.className=f+"-loading";this.parent.appendChild(m);this.footer("loading...")
};d.prototype.loaded=function(n){this.data=null;try{var o=window[b][k+this.counter]();n.parentNode.removeChild(n);if(typeof o=="string"){if(/^[\],:{}\s]*$/.test(o.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){if(window.JSON&&window.JSON.parse){var m=window.JSON.parse(o)
}else{var m=(new Function("return "+o))()}if(m.status=="success"){if(m.dropps.length){this.data=m;this.render(0)}else{this.error("no results")}}else{this.error("response error")
}}else{this.error("invalid this.data")}}else{this.error("invalid this.data type")}return true}catch(p){if(!n.readyState||n.readyState=="loaded"){this.error("fatal error")
}}};d.prototype.render=function(p){this.clear();this.resize();this.parent.style.visibility="hidden";if(this.data&&this.data.dropps){var n=this.data.dropps[p];
this.header(n.blobb.title,n.user.avatar);this.navigation();this.content();if(this.config.width<250){this.footer("by "+n.user.username+" "+i(n.created),c+"/users/"+n.user.username+"/"+n.id+"/")
}else{this.footer("dropped by "+n.user.username+" "+i(n.created),c+"/users/"+n.user.username+"/"+n.id+"/")}var m=0;for(var q=0;q<n.blobb.questions.length;
q++){if(typeof n.answers[n.blobb.questions[q].id]=="object"){if(n.blobb.questions.length>1||(this.config.single&&this.config.single=="standard")){this.question(++m,n.blobb.questions[q].question)
}var r=0;for(var o in n.answers[n.blobb.questions[q].id]){this.answer(r++,n.answers[n.blobb.questions[q].id][o].answer)}}}if(this.config.height){this.nodes.content.style.height=Math.min(this.nodes.content.offsetHeight,this.config.height-this.nodes.header.offsetHeight-this.nodes.footer.offsetHeight)+"px"
}this.overflow()}this.num=p;this.parent.style.visibility="visible"};d.prototype.header=function(q,n){var o=document.createElement("div");o.className=f+"-header"+(this.config.avatar?" with-avatar":"");
var p=document.createElement("div");p.className=f+"-title";p.appendChild(document.createTextNode(q));o.appendChild(p);if(this.config.avatar&&n){var m=document.createElement("img");
m.src=n;m.width=55;m.height=45;o.appendChild(m)}this.scale(this.nodes.header=this.parent.appendChild(o),p,{font:{min:9,max:18},height:{min:45,pad:3}})};
d.prototype.navigation=function(){if(this.data.dropps.length>1){var m=this;var n=document.createElement("div");n.className=f+"-nav";var p=document.createElement("a");
p.className=f+"-prev";p.appendChild(document.createElement("span")).appendChild(document.createTextNode("prev"));j.bind("mouseover",p,function(){j.addClass(p,"hover")
});j.bind("mouseout",p,function(){j.removeClass(p,"hover")});j.bind("click",p,function(){m.render(m.num>0?m.num-1:m.data.dropps.length-1)});n.appendChild(p);
var o=document.createElement("a");o.className=f+"-next";o.appendChild(document.createElement("span")).appendChild(document.createTextNode("next"));j.bind("mouseover",o,function(){j.addClass(o,"hover")
});j.bind("mouseout",o,function(){j.removeClass(o,"hover")});j.bind("click",o,function(){m.render(m.num>=m.data.dropps.length-1?0:m.num+1)});n.appendChild(o);
this.nodes.header.appendChild(n)}};d.prototype.content=function(){var m=document.createElement("div");m.className=f+"-content";this.nodes.content=this.parent.appendChild(m)
};d.prototype.question=function(m,p){var n=document.createElement("div");n.className=f+"-question";n.style.backgroundColor=this.config.color;var o=document.createElement("div");
o.appendChild(document.createTextNode(p));n.appendChild(o);this.scale(this.nodes.content.appendChild(n),o,{font:{min:10,max:12},height:{min:21,pad:3}})
};d.prototype.answer=function(m,r){var n=document.createElement("div");n.className=f+"-answer-"+(m%2?"odd":"even");var p=document.createElement("div"),q;
if(q=r.match(/\[URL=([^"]*)\](.*)\[\/URL\]/)){var o=document.createElement("a");o.appendChild(document.createTextNode(q[2]));o.href=q[1];o.target="_blank";
p.appendChild(o)}else{p.appendChild(document.createTextNode(r))}n.appendChild(p);this.scale(this.nodes.content.appendChild(n),p,{font:{min:10,max:11},height:{min:21,pad:3}})
};d.prototype.footer=function(q,n){var o=document.createElement("div");o.className=f+"-footer";if(n){var m=document.createElement("a");m.className=f+"-blurb";
m.href=n}else{var m=document.createElement("span")}m.className=f+"-blurb";m.appendChild(document.createTextNode(q));o.appendChild(m);var p=document.createElement("a");
p.className=f+"-logo";p.href=c;p.appendChild(document.createElement("span"));p.firstChild.appendChild(document.createTextNode("blobbr"));o.appendChild(p);
this.nodes.footer=this.parent.appendChild(o)};d.prototype.error=function(m){this.clear();this.footer(m)}})();
