jQuery.fn.textPlaceholder = function () {

	return this.each(function(){

		if (this.placeholder && 'placeholder' in document.createElement(this.tagName)) return;

		var placeholder = $(this).attr('placeholder');
		var input = $(this);

		if (placeholder == undefined) return;
		
		if (this.value === '' || this.value == placeholder) {
			input.addClass('text-placeholder');
			this.value = placeholder;
		}

		input.focus(function(){
			if (input.hasClass('text-placeholder')) {
				this.value = '';
				input.removeClass('text-placeholder')
			}
		});

		input.blur(function(){
			if (this.value === '') {
				input.addClass('text-placeholder');
				this.value = placeholder;
			} else {
				input.removeClass('text-placeholder');
			}
		});

		this.form && $(this.form).submit(function(){
			if (input.hasClass('text-placeholder')) {
				this.value = '';
			}
		});

	});

};
