/*
jQuery Masonry version 1.3.1
Copyright David DeSandro, licensed MIT
http://desandro.com/resources/jquery-masonry
*/
;(function(e){var n=e.event,o;n.special.smartresize={setup:function(){e(this).bind("resize",n.special.smartresize.handler)},teardown:function(){e(this).unbind("resize",n.special.smartresize.handler)},handler:function(j,l){var g=this,d=arguments;j.type="smartresize";o&&clearTimeout(o);o=setTimeout(function(){jQuery.event.handle.apply(g,d)},l==="execAsap"?0:100)}};e.fn.smartresize=function(j){return j?this.bind("smartresize",j):this.trigger("smartresize",["execAsap"])};e.fn.masonry=function(j,l){var g=
{getBricks:function(d,b,a){var c=a.itemSelector===undefined;b.$bricks=a.appendedContent===undefined?c?d.children():d.find(a.itemSelector):c?a.appendedContent:a.appendedContent.filter(a.itemSelector)},placeBrick:function(d,b,a,c,h){b=Math.min.apply(Math,a);for(var i=b+d.outerHeight(true),f=a.length,k=f,m=c.colCount+1-f;f--;)if(a[f]==b)k=f;d.applyStyle({left:c.colW*k+c.posLeft,top:b},e.extend(true,{},h.animationOptions));for(f=0;f<m;f++)c.colY[k+f]=i},setup:function(d,b,a){g.getBricks(d,a,b);if(a.masoned)a.previousData=
d.data("masonry");a.colW=b.columnWidth===undefined?a.masoned?a.previousData.colW:a.$bricks.outerWidth(true):b.columnWidth;a.colCount=Math.floor(d.width()/a.colW);a.colCount=Math.max(a.colCount,1)},arrange:function(d,b,a){var c;if(!a.masoned||b.appendedContent!==undefined)a.$bricks.css("position","absolute");if(a.masoned){a.posTop=a.previousData.posTop;a.posLeft=a.previousData.posLeft}else{d.css("position","relative");var h=e(document.createElement("div"));d.prepend(h);a.posTop=Math.round(h.position().top);
a.posLeft=Math.round(h.position().left);h.remove()}if(a.masoned&&b.appendedContent!==undefined){a.colY=a.previousData.colY;for(c=a.previousData.colCount;c<a.colCount;c++)a.colY[c]=a.posTop}else{a.colY=[];for(c=a.colCount;c--;)a.colY.push(a.posTop)}e.fn.applyStyle=a.masoned&&b.animate?e.fn.animate:e.fn.css;b.singleMode?a.$bricks.each(function(){var i=e(this);g.placeBrick(i,a.colCount,a.colY,a,b)}):a.$bricks.each(function(){var i=e(this),f=Math.ceil(i.outerWidth(true)/a.colW);f=Math.min(f,a.colCount);
if(f===1)g.placeBrick(i,a.colCount,a.colY,a,b);else{var k=a.colCount+1-f,m=[];for(c=0;c<k;c++){var p=a.colY.slice(c,c+f);m[c]=Math.max.apply(Math,p)}g.placeBrick(i,k,m,a,b)}});a.wallH=Math.max.apply(Math,a.colY);d.applyStyle({height:a.wallH-a.posTop},e.extend(true,[],b.animationOptions));a.masoned||setTimeout(function(){d.addClass("masoned")},1);l.call(a.$bricks);d.data("masonry",a)},resize:function(d,b,a){a.masoned=d.data("masonry")!==null;var c=d.data("masonry").colCount;g.setup(d,b,a);a.colCount!=
c&&g.arrange(d,b,a)}};return this.each(function(){var d=e(this),b={};b.masoned=d.data("masonry")!==null;var a=b.masoned?d.data("masonry").options:{},c=e.extend({},e.fn.masonry.defaults,a,j),h=a.resizeable;b.options=c.saveOptions?c:a;l=l||function(){};g.getBricks(d,b,c);if(!b.$bricks.length)return this;g.setup(d,c,b);g.arrange(d,c,b);!h&&c.resizeable&&e(window).bind("smartresize.masonry",function(){g.resize(d,c,b)});h&&!c.resizeable&&e(window).unbind("smartresize.masonry")})};e.fn.masonry.defaults=
{singleMode:false,columnWidth:undefined,itemSelector:undefined,appendedContent:undefined,saveOptions:true,resizeable:true,animate:false,animationOptions:{}}})(jQuery);

