(function($) {
	$.fn.extend({
		extlink: function (color, prefix) {
			if (typeof color === "undefined")
				color = "grey";
			if (typeof prefix === "undefined")
				prefix = "";
			var url_prefix = String(document.location)
				.replace(/^(https?:\/\/[^:\/]+).*$/, "$1")
				.replace(/^((site)?file:\/\/.+\/)[^\/]+$/, "$1")
				.replace(/(\\.)/g, "\\$1");
			var host_name = String(document.location)
				.replace(/^/, "X")
				.replace(/^X(https?|ftp):\/\/([^:\/]+).*$/, "$1")
				.replace(/^X.*$/, "")
				.replace(/(\\.)/g, "\\$1");
			$("a", this).filter(function (i) {
				var href = $(this).attr("href");
				if (href == null)
					return false;
				return (
					href.match(RegExp(
						"^(" + url_prefix + ".*" +
							(host_name != "" ? ("|" + "(https?|ftp)://" + host_name + "([/:].*)?") : "") +
						"|" + "((https?|ftp):)?/[^/].*" +
						")$"
					)) == null
					&& href.match(RegExp("^(https?|ftp)://.+")) != null
				);
			}).each(function () {
				title = $(this).attr('title');
				if(title !== undefined) {
					title = title + " - "
				} else {
					title = "";
				}
				$(this)
					.addClass('external')
					.attr("target","_blank")
					.attr("title",title + "Opens in a new browser window");
			});
		}
	});
})(jQuery);



$().ready(function() {
	$('A[rel="external"]').attr("target","_blank");
	
	$("a[href$='.pdf']").click(function(){
		window.open(this.href);
		return false;
	});
	
	$(this).extlink();

	var txt = 'Enter a search term…';
	$('input#keywords').val(txt).css('color','#999');
	$('input#keywords').focus(function(){ $(this).val(""); });
	$('#searchform').submit(function(){
		if($('input#keywords').val()==txt) { $('input#keywords').val(''); };
	});
	
	$(".box.link","#aside").click(function(){
		link = $("a:first",this).attr('href');
		window.location = link;
	});
	$(".box.link","#aside").css({cursor:'pointer'});
});
