// <![CDATA[
/**
 * dependency of this plugin:
 *
 * //@var global string http_root
 * //@var global string rp_global_image
 * //@var global string img_loader
 * //@var global string rp_cms
 *
 * //@function close_popup()
 *
*/

// You need an anonymous function to wrap around your function to avoid conflict
(function($){
 
    // Attach this new method to jQuery
    $.fn.extend({ 
         
        // This is where you write your plugin's name
        replace_radio: function(options) {
		
			// Set the default values, use comma to separate the settings, example:
            var defaults = {
				increment: 0 // The increment number.
            }
                 
            var options = $.extend(defaults, options);
			
			var $cm = this.each(function(){
				
				var o = options;
				var object = $(this);
				
				if(object.length > 0)
				{
					object.hide();
					object.after('<span class="button-radio-replacement"></span>');
					var $each_check = object.attr('checked');
					
					if($each_check === true)
					{
						$('.button-radio-replacement').css({backgroundPosition:'0px -20px'});
					}
					else
					{
						$('.button-radio-replacement').click(function(){
							var $this_parent = $(this).parent();
							var $this_check = $('.button-radio',$this_parent).attr('checked');
							var $this_value = $('.button-radio',$this_parent).val();
							//alert($this_value);
							
							if($this_check === false)
							{
								$('.button-radio').attr('checked', false);
								$('.button-radio-replacement').css({backgroundPosition:'0px 0px'});
								$('.button-radio-replacement',$this_parent).css({backgroundPosition:'0px -20px'});
								$('.button-radio',$this_parent).attr('checked', true);
							}
							
							if($this_value === '3')
							{
								//alert($this_value);
								$('.select_forum').show();
							}
							else
							{
								$('.select_forum').hide();
							}
							
						});
					
					}	
				}

			});

        }
    });
     
//pass jQuery to the function, 
//So that we will able to use any valid Javascript variable name 
//to replace "$" SIGN. But, we'll stick to $ (I like dollar sign: ) )       
})(jQuery);

// ]]>
