
	$(function() {
		
		// Global information
		numberOfRowsToDisplay = 1;
		currentIndex = 0;
		numberOfLines = $("ul.topNav").length - numberOfRowsToDisplay;
		
		
		
		// Hide all divs after the one that is visible
		$("ul.topNav:gt("+(numberOfRowsToDisplay-1)+")").hide();		// Zero indexed of course
	
		// Dynamically set height on div so we can slideUp() and slideDown() stuff inside it and it won't shrink too
		var h = $("#nav-holder").height();
		$("#nav-holder").css("height", h+"px");	
			
		// Up arrow functionality
		$("a#up-arrow")
			.addClass("disabled")	// Disabled by default since we're at the top of the list
			.click(function(e) {
			
				e.preventDefault();
			
				if ( currentIndex > 0 ) {
				
					// Old functionality for 2 rows
					/*
					$("ul.topNav:eq("+(currentIndex-1)+")").slideDown("fast", function() {
						$("ul.topNav:eq("+(currentIndex+1)+")").slideUp("fast", function() {
							$("a#down-arrow").removeClass("disabled");		// If I went up, I can go back down
							if ( --currentIndex == 0 ) {
								$("a#up-arrow").addClass("disabled");
							}
						});
					});
					*/
					
					$("ul.topNav:eq("+(currentIndex-1)+")").slideDown("fast", function() {
						$("ul.topNav:eq("+currentIndex+")").hide();
						$("a#down-arrow").removeClass("disabled");		// If I went up, I can go back down
						if ( --currentIndex == 0 ) {
							$("a#up-arrow").addClass("disabled");
						}
					});
					
				
				}
			
		});
	
	
		// Down arrow functionality
		$("a#down-arrow").click(function(e) {
			
			e.preventDefault();
			
			if ( currentIndex < numberOfLines ) {
				
				/*
				$("ul.topNav:eq("+(currentIndex+2)+")").show();
				$("ul.topNav:eq("+(currentIndex)+")").slideUp(function() {
					$("a#up-arrow").removeClass("disabled");	// If I went down, I can obviously go back up
					if ( ++currentIndex == numberOfLines ) {
						$("a#down-arrow").addClass("disabled");
					}
				});
				*/
				
				$("ul.topNav:eq("+(currentIndex+1)+")").show();
				$("ul.topNav:eq("+currentIndex+")").slideUp("fast", function() {
					$("a#up-arrow").removeClass("disabled");	// If I went down, I can obviously go back up
					if ( ++currentIndex == numberOfLines ) {
						$("a#down-arrow").addClass("disabled");
					}
				});
				
			}
			
		});
		


		// Scroll to the guy
		var selected = $("a.current-recipe");
		if ( selected.length == 0 ) {
			selected = $("ul.topNav:first a:first");
		} 
		
		// 0 is the one we're already showing
		var index = selected.closest("ul.topNav").prevAll("ul.topNav").length;
		if ( index > 0 ) {
			for ( var i = 0; i < index; i++ ) {
				$("a#down-arrow").click();		// Just click the down arrow for the very lazy user
			}
		}

	
	});
