/**
* Clickable: a jQuery Plugin
* @author: Mark James
* @url: 
* @documentation: 
* @published: 23/06/2009
* @updated: 23/09/2009
* @license Creative Commons Attribution Non-Commercial Share Alike 3.0 Licence
*		   http://creativecommons.org/licenses/by-nc-sa/3.0/
* @notes: 
* With a top of the hat to Trevor Morris - http://www.trovster.com/lab/plugins/fitted/
*
*/
if(typeof jQuery != 'undefined') {
	jQuery(function($) {
		$.fn.extend({
			clickable: function(options) {
				var settings = $.extend({}, $.fn.clickable.defaults, options);
				return this.each(
					function() {
						var $t = $(this);
						var o = $.metadata ? $.extend({}, settings, $t.metadata()) : settings;
						if($t.find(':has(a)')) {
							var $a = $t.find('a:first');
							$a2 = $a.clone(true).html('').removeClass().addClass(o['class']['link']).css('display','block');
							$t.wrapInner( $a2 ).addClass(o['class']['container']);
						}
					}
				);
			}
		});
		
		/**
		* Plugin Defaults
		*/
		$.fn.clickable.defaults = {
			'class' : {
				'link' : 'clickable-wrapper',
				'container' : 'clickable-parent'
			}
		};
	});
}
