(function($) {
	$.fn.hideIfEmpty = function(target) {
		var $this = $(this);
		var target = target ? $(target) : $this;
		if(!$this.text().length)
			target.remove();
		return $this;
	};
})(jQuery);

// Catch old shorten.byClass calls and pass them on to jQuery.shorten
var shorten = {
	byClass : function(t, c, l, e) {
		$(t + '.' + c).shorten({
			length : l,
			closure : e
		});
	}
};

$(function() {

	// Set up menu
	$('div#menu > ul > li').menu({
		dropdown : 'ul',
		effect : 'slideDown',
		duration : 150,
		swapTarget : 'a'
	});
	
	// Set up tabs
	var products = $('#products');
	products.find('h2 a').each(function(i) {
		$(this).attr('rel', i + 1);
	});
	products.tabs({
		pages : '.product_blok',
		title : 'h2 a',
		insert : 'append',
		rotate : true
	});
});


