$(function() {
	$.fn.extend({
		makeSwGridItem: function() {
			if ($(this).parents(".grid").size())
			{
				$(this).click(function(e) {
					if (e.target.nodeName.toLowerCase() == 'a')
						return true;
					var link = $("a:eq(0)", this)[0];
					var hasAttribute = false;
					if (link.hasAttribute)
					{
						hasAttribute = link.hasAttribute('href');
					}
					else
					{
						if (link.attributes['href'].nodeValue)
							hasAttribute = true;
					}
					if (hasAttribute) {
						if (link.href.indexOf('javascript:') == 0)
							hasAttribute = false;
					}
					if (hasAttribute)
					{
						if (link.target)
							window.open(link.href, link.target);
						else
							location.href = link.href;
					}
					else $(link).click();
					return false;
				}).parent().andSelf().hover(function() { $(this).addClass('hover'); }, function() { $(this).removeClass('hover'); });
			}
			if ($(this).parents(".grid:not(.grid-1-column)").size()) {
				var myRow = $(this).parents(".row");
				var myHeight = $(this).height();
				$(".record", myRow).each(function() {
					myHeight = Math.max(myHeight, $(this).height());
				});
				$(this).css({ height: myHeight + 'px' });
			}
		}
	});
});
function gridBinding(sel) {
	return function() {
		$(sel).makeSwGridItem(sel);
	}
}

