﻿(function($) {
	$.fn.extend({
		gat_itemExpander: function() {
			this.each(function() {
				var $this = $(this);
				
				if ($this.text() == $this.attr('text-expand')) {
					$($(this).attr('item-selector')).slideUp();
				}
			});

			return this.live('click', function(event) {
				event.preventDefault();
				var $this = $(this);
				var $item = $($(this).attr('item-selector'));

				// If item is hidden, then expand, else collapse
				if ($item.is(':hidden')) {
					// Display expand text and collapse item
					$this.html($this.attr('text-collapse'));
					$item.slideDown();
				}
				else {
					// Display collapse text and display item
					$this.html($this.attr('text-expand'));
					$item.slideUp();
				}
			});
		}
	});
})(jQuery); 
