(function($) {
$.fn.placeholder = function(options) {
	var defaults = {css_class: "placeholder"};
	var options = $.extend(defaults, options);
	this.each(function() {
		if ($(this).attr('placeholder') !== undefined) {
			var phvalue = $(this).attr("placeholder");
            if($(this).is("textarea"))
                phvalue = phvalue.replace("\n", "");
            
            $(this).attr("placeholder", "").removeAttr("placeholder");
            
			var currvalue = $(this).attr("value");
            if(currvalue == "")
                $(this).val(phvalue);

			if (phvalue == currvalue) {
				$(this).addClass(options.css_class);
			}
			if (currvalue == "") {
				$(this).addClass(options.css_class);
				$(this).val(phvalue);
			}
			$(this).focus(function(){
				if (phvalue == $(this).val()) {
					$(this).val("").removeClass(options.css_class);
				}
			});

			$(this).blur(function(){
				if ($(this).val() == "") {
					$(this).val(phvalue).addClass(options.css_class);
				}
			});
            var $form = $(this.form);
            var $this = $(this);
            $form.submit(function() {
                if($this.val() == phvalue) {
                    $this.val("");
                }
            });
		}
	});
	return this;
	};
})(jQuery);

$(document).ready(function() {
    $('input[type="email"], input:text, textarea').placeholder();
});
