$(document).ready(function() {
	
	var nav = $('header#top nav');
	
	function resizeNav() {
		
		var width = $(window).width();
		var re_width = $(window).width()-274;
		var ul_width = $('header#top nav ul').width();

		if ((ul_width > re_width) || (width < 1024)) { re_width = '100%'; }
		nav.css({ width: re_width });
		
	}
	
	$(window).resize(function() {
  		resizeNav();
	});
	
	var showall = $('header#top nav #show');
	
	resizeNav();
	
	$('header#top nav:has(.active)').each(function(){
		
		$('header#top nav > ul li').each(function(){

			if (!($(this).hasClass('active'))) {
				$(this).hide();
			}

			showall.show();

		});
		
	});
		
	showall.find('a').click(function(){
		
			$('header#top nav > ul li').animate({ 'width' : 'show', 'opacity' : 'show' });
			$('#artist-nav a').animate({ opacity: 'hide', top: '-15' });
			showall.fadeOut();
			
	});
	
	$(window).load(function () {
		
		$('header#top nav').fadeIn();
		
	});
		
});
