(function(){
  
  // The DOM is ready
  jQuery(function() {
    $('#mainLeftCol .portletCollection dd, #content div.tileItem, #mainRightCol .portletCollection dd, .template-atct_topic_event_view #content-core dt').enlargeClickarea();
  });

  $.fn.enlargeClickarea = function() {
    var baseurl = $('base').attr('href') || '';
    
    return this.each(function() {
      var link = $(this).find('a').eq(0),
	  	  item = $(this);
      if ( !link.length ) return;
  
      item
	  .hover(function(){
		$(this).toggleClass('hover');
	  })
	  .click(function(event) {
        if ( $(event.target).is('a') ) return true;
        
        var href = link.attr('href');
  
        window.location = href.indexOf('http') == 0 ? href : baseurl + href;
      });
	  
	  link
	  	.focus(function(){
	  		item.addClass('hover');
	  	})
		.blur(function(){
			item.removeClass('hover');
		});
    });
  };

})(jQuery);
