$(document).ready(function(){var path=location.pathname;if(path)
$('#chrono ul li ul li a[href$="'+path+'"]').attr('class','current-post');function isNumber(n){return!isNaN(parseFloat(n))&&isFinite(n);}
$('.zoom').click(function(){if($('.lightbox img').is(':visible')&&$('.overlay').is(':visible')){$('.overlay').remove();$('.lightbox').remove();$('#loading').remove();}
else{var imgURLs=[],imgURL,index=0;$('.zoom').each(function(){imgURLs.push($(this).attr('href'));});if(isNumber(document.location.hash.substring(1))){index=parseInt(document.location.hash.substr(1))-1;}
var imgURL=imgURLs[index];var overlay=jQuery('<div class="overlay"></div>');overlay.appendTo(document.body);var imgWidth=parseInt($('.zoom').eq(index).attr('width'));var imgHeight=parseInt($('.zoom').eq(index).attr('height'));var topAbsolute='50%';var imgVerticalOffset='-'+imgHeight/2+'px';var imgAspectRatio=imgWidth/imgHeight;if(imgWidth+40>$(window).width()){imgWidth=$(window).width()-40;imgHeight=imgWidth*(1/imgAspectRatio);imgVerticalOffset='-'+imgHeight/2+'px';}
if(imgHeight>$(window).height()){topAbsolute='20px';imgVerticalOffset='0';}
var loader=$('<div id="loading">loading...</div>');loader.appendTo(document.body);var lightbox=$('<div class="lightbox" style="margin-left: -'+imgWidth/2+'px; margin-top: '+imgVerticalOffset+'; top: '+topAbsolute+'"><img src="'+imgURL+'" width="'+imgWidth+'" style="margin-bottom: 20px;"></div>');lightbox.appendTo(document.body);$('.lightbox img').bind('load');$('.lightbox img').load(function(){$(this).css('visibility','visible');$('#loading').remove();});}
return false;});$('.lightbox img').live('click',function(){$('.overlay').remove();$('.lightbox').remove();$('#loading').remove();});$('.overlay').live('click',function(){$('.overlay').remove();$('.lightbox').remove();$('#loading').remove();});$('.lightbox').live('mousemove',function(e){var imgHeight=$('.lightbox').height()+40;var winHeight=$(window).height();var top=e.pageY*(imgHeight-winHeight)/imgHeight;$(document).scrollTop(top);});if($('#slides').length>0){$(window).bind('hashchange',function(e){if(e.fragment){imgIndex=parseInt(e.fragment)-1;}else{imgIndex=0;}
$('.image:visible').fadeOut(1);var newImage=$('.image:eq('+imgIndex+')');$('#images').animate({width:newImage.width(),height:newImage.height()},300);newImage.fadeIn(300);$('.circle_nav li').removeClass('red');$('.circle_nav li:eq('+imgIndex+')').addClass('red');});var imgCount=$('.image').length;$('.image_link').click(function(e){e.preventDefault();var hashImgIndex=parseInt(document.location.hash.substring(1))-1;if(!document.location.hash){imgIndex=1;}else if(isNumber(hashImgIndex)){imgIndex=hashImgIndex+1;}
if(imgIndex<imgCount){document.location.hash=imgIndex+1;}else{window.location=$('.image_link').attr('href');}});}
$('.image:first').show();$('.circle_nav li:first').addClass('red');$('.circle_nav li').click(function(){var visibleImgIndex=$('.image:visible').index();var imgIndex=$(this).index();if(visibleImgIndex!=imgIndex){document.location.hash=imgIndex+1;}});if(isNumber(document.location.hash.substring(1))){imgIndex=document.location.hash.substring(1)-1;$('.image').hide();$('.image:eq('+imgIndex+')').show();$('.circle_nav li').removeClass('red');$('.circle_nav li:eq('+imgIndex+')').addClass('red');}
$('#chrono ul li ul li a.current-post').parents('ul').show();$('#chrono ul li span').click(function(){if($(this).siblings('ul').is(':hidden')){$('#chrono ul li ul').slideUp(200);$(this).siblings('ul').slideDown(200);}});$.expr[':'].focus=function(a){return(a==document.activeElement);}
$(document).bind('keydown',function(e){if(!$('#author, #email, #url, #comment, #s, #name, #email, #web, #subject, #message').is(':focus')&&(e.ctrlKey||e.shiftKey||e.altKey)==false){if(e.which===76){e.preventDefault();$('.zoom:first').click();}
else if(e.which===27){e.preventDefault();if($('.lightbox img').is(':visible')&&$('.overlay').is(':visible')){$('.overlay').remove();$('.lightbox').remove();$('.lightbox img').remove();}
else if($('#search').is(':visible')&&$('.overlay').is(':visible')){$('#search').hide();$('.overlay').remove();}}
else if(e.which===75){e.preventDefault();if($('#slides').length>0){var hashImgIndex=parseInt(document.location.hash.substring(1))-1;if(!document.location.hash){if($('.newer > a').length==1)
location.href=$('.newer > a').attr('href');}else if(isNumber(hashImgIndex)){imgIndex=hashImgIndex+1;}
if(imgIndex>1){document.location.hash=imgIndex-1;}else{if($('.newer > a').length==1)
location.href=$('.newer > a').attr('href');}}else{if($('.newer > a').length==1)
location.href=$('.newer > a').attr('href');}}
else if(e.which===74){e.preventDefault();if($('#slides').length>0){var imgCount=$('.image').length;var hashImgIndex=parseInt(document.location.hash.substring(1))-1;if(!document.location.hash){imgIndex=1;}else if(isNumber(hashImgIndex)){imgIndex=hashImgIndex+1;}
if(imgIndex<imgCount){document.location.hash=imgIndex+1;}else{if($('.older > a').length==1)
location.href=$('.older > a').attr('href');}}else if($('.older > a').length==1){location.href=$('.older > a').attr('href');}}
else if(e.which===67){e.preventDefault();$('#comment').focus();}
else if(e.which===83){e.preventDefault();$('#searchToggle').click();}}});$('#404search').click(function(){$('#searchToggle').click();});if(!$('#hotkeys').is(':visible')){$('footer').css({margin:'-60px auto 0 auto'})}
$('#searchToggle').click(function(){if($('#search').is(':visible')&&$('.overlay').is(':visible')){$('#search').hide();$('.overlay').remove();}
else{var overlay=jQuery('<div class="overlay"></div>');overlay.appendTo(document.body);$('#search').show();}});$('.overlay').live('click',function(){$('.overlay').remove();$('#search').hide();});var search=$("#s").val();var placeholder="Search...";if(search=='')
$("#s").val(placeholder);$("#s").blur(function(){search=$("#s").val();if(!(search!=""&&search!=placeholder))
$("#s").val(placeholder);});$("#s").focus(function(){search=$("#s").val();if(search==placeholder)
$("#s").val("");});});
