Ajax.implement({

	options: {
		method: 'post',
		async: true,
		onRequest: Class.empty,
		onSuccess: Class.empty,
		onFailure: Class.empty,
		urlEncoded: true,
		encoding: 'utf-8',
		autoCancel: false,
		headers: {},
		initialize: function() {
			if(this.options.update) 
			{
				$(this.options.update).setHTML('<img src="./images/wait.gif">'); 
			}
		}
	},

	onComplete: function(){
		if (this.options.update) $(this.options.update).setHTML(this.response.text); ;
		if (this.options.evalScripts || this.options.evalResponse) this.evalScripts();
		if (this.options.updateMultiple) this.updateMultiple();
		this.fireEvent('onComplete', [this.response.text, this.response.xml], 20);
	},

	updateMultiple: function(){
		try	{ var hasscript = false; errors=false; eval("var inputObject = "+ this.response.text);	// we're expecting a JSON object, eval it to inputObject
					for (var i in inputObject) {
						if (i == 'script') { hasscript = true; } // check if we passed some javascript along too
						else {if ( elm = $(i)) { elm.innerHTML = inputObject[i]; } else { errors=true;} // if it's not script, update the corresponding div
					}
				}
				if (hasscript) eval(inputObject['script']); // some on-the-fly-javascript exchanging support too
				if(errors) alert('There was an error processing: '+this.transport.responseText); 
		} 
		catch (e) {
			alert('There was an error processing: '+this.transport.responseText); 
		} // in case of an error					
	}
});



var Scroller = Fx.Scroll.extend({
	initialize: function(el){
		this.element = $(el);
		this.toElement(this.element);
	}
});
