$(document).ready(function() {	
	
// portfolio selector navigation
	
	$('#selector a:eq(0)').addClass('active');
	$('div.container').hide();
	$('div.container:eq(0)').show();
	$('#selector a').click(function(){
		var $this = $(this);
		$('#selector a').removeClass('active');
		$('div.container').hide();
		$($this.attr('rel')).parent().fadeIn();
		$this.addClass('active');
		return false;
	});
	
	
// swap other portfolio

	$('li.forward a').click(function(){
		$('div.container').hide();
		$('#other.portfolio').parent().fadeIn();
		$('#selector a').removeClass('active');
		$('#selector #nav-other').addClass('active');
		return false;
	});
	
	
// swap web portfolio

	$('li.back a').click(function(){
		$('div.container').hide();
		$('#web.portfolio').parent().fadeIn();
		$('#selector a').removeClass('active');
		$('#selector #nav-web').addClass('active');
		return false;
	});
	$('h1#logo').click(function(){
		$('div.container').hide();
		$('#web.portfolio').parent().fadeIn();
		$('#selector a').removeClass('active');
		$('#selector #nav-web').addClass('active');
		return false;
	});
	
	
// localScroll (for going up link)

	$.localScroll({
		duration:300,
		easing:'easeInOutQuad'
	});
	
	
// image + indicator

	$('.image').hover(
	  function () {
		$('a.more').remove();
	    $(this).append('<a class="more"></a>');
		$('a.more').fadeIn('300');
	  }, 
	  function () {
	    $('a.more').fadeOut('300');
	  }
	);
	
	
// image screenshot swap

	$('.image').click( function( ) {
		$(this).children('.cover')
	    	.filter(':visible').fadeOut(300)
	    	.end( )
	    	.filter(':hidden').fadeIn(300)
		;
	});
	
	
// fancybox

	$("a#inline").fancybox({
		'hideOnContentClick' : false,
		'autoDimensions'	 : false,
		'width'			 	 : 370,
		'height'			 : 240,
		'padding'			 : 30,
		'centerOnScroll'	 : true,
		'overlayOpacity'	 : 0.3,
		'overlayColor'		 : '#000'
	});


// ajax form

	$('#success').hide();
	$('#ajaxform').ajaxForm(function() { 
		$('#ajaxform').remove();
		$('#success').fadeIn();
		$(this).wait({
		    msec:3000,
		    onEnd:function(){
		        $.fancybox.close();
		    }
		});
    });


});
