$(document).ready(function(){
	
		// remove link background images since we're re-doing the hover interaction below 
		// (doing it this way retains the CSS default hover states for non-javascript-enabled browsers)
		// we also want to only remove the image on non-selected nav items, so this is a bit more complicated
		$(".index-nav").children("li").each(function() {
			var current = "index-nav current-" + ($(this).attr("class"));
			var parentClass = $(".index-nav").attr("class");
			if (parentClass != current) {
				$(this).children("a").css({backgroundImage:"none"});
			}
		});	


		// create events for each nav item
		attachNavEvents(".index-nav", "pane1");
		attachNavEvents(".index-nav", "pane2");
	

		function attachNavEvents(parent, myClass) {
			$(parent + " ." + myClass).mouseover(function() {
				$(this).append('<ul class="index-nav-' + myClass + '"></ul>');
				$("ul.index-nav-" + myClass).css({display:"none"}).fadeIn(500);
			}).mouseout(function() {
				$("ul.index-nav-" + myClass).fadeOut(500, function() {
					$(this).remove();
				});
			}).mousedown(function() {
				$("ul.index-nav-" + myClass).attr("class", "index-nav-" + myClass + "-click");
			}).mouseup(function() {
				$("ul.index-nav-" + myClass + "-click").attr("class", "index-nav-" + myClass);
			});
		}



	});
