var controller = new Class({
        Implements: [Options, Events],
        options: {
            url:'',
            method:'post',
            request:'json',
            data:{},
            evalScripts:false,
            evalResponse:false,
            debug:false
        },
        initialize: function(options){
            this.setOptions(options);
            if(this.options.request == 'json'){
                this.controller = new Request.JSON({
                    url:this.options.url,
                    method:this.options.method,
                    evalScripts:this.options.evalScripts,
                    evalResponse:this.options.evalResponse,
                    onRequest:this.onRequest.bind(this),
                    onFailure:this.onFailure.bind(this),
                    onSuccess:this.onSuccess.bind(this)
                });
            }
        },
        onSuccess:function(reply,xml){
            //alert(reply.method);
            this[reply.method](reply.data);
        },
        onFailure:function(xhr){
            if(this.options.debug)
                alert(xhr.responseText);
        },
        onRequest:function(){
            if(this.options.debug)
                alert('Request Made');
        },
        send:function(data){
            this.set_data(data)
            this.controller.send();
        },
        set_url:function(url){
            this.controller.options.url = url;
        },
        set_data:function(data){
            this.controller.options.data = data;
        }
});
