function ClassJob()
{
    this.getImg = new createjs.Container();
    this.job_v = [];
    this.job_l = [];

    this.text = [];
    this.bg = [];
    this.mark = [];
    this.pre = [];

    for(var i = 0 ; i < 4; i++)
    {
        this.bg.push(ss_data.clone());
        this.bg[i].gotoAndStop("top_bar_green_block");
        this.bg[i].x = (23+51*i)*devise_size;
        this.bg[i].y = 6*devise_size;
        this.getImg.addChild(this.bg[i]);

        this.mark.push(ss_data.clone());
        this.mark[i].gotoAndStop("marker_top_bar");
        this.mark[i].x = (22+51*i)*devise_size;
        this.mark[i].y = 4*devise_size;
        this.getImg.addChild(this.mark[i]);

        this.pre.push(ss_data.clone());
        this.pre[i].x = (51*i)*devise_size;
        this.pre[i].y = 2*devise_size;
        this.pre[i].scaleX = this.pre[i].scaleY = 0.6;
        this.getImg.addChild(this.pre[i]);
    }

    for(i = 0 ; i < 4; i++)
    {
        this.text.push(new ClassText("", 2));
        this.text[i].getImg.x = (23+51*i)*devise_size;
        this.text[i].getImg.y = devise_size;
        this.getImg.addChild(this.text[i].getImg);
    }
}

ClassJob.prototype.Create = function()
{
    this.job_v = JSON.parse(JSON.stringify(config.lvls[game.level_num].job));
    this.job_l = JSON.parse(JSON.stringify( config.lvls[game.level_num].job));

    this.getImg.regX = -((204*devise_size) - this.job_v.length*(51*devise_size))/2;

    for(var i = 0; i < 4; i++)
    {
        if(this.job_v.length<=i)
        {
            this.bg[i].visible = false;
            this.mark[i].visible = false;
            this.text[i].getImg.visible = false;
            this.pre[i].visible = false;
        }
        else
        {
            this.bg[i].visible = true;
            this.mark[i].visible = false;
            this.text[i].getImg.visible = true;
            this.pre[i].visible = true;

            this.job_v[i].current = 0;
            this.job_l[i].current = 0;
            if(this.job_v[i].ID < 3)
            {
                this.pre[i].gotoAndStop(game.color[this.job_v[i].value]);
            }
            else
            {
                if(this.job_v[i].ID == 3)
                    this.pre[i].gotoAndStop("pumpkin2");
                else
                    this.pre[i].gotoAndStop("watermelon2");
            }
            this.text[i].setText("0/"+this.job_v[i].count);
        }
    }
};

ClassJob.prototype.AddLg = function(i, a)
{

    this.job_l[i].current += a;
    //this.Write();
};
 /*
ClassJob.prototype.Add = function(id, value, a)
{
    for(var i = 0 ; i < this.job.length; i++)
        if(this.job[i].ID < 3)
        {
            if(this.job[i].value == value)
                this.job[i].current += a;
        }
        else
        {
            if(this.job[i].ID == id)
                this.job[i].current += a;
        }
};
*/

ClassJob.prototype.Write = function()
{
    var a = "";
    for(var i = 0 ; i < this.job_v.length; i++)
        a+=this.job_v[i].current+" ";
    a+="\n";
    for(i = 0 ; i < this.job_l.length; i++)
        a+=this.job_l[i].current+" ";
    console.log(a);
};

ClassJob.prototype.AddN = function(i, a)
{

    this.job_v[i].current += a;
    //this.Write();
    this.Upd();
};

ClassJob.prototype.Upd = function()
{
    var a = 0;
    for(var i = 0 ; i < this.job_v.length; i++)
        if(this.job_v[i].current >= this.job_v[i].count)
        {
            a++;
            this.text[i].getImg.visible = false;
            this.mark[i].visible = true;
        }
        else
        {
            this.text[i].getImg.visible = true;
            this.text[i].setText(this.job_v[i].current+"/"+this.job_v[i].count);
            this.mark[i].visible = false;
        }
    /*
    if(this.job.length == a)
    {
        game.grid.getImg.mouseEnabled = false;
        game.all_job.moves.setSave();
        game.bot.Start();
    }
    */
};

ClassJob.prototype.AllEnd = function()
{
    for(var i = 0 ; i < this.job_v.length; i++)
    {
        this.text[i].getImg.visible = false;
        this.mark[i].visible = true;
    }
};

ClassJob.prototype.isTrue = function(b)
{
    for(var i = 0 ; i < this.job_l.length; i++)
        if(this.job_l[i].value == b && this.job_l[i].ID == 0) return true;
    return false;
};

ClassJob.prototype.isEnd = function()
{
    var a = 0;
    for(var i = 0 ; i < this.job_l.length; i++)
        if(this.job_l[i].count <= this.job_l[i].current) a++;
    return (a == this.job_l.length);
};

ClassJob.prototype.isWater = function()
{
    for(var i = 0; i < this.job_l.length; i++)
        if(this.job_l[i].ID != 0 && this.job_l[i].count > this.job_l[i].current)
            return true;
    return false;
};