/**
 * @author Marco Süß
 * @copyright Copyright 2004-2007, Zwölf Medien GbR, All rights reserved.
 */


/* An InplaceEditor which restores the invalid value after failure
   without server-side intervention */
var GracefulInPlaceEditor = Class.create(Ajax.InPlaceEditor,{
	handleAJAXFailure: function(transport) {
		this.triggerCallback('onFailure', transport);
	    if (this._valueToSave) {
			this.element.innerHTML = this._valueToSave;
			this._valueToSave = null;
			this.element.addClassName(this.options.errorClassName || 'param_error');
			this.element.title = this.options.errorMessageText  || 'Dieser Wert ist fehlerhaft und wurde nicht gespeichert.';
	    }
	},
	prepareSubmission: function($super) {
		if(this.element.hasClassName('param_error'))
			this.element.removeClassName('param_error');
		this.element.title = this.options.clickToEditText;
		this._valueToSave = $F(this._controls.editor);
		$super();
	}
});

/* Taken from firebugx.js */
if (!window.console || !console.firebug) {
    var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
    "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];

    window.console = {};
    for (var i = 0; i < names.length; ++i)
        window.console[names[i]] = function() {}
}

