//Placeholder jQuery plugin.
jQuery.fn.extend({
	placeholder: function(Text) {

		var self = this;
		self.Text = Text || "";

		self.supportsPlaceholder = function() {
			var Input = document.createElement("input");
			var TextArea = document.createElement("textarea");
			return "placeholder" in Input && "placeholder" in TextArea;
		}

		self.addPlaceholderValue = function(Control) {
			var ControlValue = Control.val();
			var Placeholder = Control.attr("placeholder");
			if(ControlValue == "") {
				Control.css({"color":"#ACA899"});
				Control.val(Placeholder);
			}
		}

		self.removePlaceholderValue = function(Control) {
			var ControlValue = Control.val();
			var Placeholder = Control.attr("placeholder");
			if(ControlValue == Placeholder) {
				Control.css({"color":"inherit"});
				Control.val("");
			}
		}

		if(self.Text) {
			this.attr("placeholder", self.Text);
		}

		if(!self.supportsPlaceholder()) {
			return self.each(function() {
				$(this).focus(function(){
					self.removePlaceholderValue($(this));
				});
				$(this).blur(function(){
					self.addPlaceholderValue($(this));
				});
				$(this).val("");
				self.addPlaceholderValue($(this));
			});
		}

	}
});
