$(document).ready(
	function() {


		// Toggle Search box hints: The word "search" and dark border on focus.
		$('input#q').focus(function() {
			if ($(this).val() == "" || $(this).val() == $(this).attr('title')){
				$(this).val("").removeClass("hinted").addClass("focus");
			}
		}).blur(function() {
			if ($(this).val() == "") {
				$(this).val($(this).attr('title')).addClass("hinted").removeClass("focus");
			}
		}).filter(function() {
			if ($(this).val() == "" || $(this).val() == $(this).attr('title')){
				$(this).val($(this).attr('title')).addClass("hinted").removeClass("focus");
			}
		});


		// Open links with rel="external" in new window - like ye ole' target="_blank"
		$('a[rel="external"]').click(function() {window.open( $(this).attr('href') ); return false;});


		// Zebra-stripe data tables
		$("table.data tbody").each(function() {
			$(this).removeClass("odd even");
			$("tr:odd", this).addClass("odd");
			$("tr:even", this).addClass("even");
		});

		// Wrap internal-page images with a caption block if they start with "caption:"
		$("#content img").each(function() {
			var imgalt = $(this).attr('alt');
			var imgwidth = $(this).width();
			var captionsplit = imgalt.split(":");
			if (jQuery.trim(captionsplit[0].toLowerCase()) == "caption") {
				$(this).wrap('<div style="width:'+imgwidth+'px;" class="captionbox"></div>').after('<p>' + jQuery.trim(captionsplit[1]) + '</p>');
			}
		});
		
	}
);
