cItem= Class.extend({
    init: function(options) {
        if (options['sync']) {
            this.setSync();
        } else {
            this.setASync();
        }
			
			
			
			
        this.OnReady=arguments[0]['OnReady'];
        //this.setCache('on');
        //this.Cache.setTimeout(this.timeout);
        this.uuid=Math.round(1000*Math.random());
        return this;
    },
    setSync: function() {
        this.reqMode='sync';
    },
    setASync: function() {
        this.reqMode='async';
    },
    SyncRequestItem:function(fController,fName,Params) {
        var href=document.getElementsByTagName('BASE')[0].href;
        this.cached=false;
        this.msg=this._JSONMessage(fController,fName,Params);
        this.useCache=false;
        var req=new Ajax.Request(href+"/ajax/request.method", {
            method: 'post',
            contentType: 'text/html',
            postBody: this.msg,
            asynchronous: false
        });
        ret=req.evalResponse();
        return ret;
    },
		
    callMethod: function(fController,fName,Params) {
        this.aSyncRequestItem(fController,fName,Params);
    },
    syncCallMethod: function(fController,fName,Params) {
        this.SyncRequestItem(fController,fName,Params);
    },
		
    aSyncRequestItem: function(fController,fName,Params) {
        this.cached=false;
        var href=document.getElementsByTagName('BASE')[0].href;
        //this.msg=this._XMLMessage(modName,type,fName,fParameter);
        this.msg=this._JSONMessage(fController,fName,Params);
        this.useCache=false;
			
        var req=$.ajax({
            url:href+"ajax/request.method",
            data:this.msg,
            success:jQuery.proxy(this.onSuccess,this),
            type:'post',
            dataType:'json'
        });
                       
                        
			
    },
    onSuccess: function(transport) {
        /*this.item = transport.responseJSON;
			if (transport.responseText!=undefined && (this.item==undefined || this.item==null)) {
				this.item=eval("("+transport.responseText+")");
			}
			if (this.useCache) {
				this.Cache.addItem(this.item,hex_md5(this.msg),this.timeout);
			}
			*/
                        
        eval(transport.beforeData);
        this.OnReady(this,transport.data);
        eval(transport.afterData);
			

        return;
    },
    _XMLMessage: function(modName,type,fName,fParameter) {
        var msg=new XMLRPCMessage(this.wrapperFunc);
        msg.addParameter(modName);
        msg.addParameter(type);
        msg.addParameter(fName);
        msg.addParameter(fParameter);
        return msg;
    },
    _JSONMessage: function(fController,fName,fParameter) {
        var msg='{"fController":"'+fController+'",'+'"fName":"'+fName+'",'+'"fParameter":'+JSON.stringify(fParameter)+'}';
        return msg;
    },
    _JSONBlockMessage: function(blockType,blockModule,blockName) {
        var msg='{"blockType":"'+blockType+'",'+
        '"blockModule":"'+blockModule+'",'+
        '"blockName":"'+blockName+'",'+
        '"blockRender":true}';
        return msg;
		
    }
});

function callMethod(fController,fName,fParameter,onReadyCall) {
    new cItem({
        OnReady:OnReadyCall
    }).callMethod(fController,fName,fParameter);
}


