var m_bonus_bar = [];

function ClassBonusBar()
{
    m_bonus_bar = [116*devise_size, 140*devise_size, 175*devise_size];
    this.getImg = new createjs.Container();

    this.progress = 0;

    this.bg = ss_data.clone();
    this.bg.gotoAndStop("progress_bar_bonus1");
    this.bg.x = 0;
    this.getImg.addChild(this.bg);

    this.center = ss_data.clone();
    this.center.gotoAndStop("progress_center1");
    this.center.x = 14*devise_size;
    this.center.scaleX = 1;
    this.getImg.addChild(this.center);

    this.end = ss_data.clone();
    this.end.gotoAndStop("progress_end1");
    this.end.x = (14*devise_size)+this.center.scaleX;
    this.getImg.addChild(this.end);

    /*
    this.corn = [ss_data.clone(), ss_data.clone(), ss_data.clone()];
    this.corn[0].gotoAndStop("corn");
    this.corn[1].gotoAndStop("corn");
    this.corn[2].gotoAndStop("corn");
    this.corn[0].x = (13 + 145*0.6)*devise_size;
    this.corn[1].x = (13 + 145*0.75)*devise_size;
    this.corn[2].x = (13 + 145)*devise_size;
    this.corn[0].y = -3*devise_size;
    this.corn[1].y = -3*devise_size;
    this.corn[2].y = -3*devise_size;
    this.corn[0].alpha = 0.5;
    this.corn[1].alpha = 0.5;
    this.corn[2].alpha = 0.5;
    this.getImg.addChild(this.corn[0]);
    this.getImg.addChild(this.corn[1]);
    this.getImg.addChild(this.corn[2]);
     */

    this.text_count = new ClassText("", 4);
    this.text_count.getImg.y = 23*devise_size;
    this.text_count.getImg.scaleX = this.text_count.getImg.scaleY = 0.9;
    this.getImg.addChild(this.text_count.getImg);

    this.text = ss_data.clone();
    this.text.gotoAndStop("text_yellow_collected");
    this.text.y = 47*devise_size;
    this.getImg.addChild(this.text);

    this.ef = ss_data.clone();
    this.ef.gotoAndPlay("a_lock");
    this.ef.on("animationend", function(e){ e.target.visible = false; });
    this.ef.regX = 37*devise_size;
    this.ef.regY = 37*devise_size;
    this.ef.y = 10*devise_size;
    this.getImg.addChild(this.ef);
}

ClassBonusBar.prototype.Upd = function()
{
    if(this.progress != game.score.score)
    {
        this.progress = Math.min(this.progress+3, game.score.score);
        this.center.scaleX = ((145*devise_size)*Math.min(1, this.progress/config.lvls[game.level_num].max))<<0;
        this.end.x = (14*devise_size) + this.center.scaleX;

        /*
        if(this.progress >= config.lvls[game.level_num].max*0.6 && (this.progress-3) < config.lvls[game.level_num].max*0.6)
        {
            this.corn[0].alpha = 1;
            this.ef.x = m_bonus_bar[0];
            this.ef.visible = true;
            this.ef.gotoAndPlay("a_lock");
        }
        if(this.progress >= config.lvls[game.level_num].max*0.75 && (this.progress-3) < config.lvls[game.level_num].max*0.75)
        {
            this.corn[1].alpha = 1;
            this.ef.x = m_bonus_bar[1];
            this.ef.visible = true;
            this.ef.gotoAndPlay("a_lock");
        }
        if(this.progress >= config.lvls[game.level_num].max && (this.progress-3) < config.lvls[game.level_num].max)
        {
            this.corn[2].alpha = 1;
            this.ef.x = m_bonus_bar[2];
            this.ef.visible = true;
            this.ef.gotoAndPlay("a_lock");
        }
        */

        this.text_count.setText(((this.progress/5)<<0).toString());
        this.text_count.getImg.x = ((((87*devise_size) - this.text_count.getImg.width*this.text_count.getImg.scaleX)/2)<<0) - 21*devise_size;
        this.text.x = this.text_count.getImg.x + (this.text_count.getImg.width*this.text_count.getImg.scaleX)<<0;
    }
};

ClassBonusBar.prototype.Show = function()
{
    this.ef.visible = false;
    this.progress = 0;
    /*
    this.corn[0].alpha = 0.5;
    this.corn[1].alpha = 0.5;
    this.corn[2].alpha = 0.5;
    */
    this.center.scaleX = 0;
    this.end.x = 11*devise_size;
};

ClassBonusBar.prototype.isLoad = function()
{
    return (this.progress != game.score.score);
};