/**
 * 
 * ghostText JQuery Plugin ver 1.1 (14/10/2009)
 * 
 * ver 1.1 - Introduction of textareas
 *
 **/

jQuery.fn.ghostText = function(options){
	
	var defaults = {  
		color : "#999999"
   	};  
  	var options = $.extend(defaults, options); 
	
	return this.each(function(){
		
		var TYPE = $(this).attr('tagName');
	
		var theColor = $(this).css('color');
		$(this).css('color', options.color);
		
		if(TYPE == "TEXTAREA") {
			
			var theValue = $(this).html();
			
			$(this).focus(function() {
				if($(this).html() == theValue) {
					$(this).css('color', theColor).html("");
				}
			}).blur(function() {
				if($(this).html().length < 1) {
					$(this).css('color', options.color).html(theValue);
				}
			});
			
		} else if(TYPE == "INPUT") {
			
			var theValue = $(this).val();
			
			$(this).focus(function() {
				if($(this).val() == theValue) {
					$(this).css('color', theColor).val("");
				}
			}).blur(function() {
				if($(this).val().length < 1) {
					$(this).css('color', options.color).val(theValue);
				}
			});
		}
		
	});
}


