$(document).ready(function() {
closetimer = 0;

page = $("body").attr("class");
if (page.indexOf("kate") != -1) {$("ul.about").show(); $("b#kate").addClass("fixed");}
if (page.indexOf("books") != -1) {$("ul.books").show(); $("b#books").addClass("fixed");}
if (page.indexOf("news") != -1) {$("ul.news").show(); $("b#news").addClass("fixed");}

$("b.sub").click(function(){
	if(this.className.indexOf("fixed") != -1) {
		$("b.current").next().slideUp(400);
		$("b.current").css("color","#dee0d1");
		$("b.current").removeClass("current");
	}

	if(this.className.indexOf("fixed") == -1) {
	if(this.className.indexOf("current") == -1) {
		$("b.current").css("color","#dee0d1");
		id = $(this).attr("id");
		$('b.sub').each(function() {
			id = $(this).attr("id");
			if (page.indexOf(id) == -1) {
			$(this).next().slideUp(400);
			}
		});
		$("b.sub").removeClass("current");
		$(this).next().slideDown(400);
		$(this).addClass("current");
	}
	else {
		$(this).removeClass("current");
		$(this).next().slideUp(400);
		$(this).css("color","#dee0d1");
	}
	}
});

$("b.sub").mouseover(function(){
	$(this).css("color","#ffffff");
});
$("b.sub").mouseout(function(){
	if(this.className.indexOf("current") == -1 && this.className.indexOf("fixed") == -1 ) {
	$(this).css("color","#dee0d1");
	}
});

$("#leftnav").mouseover(function() {
clearTimeout(closetimer);
});

$("#leftnav").mouseout(function() {
			closetimer = window.setTimeout(function(){

			$('b.sub').each(function() {

			id = $(this).attr("id");
			if (page.indexOf(id) == -1) {
				if(this.className.indexOf("fixed") == -1) {

				$(this).next().slideUp(400)
				$(this).css("color","#dee0d1");
				}
			}
			});
			$("b.sub").removeClass("current");
			}, 2000);
		}); 


});

