/*!
* Associated Label / Input
* @desc Given a collection, returns a collection of associated elements
		By default, it returns associated label when given a collection of inputs,
		but can also return inputs based on labels.
* @author: Trevor Morris (trovster)
* @published: 24/08/2009
*/
if(typeof jQuery != "undefined") {	
	(function($){
		$.fn.extend({
			associatedLabelInput: function(type) {
				var $collection = jQuery([]);
					
				type = (typeof type === 'undefined') ? 'label' : type;
				type = type.toLowerCase();
				
				this.each(function() {
					var $$ = $(this);
					
					switch(type) {
						case 'label':
							$collection = $collection.add('label[for=' + $$.attr('id') + ']');
							break;
							
						case 'input':
							$collection = $collection.add('#' + $$.attr('for'));
							break;
					}
				});
				
				return $collection;
			}
		});		
	})(jQuery);
}