(function($) {

$.fn.defInputValue = function(options) {

	function CleanDefValue(param){
		
		if($(param.inp).val() == param.defV){
			$(param.inp).val("");
			
			if(param.opt.editColor && param.opt.editColor.length>0)
				$(param.inp).css("color", param.opt.editColor);
		}
	}	

	function SetDefValue(param){
		
		$(param.inp).val(param.defV);
			
		if(param.defColor)
			$(param.inp).css("color", param.defColor);		
	}
	
	function initInputValue()
	{		
		$(opt.InputClass, context).each(function(){
					
			var param = {inp:this, opt:opt, defV:$(this).val(), defColor:$(this).css("color")};
			
			param.inp.SetDefValue = function(){SetDefValue(param)};
			
			elements.push(param);

			$(this).bind("focus", function(){
					
				CleanDefValue(param);
			});
			
			$(this).bind("blur", function(){
				if($(param.inp).val() == "") SetDefValue(param);				
			});
		});
	}
	
	var defaults = {
	
		InputClass:".defValue",
		editColor:"black"
	};
	
	var opt = $.extend(defaults, options);
	
	var context = $(this);
	
	var elements = [];
		
	initInputValue();
	
	return elements;
}
})(jQuery);
