/*
How to Use:

 	$( x  ).checkselect( y , a , b );
 	
 	x: a matcher/selector ( like CSS ) that identifies _all_  possible options in the radio group.
 	y: the value of the attribute "VALUE" on the radio button you want to trigger on. 
 	
 	a: a function(){}  that gets executed when somebody selects it
 	b: a function(){} that gets executed when somebody unselects it
 	
 	Example:
 	
 	<input type="radio" name="pickup" value="a" />
 	<input type="radio" name="pickup" value="b" />
 	<input type="radio" name="pickup" value="c" />
 	
 	
 	$("input[@type=radio][@name=pickup]").checkselect("b", function(){
 		alert("B was selected");
 	},function(){
 		alert("B was unselected");
 	});
 	
 	
*/

jQuery.fn.checkselect=function(key,show,hide)
{
	var family = this;
	/* this level is just creating the function and attaching it to every item in the group */
	jQuery(this).each(function(){
		
		var checkselectupdate=function(){	
		
			/* this level is what happens when a use clicks/changes any item in a group */
			jQuery(family).each(function(){ 
				if( jQuery(this).attr("value") == key )
				{
					if( jQuery(this).attr("checked")==true )
					{
						show();
					}
					else
					{
						hide();
					}
				}
			});
		};
		jQuery(this).change(function(){
			jQuery(family).each(checkselectupdate );
			/* end change code */
		});
		jQuery(this).mouseout(function(){
			jQuery(family).each( checkselectupdate );
				
			/* end change code */
		});
	});
	/* end match code */
	
}