/**
* expand: a jQuery Plugin
* @author: Trevor Morris (trovster)
* @url: http://www.trovster.com/lab/code/plugins/jquery.expand.js
* @documentation: http://www.trovster.com/lab/plugins/expand/
* @published: 11/09/2008
* @updated: 30/09/2008
* @license Creative Commons Attribution Non-Commercial Share Alike 3.0 Licence
*		   http://creativecommons.org/licenses/by-nc-sa/3.0/
*
*/
if(typeof jQuery != 'undefined') {
	jQuery(function($) {
		$.fn.extend({
			expand: function(options) {
				var settings = $.extend({}, $.fn.expand.defaults, options);

				return this.each(
					function() {
						var $t = $(this);
						var o = $.metadata ? $.extend({}, settings, $t.metadata()) : settings;
						
						/**
						* Create a link
						* Set the link text defined in settings
						* Add the class defined in settings
						* Add the href defined in settings
						* @event click
						*/
						$('<a />').text(o['text']).attr('href',o['href']).bind('click', function(event){
							var $a = $(this);
							
							/**
							* Animate the container
							*/
							$t.animate({
								height: $t.height() + parseInt(o['height'])
							}, o['speed']);
							
							/**
							* Remove focus from the anchor
							* Stop the link from being followed
							* @event blur
							*/
							$a.blur();
							return false;
						}).wrap('<p />').parent().addClass(o['class']).insertAfter($t);
					}
				);
			}
		});
		
		/**
		* Plugin Defaults
		*/
		$.fn.expand.defaults = {
			'text'	: 'Expand', //* @var string
			'class'	: 'expand-link', //* @var string (valid token)
			'href'	: '#expand', //* @var string (hash)
			'height': 150, //* @var int
			'speed' : 'slow' //* @var int|string (slow,fast or integer)
		};
	});
}