﻿(function($) {

 $.fn.divgrow = function(options) {
	var defaults = {
		initialHeight: 100, moreText: "+ Show More", lessText: "- Show Less", nHeight: 500
	};
	var options = $.extend(defaults, options);
	return this.each(function() {
		obj = $(this);
		obj.css('height', options.initialHeight).css('overflow', 'hidden');
		obj.after('<a href="#" class="adjust"></a>');
		$("a.adjust").text(options.moreText);
		$(".adjust").toggle(function() {
			//var height = $(this).prevAll("div:first").attr('rel');
			//var nHeight_a = $(this).parent().height();
			var nHeight_a = $(this).prev('div.panelStaff').children('div.staffHeight').height();
			//alert(nHeight_a);
			
			$(this).prevAll("div:first").animate({
			//$(this).prev("div.panelStaff").animate({
				//height: options.nHeight_a
				height: nHeight_a
			},
			500, function() {
				$(this).nextAll("p.continued:first").fadeOut();
				$(this).nextAll("a.adjust:first").text(options.lessText)
			})
			
			}, function() {
				$(this).prevAll("div:first").animate({
					height: options.initialHeight
					},
					500, function() {
						$(this).nextAll("p.continued:first").fadeIn();
						$(this).nextAll("a.adjust:first").text(options.moreText)
					})
				})
			})
		}
	})
(jQuery);
