// <![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
        older_string: function(options) {
		
			// Set the default values, use comma to separate the settings, example:
            var defaults = {
				pathString:				'.string-load-path',
				incrementString:		'.string-increment',
				startRowString:			'.string-start-item',
				targetElement:			'.item-needle'
            }
                 
            var options =  $.extend(defaults, options);
			var o = options;
            
			// return this.click(function(){ // original
			// "this" is already a jQuery object: 
			// When you create the click function you can assign that element to a variable and reference it within:
			var $cm = this.click(function(e){
				
				// Set the variable and store the data.
				var path_string = $(o.pathString).text();
				var increment_string = parseInt($(o.incrementString).text());
				var start_row_string = parseInt($(o.startRowString).text());
				var target_insert = $(o.targetElement);
				
				// Create a container.
				if($('.items-needle-temp').length > 0) $(".item-needles-temp").filter(":last").after("<div class='items-needle-temp'></div>");
				target_insert.filter(":last").after("<div class='items-needle-temp'></div>");
				
				// Hide the last item of .item-temp.
				$('.items-needle-temp:last').hide();
				
				// Load the content.
				$('.items-needle-temp:last').load( path_string + start_row_string, function(){
					
					// Set the next number.
					var string_start_item_new = start_row_string + increment_string;
					
					// Set the new start item number.
					$(o.startRowString).text(string_start_item_new);
					
					// Fade in and slide down the content.
					$('div',this).hide().fadeIn();
					$(this).slideDown();
					
					$.fn.micromenu_string();
					
					$('form *[title]',$(this)).inputHint(); 
					
				});
		
				// Keep the lines below for checking.
				//alert(o.popupEdit);
				//alert(path_rescale);
				//alert(path_edit);
				//alert(item_id);
				//alert(o.top);
				//alert($cm.selector);
					
				return false;
				
			});

        }
    });
     
//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);

// ]]>
