/** LAYOUT HELPERS **/

function openSection(page)
{
	$.address.value(page);
	$('#subnav a').removeClass('active');
	
	switch (page) {
		case 'edit':
			$('#subnav .original').addClass('active');
			doubleTrack('ND_home_editoriginal');
		break;
		case 'create':
			$('#subnav .author').addClass('active');
			doubleTrack('ND_home_authoryourown');
		break;
		case 'gallery':
			$('#subnav .gallery').addClass('active');
			doubleTrack('ND_home_viewgallery');
		break;
		default:
			$('#subnav .gallery').addClass('active');
			doubleTrack('ND_home_viewgallery');
		break;
	} 
	$('html, body').animate({scrollTop:$('#tabs').offset().top}, 'slow');
}

	
function loadPage()
{
	var path = $.address.path();
	var page = path.substring(path.lastIndexOf('/')+1);
	//if (page == '') { page = 'gallery'; }
	
	if (page) {
		openSection(page);
		$('#content').slideUp('slow', function()
		{
			$('#content').load(Ajax.getUrl('/newdeclaration/'+page), function() { $('#content').slideDown('slow'); 	$.address.title('Levi\'s Go Forth - New Declaration - '+page); });
		});
	}
}	

$(function()
{
	loadPage();
	$.address.change(loadPage);
});