var obj = null;

function checkHover() {
	if ( obj==1 ) {
		$('#drawer').slideDown('slow',function() { $('#spacer').fadeIn('slow'); });
        } else {
                $('#drawer').slideUp('medium'); $('#spacer').hide();
	} //if
} //checkHover

$(document).ready(function() {
// drawer
	$('.n').hover(function() { obj = 1; setTimeout("checkHover()",900); });
	$('#nav').mouseout(function() { obj = null; setTimeout("checkHover()",900); });
	$('#drawer').hide(); $('#spacer').hide();

// fix content height
	var sbheight = document.getElementById("sidebar").offsetHeight;
	var cheight = document.getElementById("content").offsetHeight;
	if(sbheight > (cheight - 160)) {
		document.getElementById("content").style.height = (sbheight+160) + 'px';
	}

    // crawl
    $('#crawl div').hide();
    var randomnumber=Math.floor(Math.random()*3)+1;
    crawly(randomnumber);

});

    function crawly(which) { 
	if(!which) { which = 1; }
	$('#crawl'+which).animate({"height":"77px"}, 20000, function() {
            var next = which+1; if(next>3) { next = 1; }
	    $('#crawl'+which).fadeOut(2000, function() {
                $('#crawl'+next).fadeIn(1000);
	    });
        }); 
    }
