;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);;(function($){var $scrollTo=$.scrollTo=function(target,duration,settings){$(window).scrollTo(target,duration,settings);};$scrollTo.defaults={axis:'y',duration:1};$scrollTo.window=function(scope){return $(window).scrollable();};$.fn.scrollable=function(){return this.map(function(){var win=this.parentWindow||this.defaultView,elem=this.nodeName=='#document'?win.frameElement||win:this,doc=elem.contentDocument||(elem.contentWindow||elem).document,isWin=elem.setInterval;return elem.nodeName=='IFRAME'||isWin&&$.browser.safari?doc.body:isWin?doc.documentElement:this;});};$.fn.scrollTo=function(target,duration,settings){if(typeof duration=='object'){settings=duration;duration=0;}
if(typeof settings=='function')
settings={onAfter:settings};settings=$.extend({},$scrollTo.defaults,settings);duration=duration||settings.speed||settings.duration;settings.queue=settings.queue&&settings.axis.length>1;if(settings.queue)
duration/=2;settings.offset=both(settings.offset);settings.over=both(settings.over);return this.scrollable().each(function(){var elem=this,$elem=$(elem),targ=target,toff,attr={},win=$elem.is('html,body');switch(typeof targ){case'number':case'string':if(/^([+-]=)?\d+(px)?$/.test(targ)){targ=both(targ);break;}
targ=$(targ,this);case'object':if(targ.is||targ.style)
toff=(targ=$(targ)).offset();}
$.each(settings.axis.split(''),function(i,axis){var Pos=axis=='x'?'Left':'Top',pos=Pos.toLowerCase(),key='scroll'+Pos,old=elem[key],Dim=axis=='x'?'Width':'Height',dim=Dim.toLowerCase();if(toff){attr[key]=toff[pos]+(win?0:old-$elem.offset()[pos]);if(settings.margin){attr[key]-=parseInt(targ.css('margin'+Pos))||0;attr[key]-=parseInt(targ.css('border'+Pos+'Width'))||0;}
attr[key]+=settings.offset[pos]||0;if(settings.over[pos])
attr[key]+=targ[dim]()*settings.over[pos];}else
attr[key]=targ[pos];if(/^\d+$/.test(attr[key]))
attr[key]=attr[key]<=0?0:Math.min(attr[key],max(Dim));if(!i&&settings.queue){if(old!=attr[key])
animate(settings.onAfterFirst);delete attr[key];}});animate(settings.onAfter);function animate(callback){$elem.animate(attr,duration,settings.easing,callback&&function(){callback.call(this,target,settings);});};function max(Dim){var attr='scroll'+Dim,doc=elem.ownerDocument;return win?Math.max(doc.documentElement[attr],doc.body[attr]):elem[attr];};}).end();};function both(val){return typeof val=='object'?val:{top:val,left:val};};})(jQuery);
CP.feedNavigationItem=-1;CP.getKeyCode=function(event)
{var keyCode=event.keyCode;if(!keyCode)
{keyCode=event.which;}
return keyCode;};CP.isDocumentKeypress=function(event)
{if($(event.target).closest("form").length==0&&!event.altKey&&!event.ctrlKey&&!event.metaKey&&!event.shiftKey)
{return true;}
return false;};$(function()
{var scrollDuration=500;var scrollOffset=-20;function feedNavigation(event)
{if(CP.isDocumentKeypress(event))
{switch(CP.getKeyCode(event))
{case 37:case 74:previousFeedItem();break;case 39:case 75:nextFeedItem();break;case 72:CP.olderFeedPage();break;case 76:CP.newerFeedPage();break;case 79:case 86:openFeedItem();break;}}}
function nextFeedItem()
{if(CP.feedNavigationItem>0)
{CP.feedNavigationItem--;}
else if(CP.feedNavigationItem<0)
{CP.feedNavigationItem=0;}
$(window).stop().scrollTo($(".hfeed .hentry:eq("+CP.feedNavigationItem+")").position().top+scrollOffset,scrollDuration,{axis:"y"});}
function openFeedItem()
{if(CP.feedNavigationItem!=-1)
{var permalink=$(".hfeed .hentry:eq("+CP.feedNavigationItem+") a.permalink").attr("href")
if(permalink)
{window.location=permalink;}}}
function previousFeedItem()
{var feedItemCount=$(".hfeed .hentry").length-1;if(CP.feedNavigationItem<feedItemCount)
{CP.feedNavigationItem++;}
$(window).stop().scrollTo($(".hfeed .hentry:eq("+CP.feedNavigationItem+")").position().top+scrollOffset,scrollDuration,{axis:"y"});}
$(document).keydown(feedNavigation);});
CP.getPhotoMaximumSizes=function(maximumPhotoWidth,maximumPhotoHeight,topMargin)
{var windowHeight=$(window).height()-topMargin;var contentWidth=$("#content").width()-10;if(maximumPhotoHeight>windowHeight||maximumPhotoWidth>contentWidth)
{var heightRatio=maximumPhotoHeight/windowHeight;var widthRatio=maximumPhotoWidth/contentWidth;if(heightRatio>widthRatio&&contentWidth>300)
{maximumPhotoHeight/=heightRatio;maximumPhotoWidth/=heightRatio;}
else
{maximumPhotoHeight/=widthRatio;maximumPhotoWidth/=widthRatio;}}
return{height:Math.round(maximumPhotoHeight),width:Math.round(maximumPhotoWidth)};}
$(function()
{function displayPhoto(photoId)
{var photo=null;for(var i=0,l=CP.album.photos.length;i<l;i++)
{photo=CP.album.photos[i];if(photo.id==photoId)
{updatePhoto(photo,i+1);}}}
function nextPhoto(event)
{var photoPosition=parseInt($("#photo-position").text());if(photoPosition<CP.album.photos.length)
{var nextPhotoPosition=photoPosition+1;updatePhoto(CP.album.photos[nextPhotoPosition-1],nextPhotoPosition);event.preventDefault();}}
function photoLoad()
{$(this).show();$.scrollTo("div.photo-navigation");}
function photoNavigation(event)
{if(CP.isDocumentKeypress(event))
{switch(CP.getKeyCode(event))
{case 37:previousPhoto(event);break;case 39:nextPhoto(event);break;}}}
function preloadPhotos()
{for(var i=0,l=CP.album.photos.length;i<l;i++)
{$("<img>").attr("src",CP.album.photos[i].src);}}
function previousPhoto(event)
{var photoPosition=parseInt($("#photo-position").text());if(photoPosition>1)
{var previousPhotoPosition=photoPosition-1;updatePhoto(CP.album.photos[previousPhotoPosition-1],previousPhotoPosition);event.preventDefault();}}
function updatePhoto(newPhoto,position)
{var commentCount=newPhoto.comments;var newPhotoId=newPhoto.id;var photo=$("#photo-container img");var photoId="photo-"+newPhotoId;var url="http://www.flickr.com/photos/chrispederick/"+newPhotoId+"/in/set-"+CP.album.id+"/";updatePhotoMaximumSizes(newPhoto.width,newPhoto.height);photo.hide().attr({alt:newPhoto.title+" photo",src:newPhoto.src});$("#photo-description").html(newPhoto.description);$("#photo-position").text(position)
if(position==1)
{$("p.older").hide();}
else
{$("p.older a").attr("href","#photo-"+CP.album.photos[position-2].id);$("p.older").css("display","inline");}
if(position==CP.album.photos.length)
{$("p.newer").hide();}
else
{$("p.newer a").attr("href","#photo-"+CP.album.photos[position].id);$("p.newer").css("display","inline");}
document.title=newPhoto.title+" in "+CP.album.title+" on chrispederick.com";$("#photo-container a").attr("href",url);$("div.photo-navigation").attr("id",photoId);if(commentCount==1)
{$("#photo-comments").attr("href",url).text("1 comment");}
else
{$("#photo-comments").attr("href",url).text(commentCount+" comments");}
window.location.hash="#"+photoId;}
function updatePhotoMaximumSizes(maximumWidth,maximumHeight)
{var photoMaximumSizes=CP.getPhotoMaximumSizes(maximumWidth,maximumHeight,55);$("#photo-container").css({"height":photoMaximumSizes.height+10+"px","width":photoMaximumSizes.width+10+"px"});$("#photo-container img").css({"max-height":photoMaximumSizes.height+"px","max-width":photoMaximumSizes.width+"px"});}
var photo=$("#photo-container img");if(window.location.hash)
{displayPhoto(window.location.hash.replace(/#photo-/,""));}
else
{updatePhotoMaximumSizes(photo.css("max-width").replace(/px/,""),photo.css("max-height").replace(/px/,""));}
photo.hide().load(photoLoad);$("p.newer a").click(nextPhoto);$("p.older a").click(previousPhoto);$(document).keydown(photoNavigation);preloadPhotos();});