$(document).ready(function() {

	var hash = location.hash;
	
	$(".images a").fancybox();
	
	// $('.multimedia_gallery a').fancybox();

	$('a.close_btn').hide();
	
	if(hash != '')
	{
		animateMap(hash);
	}
	
	$('#map_links a').click(function() {
		return false;
	});
	
	$('#map_links a').mouseover(function() {
		animateMap('#' + this.id);
	});
	
	$('a.close_btn').click(function() {
		returnMap();
		$('a.close_btn').hide();
		return false;
	});
	
	$('.images img').mouseover(function() {
		$(this).animate({opacity: .7}, 'slow');
	});
	$('.images img').mouseout(function() {
		$(this).animate({opacity: 1}, 'fast');
	});
});

function returnMap()
{
	$('#wrapper .community_info').hide();
	$('#wrapper').css('height', '500px');
	$('.masterplan_header').fadeIn('slow');
	$('.map_download_link').fadeIn('slow');
	$('.directions').fadeIn('slow');
	$('#wrapper img.map').animate({
		width: '842px',
		top: '25px',
		left: '25px'
		}, 900
	);
	$('a#park').animate({
		top: '400px', 
		left: '60px'
		}, 900
);
	$('a#village').animate({
		top: '405px', 
		left: '360px'
		}, 900
	);
	$('a#mountain').animate({
		top: '200px', 
		left: '475px'
		}, 900
	);
	$('a').css('z-index', '10');
}


function animateMap(selector)
{
	// Set selector to what JQuery needs to do work below
	var selector = selector + '_info';
	$('#wrapper .community_info').not(selector).hide();
	$('.masterplan_header').hide();
	$('.directions').hide();
	$('.map_download_link').hide();
	$('a.close_btn').fadeIn('slow');
	$('#wrapper').css('height', '750px');
	$(selector).fadeIn('normal');
	$('#wrapper').animate({
		width: "800px"
		}, 'normal'
	);
	// $('#wrapper').css('height', '750px');
	// $('a.close_btn').css('position', 'absolute');
	// $('#wrapper img.map').css('position', 'absolute');
	// $('#map_links a').css('position', 'absolute');
	$('#wrapper img.map').animate({
		width: '500px',
		top: '0px', 
		left: '375px'
		}, 900
	);
	$('a#park').animate({
		top: '150px', 
		left: '375px'
		}, 900
	);
	$('a#village').animate({
		top: '140px', 
		left: '550px'
		}, 900
	);
	$('a#mountain').animate({
		top: '25px', 
		left: '675px'
		}, 900
	);
	$('a').css('z-index', '10');
	
	//Set the hash back to # after loading the right section, if you don't do this then page will jump to anchors
	if(location.hash != '')
	{
		location.hash = '#';
	};
	return false;
}
