$(document).ready(function() {

	// Resize the lightbox.
	$('#lightbox #lb-bg').css({height:$("body").height()});
	
	//
	// Put some niceness on the search form.
	//
	
	// Show the clear button if there is text in the input.
	if ( $(".search input").val() == '' || $(".search input").val() == 'Search' ) {
		$(".search .submit").css({opacity:0.2});
	} else {
		$(".search input").addClass("active");
	}
	// Do stuff when selecting the input field.
	$(".search input").focus(
		function()
		{
			if ( $(this).val() != '' ) {
				$(this).attr("rel", $(this).val())
					.val("")
					.addClass("active")
					.parent().parent().find(".submit").css({opacity:0.2});
			}
		}
	).blur(
		function()
		{
			if ( $(this).val() == '' ) {
				var relValue = $(this).attr("rel");
				$(this).val($(this).attr("rel")).removeAttr("rel");
				if ( relValue == '' || relValue == 'Search' ) {
					$(this).removeClass("active")
					.parent().parent().find(".submit").css({opacity:0.2});
				} else {
					$(this).parent().parent().find(".submit").css({opacity:1});
				}
			}
		}
	).keyup(
		function()
		{
			if ( $(this).val() == '' ) {
				$(this).parent().parent().find(".submit").css({opacity:0.2});
			} else {
				$(this).parent().parent().find(".submit").css({opacity:1});
			}
		}
	);
});

function validateSearch( el )
{
	if ( el.find("input").val() == '' || el.find("input").val() == 'Search' ) {
		return false;
	}
	return true;
}
