function WindowLevelComplete()
{
    this.name = "win";
    this.layer = 1;
    this.animation_time_in = 20;
    this.animation_time_out = 20;

    this.getImg.x = 160*devise_size;
    this.getImg.y = 2048;
    this.getImg.regX = 110*devise_size;
    this.getImg.regY = 105*devise_size;

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

    this.lights = ss_data.clone();
    this.lights.gotoAndStop("lights");
    this.lights.x = -43*devise_size;
    this.lights.y = 60*devise_size;
    this.getImg.addChild(this.lights);

    this.bonus_text = ss_data.clone();
    this.bonus_text.gotoAndStop("text_white_bonus_reward");
    this.bonus_text.x = 32*devise_size;
    this.bonus_text.y = 120*devise_size;
    this.getImg.addChild(this.bonus_text);

    var up = ss_data.clone();
    up.gotoAndStop("text_yellow_level_complete");
    up.x = 32*devise_size;
    up.y = -55*devise_size;
    this.getImg.addChild(up);

    this.text_num_lvl = new ClassText("", 4);
    this.text_num_lvl.getImg.x = 158*devise_size;
    this.text_num_lvl.getImg.y = -80*devise_size;
    this.getImg.addChild(this.text_num_lvl.getImg);

    this.btn_m = ss_data.clone();
    this.btn_m.gotoAndStop("btn");
    this.btn_m.on("mousedown", function(){
        window_controller.Show("map");
    });
    this.btn_m.x = 15*devise_size;
    this.btn_m.y = 180*devise_size;
    this.getImg.addChild(this.btn_m);
    var btn_m_up = ss_data.clone();
    btn_m_up.gotoAndStop("icon_menu");
    btn_m_up.x = 15*devise_size;
    btn_m_up.y = 180*devise_size;
    this.getImg.addChild(btn_m_up);

    this.btn_r = ss_data.clone();
    this.btn_r.gotoAndStop("btn");
    this.btn_r.on("mousedown", function(){
        game.CreateLvl(game.level_num);
        window_controller.Show("location");
        window_controller.Show("job");
    });
    this.btn_r.x = 84*devise_size;
    this.btn_r.y = 180*devise_size;
    this.getImg.addChild(this.btn_r);
    var btn_r_up = ss_data.clone();
    btn_r_up.gotoAndStop("icon_reset");
    btn_r_up.x = 84*devise_size;
    btn_r_up.y = 180*devise_size;
    this.getImg.addChild(btn_r_up);

    this.btn_n = ss_data.clone();
    this.btn_n.gotoAndStop("btn");
    this.btn_n.on("mousedown", function(){
        adManager.showAd(function () {
            game.CreateLvl(game.level_num+1);
            window_controller.Show("location");
            if(config.lvls[game.level_num].bonus_lvl != 0)
                window_controller.Show("bonuslvl");
            else
                window_controller.Show("job");
        });
    });
    this.btn_n.x = 152*devise_size;
    this.btn_n.y = 180*devise_size;
    this.getImg.addChild(this.btn_n);
    var btn_n_up = ss_data.clone();
    btn_n_up.gotoAndStop("icon_right");
    btn_n_up.x = 152*devise_size;
    btn_n_up.y = 180*devise_size;
    this.getImg.addChild(btn_n_up);

    this.progress = new ClassProgressBar();
    this.progress.getImg.x = 37*devise_size;
    this.progress.getImg.y = 67*devise_size;
    this.getImg.addChild(this.progress.getImg);

    this.gift0 = new ClassAddBonus();
    this.getImg.addChild(this.gift0.gift_st);
    this.getImg.addChild(this.gift0.gift);

    this.gift1 = new ClassAddBonus();
    this.getImg.addChild(this.gift1.gift_st);
    this.getImg.addChild(this.gift1.gift);
}
WindowLevelComplete.prototype = new ClassWindow();

WindowLevelComplete.prototype.Show = function()
{
    this.getImg.y = 2048;

    var c = 0;
    if(config.lvls[game.level_num].moves * 0.6 >= (config.lvls[game.level_num].moves - game.all_job.moves.moves_save))//.max * 0.75 <= game.score.score)
    {
        game.save.setMap(3);
        c = 3;
    }
    else
    {
        if(config.lvls[game.level_num].moves * 0.75 >= (config.lvls[game.level_num].moves - game.all_job.moves.moves_save))//.max * 0.6 <= game.score.score)
        {
            game.save.setMap(2);
            c = 2;
        }
        else
        {
            game.save.setMap(1);
            c = 1;
        }
    }

    if(audio_supported) s_level_completed.play();
    this.progress.Show(config.lvls[game.level_num].max, game.score.score, c);

    if(config.lvls[game.level_num].moves * 0.5 >= (config.lvls[game.level_num].moves - game.all_job.moves.moves_save))       // 15 <= 10
    {
        this.lights.visible = true;
        this.bonus_text.visible = true;
        this.gift0.Show(85*devise_size, 164*devise_size, true);
        this.gift1.Show(135*devise_size, 164*devise_size, true);

        this.progress.getImg.y = 67*devise_size;
    }
    else
    {
        if(config.lvls[game.level_num].moves * 0.75 >= (config.lvls[game.level_num].moves - game.all_job.moves.moves_save))    // 10 <= 10
        {
            this.lights.visible = true;
            this.bonus_text.visible = true;
            this.gift0.Show(110*devise_size, 164*devise_size, true);
            this.gift1.Show(0, 0, false);

            this.progress.getImg.y = 67*devise_size;
        }
        else
        {
            this.lights.visible = false;
            this.bonus_text.visible = false;
            this.gift0.Show(0, 0, false);
            this.gift1.Show(0, 0, false);

            this.progress.getImg.y = 100*devise_size;
        }
    }

    this.text_num_lvl.setText((game.level_num+1).toString());
    this.text_num_lvl.getImg.regX = (this.text_num_lvl.getImg.width/2)<<0;
};

WindowLevelComplete.prototype.Hide = function()
{
    this.gift0.Hide();
    this.gift1.Hide();
};

WindowLevelComplete.prototype.Drw = function()
{
    if(this.isSt())
    {
        if(this.progress.isLoad())
        {
            this.progress.Upd();
        }
        else
        {
            if(this.gift0.gift.visible)
            {
                this.gift0.Drw();
            }
            else
            {
                if(this.gift1.gift.visible)
                    this.gift1.Drw();
            }
        }
    }
};

WindowLevelComplete.prototype.DrwIn = function()
{
    this.getImg.y = (-105 + 345*(this.animation/this.animation_time_in))*devise_size;
};

WindowLevelComplete.prototype.DrwOut = function()
{
    this.getImg.y = (240 + 345*(this.animation/(-this.animation_time_out)))*devise_size;
    if(this.animation == -this.animation_time_out) this.getImg.y = 2048;
};