$('#nav').delegate('a', 'click', function(e) {
	e.preventDefault();
	var name = $(this).attr('name');
	var elements = $('#artists > div:visible');
	// don't think this "if" case is ever executed,
	// the default is to always display the first..
	if (elements.length == 0) {
		$('#' + name).fadeIn('slow');
	}
	else {
		elements.fadeOut(400, function() {
			$('#' + name).fadeIn('slow');
			footer.needsAdjustment = true;
			footer.adjust();
		});
	}
});

var footer = {
	// DRY
	element: $('footer'),
	// track whether the footer requires us to check the adjustment
	needsAdjustment: true,
	// adjust the footer between fixed and relative, if a check is necessary
	adjust: function() {
		if (footer.needsAdjustment && footer.element.hasClass('adjustable')) {
			//var priorPosition = footer.element.css('position');

			footer.element.removeAttr('style');
			// if the visible window is the whole document
			if ($(window).height() >= $(document).height()) {
				// then fix the footer to the bottom
				footer.element.css({
					position: 'fixed',
					bottom: 0,
					left: footer.element.offset().left
				});
			}
			// otherwise display as it was styled
			else {
				footer.element.removeAttr('style');
			}
			/*if (footer.element.css('position') != priorPosition) {
				console.log('different!');
			}*/
			footer.needsAdjustment = false;
		}
	}
}

// adjust the footer intially when the page loads
$(window).load(function() {
	footer.adjust();
});

// adjust the footer as the user resizes the viewport
$(window).resize(function() {
	footer.needsAdjustment = true;
});

setInterval(footer.adjust, 250);

