$(function(){
	var $h = $('#header'),
		$l = $('h1 a', $h),
		$s = $('#s', $h),
		op = $h.css('opacity');

	if ($s[0].value.length > 1) {
		$s.addClass('infocus');
	}
	// add header fadout when focus leaves search box
	$s.focusin(function(){
		$(this).addClass('infocus');
		$h.css('opacity','0.9');
	});
	$s.focusout(function(){
		if (this.value.length < 1) {
			$(this).removeClass('infocus');
			$h.animate({opacity:op}, 800);
		}
	});
	// add fadeout when hover/focus leaves header
	$h.hover(
		function(){
			$h.css('opacity', '0.9');
		},
		function(){
			if (! $s.hasClass('infocus')) {
				$h.animate({opacity:op}, 400);
			}
		}
	);	
});

