$(document).ready(function(){ 
// About 
  $('<a class="toggler" href="#" title="What is this place?">What is this place?</a>').insertBefore('#about-box'); 
  var $div = $('div#about-box');
  var $link = $('a.toggler');
  var height = $div.height();
  $div.hide().css({ height : 0 });
  $('div#header').css({'margin-top' : '0'});
  $('div#menu').css({'border-top':'1px solid #e5e0cb'});
      
  $('a.toggler').click(function () {
    $link.toggleClass("toggler-opened");
       if ($div.is(':visible')) {
          $div.animate({ height: 0 }, { duration: 500, complete: function () {
              $div.hide(); 
           } });
      } else {
          $div.show().animate({ height : height }, { duration: 1000, easing: 'easeOutBounce' });
       }
      return false;
  });

  $('span.me a').click(function() { 
  		$("span.inner").stop().animate({ width: 'toggle' }, {queue:false, duration:500});
  });
 
 
// Portfolio Navigation 
  $("dl#toggle dd img").css({'opacity' : '0.6'});
  $("dl#toggle dd img").hover(function(){	
          $(this).stop().fadeTo("fast", 1.0);},
      function(){ 
        if (!$(this).hasClass('active'))
          $(this).stop().fadeTo("slow", 0.6);  			
      }
  ).click(function(){
      $("dl#toggle dd img.active").stop().fadeTo("slow", 0.6).removeClass('active');
      $(this).addClass('active').stop().fadeTo("fast", 1.0);
  });
  
  $('div#about-box').localScroll();
  $('div#footer').localScroll();
  $('div.post').localScroll();

  
// Post Navigation
$('.post').each(function() {
		$(this).children('.col1').append(
			$('<ul />').addClass('post-nav') 
		);

		if ( $('.post').index(this) > 0 ) { 
			$(this).find('.post-nav').append(
				$('<li>Previous Post<\/li>').addClass('prev-post').attr({ title: 'Previous post'})
			);
		}
		if ( $('.post').index(this)+1 != $('.post').length ) {
			$(this).find('.post-nav').append(
				$('<li>Next Post<\/li>').addClass('next-post').attr({ title: 'Next post'})
			);
		} 
	});
  $('.next-post:eq(0)').css('margin-left', '36px');
	
	var portSpeed = 800;
	var posteasing = 'easeInOutQuint';
	$('.prev-post').click(function() {
		var h = $(this).parents('.post').prev().offset().top;
		$('html, body').stop().animate({scrollTop: h}, portSpeed,posteasing);
	});
	$('.next-post').click(function() {
		var h = $(this).parents('.post').next().offset().top;
		$('html, body').stop().animate({scrollTop: h}, portSpeed,posteasing);
	});	
  
});