/*
Tumblr notes functions are based off Guillermo Esteves notes script:
http://blog.gesteves.com/

Licensed under the Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License:
http://creativecommons.org/licenses/by-nc-sa/3.0/
*/
function tumblrNotesLoaded(a){$(".notes-more").remove();buildNotes(a);return false;}
function buildNotes(notesHTML){var notes=$(notesHTML);notes.each(function(){if($(this).hasClass("more_notes_link_container")){var id=$(this).attr("id");$("#notes").append($("<div class=\"notes-more\" id=\""+id+"\"></div>").html($(this).html()));}else{if($(this).hasClass("like")){if($(this).find("a").length>0){var b=$("<li></li>").append($(this).find("a").first());b.find("img").attr("src",b.find("img").css({width:30}).attr("src").replace(/_[\d]+\./,"_30."));$("#notes-likes ul").append(b);}}else{if($(this).hasClass("reblog")&&$(this).find("span").text().indexOf("posted")>0){return;}else if($(this).hasClass("reblog")&&$(this).hasClass("with_commentary")){if(($(this).find("img.avatar").length)){var b=$("<li class=\"group\"></li>").append($(this).find("a").first()),d=$("<div class=\"message\"></div>");d.append($("<p class=\"action\"></p>").prepend($(this).find("span.action a").first()));d.append($("<p class=\"message\"></p>").append($(this).find("blockquote")));b.find("img").attr("src",b.find("img").css({width:60}).attr("src").replace(/_[\d]+\./,"_64."));$("#reblogswithcommentary").append(b.append(d));}}else if($(this).hasClass("reblog")&&$(this).hasClass("without_commentary")){if(($(this).find("img.avatar").length)){var b=$("<li></li>").append($(this).find("a").first());b.find("img").attr("src",b.find("img").css({width:30}).attr("src").replace(/_[\d]+\./,"_30."));$("#reblogswithoutcommentary").append(b);}}else{if($(this).find("img.avatar").length){var b=$("<li class=\"group\"></li>").append($(this).find("a").first()),d=$("<div class=\"message\"></div>");b.find("img.avatar").attr("src",b.find("img.avatar").css({width:60}).attr("src").replace(/_[\d]+\./,"_64."));if($(this).hasClass("reply")){d.append($("<p class=\"action\"></p>").prepend($(this).find("span.action a").first()));d.append($("<p class=\"message\"></p>").append($(this).find("span.answer_content")));}else{if($(this).hasClass("answer")){d.append($("<p class=\"action\"></p>").prepend($(this).find("span.action a").first()));d.append($("<p class=\"message\"></p>").append($(this).find("span.answer_content")));}else{if($(this).hasClass("photo")){d.append($("<img alt=\"Photo reply\" class=\"photo-reply\" />").attr("src",$(this).find(".photo_container img").first().attr("src")));}}}
$("#notes-replies ul").append(b.append(d));}}}}});if(($("#notes-replies li").length>0)&&($("#notes-replies h5").length===0)){$("#notes-replies").prepend("<h5>Replies:</h5>");}
if(($("#notes-likes li").length>0)&&($("#notes-likes h5").length===0)){$("#notes-likes").prepend("<h5>Likes:</h5>");}
if(($("#notes-reblogs li").length>0)&&($("#notes-reblogs h5").length===0)){$("#notes-reblogs").prepend("<h5>Reblogs:</h5>");}
if($("#reblogswithcommentary li").length>0&&$("#reblogswithoutcommentary li").length>0){$("#reblogswithcommentary").css({marginBottom:25});}
if($("#notes-likes li").length>0&&$("#reblogswithoutcommentary li").length>0){$("#reblogswithoutcommentary").css({marginBottom:25});}
if($("#reblogswithoutcommentary li").length===0&&$("#reblogswithcommentary li").length>0){$("#reblogswithcommentary").css({marginBottom:25});}
if($("#notes li").length>0){$("#notes").css({display:"block"});}}
$(window).load(function(){$("#likes").masonry({singleMode:true});$(".post-main").each(function(){var caption=$(this).find(".caption");media=$(this).find("img:first, object:first");if(caption.height()<media.height()){media.css({marginBottom:0});}});});$(document).ready(function(){$("#likes li:even").css({marginRight:20});$("#likes li").addClass("ds");$(".tags-arrow").each(function(){var posLeft=Math.floor(Math.random()*300)+75,rotNum=Math.floor(Math.random()*3),rotate=["rotright","rotleft"];switch(rotNum){case 0:case 1:$(this).css({left:posLeft}).addClass(rotate[rotNum]);break;default:$(this).css({left:posLeft});break;}});$("ul.chatcontents li").each(function(){var t=$(this),label=t.find(".linelabel"),contents=t.find(".linecontents"),newLabel=label.text().replace(":","");label.text(newLabel);var labelWidth=label.width();contents.width(488-labelWidth);});$("<a href=\"http://www.pinkbike.com\">now back to pinkbike</a>").appendTo("body").css({display:"block",position:"fixed",bottom:0,right:10,fontSize:12,fontWeight:"bold"});$.ajax({url:$("#postnotesurl").attr("href"),success:function(notes){buildNotes($(notes).find("li"));}});});
