jQuery(document).ready(function($){
// gallery colorize
  $('a#colorize').click(function(){
	$this = $(this);
    if('colorize' == $this.text()){
	  $this.text('monochromize');
	  $('.color').fadeIn();
	}
	else{
	  $this.text('colorize');
      $('.color').fadeOut();
	}
	return false;
  });										   
// colorbox
	if(jQuery.fn.colorbox){
	  $('a[href$=.jpg], a[href$=.png]', '.contents').attr('rel', 'colorbox');
	  $('a[rel=colorbox]').colorbox({previous:'前の画像', next:'次の画像', close:'閉じる'});
	}
//back to top
  function updateB2T(){
  	$this = $(window);
	var top = $this.scrollTop();
	if(top > 600)
	  $(".to-top:hidden").fadeIn();
	if(top < 600)
	  $(".to-top:visible").fadeOut();
	$home = $("#home");
	$(".to-top").css('top', $this.height() - 200).css('left', $home.position().left + $home.width() + 10);
  }
  $(window).scroll(function(){updateB2T();});
  updateB2T();
//smooth scroll
  $('a[href*=#]').each(function(){
	if($(this).attr('href') != '#'){
	  $(this).click(function() {
		if(location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
		&& location.hostname == this.hostname) {
		  var $target = $(this.hash);  
		  $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
		  if ($target.length) {  
			var targetOffset = $target.offset().top - 20;
			$('html,body').animate({scrollTop: targetOffset}, 'fast');
			return false;  
		  }
		}
		return false;
	  })
	}
  });
});