function load()

end
function setcurentleaf(leafname,level,sublevel)
     set_activ_leaf(leafname,level,sublevel);
     dofile("data\\"..level.."\\"..sublevel.."\\level.lua");
     g_leafname=leafname;
     g_level=level;
     g_sublevel=sublevel;
end;
function AddHints()

     AddButtonToWnd1("hint1","pb",34,23,19,19);
     AddButtonToWnd1("hint2","pb",34,48,19,19);
     AddButtonToWnd1("hint3","pb",34,73,19,19);
     AddButtonToWnd1("hint4","pb",34,97,19,19);    
add_animation(999);
add_animation_frame(999,"menuAn",882,655,0 ,0,134,106,0.1);
add_animation_frame(999,"menuAn",882,655,134,0,134,106,0.1);
add_animation_frame(999,"menuAn",882,655,268,0,134,106,0.1);
add_animation_frame(999,"menuAn",882,655,402,0,134,106,0.1);  
add_animation_frame(999,"menuAn",882,655,536,0,134,106,0.1);  
add_animation_frame(999,"menuAn",882,655,670,0,134,106,0.1);  
add_animation_frame(999,"menuAn",882,655,804,0,134,106,0.1);  
add_animation_frame(999,"menuAn",882,655,0,106,134,106,0.1);  
add_animation_frame(999,"menuAn",882,655,134,106,134,106,0.1);  
add_animation_frame(999,"menuAn",882,655,268,106,134,106,0.1);  
add_animation_frame(999,"menuAn",882,655,402,106,134,106,0.1);  
add_animation_frame(999,"menuAn",882,655,536,106,134,106,0.1);  
add_animation_frame(999,"menuAn",882,655,670,106,134,106,3);  

AddAnimeToWnd1(999,0+59,10,134,106,true);
StartAnimation(999)     
end;

function CreateWindow(posx,posy,textid,windowId,image,textX,textY,item,itemX,itemY,fMethod)
playeffect("01");
  if textX==nil then textX=200 end;
  if textY==nil then textY=100 end;
  if fMethod==nil then fMethod=8 end;
  AddWindow(posx,posy,490,256,windowId,fMethod);
  AddWindowElementText(1000025,textX,textY,textid);
  if item~=nil then AddWindowElementImage(1000028,item,itemX,itemY) end;
  if image==nil
    then
      AddWindowElementImage(1000024,"message",0,0);
    else
      AddWindowElementImage(1000024,image,0,0); 
  end;
  SetWindowElementTextColor(textid,1,1,1,1);
end;

function DoFile(level,sub_level)
 UpdateStack();
 dofile("./data/"..level.."/"..sub_level.."/res.lua");
 dofile("./data/"..level.."/"..sub_level.."/level.lua");
end
function rendertar(tex_name,tex_id)
 SetTextureID(TargetID,tex_id)
 FlipVertical(TargetID);
 SetObjectPosition(TargetID,0,-256);
 LeaveObjectsOnReder("leafobj");
 BlackAndWite(TargetID);
return end

-- function DarkScreen()
-- end
function DarkScreen(todark)
StopSheet=true;
  if todark then
  if not whole_darkness then
    BlockCursor(true);
  --  speciale_action(2,501,true);
    whole_darkness=true
    SetAlfa(501,0,0.7,1);      
    speciale_action(4,501);

   return;end;    
  return;end;
  if whole_darkness then
    BlockCursor(true);
    whole_darkness=false;
    SetAlfa(501,0.7,0,1);
    --emitters(true);
  end;  
end;

function AddSkipBtn(SkipX,SkipY)
  addstaticobjecttogame(5001,"skip",SkipX+10,SkipY,"",12,48,193,47);
  addactivobjecttogame(5000,"skip",SkipX,SkipY,"","",0,0,0,0,324,47);
  speciale_action(10,5001);
  addtexttogame(5100,SkipX+210,SkipY+10,"400"); 
  setcolor(5100,1,1,1,1,1);
  speciale_action(4,5100);
  StartProgress(5001,30,true)
  set_visible_object(5001,false)
end;

function HideSkipBtn ()
  speciale_action(2,5000)
  set_visible_object(5001,false)
  speciale_action(2,5100)
end;

-- function SaveLavel(tabe)
  -- save_this(tabe);
-- end;
function SaveLevel()
     local count=0;
     for key,value in pairs(flags) do
          count=count+1;
     end
return flags,count; end;
function SetAlfaSheet(TimeAlfa)
     -- StartTimer(9999,TimeAlfa);
   AlternateTimer("Timer",TimeAlfa*1000);
     StopSheet=false;
end;
function RestoreSheet(name)
  SetCurrentRM("menu");
  loadresource("data\\buttons_sheets.png","buttons_sheets",0000000000000);
  addstaticobjecttogame(777777777,"buttons_sheets",75,698,"",0,0,61,61);        
  AddSheet(1001,"gr","green_b",108,705,34,37,"green",185,675,650,60,11,11,15,13,1,48,777777777,10,"buttonsX");
  SetCurrentRM("main");
end;
-- function SaveLevel()
  -- local val="";

  -- for key,value in pairs(flags) do
    -- if(value) then
      -- val=val.."t"; 
    -- else
      -- val=val.."f";
    -- end;
  -- end
-- return val; end;      
function LoadLevel(param)
  local c=1;
  local val="";
  c=1;
  for key,value in pairs(flags) do
    val=string.char(string.byte (param,c));
    if(val=="t") then
      flags[key]=true;
    else
      flags[key]=false;    
    end;
    c=c+1;
  end
return; end;