/**
* 
*/

// APPLET FUNCTIONS
function GraphHandler(idgraph){
    
    this.graphApplet = idgraph;
    this.graphMenu = new GraphMenu(this);
       
    this.request = function(rics, fids, colors){
        this.request_(this.graphApplet, rics, fids, colors); 
    }
    
    this.viewCalculation = function(calculation, color){
        this.viewCalculation_(this.graphApplet, calculation, color); 
    }
    
    this.setNumDecimalPlaces = function(numPlaces){
        this.setNumDecimalPlaces_(this.graphApplet, numPlaces);
    }
    
    this.addMenuItem = function(text, enable, callback){
        this.addMenuItem_(this.graphApplet, text, enable, callback);
    }
    
    this.addCheckboxMenuItem = function(text, clickable, enable, callback){
        this.addCheckboxMenuItem_(this.graphApplet, text,clickable,enable, callback);
    }
    
    this.enableMenuItem = function(text,  enable){
        this.enableMenuItem_(this.graphApplet, text,enable);
    }
    
    this.checkMenuItem = function(text,  checked){
        this.enableMenuItem_(this.graphApplet, text, checked);
    }
    
    this.removeMenuItem = function(text){
        this.removeMenuItem_(this.graphApplet, text);
    }
    
    this.setDateFormat = function(format){
        this.setDateFormat_(this.graphApplet, format);
    }
    
    this.setPopupDateFormat = function(format){
        this.setPopupDateFormat_(this.graphApplet, format);
    }
    
    this.setTitle = function(title){
        this.setTitle_(this.graphApplet,title);
    }
    
    this.setYAxisLabelRight = function(label){
        this.setYAxisLabelRight_(this.graphApplet,label);
    }
    
    this.setYAxisLabelLeft = function(label){
        this.setYAxisLabelLeft_(this.graphApplet,label);
    }
    
    this.startDownload = function(rics,fids, ascending){
        this.startDownload_(this.graphApplet,rics,fids, ascending);
    }
    
    this.addPoint = function(ric,fid,strtimes,strvalues){
        this.addPoint_(this.graphApplet,ric,fid,strtimes,strvalues);
    }
    this.finishedDownload = function(ric,fid){
        this.finishedDownload_(this.graphApplet,ric,fid);
    }
    this.setLoading = function(bool){
        this.setLoading_(this.graphApplet,bool);
    }
    
    
    this.request_ = function(idgraph, rics, fids, colors){
        var dynGraph = parent.document.getElementById(idgraph);
        dynGraph.request(rics, fids, colors); 
    }
    
    this.viewCalculation_ = function(idgraph, calculation, color){
        var dynGraph = parent.document.getElementById(idgraph);
        dynGraph.viewCalculation(calculation, color); 
    }
    
    this.setNumDecimalPlaces_ = function(idgraph, numPlaces){
        var dynGraph = parent.document.getElementById(idgraph);
        dynGraph.setNumDecimalPlaces(numPlaces);
    }
    
    this.addMenuItem_ = function(idgraph, text, enable, callback){
        var dynGraph = parent.document.getElementById(idgraph);
        dynGraph.addMenu(text,enable, callback);
    }
    
    this.addCheckboxMenuItem_ = function(idgraph, text, clickable, enable, callback){
        var dynGraph = parent.document.getElementById(idgraph);
        dynGraph.addCheckboxMenu(text,clickable,enable, callback);
    }
    
    this.checkMenuItem_ = function(idgraph,text,  checked){
        var dynGraph = parent.document.getElementById(idgraph);
         dynGraph.checkMenu(text,checked);
    }
    
    this.enableMenuItem_ = function(idgraph,text,  enable){
        var dynGraph = parent.document.getElementById(idgraph);
         dynGraph.enableMenu(text,enable);
    }
    
    this.removeMenuItem_ = function(idgraph,text){
        var dynGraph = parent.document.getElementById(idgraph);
         dynGraph.removeMenu(text);
    }
    
    this.setDateFormat_ = function(idgraph,format){
        var dynGraph = parent.document.getElementById(idgraph);
        dynGraph.setDateFormat(format);
    }
    
    this.setPopupDateFormat_ = function(idgraph,format){
        var dynGraph = parent.document.getElementById(idgraph);
        dynGraph.setPopupDateFormat(format);
    }
    
    this.setTitle_ = function(idgraph,title){
        var dynGraph = parent.document.getElementById(idgraph);
        dynGraph.setTitle(title);
    }
    
    this.setYAxisLabelRight_ = function(idgraph,label){
        var dynGraph = parent.document.getElementById(idgraph);
        dynGraph.setYAxisLabelRight(label);
    }
    
    this.setYAxisLabelLeft_ = function(idgraph,label){
        var dynGraph = parent.document.getElementById(idgraph);
        dynGraph.setYAxisLabelLeft(label);
    }
    
    this.startDownload_ = function(idgraph,rics,fids, ascending){
        var dynGraph = parent.document.getElementById(idgraph);
        dynGraph.startDownload(rics,fids, ascending);
    }
    
    this.addPoint_ = function(idgraph,ric,fid,strtimes,strvalues){
        var dynGraph = parent.document.getElementById(idgraph);
        dynGraph.addPoint(ric,fid,strtimes,strvalues);
    }
    this.finishedDownload_ = function(idgraph,ric,fid){
        var dynGraph = parent.document.getElementById(idgraph);
        dynGraph.finishedDownload(ric,fid);
    }
    this.setLoading_ = function(idgraph,bool){
        var dynGraph = parent.document.getElementById(idgraph);
        dynGraph.setLoading(bool);
    }
}

   
