(function($) {

	// Enables IE6 for the drop-downs, and allows keyboard visibility for others.
	function dropDown() {
		if (document.all) {
			$("#navbarleft ul>li").bind("mouseenter",function() {
				$(this).children("ul").css("left", "auto");
				}).bind("mouseleave",function(){
				$(this).children("ul").css("left", "-999em");
			});
		}
		$("#navbarleft>ul>li>a").bind("focus",function() {
			$(this).next().css("left", "auto");
		});
		$("#navbarleft ul ul li:last-child a").bind("blur",function() {
			$(this).parent().parent().css("left", "-999em");
		});
	}

	// Shrinks the 'read more' links on the homepage.
	function shrinkLink() {
		var links = $("#contentbody p.more a");
		$(links).each(function(i){
				var link = links[i];			// This link
				var contents = $(link).text();	// The text of the link
				if( contents.length>25 ) {
					var newContent = contents.substring(0,34) + "...";
					$(link).empty().append(newContent);
				}
		});// end each
	}

	// Clears default text from search.
	function clearSearch() {
		$("#s").focus( function () { 
			if( $("#s").attr("value") == "search") {
				$("#s").attr("value", "");
			}
		});
	}

	// Functions to call on DOM ready.
	$(document).ready(function() {
		shrinkLink();
		dropDown();
		clearSearch();
	});
})(jQuery);