

/*
 * Takes care of the clearing text fields and displaying the default value
 * Now all you need to do is give your input text fields a unique id, and the class of ‘default-value’, 
 * then the script will take care of the rest.
 */
var active_color = '#000'; // Colour of user provided text
var inactive_color = '#999'; // Colour of default text
 
Event.observe( window, 'load', function () {
    var default_values = new Array();
    $$("input.default-value").each( function (s) {
        $(s).setStyle({ color: inactive_color });
        $(s).observe( 'focus', function () {
            if (!default_values[s.id]) {
                default_values[s.id] = s.value;
            }
            if (s.value == default_values[s.id]) {
                s.value = '';
                $(s).setStyle({ color: active_color });
            }
            $(s).observe( 'blur', function () {
                if (s.value == '') {
                    $(s).setStyle({ color: inactive_color });
                    s.value = default_values[s.id];
                }
            });
        });
    });
});

