$(document).ready(function() {

	$('input[data-placeholder]')
		.each(function() {
			var $this = $(this);
			if ($this.val().length) {
				$this.addClass('active');
			} else {
				if (this.type == 'password') {
					$this.attr('data-password', true);
					try {
						this.type = 'text';
					} catch(e) {}
				}
				$this.removeClass('active').val($this.attr('data-placeholder'));
			}
		})
		.focus(function() {
			var $this = $(this);
			if ($this.hasClass('active')) {
				return;
			}
			$this.val('').addClass('active');
			if ($this.attr('data-password')) {
				try {
					this.type = 'password';
				} catch(e) {}
			}
		})
		.blur(function() {
			var $this = $(this);
			if (!$this.val().length) {
				try {
					this.type = 'text';
				} catch(e) {}
				$this.val($this.attr('data-placeholder')).removeClass('active');
			}
		});
	$('form').submit(function() {
		var $this = $(this);
		$this.find('input[data-placeholder]').each(function() {
			var $this = $(this);
			if (!$this.hasClass('active')) {
				this.value = '';
			}
		});
	});

});
