$(document).ready(function(){

	/* in-field labels */
	$(':input[title]').each(function() {
	  var $this = $(this);
	  if($this.val() === '') {
		$this.val($this.attr('title'));
	  }
	  $this.focus(function() {
		if($this.val() === $this.attr('title')) {
		  $this.val('');
		}
	  });
	  $this.blur(function() {
		if($this.val() === '') {
		  $this.val($this.attr('title'));
		}
	  });
	});
	
	/* smart columns (gallery) */
	function smartColumns() { 
	$("#gallery ul").css({'width':"100%"});
		var colWrap = $("#gallery ul").width();
		var colNum = Math.floor(colWrap / 300);
		var colFixed = Math.floor(colWrap / colNum);
		$("#gallery ul").css({'width':colWrap});
		$("#gallery ul li").css({'width':colFixed});
	}
	smartColumns();
	
	/* fade in */
	$(".fade-in").fadeTo(100, 0.8);
	$(".fade-in").hover(function(){
		$(this).fadeTo(400, 1.0);
		},function(){
		$(this).fadeTo(200, 0.8);
	});
	
	/* fade out */
	$(".fade-out").hover(function(){
		$(this).fadeTo(400, 0.8);
		},function(){
		$(this).fadeTo(200, 1.0);
	});
	
	/* page scrolling */
	$(function(){
		$('.page-scroll').bind('click',function(event){
			var $anchor = $(this);
			$('html, body').stop().animate({
				scrollTop:$($anchor.attr('href')).offset().top
			},1500,'easeInOutExpo');
			event.preventDefault();
		});
	});

});
