/**
* (c) 2008 cocoachina.com
*/
Flame=Class.create(Ajax.Base);
Object.extend(Object.extend(Flame.prototype, Ajax.Request.prototype), {
    initialize: function(Url, Func, paramObj, callBack, id) {
        param = paramObj === undefined ? 'null' : Object.toJSON(paramObj);
        var method = 'post';
        this.id = id;
        this.url = Url;
        this.callback = callBack;
        this.transport = Ajax.getTransport(Url);
        this.setOptions({method: method, requestHeaders: {Accept:'application/json'}, parameters: 'method='+Func+'&fa='+encodeURIComponent(param)});
        this.options.onComplete = this.onReceive.bind(this);
        this.options.onFailure = this.onError.bind(this);
        this.request(this.url);
    },
    onReceive: function(response, json) {
    	alert(response.responseText);
    if (!json) {
            try { json = response.responseText.evalJSON(true)} catch(e) {}
        }
        this.callback(json, this.id);
    },
    onError: function() {
    	alert('error');
    }
});
function c(u, f, p, cb, id) {
    id = id === undefined ? Math.floor(Math.random()*1000000) : id;
    var req = new Flame(u, f, p, cb, id);
    return id;
}
function isempty(v){
    switch (typeof v){
        case 'undefined' : return true;
        case 'string'    : if(trim(v).length == 0) return true; break;
        case 'boolean'   : if(!v) return true; break;
        case 'number'    : if(0 === v) return true; break;
        case 'object'    : 
            if(null === v) return true;
            if(undefined !== v.length && v.length==0) return true;
            for(var k in v){return false;} return true;
            break;
    }
    return false;
}
