/*
 * InPlaceEditor extension that adds a 'click to edit' text when the field is 
 * empty.
 *
 * Adapted from http://wiki.script.aculo.us/scriptaculous/show/Ajax.InPlaceEditor
 */
Ajax.InPlaceEditor.prototype.__initialize = Ajax.InPlaceEditor.prototype.initialize;
Ajax.InPlaceEditor.prototype.__getText = Ajax.InPlaceEditor.prototype.getText;
Ajax.InPlaceEditor.prototype.__onComplete = Ajax.InPlaceEditor.prototype.onComplete;
Ajax.InPlaceEditor.prototype = Object.extend(Ajax.InPlaceEditor.prototype, {

    initialize: function(element, url, options) {
        this.__initialize(element,url,options)
 this.setOptions(options);
        this._checkEmpty();
    },

    setOptions: function(options) {
        this.options = Object.extend(Object.extend(this.options,{
            emptyClassName: 'inplaceeditor-empty'
 }),options||{});
    },

    _checkEmpty: function() {
        if(  _proxy_jslib_handle(this.element, 'innerHTML', '', 0, 0).length == 0 ){
            child = document.createElement("span");
            Element.addClassName(child, this.options.emptyClassName);
             _proxy_jslib_assign('', child, 'innerHTML', '=', ( this.options.emptyText));
            this.element.appendChild(child);
        }
    },

    getText: function() {
        document.getElementsByClassName(this.options.emptyClassName,this.element).each(function(child) {
            this.element.removeChild(child);
        }.bind(this));
        return this.__getText();
    },

    onComplete: function(transport) {
        this._checkEmpty();
        this.__onComplete(transport);
    }
});
 ;
_proxy_jslib_flush_write_buffers() ;