$(document).ready(function() {

    //console.log("page loaded: DOM ready");

    /*****************************
     ** Menu Slider
     ****************************/

    var showmemorebtn = "<li id=\"showmemore\"><a href=\"#\">expand</a></li>";

    function showMenu() {

	$("ul#first-level")
	    .find("ul").addClass("jq")
	    .end()
	    .animate({height:"13em"},"slow")
	    .find("li#showmemore a").empty().append("collapse");
    }

    function hideMenu() {

	$("ul#first-level")
	    .animate({height:"1.5em"},"slow", null, 
		     function() {
			 $("ul", $(this)).removeClass("jq");
		     })
	    .find("li#showmemore a").empty().append("expand");

    }

    //add class jq to all <ul>'s and hide
    $("ul#first-level")
	.addClass("jq")
	.removeClass("minimal")
	.append(showmemorebtn);

    //the sliding
    var menuswitch = 0;
    $("li#showmemore a").click(function() {
	if (menuswitch == 0) {
	    showMenu();
	    menuswitch = 1;
	    $(this).addClass("collapse");
	}

	else {
	    hideMenu();
	    menuswitch = 0;
	    $(this).removeClass("collapse");
	}
	
	return false;
    });

    /*****************************
     ** Search form
     ****************************/

    $("form#searchbox input#s")
	.focus(function() {
	    if (this.value == 'search...')
		this.value = '';
	    })
	.blur(function() {
	    if (this.value == '')
		this.value = 'search...';
	    });

});
