// <![CDATA[
/**
 * dependency of this plugin:
 *
 * //@var global string http_root
 * //@var global string rp_global_image
 * //@var global string image_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
        scroll_to_top: function(options) {
		
			// Set the default values, use comma to separate the settings, example:
            var defaults = {
				speedAnimate:		'slow',
				topMargin:			0
            }
			
			// Always leave this line here.
			var options = $.extend(defaults, options);
			var o = options;
			
			this.unbind('click');
                 
           // Attach click function.
			var $cm = this.click(function(){
			
				//var $cm = this.each(function(index,element){
				// "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.ready(function(e){
				
				
				var object = $(this); // always return #document if you have: var $cm = this.ready(function(e){}).
				
				// Keep the lines below for checking.
				//alert(object.get(0).nodeName);
				//alert(object.selector);
				//alert($cm.selector);
				//alert(o.insertBeforeTarget);
				//alert(o.durationAnimate);
					
				//});
				
				
				//alert('1');	
				
				$('html, body').animate({scrollTop:o.topMargin}, o.speedAnimate);
				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);

// ]]>
