/*
	JS by Joshua Gatcke http://www.99lime.com
*/

$(document).ready(function(){
	
	// default hash
	set_page('welcome');
	
	// bind hash
	$.History.bind(set_page);
	
	function set_page(hash)
	{
		if(hash == '') { hash = 'welcome'; }
	
		// stay at top of page
		$(window).scrollTop(0);
		
		// hide all pages
		$('.page').hide();
		//fade in correct page
		$('#'+hash).fadeIn('slow');
		// remove anchor classes
		$('#nav li a.current').removeClass('current');
		// anchor page
		$('#nav li a[href=\#'+hash+']').addClass('current');
		
		// hidden show_all
		if(hash == 'show-all') { $('.page').show(); }
		
		// add page class to body tag (for css)
		$('body').attr('class', hash);
		
		header_fade();
	}
	
	function header_fade()
	{
		current_page = $('.page:visible');
		holder_images = $('#holder img');
		holder_images.hide();
		current_image = 'image'+current_page.attr('rel');
		$('#holder img#'+current_image).fadeIn('fast');
	}
	
});