// JavaScript Document
$(document).ready(function() {				   
	
	$("a[rel=fancy_pic]").fancybox({									 
		'width'				: '75%',
		'height'			: '75%',
		'autoScale'     	: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition'     : 'over'
	});								   
	
	// Check for hash value in the URL
	var hash = window.location.hash.substr(1);
	var href = $('#menu_item a').each(function() {
		var href=$(this).attr('href');
		if(hash==href.substr(0,href.length-5)) {
			var toLoad = hash+'.html #content';
			$('#content').load(toLoad)
		}
	});

	$('#menu_item a').click(function() {
		
		var toLoad = $(this).attr('href')+' #content';
		$('#content').fadeOut('fast',loadContent);
		$('#load').remove();
		$('#wrapper').append('<span id="load">loading...</span>');
		$('#load').fadeIn('normal');
		// remove the current page contect
		// get new page content and append to content DIV
		window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5);
						   
		function loadContent() {
			$('#content').load(toLoad,'',showNewContent)
		}
		
		function showNewContent() {
			$('#content').fadeIn('normal',hideLoader);
		}
		
		function hideLoader() {
			$('#load').fadeOut('normal');
		}		
		
		return false;
	});
	
});
