var m_progress_bar = [];

function ClassProgressBar()
{
    m_progress_bar = [11*devise_size, -32*devise_size, 75*devise_size, -42*devise_size, 132*devise_size, -34*devise_size];

    this.getImg = new createjs.Container();

    this.progress = 0;
    this.progress_w = 0;

    this.bg = ss_data.clone();
    this.bg.gotoAndStop("progress_bar_bonus2");
    this.getImg.addChild(this.bg);

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

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

    this.text = new ClassText("", 4);
    this.text.getImg.y = 10*devise_size;
    this.text.getImg.x = 72*devise_size;
    this.text.getImg.scaleX = this.text.getImg.scaleY = 0.8;
    this.getImg.addChild(this.text.getImg);

    this.points = ss_data.clone();
    this.points.gotoAndStop("points");
    this.points.y = 34*devise_size;
    this.getImg.addChild(this.points);

    this.corn = ss_data.clone();
    this.corn.gotoAndStop("corn0");
    this.corn.y = -66*devise_size;
    this.corn.x = -15*devise_size;
    this.getImg.addChild(this.corn);

    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.getImg.addChild(this.ef);
}

ClassProgressBar.prototype.Show = function(max, a, b)
{
    this.max = max;
    this.progress_w = a;
    this.progress = 0;
    this.center.scaleX = 0;
    this.end.x = 13*devise_size+this.center.scaleX;


    if(b >= 1)
    {
        setTimeout(function(){
            var ths = window_controller.windows[window_controller.getIDbyName("win")].progress;
            ths.corn.gotoAndStop("corn1");
            ths.ef.x = m_progress_bar[0];
            ths.ef.y = m_progress_bar[1];
            ths.ef.visible = true;
            ths.ef.gotoAndPlay("a_lock");
        }, 1000);
    }
    if(b >= 2)
    {
        setTimeout(function(){
            var ths = window_controller.windows[window_controller.getIDbyName("win")].progress;
            ths.corn.gotoAndStop("corn2");
            ths.ef.x = m_progress_bar[2];
            ths.ef.y = m_progress_bar[3];
            ths.ef.visible = true;
            ths.ef.gotoAndPlay("a_lock");
        }, 1500);
    }
    if(b == 3)
    {
        setTimeout(function(){
            var ths = window_controller.windows[window_controller.getIDbyName("win")].progress;
            ths.corn.gotoAndStop("corn3");
            ths.ef.x = m_progress_bar[4];
            ths.ef.y = m_progress_bar[5];
            ths.ef.visible = true;
            ths.ef.gotoAndPlay("a_lock");
        }, 2000);
    }
};

ClassProgressBar.prototype.isLoad = function()
{
    return !(this.progress_w == this.progress);
};

ClassProgressBar.prototype.Upd = function()
{
    if(this.progress != this.progress_w)
    {
        this.progress = Math.min(this.progress+7, this.progress_w);
        /*
        if(this.progress >= 1 && (this.progress-7) < 1)
        {

        }
        if(this.progress >= config.lvls[game.level_num].max*0.6 && (this.progress-7) < config.lvls[game.level_num].max*0.6)
        {
            this.corn.gotoAndStop("corn2");
            this.ef.x = m_progress_bar[2];
            this.ef.y = m_progress_bar[3];
            this.ef.visible = true;
            this.ef.gotoAndPlay("a_lock");
        }
        if(this.progress >= config.lvls[game.level_num].max*0.75 && (this.progress-7) < config.lvls[game.level_num].max*0.75)
        {
            this.corn.gotoAndStop("corn3");
            this.ef.x = m_progress_bar[4];
            this.ef.y = m_progress_bar[5];
            this.ef.visible = true;
            this.ef.gotoAndPlay("a_lock");
        }
        */
        if(this.progress > 999)
        {
            var a = this.progress.toString();
            this.text.setText(a.substr(0, a.length-3) + ',' + a.substr(a.length-3, 3));
        }
        else
        {
            this.text.setText(this.progress.toString());
        }

        this.text.getImg.x = (72*devise_size)-(this.text.getImg.width*this.text.getImg.scaleX+50*devise_size)/2;
        this.points.x = this.text.getImg.x + this.text.getImg.width - (4*devise_size);
        this.center.scaleX = ((117*devise_size)*Math.min(1, this.progress/this.max))<<0;
        this.end.x = 13*devise_size+this.center.scaleX;
         /*
        this.progress = Math.min(this.progress+9, game.score.score);
        this.center.scaleX = (154*Math.min(1, this.progress/config.lvls[game.level_num].max))<<0;
        this.end.x = (154 + 13)*devise_size + this.center.scaleX;
        */
    }
};