// <![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
        replace_input_password: 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)
				{
					// Create the a dump-password-input-field next to the current input and hide the password input.
					var val_name = object.attr('name');
					var target = object.parent();
					object.after("<input name='"+val_name+"_dump' type='password' value=''/>");
					object.next().hide();
					
					// On focus.
					object.focus(function () {
						
						// Hide the input and display the next input and put focus on it.
						$(this).hide();
						$(this).next().show().focus();
						
						// Get the value from the dump-password-input-field and put it into actual password input for database validation.
						$(this).next().keyup(function () {
							var value = $(this).val();
							$(this).prev().val(value);
						}).keyup();
						
					}).next().blur(function(){
						
						// If the password input is empty.
						if($(this).val() == '')
						{
							$(this).hide();
							$(this).prev().show();
							$('form *[title]').inputHint();
						}
						//alert($(this).parent().html());
							
					});	
				}

			});

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

// ]]>
