// TODO implement _t()
var i18n = i18n || {};

;(function($) {
	
	$.fn.DemandMap_collapsible = function() { 
		return this.each(function(){
			var $this = $(this);
			var container = this;

			// set up collapsible boxes
			$('li ul', container).hide();
			$('li.category', container).each(function(el) {
				if($('li.subcategory', this).length > 0) {
					$(this).children('label').after(
						$.sprintf('<small class="toggle">(<a href="#">%s</a>)</small>',
							$.i18n._t('EXPAND')
						)
					);
				}
			});
			$('li.category .toggle', container).bind('click', function(e) {
				$(this).siblings('ul').toggle();
				$(this).siblings('ul').is(':visible') ? $('a', this).html($.i18n._t('COLLAPSE')) : $('a', this).html($.i18n._t('EXPAND'));
				return false; 
			});

		});
	}
})(jQuery);