/**
* WebProduction Packages
* Copyright (C) 2007-2010  WebProduction <webproduction.com.ua>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

/**
* Универсальная prototype-реализация атрибута placeholder для тега input из HTML5.
*
* @package JSPlaceHolder
* @copyright WebProduction
* @author Max
*/
document.observe("dom:loaded", function() {
    $$('input').each(function (e) {
        var v = e.readAttribute('placeholder');
        if (v) {
            if (e.getValue() == '') {
                // if no value - use placeholder value
                e.value = v;
            }
            e.observe('focus', function () {
                if (e.getValue() == v) {
                    e.value = '';
                }
            });
            e.observe('blur', function () {
                if (e.getValue() == '') {
                    e.value = v;
                }
            });
        }
    });
});

