jQuery(function($) {
	
	turnBlockElementsToLinks( $('.block-link') );
	
	$('#p-query').bind('focus', function(e) { toggleText($(this), "Search assignments"); });
	$('#p-query').bind('blur', function(e) { toggleText($(this), "Search assignments"); });
	$('#query').bind('focus', function(e) { toggleText($(this), "Search"); });
	$('#query').bind('blur', function(e) { toggleText($(this), "Search"); });

	/**
	 * This function takes a set of modules and wraps them in
	 * a-tags. This makes it possible to make an entire module
	 * clickable while still conforming to XHTML 1.0 Strict.
	 */
	
	function turnBlockElementsToLinks(modules) {
		modules.each(function() {
			var link = $('<div>').append($(this).find('a:first').clone()).find('a');
			link.html('').addClass('block-link');
			
			link.append($(this).children().clone()).remove();
			
			$(this).html('').append(link);
		});
	}
	
	/**
	 * This function toggles describing for search forms
	 */
		
	function toggleText(that, text) {
		if (text == that.val()) {
			that.val('');
		} else if ("" == that.val()) {
			that.val(text);
		}
	}
})
