/**
 * Класс калькулятора
 *
 */
var CalcClass = go.Class({

    'NODE_GARBAGE_TYPE'     : "#calc-garbage-type",
    'NODES_CONTAINERS_LIST' : "#calc-cnt-list li",
    'NODES_CONTAINERS_BIG'  : "#calc-cnt-big img",
    'NODES_CONTAINERS_TEXT' : ".text_about_cont .calc-text",
    'NODES_MAP_LINKS'       : ".okrug a",
    'NODES_MAP_AREA'        : "#Map area",
    'NODES_MAP_IMAGES'      : "#map-sprites img",
    'NODE_SLIDER'           : ".filtr .slider",
    'NODE_VOLUME'           : ".f_scroll .calc-volume span.meter3",
    'NODE_WITH_LOADING'     : "#snow",
    'NODE_BUTTON_PRICE'     : ".calc-norpice-yes",    
    'NODE_BUTTON_NO'        : ".calc-norpice-no",
    'NODE_DETAILS'          : "#calc-noprice .price_n",
    'NODE_TONNS'            : ".tonns_count",
    'NODE_FORM'             : ".callme",

    '__construct': (function() {
        this.garbageType = new CalcClass.GarbageTypeClass(this.NODE_GARBAGE_TYPE, true);
        this.containers  = new CalcClass.ContainersClass(this.NODES_CONTAINERS_LIST, this.NODES_CONTAINERS_BIG, this.NODES_CONTAINERS_TEXT);
        this.map         = new CalcClass.MapClass(this.NODES_MAP_LINKS, this.NODES_MAP_AREA, this.NODES_MAP_IMAGES);
        this.slider      = new CalcClass.SliderClass(this.NODE_SLIDER, this.NODE_VOLUME);        
        this.withLoading = new CalcClass.WithLoading(this.NODE_WITH_LOADING);
        this.button      = new CalcClass.ButtonClass(this, this.NODE_BUTTON_PRICE, this.NODE_BUTTON_NO);
        this.details     = new CalcClass.DetailsClass(this.NODE_DETAILS);
        this.tonns       = new CalcClass.TonnsClass(this.NODE_TONNS);
        this.form        = new CalcClass.FromClass(this, this.NODE_FORM);
        
        $("body").click(function() {
            $(".thanx").hide();
        });        
    }),
    
    '__destruct': (function() {
        this.garbageType.destroy();
        this.containers.destroy();
        this.map.destroy();
        this.slider.destroy();
        this.withLoading.destroy();
        this.details.destroy();
        this.tonns.destroy();
        this.form.destroy();
    }),
    
    'run': (function() {
        this.button.init();
        this.garbageType.addEventListener(this.onGarbageTypeChange);
        this.containers.addEventListener(this.onContainerChange);
        this.map.addEventListener(this.onMapChange);
        this.slider.addEventListener(this.onSliderChange);
        this.withLoading.addEventListener(this.onLoadingChange);
    }),    
    
    'onGarbageTypeChange_bind': (function(type) {
        this.containers.filterGarbage(type);
        this.withLoading.setGarbageType(type);
        this.button.onGarbageTypeChange(type);
    }),
    
    'onContainerChange_bind': (function(container) {
        this.slider.setContainer(container);
        this.button.onContainerVolumeChange(container);
    }),
    
    'onMapChange_bind': (function(sec, inttk) {
        this.button.onMapChange(sec, inttk);
    }),
    
    'onSliderChange_bind': (function(volume) {
        this.button.onSliderChange(volume);
    }),
    
    'onLoadingChange_bind': (function(checked) {
        this.button.onLoadingChange(checked);
    }),
    
    'eoc': null
});

