//https://github.com/scottjehl/iOS-Orientationchange-Fix
(function(j){var i=j.document;if(!i.querySelector){return}var l=i.querySelector("meta[name=viewport]"),a=l&&l.getAttribute("content"),h=a+", maximum-scale=1",d=a+", maximum-scale=10",g=true,c=j.orientation,k=0;if(!l){return}function f(){l.setAttribute("content",d);g=true}function b(){l.setAttribute("content",h);g=false}function e(m){c=Math.abs(j.orientation);k=Math.abs(m.gamma);if(k>8&&c===0){if(g){b()}}else{if(!g){f()}}}j.addEventListener("orientationchange",f,false);j.addEventListener("deviceorientation",e,false)})(this);
// https://github.com/davatron5000/FitVids.js
(function(a){a.fn.fitVids=function(b){var c={customSelector:null};var e=document.createElement("div"),d=document.getElementsByTagName("base")[0]||document.getElementsByTagName("script")[0];e.className="fit-vids-style";e.innerHTML="";d.parentNode.insertBefore(e,d);if(b){a.extend(c,b)}return this.each(function(){var f=["iframe[src^='http://player.vimeo.com']","iframe[src^='http://www.youtube.com']","iframe[src^='http://www.kickstarter.com']","object","embed"];if(c.customSelector){f.push(c.customSelector)}var g=a(this).find(f.join(","));g.each(function(){var j=a(this);if(this.tagName.toLowerCase()=="embed"&&j.parent("object").length||j.parent(".fluid-width-video-wrapper").length){return}var h=this.tagName.toLowerCase()=="object"?j.attr("height"):j.height(),i=h/j.width();j.wrap('
').parent(".fluid-width-video-wrapper").css("padding-top",(i*100)+"%");j.removeAttr("height").removeAttr("width")})})}})(jQuery);
// http://mths.be/placeholder v1.8.5 by @mathias
jQuery(function(g,a,$){var f='placeholder' in a.createElement('input'),b='placeholder' in a.createElement('textarea');if(f&&b){$.fn.placeholder=function(){return this};$.fn.placeholder.input=$.fn.placeholder.textarea=true}else{$.fn.placeholder=function(){return this.filter((f?'textarea':':input')+'[placeholder]').bind('focus.placeholder',c).bind('blur.placeholder',e).trigger('blur.placeholder').end()};$.fn.placeholder.input=f;$.fn.placeholder.textarea=b;$(function(){$('form').bind('submit.placeholder',function(){var h=$('.placeholder',this).each(c);setTimeout(function(){h.each(e)},10)})});$(g).bind('unload.placeholder',function(){$('.placeholder').val('')})}function d(i){var h={},j=/^jQuery\d+$/;$.each(i.attributes,function(l,k){if(k.specified&&!j.test(k.name)){h[k.name]=k.value}});return h}function c(){var h=$(this);if(h.val()===h.attr('placeholder')&&h.hasClass('placeholder')){if(h.data('placeholder-password')){h.hide().next().show().focus().attr('id',h.removeAttr('id').data('placeholder-id'))}else{h.val('').removeClass('placeholder')}}}function e(){var l,k=$(this),h=k,j=this.id;if(k.val()===''){if(k.is(':password')){if(!k.data('placeholder-textinput')){try{l=k.clone().attr({type:'text'})}catch(i){l=$('').attr($.extend(d(this),{type:'text'}))}l.removeAttr('name').data('placeholder-password',true).data('placeholder-id',j).bind('focus.placeholder',c);k.data('placeholder-textinput',l).data('placeholder-id',j).before(l)}k=k.removeAttr('id').hide().prev().attr('id',j).show()}k.addClass('placeholder').val(k.attr('placeholder'))}else{k.removeClass('placeholder')}}}(this,document,jQuery));
// https://github.com/manuelbieh/Details-Polyfill
jQuery(function(a){(function(){var b=this;this.hideDetailChildren=function(c){var d=c instanceof jQuery?c[0].childNodes:c.childNodes,e=d.length;a(c).attr("open",false);if(a.browser.safari==true){for(var f=0;f");g.text(d[f].textContent).hide();a(d[f]).after(g);d[f].textContent="";e++}}}a.each(d,function(d,e){if(a(e)[0].nodeType==1&&e==a(e).parent().find("> summary:first-of-type")[0]){if(a(e).data("processed")!=true){a(e).css({display:"block",cursor:"pointer"}).data("processed",true).addClass("detailHidden").bind("click",function(){b.toggleDetailChildren(a(this))});a(c).prepend(a(e))}}else if(a(e)[0].nodeType==3&&!e.isElementContentWhitespace&&!!a.browser.safari==false){var f=a("");f.text(e.textContent).hide();a(e).after(f);e.textContent=""}else if(a(c).find("> summary").length==0){var g=a("").text("Details").css({display:"block",cursor:"pointer"}).data("processed",true).addClass("detailHidden").bind("click",function(){b.toggleDetailChildren(a(this))});a(c).prepend(g)}a(c).find("> :visible:not(summary:first-child)").hide()})};this.showDetailChildren=function(b){a(b).attr("open",true);a.each(a(b).find("> *"),function(b,c){a(c).show()})};this.toggleDetailChildren=function(a){if(a.hasClass("detailHidden")){a.removeClass("detailHidden");b.showDetailChildren(a.parents("details")[0])}else{a.addClass("detailHidden");b.hideDetailChildren(a.parents("details")[0])}};if("open"in document.createElement("details")==false){a.each(a("details"),function(c,d){b.hideDetailChildren(d);var e=a("").text('summary {-webkit-text-size-adjust: none;} details > summary:first-child:before {content: "▼ "} details > summary.detailHidden:first-child:before {content: "► "}');a("head").append(e)})}})()})
// https://github.com/yatil/accessifyhtml5.js
var AccessifyHTML5=function(b){var a={article:{role:"article"},aside:{role:"complementary"},nav:{role:"navigation"},output:{"aria-live":"polite"},section:{role:"region"},"[required]":{"aria-required":"true"}};if(b){if(b.header){a[b.header]={role:"banner"}}if(b.footer){a[b.footer]={role:"contentinfo"}}}jQuery.each(a,function(c,d){jQuery(c).attr(d)})};
// 2k11
jQuery(document).ready(function($) {
// Assign WAI-ARIA roles
AccessifyHTML5({header:'#banner',footer:'#colophon'});
// Cloned primary navigation for small screen
var $select = $('');
$('#primary-nav li').each(function(){var $el=$(this);if($el.find('span').length){$('',{'selected':'selected','value':'','text':$el.text()}).appendTo($select);}else{$('',{'value':$el.find('a').attr('href'),'text':$el.text()}).appendTo($select);}});
if($select.children().size()>0){$select.appendTo('#primary-nav').change(function(){window.location=$(this).find('option:selected').val();});}
// Replace entrypaging icons
$('.serendipity_entrypaging_left .epicon').text('←');
$('.serendipity_entrypaging_right .epicon').text('→');
// Fit embedded videos
$('#content>article').fitVids();
// placeholder polyfill
$('input, textarea').placeholder();
// Disable trackback + short url links
$('#trackback_url>a,.short-url').click(function(){var linkMsg=$(this).attr('title');alert(linkMsg);return false;});
// Comment reply
$('.comment_reply').click(function(){var commentId=$(this).attr('id').replace(/serendipity_reply_/g,"");$('#serendipity_replyTo').val(commentId);});
// Confirm comment deletion
$('.comment_source_ownerlink').click(function(){var deleteMsg=$(this).attr('title');return confirm(deleteMsg);});
// Move preview comment in the DOM to fix comment preview
$('#c').insertAfter('#feedback');
// Hide reply-to form element
$('.comment_reply').click(function(){$('#reply-to-comment').remove();var replyToPlaceholder='';$('#serendipity_replyTo').after(replyToPlaceholder);});
$('#reply-to-hint,#serendipity_replyTo').addClass('visuallyhidden');
});