;(function($){var $scrollTo=$.scrollTo=function(target,duration,settings){$(window).scrollTo(target,duration,settings);};$scrollTo.defaults={axis:'xy',duration:parseFloat($.fn.jquery)>=1.3?0:1};$scrollTo.window=function(scope){return $(window)._scrollable();};$.fn._scrollable=function(){return this.map(function(){var elem=this,isWin=!elem.nodeName||$.inArray(elem.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!isWin)
return elem;var doc=(elem.contentWindow||elem).document||elem.ownerDocument||elem;return $.browser.safari||doc.compatMode=='BackCompat'?doc.body:doc.documentElement;});};$.fn.scrollTo=function(target,duration,settings){if(typeof duration=='object'){settings=duration;duration=0;}
if(typeof settings=='function')
settings={onAfter:settings};if(target=='max')
target=9e9;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+(\.\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],max=$scrollTo.max(elem,axis);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[axis=='x'?'width':'height']()*settings.over[pos];}else{var val=targ[pos];attr[key]=val.slice&&val.slice(-1)=='%'?parseFloat(val)/100*max:val;}
if(/^\d+$/.test(attr[key]))
attr[key]=attr[key]<=0?0:Math.min(attr[key],max);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);});};}).end();};$scrollTo.max=function(elem,axis){var Dim=axis=='x'?'Width':'Height',scroll='scroll'+Dim;if(!$(elem).is('html,body'))
return elem[scroll]-$(elem)[Dim.toLowerCase()]();var size='client'+Dim,html=elem.ownerDocument.documentElement,body=elem.ownerDocument.body;return Math.max(html[scroll],body[scroll])
-Math.min(html[size],body[size]);};function both(val){return typeof val=='object'?val:{top:val,left:val};};})(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.scrollDuration=500;CP.scrollOffset=-20;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;};CP.nextFeedItem=function()
{if(CP.feedNavigationItem>0)
{CP.feedNavigationItem--;}
else if(CP.feedNavigationItem<0)
{CP.feedNavigationItem=0;}
$(window).stop().scrollTo($(".hfeed .hentry:eq("+CP.feedNavigationItem+")").position().top+CP.scrollOffset,CP.scrollDuration,{axis:"y"});};CP.openFeedItem=function()
{if(CP.feedNavigationItem!=-1)
{var permalink=$(".hfeed .hentry:eq("+CP.feedNavigationItem+") a.permalink").attr("href")
if(permalink)
{window.location=permalink;}}};CP.previousFeedItem=function()
{var feedItemCount=$(".hfeed .hentry").length-1;if(CP.feedNavigationItem<feedItemCount)
{CP.feedNavigationItem++;}
$(window).stop().scrollTo($(".hfeed .hentry:eq("+CP.feedNavigationItem+")").position().top+CP.scrollOffset,CP.scrollDuration,{axis:"y"});};$(function()
{$(document).keydown(CP.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)};}
CP.feedNavigation=function(event)
{if(CP.isDocumentKeypress(event))
{switch(CP.getKeyCode(event))
{case 37:case 74:CP.previousPhoto(event);break;case 39:case 75:CP.nextPhoto(event);break;}}};CP.nextPhoto=function(event)
{var photoPosition=parseInt($("#photo-position").text());if(photoPosition<CP.album.photos.length)
{var nextPhotoPosition=photoPosition+1;CP.updatePhoto(CP.album.photos[nextPhotoPosition-1],nextPhotoPosition);event.preventDefault();}};CP.previousPhoto=function(event)
{var photoPosition=parseInt($("#photo-position").text());if(photoPosition>1)
{var previousPhotoPosition=photoPosition-1;CP.updatePhoto(CP.album.photos[previousPhotoPosition-1],previousPhotoPosition);event.preventDefault();}};CP.updatePhoto=function(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+"/";CP.updatePhotoMaximumSizes(newPhoto.width,newPhoto.height);photo.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;};CP.updatePhotoMaximumSizes=function(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"});};$(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)
{CP.updatePhoto(photo,i+1);}}}
function photoLoad()
{$(this).show();$.scrollTo("div.photo-navigation");}
function preloadPhotos()
{for(var i=0,l=CP.album.photos.length;i<l;i++)
{$("<img>").attr("src",CP.album.photos[i].src);}}
var photo=$("#photo-container img");if(window.location.hash)
{displayPhoto(window.location.hash.replace(/#photo-/,""));}
else
{CP.updatePhotoMaximumSizes(photo.css("max-width").replace(/px/,""),photo.css("max-height").replace(/px/,""));}
photo.load(photoLoad);$("p.newer a").click(CP.nextPhoto);$("p.older a").click(CP.previousPhoto);preloadPhotos();});