// --- StatusReader ---
var HSStatusReader = function(config) {
    this.project = config.project;
    this.url     = config.url;
    this.handler = config.handler;

    this.save = function(data){
        Ext.Ajax.request({
            url: this.url,
            method: "post",
            success: function(){},
            failure: function(){alert('StatusReader save failure!');},
            jsonData: {"project":this.project,"request":"save","data":data}
        });
    }

    this.load = function(){
        Ext.Ajax.request({
            url: this.url+'?project='+this.project+'&request=load',
            scope: this,
            success: this.loadResponse,
            failure: function(){alert('StatusReader load failure!');}
        });
    }

    this.loadResponse = function(r,o){
        if(r.responseText){
            if(r.responseText=='null'){
                this.handler(null);
                return;
            }else try{
                var data = Ext.util.JSON.decode(r.responseText);
            }catch(e){
                alert('StatusReader load data error!'+r.responseText);
            }
            this.handler(data);
        }
    }
} // end class

