$(function()
{
	var EXCERPT_HEIGHT = 0; // usually the height of the number of lines expected, ex. 16*2 = 32 two lines excerpt
	var LINE_PAD = 10;
	var PAD_OFF = 0;
	var PAD_ON = 10; // should be 0 if reverted to >0 excerpt
	var height;
	var item;
	
	var isIE = (/MSIE [6789]/i).test(navigator.userAgent);
	var isIE8 = (/MSIE [89]/i).test(navigator.userAgent);
	var isIE7 = (/MSIE [7]/i).test(navigator.userAgent);
	var isIE6 = (/MSIE [6]/i).test(navigator.userAgent);
	
	if (isIE) {
		LINE_PAD += 5;
		//PAD_OFF += 5;
		PAD_ON += 5;
	}
	
	if (isIE6) {
		PAD_ON += 10;
	}
	
	var desc = $('.expand');
	for (var i = 0, m = desc.length; i < m; i++) {
		item = $(desc[i]);
		if ((height = item.height()) > EXCERPT_HEIGHT + LINE_PAD) {
			item.height(EXCERPT_HEIGHT + PAD_OFF);
			item.after('<div class="expand-after"><p><a href="" id="more-info-' + i + '" class="bottom-link">More Info</a></p></div>');
			var link = $('#more-info-' + i).click(toggle);
			link[0].parentDescription = item;
			link[0].fullDescriptionHeight = height;
		}
	}
	
	function toggle()
	{
		try {
			var me = $(this);
			var that = this;
			// TRICKY: display toggles via callbacks are required for IE6/7 for proper spacing
			if (me.hasClass('bottom-link')) {
				me.removeClass('bottom-link').addClass('top-link').html('Less Info');
				if (isIE6 || isIE7) this.parentDescription.show();
				this.parentDescription.animate({'height': this.fullDescriptionHeight - LINE_PAD + PAD_ON}, this.fullDescriptionHeight - EXCERPT_HEIGHT); 
			} else {
				me.removeClass('top-link').addClass('bottom-link').html('More Info');
				this.parentDescription.animate({'height': EXCERPT_HEIGHT + PAD_OFF}, this.fullDescriptionHeight - EXCERPT_HEIGHT, 'linear', function () { if (isIE6 || isIE7) that.parentDescription.hide() });
			}
		} catch (e) {
			// alert(e);
		}
		
		return false;
	}
});