$(function(){

	if(p = location.hash.slice(2))
		goto(p);
	else
		goto("about");

	$("#about .content-scroller").jScrollPane({
		showArrows: true,
		scrollbarWidth: 20,
		dragMinHeight: 23,
		dragMaxHeight: 23
	});

	$("#menu a")
		.mouseover(function(){
			if(!$(this).hasClass("current"))
			{
				var src = $("img", this).attr("src");
				$("img", this).attr("src", src.replace('0.png', '1.png'));
			}
		})
		.mouseout(function(){
			if(!$(this).hasClass("current"))
			{
				var src = $("img", this).attr("src");
				$("img", this).attr("src", src.replace('1.png', '0.png'));
			}
		})
		.click(function(){
			goto($(this).attr("href").slice(2));
		});
		
	$(window).scroll(function(){
		$("#menu").css("top", (50-$(window).scrollTop()));
	});
	
	$("#contact form").submit(function(){
		$.post("send.php", $(this).serialize(), function(response){
			alert(response);
		});
		return false;
	});
	
	$("#photo-gallery .scrollable").scrollable({size:4}).circular();
	
	$("#photo-gallery a").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	false,
		'titlePosition' 	: 'over',
		'hideOnContentClick' : true
	});

});

function goto(p)
{
	$.scrollTo($("#"+p).position().left, 1500, {
		axis: 'x',
		easing: 'easeOutBack'
	});
	
	$("#menu a").removeClass("current");
	$("#menu a[href='#/"+p+"']").addClass("current");
	
	$("#menu a img").each(function(){
		$(this).attr("src", $(this).attr("src").replace('1.png', '0.png'));
	});
	
	$("#menu a.current img").attr("src", $("#menu a.current img").attr("src").replace('0.png', '1.png'));

}
