
function open_sitemap() 
{
	$('#sitemap').animate(
		{	height: 'toggle'	},
		{	duration:500, step:update_scroll, complete:open_complete	}
	)
	$('#sitemap').css('visibility', 'visible');
};

function open_complete()
{
	$('#open_sitemap').css('visibility', 'hidden');
	update_scroll();
};

function close_sitemap()
{	
	$('#open_sitemap').css('visibility', 'visible');
	$('#sitemap').css('visibility', 'hidden');
	
	$('#sitemap').animate(
		{	height: 'toggle'	},
		{	duration:3	}
  	);
	
	// Fire this slightly early to get rid of IE flicker at end of animation
	//setTimeout(close_complete, 480);
};

function close_complete()
{
	$('#sitemap').css('visibility', 'hidden');
};
  
function update_scroll()
{	
	if($("#scrollToHere").offset().top > ($("#open_sitemap").offset().top + 100))
	{
  		$('html, body').animate({scrollTop: $("#scrollToHere").offset().top	}, 2);
	}
}

function init_sitemap()
{
	$('#sitemap').css('visibility', 'hidden');	
	$('#sitemap').animate(
		{	height: 'toggle'	},
		{	duration:0, complete:unhide_sitemap	}
  	);
};

function unhide_sitemap()
{
	$('#sitemapHolder').css('visibility', 'visible');	
}
