(function($){
	$.fn.boxLink = function() {
		return this.each(function(){
			var href = this.href;
			var title = this.title;
			if (!href) {
				$("a", this).each(function(){
					if (this.href) {
						href = this.href;
						title = this.title;
						return false;
					}
				});
			}
			
			if (!href) return;
			if (!title) title = "";
			
			var $p = $(this).parent();
			var $a = $("<a href='"+href+"' title='"+title+"'></a>");
			
			$p.css({ position: "relative" });
			
			$p.append($a.css({
				position: "absolute",
				width: $p.outerWidth()+"px",
				height: $p.outerHeight()+"px",
				left:0,
				top:0,
				zIndex:10
			}).addClass("boxLinked"));
		});
	};
	
	$(document).ready(function(){
		$(".boxLink").boxLink();
	});
})(jQuery);