YUI(yuiConfig).use('node', function(Y) {

    var supportsInputPlaceholder = function() {
		var i = document.createElement('input');
		return 'placeholder' in i;
    };

    var setupPlaceholder = function(node) {

	var activatePlaceholder = function(node) {
	    if (node.get('value') == '' || node.get('value') == node.getAttribute('placeholder')) {
			if (node.getAttribute('type') == 'password') {
		    	node.setAttribute('data-original-type', 'password');
		    	node.set('type', 'text');
			}

			node.set('value', node.getAttribute('placeholder'));
			node.addClass('placeholder');
	    }	
	};

	var deactivatePlaceholder = function(node) {
	    if (node.get('value') == node.getAttribute('placeholder')) {
			if (node.getAttribute('data-original-type') == 'password') {
		    	node.set('type', 'password');
			}

			node.set('value', '');
			node.removeClass('placeholder');		
	    }
	};

	activatePlaceholder(node);
	
	node.on('focus', function(e) {
	    deactivatePlaceholder(e.target);
	});

	node.on('blur', function(e) {
	    activatePlaceholder(e.target);
	});

    };

    if (!supportsInputPlaceholder()) {
		Y.all("input[placeholder]").each(setupPlaceholder);
    }

});
