/**
 * placeholders
 */
(function() {
	var labels = document.getElementsByTagName('label'), input;
	
	var showPlaceholder = function() {
		if (!this.value) {
			this.value = this.placeholder;
			this.className = this.className.replace(/\s*blured\s*/, '');
		}
	}

	var hidePlaceholder = function() {
		if (this.value == this.placeholder) {
			this.value = '';
			this.className += 'blured';
		}
	}

	for (var i = 0; i < labels.length; i++) {
		if (/placeholder/.test(labels[i].className)
			&& (input = document.getElementById(labels[i].getAttribute('for') || labels[i].htmlFor))
		) {
			if (input.value.length == 0 || input.value == labels[i].innerHTML) {
				input.value = labels[i].innerHTML;
				input.className += 'blured';
			}
			input.placeholder = labels[i].innerHTML;
			cm.addEvent(input, 'focus', hidePlaceholder);
			cm.addEvent(input, 'blur', showPlaceholder);
		}
	}
})();