(function ($) {
	$.fn.defaultInputText = function (value) {
    	return this.each(function () {
    		
    		var input = $(this);
    		var defaultInputValue;
    		
    		if (value) {
    			defaultInputValue = value;
    			if (input.val() == '')
    				input.val(defaultInputValue);
    		} else
    			defaultInputValue = input.attr('value');
    		
    		var type = input.attr('type');
    		
    		if (type != 'text' && type != 'password' && input.get(0).tagName != 'TEXTAREA')
    			return;
    		
    		if (type == 'password' && input.val() == defaultInputValue) {
    			var dummy_element = document.createElement('input');
    			dummy_element.type = 'text';
    			dummy_element.name = input.attr('name') + '_dummy';
    			dummy_element.id = input.attr('id') + '_dummy';
    			dummy_element.value = input.attr('value');
    			$(dummy_element).insertAfter(this);
    			input.hide();
    			$(dummy_element).focus(function() {
    				$(this).hide();
					input.show();
					input.focus();
    			});
    			input.blur(function() {
    				if ($(this).val() == '') {
    					$(this).hide();
						$(dummy_element).show();
    				}
    			});
    		}
    	
    		input.focus(function() {
				var id = $(this).attr('id');
				var name = $(this).attr('name');
				var val = $(this).val();
				if (val == defaultInputValue) {
					$(this).val('');
				}
			});
			
			input.blur(function() {
				var id = $(this).attr('id');
				if ($(this).val() == '') {
					$(this).val(defaultInputValue);
				}
			});
			
    	});
    };
})(jQuery);
