gCurrentFile = 1;
gFilesCount = 0;
function Geter( aValue, aDef )
    if( aValue==nil or  aValue=="")then
        return aDef;
    else
        return aValue;
    end
end


function GetStartValue(aName)
    if( not PreviewTable )then return nil; end;
    return PreviewTable[aName];
end


function StartUp()
    gFilesCount = table.getn(PreviewTable);
    SetScreen(1);
end


function SetScreen(screen)
    if(screen<1 or screen>gFilesCount)then
        PopModal("preview_bonus_dialog");
    else
        gCurrentFile = screen;
        if(gCurrentFile==1)then
            SetLabel("first_button","Close");
            EnableWindow("first_button",false);
        else
            SetLabel("first_button","Prev");
            EnableWindow("first_button",true);          
        end;
        
        if(gCurrentFile==gFilesCount)then
            SetLabel("second_button","Start!");
        else
            SetLabel("second_button","Next");
        end;
        

        if( PreviewTable[gCurrentFile].Msg )then
            SetLabel ( "text_label", GetString( PreviewTable[gCurrentFile].Msg));
        end

        if( PreviewTable[gCurrentFile].Bg  and PreviewTable[gCurrentFile].Bg~=""  )then
            SetBitmap( "backgroundimage", PreviewTable[gCurrentFile].Bg);
        end
    end
end

            


MakeDialog
    {
        name="preview_bonus_dialog",
        Bitmap
        {
            x=200,
            y=200,
            name="backgroundimage",
            image="backgrounds/ingame_help_win";
               
            Text
            {
                name="text_label";
                label = "",
                x=20,
                y=20,
                w=303 - 40,
                h=210 - 40,  
                font = DialogBodyFont,
                flags = kHAlignCenter + kVAlignCenter,
            },
            
            -- Button
            -- {
                -- x=5,
                -- y=140,
                -- w=100,
                -- h = 44,
                -- font = StandardButtonFont,
                -- graphics = TutorialButton,
                -- name="first_button",
                -- label="prev",
                -- type = kPush,
                -- command=
                    -- function()
                        -- SetScreen(gCurrentFile-1);
                    -- end
            -- },
            
            --[[
            Button
            {
                x=20,
                y=140,
                w=100,
                h = 44,
                font = StandardButtonFont,
                graphics = TutorialButton,
                name="skip_button",
                label="skip",
                type = kPush,
                command=
                    function()
                        SetScreen(999999);
                    end
            },--]]
            
            
            
            Button
            {
                x=90,
                y=140,
                w=100,
                h = 44,         
                font = StandardButtonFont,
                graphics = TutorialButton,
                name="second_button",
                label="next",
                type = kPush,
                command=
                    function()
                        SetScreen(gCurrentFile+1);
                    end
            }       
            
            
         
        }
    }
    
StartUp();