local w,h = term.getSize()
local fgc = term.setTextColor
local bgc = term.setBackgroundColor
local register = 0
local login = 0
local deleteusers = 0
local nastaveni={barva=colors.blue}
local f=fs.open("system/.core/colors","r")
local cnt=f.readAll()
f.close()
local nastaveni=textutils.unserialize(cnt)
      
local f=fs.open("system/.core/textcol","r")
local tnt=f.readAll()
f.close()
local text=textutils.unserialize(tnt)
local propojeni = ""

if fs.exists ("/system/.core/logo.nft") then
        shell.run ("mv /system/.core/logo.nft /system/.core/ikon/logo.nft")
        end

if not fs.exists ("/system/programs/setdata/ikon/Ikon.nft") then
    shell.run ("pastebin get RPyte0cc /system/programs/setdata/ikon/Ikon.nft")
    end

local function prc(text, y)
  local w = term.getSize()
  local _, cy = term.getCursorPos()
  term.setCursorPos(math.ceil((w-#text)/2), y or cy)
  write(text)
end

function start ()
    if fs.exists ("/system/RAM/setdata") then
        local data = fs.open ("/system/RAM/setdata", "r")
        local funkce = data.readLine ()
        data.close ()
        local myWindow = window.create(term.current(),1,1,16,19)
    myWindow.setBackgroundColor(colors.gray)
    myWindow.clear()
        resus ()
    else
    term.setBackgroundColor(colors.magenta)
    term.setTextColor(colors.white)
    term.clear ()
    local image = paintutils.loadImage("/system/programs/setdata/ikon/Ikon.nft")
    paintutils.drawImage(image, 18, 4)
    prc ("Setting", 16)
    o=fs.open ("/system/RAM/setting", "r")
    user=o.readLine()
    passI=o.readLine()
    o.close()
    sleep (1)
setupmenu ()
end
end

function minimalizace ()
	if fs.exists ("/system/RAM/setdata") then
	fs.delete ("/system/RAM/setdata")
	end
	
	local data = fs.open ("/system/RAM/setdata", "w")
	data.writeLine(funkce)
	data.close ()
	local data = fs.open ("/system/RAM/prlists", "w")
        data.writeLine ("Setting")
        data.close ()
	shell.run ("/system/api/mineditor")
end

function ukonceni ()
	fs.delete ("/system/RAM/setdata")
	shell.run ("desktop")
end

function resus ()

local data = fs.open ("/system/RAM/setdata", "r")
        local funkce = data.readLine ()
        data.close ()
		
    local myFuncs = {
        ["label"] = function()
        network ()
        end,
        
        ["modem"] = function()
		network ()
        end,
        
        ["info"] = function()
        info ()
        end,
        
		["credits"] = function()
         credits ()
        end,
		
        ["diskinfo"] = function()
         disk ()
        end,
        
        ["theme"] = function()
         theme ()
        end,
        
        ["tapety"] = function()
         tapety ()
        end,
        
        ["account"] = function()
         account ()
        end,
        
        ["deleteuser"] = function()
         account ()
        end,
        
        ["createuser"] = function()
         account ()
        end,
        
        ["logon"] = function()
         account ()
        end,
        
        ["password"] = function()
        account ()
        end,
        
        ["network"] = function()
         network ()
        end,
        
        ["updates"] = function()
         updates ()
        end,
        
        ["update"] = function()
         update ()
        end,
        
        ["apps"] = function()
         apps ()
        end,
        
        ["setprograms"] = function()
         apps ()
        end,
        
        ["downloader"] = function()
         downloader ()
        end,
        
        ["language"] = function()
         language ()
        end,
}

myFuncs[funkce]()
end

function setupmenu ()
    local myWindow = window.create(term.current(),16,1,37,19)
    myWindow.setBackgroundColor(colors.white)
    myWindow.clear()
    local image = paintutils.loadImage("/system/.core/logo.nft")
    paintutils.drawImage(image, 22, 5)
    term.setBackgroundColor(colors.white)
    term.setTextColor(colors.blue)
    myWindow.setCursorPos(20,17)
    print"  Pepek"
    myWindow.setCursorPos(28,17)
    print"Soft  "
    myWindow.setCursorPos(22,18)
    term.setTextColor(colors.black)
    print"2014-2015"
    myWindow.setCursorPos(27,17)
    myWindow.setTextColor(colors.lime)
    print"@"
    local myWindow = window.create(term.current(),1,1,16,19)
    myWindow.setBackgroundColor(colors.gray)
    myWindow.clear()
    local myWindow = window.create(term.current(),1,1,15,19)
    myWindow.setBackgroundColor(nastaveni.barva)
    myWindow.clear()
    term.setBackgroundColor (nastaveni.barva)
    term.setTextColor(colors.lime)
    term.setCursorPos(2,3)
    print "Setting"
    term.setTextColor(text.barva)
    term.setCursorPos(2,5)
    print "Info"
    term.setCursorPos(2,7)
    print "Accounts"
    term.setCursorPos(2,9)
    print "Network"
    term.setCursorPos(2,11)
    print "Language"
    term.setCursorPos(2,13)
    print "System"
    term.setCursorPos(2,15)
    print "Programs"
    term.setCursorPos(2,17)
    print "Themes"
    
      while true do
    local event, button, x, y = os.pullEvent("mouse_click")
    xy = x..","..y
     
    if x >= 2 and x <= 16 and y == 5 and button == 1 then
    info ()
    elseif x >= 2 and x <= 16 and y == 7 and button == 1 then
    account ()
    elseif x >= 2 and x <= 16 and y == 9 and button == 1 then
    network ()
    elseif x >= 2 and x <= 16 and y == 11 and button == 1 then
    language ()
    elseif x >= 2 and x <= 16 and y == 13 and button == 1 then
    updates ()
    elseif x >= 2 and x <= 16 and y == 15 and button == 1 then
    apps ()
    elseif x >= 2 and x <= 16 and y == 17 and button == 1 then
    theme ()
	else
	paintutils.drawLine(1, 1, 51, 1, colors.black)
	paintutils.drawPixel (51,1, colors.red)
	term.setCursorPos (51,1)
	print "*"
			 while true do
		local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y
		
		if x == 51 and y == 1 then
			ukonceni ()
		else 
		setupmenu ()
			end
			end
    break
    end
    end
end

function label ()
funkce = "label"
        local myWindow = window.create(term.current(),17,1,37,19)
    myWindow.setBackgroundColor(colors.white)
    myWindow.clear()
    term.setBackgroundColor(nastaveni.barva)
       term.setCursorPos(1,1)
       print "               "
       paintutils.drawPixel(16, 1, colors.gray)
       term.setBackgroundColor(colors.white)
       term.setCursorPos(17,1)
       print "                                   "
     myWindow.setTextColor(colors.black)
    myWindow.setCursorPos(2, 9)
    print("Set label: ")
    myWindow.setCursorPos(2, 11)
    print("Label clear: ")
    term.setBackgroundColor(colors.lightGray)
    myWindow.setTextColor(colors.white)
    myWindow.setCursorPos(14, 9)
    print "          "
    myWindow.setCursorPos(14, 9)
    if os.getComputerLabel() == nil then
        print "None"
        else
    print(os.getComputerLabel())
    end
    term.setBackgroundColor(colors.gray)
    myWindow.setCursorPos(15, 11)
    print " Clear "
    
    
    	while true do
		local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y
    
    if x >= 29 and x <= 39 and y == 9 and button == 1 then
        term.setBackgroundColor(colors.gray)
        myWindow.setCursorPos(14, 9)
        print "          "
        myWindow.setCursorPos(14, 9)
        propojeni = read ()
        os.setComputerLabel(propojeni)
        label ()
    elseif x >= 30 and x <= 37 and y == 11 and button == 1 then
        myWindow.setCursorPos(14, 9)
        shell.run ("label clear")
        label ()
    elseif x >= 2 and x <= 16 and y == 3 and button == 1 then
    setupmenu ()
    elseif x >= 2 and x <= 16 and y == 5 and button == 1 then
    modem ()
    elseif x >= 2 and x <= 16 and y == 7 and button == 1 then
    label ()
	else
	paintutils.drawLine(1, 1, 51, 1, colors.black)
	paintutils.drawPixel (51,1, colors.red)
    term.setTextColor(colors.white)
    term.setCursorPos (51,1)
	print "*"
    paintutils.drawPixel (50,1, colors.lightGray)
    term.setCursorPos (50,1)
    print "<"
    paintutils.drawPixel (49,1, colors.lightGray)
		term.setCursorPos (49,1)
		print "_"

			 while true do
		local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y
		
		if x == 51 and y == 1 then
			ukonceni ()
		elseif x == 50 and y == 1 then
			network ()
        elseif x == 49 and y == 1 then
			minimalizace ()
        else
		label ()
			end
			end
end
end
end

function modem ()
    funkce = "modem"
    term.setBackgroundColor(nastaveni.barva)
       term.setCursorPos(1,1)
       print "               "
       paintutils.drawPixel(16, 1, colors.gray)
    local myWindow = window.create(term.current(),17,1,37,19)
    myWindow.setBackgroundColor(colors.white)
    myWindow.clear()
        if not fs.exists ("/system/.core/modem") then
        back = "0"
        left = "0"
        right = "0"
        top = "1"
        bottom = "0"
        else
    data = fs.open ("/system/.core/modem", "r")
        back = data.readLine ()
        left = data.readLine ()
        right = data.readLine ()
        top = data.readLine ()
        bottom = data.readLine ()
        data.close ()
        end
		
    if back == "1" then
local function openRednet()
  for _,side in ipairs({"back"}) do
        if peripheral.isPresent(side) and peripheral.getType(side) == "modem" then
          rednet.open(side)
          return side
        end
  end
  back = "0"
end

modemSide = openRednet()
if modemSide == nil then
  back = "0"
else
  print("Opened modem on "..modemSide)
end
    end
    
    if left == "1" then
local function openRednet()
  for _,side in ipairs({"left"}) do
        if peripheral.isPresent(side) and peripheral.getType(side) == "modem" then
          rednet.open(side)
          return side
        end
  end
  left = "0"
end

modemSide = openRednet()
if modemSide == nil then
  left = "0"
else
  print("Opened modem on "..modemSide)
end
    end
    
    if right == "1" then
local function openRednet()
  for _,side in ipairs({"right"}) do
        if peripheral.isPresent(side) and peripheral.getType(side) == "modem" then
          rednet.open(side)
          return side
        end
  end
  right = "0"
end

modemSide = openRednet()
if modemSide == nil then
  right = "0"
else
  print("Opened modem on "..modemSide)
end

    end
    
    if top == "1" then
local function openRednet()
  for _,side in ipairs({"top"}) do
        if peripheral.isPresent(side) and peripheral.getType(side) == "modem" then
          rednet.open(side)
          return side
        end
  end
  top = "0"
end

modemSide = openRednet()
if modemSide == nil then
  top = "0"
else
  print("Opened modem on "..modemSide)
end

    end
    
    if bottom == "1" then
local function openRednet()
  for _,side in ipairs({"bottom"}) do
        if peripheral.isPresent(side) and peripheral.getType(side) == "modem" then
          rednet.open(side)
          return side
        end
  end
  bottom = "0"
end

modemSide = openRednet()
if modemSide == nil then
  bottom = "0"
else
  print("Opened modem on "..modemSide)
end

    end
	
    term.setTextColor(colors.blue)
    myWindow.setCursorPos (2,2)
    print "Modem connection"
    term.setCursorPos(22, 7)
    term.setTextColor(colors.black)
    print ("Back")
    term.setCursorPos(37, 7)
         if back == "0" then
        stavback = "No"
        else
        stavback = "Yes"
        end
        
        term.setBackgroundColor(colors.lightGray)
        term.setTextColor(colors.white)
    print ("  "..stavback.."  ")
        if stavback == "Yes" then
            paintutils.drawPixel (37, 7, colors.lime)
        elseif stavback == "No" then
            paintutils.drawPixel (43, 7, colors.red)
            paintutils.drawPixel (37, 7, colors.lightGray)
       end
       term.setBackgroundColor(colors.white)
       term.setTextColor(colors.black)
       term.setCursorPos(22, 9)
    print ("Left")
    term.setCursorPos(37, 9)
         if left == "0" then
        stavleft = "No"
        else
        stavleft = "Yes"
        end
        
        term.setBackgroundColor(colors.lightGray)
        term.setTextColor(colors.white)
    print ("  "..stavleft.."  ")
        if stavleft == "Yes" then
            paintutils.drawPixel (37, 9, colors.lime)
        elseif stavleft == "No" then
            paintutils.drawPixel (43, 9, colors.red)
            paintutils.drawPixel (37, 9, colors.lightGray)
       end
       term.setBackgroundColor(colors.white)
       term.setTextColor(colors.black)
       term.setCursorPos(22, 11)
    print ("Right")
    term.setCursorPos(37, 11)
         if right == "0" then
        stavright = "No"
        else
        stavright = "Yes"
        end
        
        term.setBackgroundColor(colors.lightGray)
        term.setTextColor(colors.white)
    print ("  "..stavright.."  ")
        if stavright == "Yes" then
            paintutils.drawPixel (37, 11, colors.lime)
        elseif stavright == "No" then
            paintutils.drawPixel (43, 11, colors.red)
            paintutils.drawPixel (37, 11, colors.lightGray)
       end
       term.setBackgroundColor(colors.white)
       term.setTextColor(colors.black)
       term.setCursorPos(22, 13)
    print ("Top")
    term.setCursorPos(37, 13)
         if top == "0" then
        stavtop = "No"
        else
        stavtop = "Yes"
        end
        
        term.setBackgroundColor(colors.lightGray)
        term.setTextColor(colors.white)
    print ("  "..stavtop.."  ")
        if stavtop == "Yes" then
            paintutils.drawPixel (37, 13, colors.lime)
        elseif stavtop == "No" then
            paintutils.drawPixel (43, 13, colors.red)
            paintutils.drawPixel (37, 13, colors.lightGray)
       end
       term.setBackgroundColor(colors.white)
       term.setTextColor(colors.black)
       term.setCursorPos(22, 15)
    print ("Bottom")
    term.setCursorPos(37, 15)
         if bottom == "0" then
        stavbottom = "No"
        else
        stavbottom = "Yes"
        end
        
        term.setBackgroundColor(colors.lightGray)
        term.setTextColor(colors.white)
    print ("  "..stavbottom.."  ")
        if stavbottom == "Yes" then
            paintutils.drawPixel (37, 15, colors.lime)
        elseif stavbottom == "No" then
            paintutils.drawPixel (43, 15, colors.red)
            paintutils.drawPixel (37, 15, colors.lightGray)
       end
    local myWindow = window.create(term.current(),1,1,16,19)
    myWindow.setBackgroundColor(colors.gray)
    myWindow.clear()
    local myWindow = window.create(term.current(),1,1,15,19)
    myWindow.setBackgroundColor(nastaveni.barva)
    myWindow.clear()
    term.setBackgroundColor (nastaveni.barva)
    term.setTextColor(colors.lime)
    term.setCursorPos(2,3)
    print "< Network"
    term.setTextColor(text.barva)
    term.setCursorPos(2,5)
    print "Modem"
    term.setCursorPos(2,7)
    print "Label"  
    
    while true do
		local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y

    if x >= 37 and x <= 43 and y == 7 and button == 1 then
    if back == "1" then
    back = "0"
    rednet.close ("back")
    elseif back == "0" then
    back = "1"
    end
           data = fs.open ("/system/.core/modem", "w")
           data.writeLine (back)
           data.writeLine (left)
           data.writeLine (right)
           data.writeLine (top)
           data.writeLine (bottom)
           data.close ()
        modem ()
    elseif x >= 37 and x <= 43 and y == 9 and button == 1 then
    if left == "1" then
    left = "0"
    rednet.close ("left")
    elseif left == "0" then
    left = "1"
    end
           data = fs.open ("/system/.core/modem", "w")
           data.writeLine (back)
           data.writeLine (left)
           data.writeLine (right)
           data.writeLine (top)
           data.writeLine (bottom)
           data.close ()
        modem ()
    elseif x >= 37 and x <= 43 and y == 11 and button == 1 then
    if right == "1" then
    right = "0"
    rednet.close ("right")
    elseif right == "0" then
    right = "1"
    end
           data = fs.open ("/system/.core/modem", "w")
           data.writeLine (back)
           data.writeLine (left)
           data.writeLine (right)
           data.writeLine (top)
           data.writeLine (bottom)
           data.close ()
        modem ()
    elseif x >= 37 and x <= 43 and y == 13 and button == 1 then
    if top == "1" then
    top = "0"
    rednet.close ("top")
    elseif top == "0" then
    top = "1"
    end
           data = fs.open ("/system/.core/modem", "w")
           data.writeLine (back)
           data.writeLine (left)
           data.writeLine (right)
           data.writeLine (top)
           data.writeLine (bottom)
           data.close ()
        modem ()
    elseif x >= 37 and x <= 43 and y == 15 and button == 1 then
    if bottom == "1" then
    bottom = "0"
    rednet.close ("bottom")
    elseif bottom == "0" then
    bottom = "1"
    end
           data = fs.open ("/system/.core/modem", "w")
           data.writeLine (back)
           data.writeLine (left)
           data.writeLine (right)
           data.writeLine (top)
           data.writeLine (bottom)
           data.close ()
        modem ()
    elseif x >= 2 and x <= 16 and y == 3 and button == 1 then
    setupmenu ()
	elseif x >= 2 and x <= 16 and y == 5 and button == 1 then
    modem ()
    elseif x >= 2 and x <= 16 and y == 7 and button == 1 then
    label ()
	else
	paintutils.drawLine(1, 1, 51, 1, colors.black)
	paintutils.drawPixel (51,1, colors.red)
    term.setTextColor(colors.white)
    term.setCursorPos (51,1)
	print "*"
    paintutils.drawPixel (50,1, colors.lightGray)
    term.setCursorPos (50,1)
    print "<"
    paintutils.drawPixel (49,1, colors.lightGray)
	term.setCursorPos (49,1)
	print "_"
			 while true do
		local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y
		
		if x == 51 and y == 1 then
			ukonceni ()
		elseif x == 50 and y == 1 then
			network ()
        elseif x == 49 and y == 1 then
			minimalizace ()
        else
		modem ()
			end
			end
end
end
end

local function prc(text, y)
  local w = term.getSize()
  local _, cy = term.getCursorPos()
  term.setCursorPos(math.ceil((w-#text)/2), y or cy)
  write(text)
end


function info ()
funkce = "info"
        local myWindow = window.create(term.current(),16,1,37,19)
    myWindow.setBackgroundColor(colors.white)
    myWindow.clear()
        local myWindow = window.create(term.current(),1,1,16,19)
    myWindow.setBackgroundColor(colors.gray)
    myWindow.clear()
local myWindow = window.create(term.current(),1,1,15,19)
    myWindow.setBackgroundColor(nastaveni.barva)
    myWindow.clear()
    term.setBackgroundColor (nastaveni.barva)
    term.setTextColor(colors.lime)
    term.setCursorPos(2,3)
    print "< Info"
    term.setTextColor(text.barva)
    term.setCursorPos(2,5)
    print "Credits"
    term.setCursorPos(2,7)
    print "Disk"
    
      while true do
    local event, button, x, y = os.pullEvent("mouse_click")
    xy = x..","..y
     
    if x >= 2 and x <= 16 and y == 3 and button == 1 then
    setupmenu ()
    elseif x >= 2 and x <= 16 and y == 5 and button == 1 then
    credits ()
    elseif x >= 2 and x <= 16 and y == 7 and button == 1 then
    disk ()
	else
	paintutils.drawLine(1, 1, 51, 1, colors.black)
	paintutils.drawPixel (51,1, colors.red)
    term.setCursorPos (51,1)
	print "*"
    paintutils.drawPixel (50,1, colors.lightGray)
    term.setCursorPos (50,1)
    print "<"
    paintutils.drawPixel (49,1, colors.lightGray)
		term.setCursorPos (49,1)
		print "_"

			 while true do
		local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y
		
		if x == 51 and y == 1 then
			ukonceni ()
		elseif x == 50 and y == 1 then
			setupmenu ()
        elseif x == 49 and y == 1 then
			minimalizace ()
        else
		info ()
			end
			end
end
end
end

function credits ()
funkce = "credits"
        local myWindow = window.create(term.current(),17,1,37,19)
    myWindow.setBackgroundColor(colors.white)
    myWindow.clear()
    term.setBackgroundColor(nastaveni.barva)
       term.setCursorPos(1,1)
       print "               "
       paintutils.drawPixel(16, 1, colors.gray)
       term.setBackgroundColor(colors.white)
       term.setCursorPos(17,1)
       print "                                   "
       myWindow.setTextColor(colors.lime)
    myWindow.setCursorPos(2, 2)
    print "Pepek@Soft"
    term.setTextColor(colors.black)
    myWindow.setCursorPos(13, 2)
    print "Programs"
    myWindow.setTextColor(colors.blue)
    myWindow.setCursorPos(7, 2)
    print "@"
    myWindow.setTextColor(colors.black)

    
    	while true do
		local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y
    
    if x >= 2 and x <= 16 and y == 3 and button == 1 then
    setupmenu ()
    elseif x >= 2 and x <= 16 and y == 5 and button == 1 then
    credits ()
    elseif x >= 2 and x <= 16 and y == 7 and button == 1 then
    disk ()
	else
	paintutils.drawLine(1, 1, 51, 1, colors.black)
	paintutils.drawPixel (51,1, colors.red)
    term.setTextColor(colors.white)
    term.setCursorPos (51,1)
	print "*"
    paintutils.drawPixel (50,1, colors.lightGray)
    term.setCursorPos (50,1)
    print "<"
    paintutils.drawPixel (49,1, colors.lightGray)
		term.setCursorPos (49,1)
		print "_"

			 while true do
		local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y
		
		if x == 51 and y == 1 then
			ukonceni ()
		elseif x == 50 and y == 1 then
			info ()
        elseif x == 49 and y == 1 then
			minimalizace ()
        else
		credits ()
			end
			end
end
end
end

function disk ()
funkce = "diskinfo"
        local myWindow = window.create(term.current(),17,1,37,19)
    myWindow.setBackgroundColor(colors.white)
    myWindow.clear()
    term.setBackgroundColor(nastaveni.barva)
       term.setCursorPos(1,1)
       print "               "
       paintutils.drawPixel(16, 1, colors.gray)
       term.setBackgroundColor(colors.white)
       term.setCursorPos(17,1)
       print "                                   "
     myWindow.setTextColor(colors.black)
    myWindow.setCursorPos(2, 9)
    print("Free Space: "..fs.getFreeSpace("/").." KB")
        if fs.exists ("disk/") then
            print("Free Space: "..fs.getFreeSpace("disk/").." KB")
            end

    
    	while true do
		local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y
    

if x >= 2 and x <= 16 and y == 3 and button == 1 then
    setupmenu ()
    elseif x >= 2 and x <= 16 and y == 5 and button == 1 then
    credits ()
    elseif x >= 2 and x <= 16 and y == 7 and button == 1 then
    disk ()
	else
	paintutils.drawLine(1, 1, 51, 1, colors.black)
	paintutils.drawPixel (51,1, colors.red)
    term.setTextColor(colors.white)
    term.setCursorPos (51,1)
	print "*"
    paintutils.drawPixel (50,1, colors.lightGray)
    term.setCursorPos (50,1)
    print "<"
    paintutils.drawPixel (49,1, colors.lightGray)
		term.setCursorPos (49,1)
		print "_"

			 while true do
		local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y
		
		if x == 51 and y == 1 then
			ukonceni ()
		elseif x == 50 and y == 1 then
			info ()
        elseif x == 49 and y == 1 then
			minimalizace ()
        else
		disk ()
			end
			end
end
end
end

function theme ()
funkce = "theme"
if funkces == nil then
    local f=fs.open("system/.core/colors","r")
local cnt=f.readAll()
f.close()
local nastaveni=textutils.unserialize(cnt)
      
local f=fs.open("system/.core/textcol","r")
local tnt=f.readAll()
f.close()
local text=textutils.unserialize(tnt)

local myWindow = window.create(term.current(),1,1,15,19)
    myWindow.setBackgroundColor(nastaveni.barva)
    myWindow.clear()
    term.setBackgroundColor (nastaveni.barva)
    term.setTextColor(colors.lime)
    term.setCursorPos(2,3)
    print "< Info"
    term.setTextColor(text.barva)
    term.setCursorPos(2,5)
    print "Colors"
    term.setCursorPos(2,7)
    print "Background"
    
    local myWindow = window.create(term.current(),17,1,37,19)
    myWindow.setBackgroundColor(colors.white)
    myWindow.clear()
    term.setBackgroundColor (nastaveni.barva)
    term.setTextColor(colors.lime)
    term.setCursorPos(2,3)
    print "< Theme"
    
        local myWindow = window.create(term.current(),17,1,37,19)
    myWindow.setBackgroundColor(colors.white)
    myWindow.clear()
    term.setBackgroundColor(nastaveni.barva)
       term.setCursorPos(1,1)
       print "               "
end

       paintutils.drawPixel(16, 1, colors.gray)
       term.setBackgroundColor(colors.white)
       term.setCursorPos(17,1)
       print "                                   "
       term.setCursorPos(19,6)
       term.setTextColor(colors.black)
       print "Change background color."
       term.setCursorPos(19,13)
       print "Change text color."
	   term.setCursorPos(30,8)
	   print "W"
	   term.setCursorPos(30,15)
	   print "W"
       paintutils.drawPixel(20, 8, colors.orange)
       paintutils.drawPixel(22, 8, colors.magenta)
       paintutils.drawPixel(24, 8, colors.yellow)
       paintutils.drawPixel(26, 8, colors.cyan)
       paintutils.drawPixel(28, 8, colors.purple)
       paintutils.drawPixel(20, 10, colors.blue)
       paintutils.drawPixel(22, 10, colors.brown)
       paintutils.drawPixel(24, 10, colors.green)
       paintutils.drawPixel(26, 10, colors.red)
       paintutils.drawPixel(28, 10, colors.black)
	   paintutils.drawPixel(30, 10, colors.gray)
       paintutils.drawPixel(20, 15, colors.orange)
       paintutils.drawPixel(22, 15, colors.magenta)
       paintutils.drawPixel(24, 15, colors.yellow)
       paintutils.drawPixel(26, 15, colors.cyan)
       paintutils.drawPixel(28, 15, colors.purple)
       paintutils.drawPixel(20, 17, colors.blue)
       paintutils.drawPixel(22, 17, colors.brown)
       paintutils.drawPixel(24, 17, colors.green)
       paintutils.drawPixel(26, 17, colors.red)
       paintutils.drawPixel(28, 17, colors.black)
	   paintutils.drawPixel(30, 17, colors.gray)
       paintutils.drawPixel(35, 8, nastaveni.barva)
       paintutils.drawPixel(36, 8, nastaveni.barva)
       paintutils.drawPixel(37, 8, nastaveni.barva)
       paintutils.drawPixel(35, 9, nastaveni.barva)
       paintutils.drawPixel(36, 9, nastaveni.barva)
       paintutils.drawPixel(37, 9, nastaveni.barva)
       paintutils.drawPixel(35, 10, nastaveni.barva)
       paintutils.drawPixel(36, 10, nastaveni.barva)
       paintutils.drawPixel(37, 10, nastaveni.barva)
       paintutils.drawPixel(38, 8, nastaveni.barva)
       paintutils.drawPixel(38, 9, nastaveni.barva)
       paintutils.drawPixel(38, 10, nastaveni.barva)
       term.setCursorPos (35,9)
       term.setTextColor(text.barva)
       print "Text"
       term.setTextColor(colors.white)
       term.setBackgroundColor(colors.gray)
           term.setCursorPos(44, 16)
    print " Apply "
       

    
    	while true do
		local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y
    
    if x == 20 and y == 8 and button == 1 then
        local novaBarva= "orange"
    if colors[novaBarva:lower()] then
  nastaveni.barva=colors[novaBarva:lower()]
    end
    funkces = 1
    theme ()
    elseif x == 22 and y == 8 and button == 1 then
    local novaBarva= "magenta"
    if colors[novaBarva:lower()] then
  nastaveni.barva=colors[novaBarva:lower()]
    end
    funkces = 1
    theme ()
	elseif x == 30 and y == 8 and button == 1 then
    local novaBarva= "white"
    if colors[novaBarva:lower()] then
  nastaveni.barva=colors[novaBarva:lower()]
    end
    funkces = 1
    theme ()
    elseif x == 24 and y == 8 and button == 1 then
    local novaBarva= "yellow"
    if colors[novaBarva:lower()] then
  nastaveni.barva=colors[novaBarva:lower()]
    end
    funkces = 1
    theme ()
    elseif x == 26 and y == 8 and button == 1 then 
    local novaBarva= "cyan"
    if colors[novaBarva:lower()] then
  nastaveni.barva=colors[novaBarva:lower()]
    end
    funkces = 1
    theme ()
    elseif x == 28 and y == 8 and button == 1 then 
    local novaBarva= "purple"
    if colors[novaBarva:lower()] then
  nastaveni.barva=colors[novaBarva:lower()]
    end
    funkces = 1
    theme ()
    elseif x == 20 and y == 10 and button == 1 then 
    local novaBarva= "blue"
    if colors[novaBarva:lower()] then
  nastaveni.barva=colors[novaBarva:lower()]
    end
    funkces = 1
    theme ()
    elseif x == 22 and y == 10 and button == 1 then 
    local novaBarva= "brown"
    if colors[novaBarva:lower()] then
  nastaveni.barva=colors[novaBarva:lower()]
    end
    funkces = 1
    theme ()
    elseif x == 24 and y == 10 and button == 1 then 
    local novaBarva= "green"
    if colors[novaBarva:lower()] then
  nastaveni.barva=colors[novaBarva:lower()]
    end
    funkces = 1
    theme ()
    elseif x == 26 and y == 10 and button == 1 then 
    local novaBarva= "red"
    if colors[novaBarva:lower()] then
  nastaveni.barva=colors[novaBarva:lower()]
    end
    funkces = 1
    theme ()
    elseif x == 28 and y == 10 and button == 1 then 
    local novaBarva= "black"
    if colors[novaBarva:lower()] then
  nastaveni.barva=colors[novaBarva:lower()]
    end
    funkces = 1
    theme ()
	elseif x == 30 and y == 10 and button == 1 then 
    local novaBarva= "gray"
    if colors[novaBarva:lower()] then
  nastaveni.barva=colors[novaBarva:lower()]
    end
    funkces = 1
    theme ()
    elseif x == 20 and y == 15 and button == 1 then
        local textBarva= "orange"
    if colors[textBarva:lower()] then
  text.barva=colors[textBarva:lower()]
    end
    funkces = 1
    theme ()
    elseif x == 22 and y == 15 and button == 1 then
    local textBarva= "magenta"
    if colors[textBarva:lower()] then
  text.barva=colors[textBarva:lower()]
    end
    funkces = 1
    theme ()
    elseif x == 24 and y == 15 and button == 1 then
    local textBarva= "yellow"
    if colors[textBarva:lower()] then
  text.barva=colors[textBarva:lower()]
    end
    funkces = 1
    theme ()
    elseif x == 26 and y == 15 and button == 1 then 
    local textBarva= "cyan"
    if colors[textBarva:lower()] then
  text.barva=colors[textBarva:lower()]
    end
    funkces = 1
    theme ()
    elseif x == 28 and y == 15 and button == 1 then 
    local textBarva= "purple"
    if colors[textBarva:lower()] then
  text.barva=colors[textBarva:lower()]
    end
    funkces = 1
    theme ()
    elseif x == 20 and y == 17 and button == 1 then 
    local textBarva= "blue"
    if colors[textBarva:lower()] then
  text.barva=colors[textBarva:lower()]
    end
    funkces = 1
    theme ()
    elseif x == 22 and y == 17 and button == 1 then 
    local textBarva= "brown"
    if colors[textBarva:lower()] then
  text.barva=colors[textBarva:lower()]
    end
    funkces = 1
    theme ()
    elseif x == 24 and y == 17 and button == 1 then 
    local textBarva= "green"
    if colors[textBarva:lower()] then
  text.barva=colors[textBarva:lower()]
    end
    funkces = 1
    theme ()
    elseif x == 26 and y == 17 and button == 1 then 
    local textBarva= "red"
    if colors[textBarva:lower()] then
  text.barva=colors[textBarva:lower()]
    end
    funkces = 1
    theme ()
	elseif x == 30 and y == 15 and button == 1 then 
    local textBarva= "white"
    if colors[textBarva:lower()] then
  text.barva=colors[textBarva:lower()]
    end
    funkces = 1
    theme ()
    elseif x == 30 and y == 17 and button == 1 then 
    local textBarva= "gray"
    if colors[textBarva:lower()] then
  text.barva=colors[textBarva:lower()]
    end
    funkces = 1
    theme ()
    elseif x == 28 and y == 17 and button == 1 then 
    local textBarva= "black"
    if colors[textBarva:lower()] then
  text.barva=colors[textBarva:lower()]
    end
    funkces = 1
    theme ()
    elseif x >= 44 and x <= 51 and y == 16 and button == 1 then
        local f=fs.open("system/.core/colors","w") --#otevrit soubor
        f.write(textutils.serialize(nastaveni)) --#zapsat tabulku jako text a ten ulozit
        f.close()
        local nastaveni={barva=colors.blue}
        local f=fs.open("system/.core/textcol","w") --#otevrit soubor
        f.write(textutils.serialize(text)) --#zapsat tabulku jako text a ten ulozit
        f.close()
        local text={barva=colors.white}
        funkces = nil
        theme ()
    elseif x >= 2 and x <= 16 and y == 3 and button == 1 then
    funkces = nil
    setupmenu ()
    elseif x >= 2 and x <= 16 and y == 5 and button == 1 then
    funkces = nil
    theme ()
    elseif x >= 2 and x <= 16 and y == 7 and button == 1 then
    funkces = nil
    tapety ()
	else
    funkces = nil
	paintutils.drawLine(1, 1, 51, 1, colors.black)
	paintutils.drawPixel (51,1, colors.red)
    term.setTextColor(colors.white)
    term.setCursorPos (51,1)
	print "*"
    paintutils.drawPixel (50,1, colors.lightGray)
    term.setCursorPos (50,1)
    print "<"
    paintutils.drawPixel (49,1, colors.lightGray)
	term.setCursorPos (49,1)
	print "_"
			 while true do
		local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y
		
		if x == 51 and y == 1 then
			ukonceni ()
		elseif x == 50 and y == 1 then
			setupmenu ()
        elseif x == 49 and y == 1 then
			minimalizace ()
        else
		theme ()
			end
			end
end
end
end

function tapety ()
funkce = "tapety"
    o=fs.open ("/system/RAM/setting", "r")
    user = o.readLine()
    o.close()
    local myWindow = window.create(term.current(),1,1,16,19)
    myWindow.setBackgroundColor(colors.gray)
    myWindow.clear()
    local myWindow = window.create(term.current(),1,1,15,19)
    myWindow.setBackgroundColor(nastaveni.barva)
    myWindow.clear()
    term.setBackgroundColor (nastaveni.barva)
    term.setTextColor(colors.lime)
    term.setCursorPos(2,3)
    print "< Info"
    term.setTextColor(text.barva)
    term.setCursorPos(2,5)
    print "Colors"
    term.setCursorPos(2,7)
    print "Background"
    local myWindow = window.create(term.current(),17,1,37,19)
    myWindow.setBackgroundColor(colors.white)
    myWindow.clear()
    term.setBackgroundColor (nastaveni.barva)
    term.setTextColor(colors.lime)
    term.setCursorPos(2,3)
    print "< Theme"
    
        local myWindow = window.create(term.current(),17,1,37,19)
    myWindow.setBackgroundColor(colors.white)
    myWindow.clear()
    term.setBackgroundColor(nastaveni.barva)
       term.setCursorPos(1,1)
       print "               "
       paintutils.drawPixel(16, 1, colors.gray)
       term.setBackgroundColor(colors.white)
       term.setCursorPos(17,1)
       print "                                   "
       myWindow.setCursorPos(2,6)
       term.setTextColor(colors.black)
       print "Change background image."
       myWindow.setCursorPos(2, 8)
       print "- Background clear"
       myWindow.setCursorPos(2, 10)
       print "- Pepdroll"
       myWindow.setCursorPos(2, 12)
       print "- Farm"
       myWindow.setCursorPos(2, 14)
       print "- Windows XP"
       

    
    	while true do
		local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y
    

    if x >= 2 and x <= 16 and y == 3 and button == 1 then
    setupmenu ()
    elseif x >= 2 and x <= 16 and y == 5 and button == 1 then
    theme ()
    elseif x >= 2 and x <= 16 and y == 5 and button == 1 then
    theme ()
    elseif x >= 16 and x <= 35 and y == 8 and button == 1 then
    myWindow.setCursorPos(2, 16)
    shell.run(" delete /system/.ucet/"..user.."/bar.nfp")
    tapety ()
    elseif x >= 16 and x <= 35 and y == 10 and button == 1 then
    myWindow.setCursorPos(2, 16)
    shell.run(" delete /system/.ucet/"..user.."/bar.nfp")
    shell.run("pastebin get C3MXEfYf /system/.ucet/"..user.."/bar.nfp")
    tapety ()
    elseif x >= 16 and x <= 35 and y == 12 and button == 1 then
    myWindow.setCursorPos(2, 16)
    shell.run(" delete /system/.ucet/"..user.."/bar.nfp")
    shell.run("pastebin get K0zXPiKn /system/.ucet/"..user.."/bar.nfp")
    tapety ()
    elseif x >= 16 and x <= 35 and y == 14 and button == 1 then
    myWindow.setCursorPos(2, 16)
    shell.run(" delete /system/.ucet/"..user.."/bar.nfp")
    shell.run("pastebin get iy3EcA4Z /system/.ucet/"..user.."/bar.nfp")
    tapety ()
	else
	paintutils.drawLine(1, 1, 51, 1, colors.black)
	paintutils.drawPixel (51,1, colors.red)
    term.setTextColor(colors.white)
    term.setCursorPos (51,1)
	print "*"
    paintutils.drawPixel (50,1, colors.lightGray)
    term.setCursorPos (50,1)
    print "<"
    paintutils.drawPixel (49,1, colors.lightGray)
	term.setCursorPos (49,1)
	print "_"
			 while true do
		local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y
		
		if x == 51 and y == 1 then
			ukonceni ()
		elseif x == 50 and y == 1 then
			setupmenu ()
        elseif x == 49 and y == 1 then
			minimalizace ()
        else
		tapety ()
			end
			end

end
end
end


function account ()
funkce = "account"
    defuser = user
        local myWindow = window.create(term.current(),16,1,37,19)
    myWindow.setBackgroundColor(colors.white)
    myWindow.clear()
        local myWindow = window.create(term.current(),1,1,16,19)
    myWindow.setBackgroundColor(colors.gray)
    myWindow.clear()
    local myWindow = window.create(term.current(),1,1,15,19)
    myWindow.setBackgroundColor(nastaveni.barva)
    myWindow.clear()
    term.setBackgroundColor (nastaveni.barva)
    term.setTextColor(colors.lime)
    term.setCursorPos(2,3)
    print "< Accounts"
    term.setTextColor(text.barva)
    term.setCursorPos(2,5)
    print "Password"
    term.setCursorPos(2,7)
    print "Login"
    term.setCursorPos(2,9)
    print "New user"
    term.setCursorPos(2,11)
    print "Delete users"
    term.setCursorPos(2,13)
    print "Log out"
    
    if fs.exists ("/system/RAM/setdata")then
     local data = fs.open ("/system/RAM/setdata", "r")
        funkce = data.readLine ()
        data.close ()
        end
        
        
        if funkce == "password" then
            password ()
        elseif funkce == logon then
            login ()
        elseif funkce == "createuser" then
            createuser ()
        elseif funkce == "deleteuser" then
            deleteuser ()
        end
        
        logon ()
end

function deleteuser ()
funkce = "deleteuser"    
    function dele ()
                term.setCursorPos (20, 13)
                term.setTextColor(colors.lime)
                print "User is deleted!"
                sleep (1)
                fs.delete ("/system/.ucet/"..deluser)
                deleteusers = 0
                deleteuser ()
                end
                        function defuserdel ()
                           if defuser == deluser then
                               term.setCursorPos (20, 13)
                                term.setTextColor(colors.red)
                                print "User is a default!"
                                sleep (1)
                                local myWindow = window.create(term.current(),19,10,21,5)
                                myWindow.setBackgroundColor(colors.gray)
                                myWindow.clear()
                                local myWindow = window.create(term.current(),18,9,21,5)
                                myWindow.setBackgroundColor(colors.yellow)
                                myWindow.clear()
                                term.setTextColor(colors.black)
                                myWindow.setCursorPos (2,2)
                                print "Do you want change"
                                myWindow.setCursorPos (2,3)
                                print "default user now ?"
                                myWindow.setCursorPos (2,5)
                                print "Yes             No"
                                
                        while true do
                		local event, button, x, y = os.pullEvent("mouse_click")
                		xy = x..","..y
                                if x >= 19 and x <= 21 and y == 13 and button == 1 then
                                logon ()
                                else
                                deleteusers = 1
                                deleteuser ()
                                end
                                end
                                else
                                dele ()
                                end
                                end
                                
                                function resetnow ()
                                 local myWindow = window.create(term.current(),19,10,21,5)
                                myWindow.setBackgroundColor(colors.gray)
                                myWindow.clear()
                                local myWindow = window.create(term.current(),18,9,21,5)
                                myWindow.setBackgroundColor(colors.yellow)
                                myWindow.clear()
                                term.setTextColor(colors.black)
                                myWindow.setCursorPos (2,2)
                                print "Do you want       "
                                myWindow.setCursorPos (2,3)
                                print "restart now ?     "
                                myWindow.setCursorPos (2,5)
                                print "Yes             No"
                                
                        while true do
                		local event, button, x, y = os.pullEvent("mouse_click")
                		xy = x..","..y
                                if x >= 19 and x <= 21 and y == 13 and button == 1 then
                                restart ()
                                else
                                deleteusers = 1
                                deleteuser ()
                                end
                                end
                                end   
                
        if deleteusers == 0 then
            deluser = ""
            end
            
    term.setBackgroundColor(nastaveni.barva)
       term.setCursorPos(1,1)
       print "               "
       paintutils.drawPixel(16, 1, colors.gray)
    local myWindow = window.create(term.current(),17,1,37,19)
    myWindow.setBackgroundColor(colors.white)
    myWindow.clear()
    term.setTextColor(colors.blue)
    myWindow.setCursorPos (2,3)
    print "Delete an account"
    term.setTextColor(colors.black)
    myWindow.setCursorPos(2, 5)
    print "User name:"
    term.setBackgroundColor(colors.gray)
    term.setTextColor(colors.white)
    myWindow.setCursorPos(30, 16)
    print " Apply "
    term.setBackgroundColor(colors.lightGray)
    myWindow.setCursorPos(13, 5)
    print "              "
    term.setCursorPos(29, 5)
    print (deluser)
    myWindow.setCursorPos(35,9)
    print "<"
            
    while true do
		local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y

    if x >= 29 and x <= 44 and y == 5 and button == 1 then
            term.setBackgroundColor(colors.gray)
            term.setCursorPos(29, 5)
            print "              "
            term.setCursorPos(29, 5)
            deluser = read ()
            deleteusers = 1
            deleteuser ()
    elseif x >= 44 and x <= 51 and y == 16 and button == 1 then
        term.setBackgroundColor(colors.white)
        
        if fs.exists ("/system/RAM/"..deluser) then
            term.setCursorPos (20, 13)
                        term.setTextColor(colors.red)
                        print "You must restart computer"
                        sleep (1)
                        resetnow ()
                        end
                        
        if fs.exists ("/system/.ucet/"..deluser) then
             if fs.exists ("/system/.core/defuser") then
               data = fs.open ("/system/.core/defuser", "r")
               defuser = data.readLine ()
               defuserdel ()
               else
               dele ()
               end
           else
           term.setCursorPos (20, 13)
                term.setTextColor(colors.red)
                print "User is not found!"
                sleep (1)
                deleteusers = 1
                deleteuser ()
                end
                
    elseif x == 51 and y == 9 and button == 1 then               
        local myWindow = window.create(term.current(),1,17,51,3)
        myWindow.setBackgroundColor(colors.yellow)
        myWindow.clear()
        term.setCursorPos(1,17)
        shell.run ("ls /system/.ucet/")
        
        while true do
		local event, button, xPos, yPos = os.pullEvent("mouse_click")
        local myWindow = window.create(term.current(),1,17,15,3)
        myWindow.setBackgroundColor(nastaveni.barva)
        myWindow.clear()
        local myWindow = window.create(term.current(),17,17,40,3)
        myWindow.setBackgroundColor(colors.white)
        myWindow.clear()
        paintutils.drawPixel(16, 17, colors.gray) 
        paintutils.drawPixel(16, 18, colors.gray) 
        paintutils.drawPixel(16, 19, colors.gray)
        deleteuser () 
        end
    elseif x >= 2 and x <= 16 and y == 3 and button == 1 then
    setupmenu ()
	elseif x >= 2 and x <= 16 and y == 5 and button == 1 then
    password ()
    elseif x >= 2 and x <= 16 and y == 7 and button == 1 then
    logon ()
    elseif x >= 2 and x <= 16 and y == 9 and button == 1 then
    createuser ()
    elseif x >= 2 and x <= 16 and y == 11 and button == 1 then
    deleteuser ()
	elseif x >= 2 and x <= 16 and y == 13 and button == 1 then
    odhlasit ()
	else
	paintutils.drawLine(1, 1, 51, 1, colors.black)
	paintutils.drawPixel (51,1, colors.red)
    term.setTextColor(colors.white)
    term.setCursorPos (51,1)
	print "*"
    paintutils.drawPixel (50,1, colors.lightGray)
    term.setCursorPos (50,1)
    print "<"
    paintutils.drawPixel (49,1, colors.lightGray)
	term.setCursorPos (49,1)
	print "_"
			 while true do
		local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y
		
		if x == 51 and y == 1 then
			ukonceni ()
		elseif x == 50 and y == 1 then
			account ()
        elseif x == 49 and y == 1 then
			minimalizace ()
        else
		deleteuser ()
			end
			end
end
end
end

function createuser ()
funkce = "createuser"
        if register == 0 then
            newuser = ""
            newpass = ""
            newpas = ""
            end
            
    term.setBackgroundColor(nastaveni.barva)
       term.setCursorPos(1,1)
       print "               "
       paintutils.drawPixel(16, 1, colors.gray)
    local myWindow = window.create(term.current(),17,1,37,19)
    myWindow.setBackgroundColor(colors.white)
    
    myWindow.clear()
    myWindow.setCursorPos (2,3)
    term.setTextColor(colors.blue)
    print "Create a new account"
    term.setTextColor(colors.black)
    myWindow.setCursorPos(2, 5)
    print "User name:"
    myWindow.setCursorPos(2, 7)
    print " Password:"
    term.setBackgroundColor(colors.gray)
    term.setTextColor(colors.white)
    myWindow.setCursorPos(30, 16)
    print " Apply "
    term.setBackgroundColor(colors.lightGray)
    myWindow.setCursorPos(13, 5)
    print "              "
    myWindow.setCursorPos(13, 5)
    print (newuser)
    myWindow.setCursorPos(13, 7)
    print "              "
    myWindow.setCursorPos(13, 7)
    print (newpas)
    myWindow.setCursorPos(35,9)
    print "<"
    
    while true do
		local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y
    
        if x >= 29 and x <= 44 and y == 5 and button == 1 then
            term.setBackgroundColor(colors.gray)
            term.setCursorPos(29, 5)
            print "              "
            term.setCursorPos(29, 5)
            newuser = read ()
            register = 1
            createuser ()
        elseif x >= 29 and x <= 44 and y == 7 and button == 1 then
            term.setBackgroundColor(colors.gray)
            term.setCursorPos(29, 7)
            print "              "
            term.setCursorPos(29, 7)
            newpass= read ("@")
            newpas = "Password"
            register = 1
            createuser ()
    elseif x >= 44 and x <= 51 and y == 16 and button == 1 then
    term.setBackgroundColor(colors.white)
                if not fs.exists ("/system/.ucet/"..newuser) then
                        file = fs.open ("/system/.ucet/"..newuser.."/.data", "w")
                        file.writeLine(newuser)
                        file.writeLine(newpass)
                        file.close ()
                        term.setCursorPos(17,13)
                        shell.run ("pastebin get C3MXEfYf ", ".ucet/"..newuser.."/bar.nfp")
                        term.setCursorPos(17,13)
                        shell.run ("pastebin get 2Rg15U0q ", ".ucet/"..newuser.."/user")
                        local myWindow = window.create(term.current(),17,13,34,3)
                        myWindow.setBackgroundColor(colors.white)
                        myWindow.clear ()
                        term.setCursorPos(20,14)
                        term.setTextColor(colors.lime)
                        print "Complete"
                        register = 0
                        local myWindow = window.create(term.current(),1,14,15,2)
                        myWindow.setBackgroundColor(nastaveni.barva)
                        myWindow.clear()
                        paintutils.drawPixel(16, 14, colors.gray)
                        paintutils.drawPixel(16, 15, colors.gray)
                        sleep (1)
                        createuser ()
                        else
                        term.setCursorPos (20, 13)
                        term.setTextColor(colors.red)
                        print "User is exists"
                        sleep (1)
                        register = 1
                        createuser ()
                    end
    elseif x == 51 and y == 9 and button == 1 then               
        local myWindow = window.create(term.current(),1,17,51,3)
        myWindow.setBackgroundColor(colors.yellow)
        myWindow.clear()
        term.setCursorPos(1,17)
        shell.run ("ls /system/.ucet/")
        
        while true do
		local event, button, xPos, yPos = os.pullEvent("mouse_click")
        local myWindow = window.create(term.current(),1,17,15,3)
        myWindow.setBackgroundColor(nastaveni.barva)
        myWindow.clear()
        local myWindow = window.create(term.current(),17,17,40,3)
        myWindow.setBackgroundColor(colors.white)
        myWindow.clear()
        paintutils.drawPixel(16, 17, colors.gray) 
        paintutils.drawPixel(16, 18, colors.gray) 
        paintutils.drawPixel(16, 19, colors.gray)
        createuser () 
        end
        
    elseif x >= 2 and x <= 16 and y == 3 and button == 1 then
    setupmenu ()
	elseif x >= 2 and x <= 16 and y == 5 and button == 1 then
    password ()
    elseif x >= 2 and x <= 16 and y == 7 and button == 1 then
    logon ()
    elseif x >= 2 and x <= 16 and y == 9 and button == 1 then
    createuser ()
    elseif x >= 2 and x <= 16 and y == 11 and button == 1 then
    deleteuser ()
	elseif x >= 2 and x <= 16 and y == 13 and button == 1 then
    odhlasit ()
	else
	paintutils.drawLine(1, 1, 51, 1, colors.black)
	paintutils.drawPixel (51,1, colors.red)
    term.setTextColor(colors.white)
    term.setCursorPos (51,1)
	print "*"
    paintutils.drawPixel (50,1, colors.lightGray)
    term.setCursorPos (50,1)
    print "<"
    paintutils.drawPixel (49,1, colors.lightGray)
	term.setCursorPos (49,1)
	print "_"
			 while true do
		local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y
		
		if x == 51 and y == 1 then
			ukonceni ()
		elseif x == 50 and y == 1 then
			account ()
        elseif x == 49 and y == 1 then
			minimalizace ()
        else
		createuser ()
			end
			end
end
end
end
   function logon ()
   funkce = "logon"
	defuser = user
       function apply ()
               term.setBackgroundColor(colors.white)
        data = fs.open("/system/.core/defuser","w")
        data.writeLine(defuser)
        data.close()
        term.setCursorPos (20, 13)
                term.setTextColor(colors.lime)
                print "Successeful!"
                sleep (1)
        logon ()
           end
        local data = fs.open("/system/.core/defuser","r")
        defuser = data.readLine ()
        data.close ()   
        local n=fs.open("/system/.core/logon.cfg","r")
        preskoclog = n.readLine ()
        n.close ()
       term.setBackgroundColor(nastaveni.barva)
       term.setCursorPos(1,1)
       print "               "
       paintutils.drawPixel(16, 1, colors.gray)
        local myWindow = window.create(term.current(),17,1,37,19)
    myWindow.setBackgroundColor(colors.white)
    myWindow.clear()
    term.setTextColor(colors.blue)
    myWindow.setCursorPos (2,3)
    print "Setting a login"

    term.setBackgroundColor(colors.white)
    term.setTextColor(colors.black)
    term.setCursorPos(22, 9)
    print ("You must log")
    term.setCursorPos(20, 16)
    print ("If you want skip login,")
    term.setCursorPos(20, 17)
    print ("default user will ")
    term.setCursorPos(38, 17)
    term.setBackgroundColor(colors.lightGray)
    print (defuser)
        myWindow.setCursorPos(35,9)
    print "<"
    term.setBackgroundColor(colors.lightGray)
    term.setCursorPos(37,9)   
    if preskoclog == "1" then
        stavlog = "No"
        else
        stavlog = "Yes"
        n.close()
        end
        term.setTextColor(colors.white)
    print ("  "..stavlog.."  ")
        if stavlog == "Yes" then
            paintutils.drawPixel (37, 9, colors.lime)
        elseif stavlog == "No" then
            paintutils.drawPixel (43, 9, colors.red)
            paintutils.drawPixel (37, 9, colors.lightGray)
       end

    
    
    	while true do
		local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y
    
    if x >= 37 and x <= 43 and y == 17 and button == 1 then
        term.setCursorPos(38, 17)
        term.setBackgroundColor(colors.gray)
        print "          "
        term.setCursorPos(38, 17)
        defus = read ()
            if fs.exists ("/system/.ucet/"..defus) then
                defuser = defus
                apply ()
                else
                term.setBackgroundColor(colors.white)
                term.setCursorPos (20, 13)
                term.setTextColor(colors.red)
                print "User not found!"
                sleep (1)
                logon ()
             end
        end
        
   if x >= 37 and x <= 43 and y == 9 and button == 1 then

    if preskoclog == "1" then
    preskoclog = "0"
    elseif preskoclog == "0" then
    preskoclog = "1"
    n.close()
    end
    
local n=fs.open("/system/.core/logon.cfg","w")
n.writeLine(preskoclog)
n.close()
logon ()
        
    elseif x == 51 and y == 9 and button == 1 then               
        local myWindow = window.create(term.current(),1,17,51,3)
        myWindow.setBackgroundColor(colors.yellow)
        myWindow.clear()
        term.setCursorPos(1,17)
        shell.run ("ls /system/.ucet/")
        
        while true do
		local event, button, xPos, yPos = os.pullEvent("mouse_click")
        local myWindow = window.create(term.current(),1,17,15,3)
        myWindow.setBackgroundColor(nastaveni.barva)
        myWindow.clear()
        local myWindow = window.create(term.current(),17,17,40,3)
        myWindow.setBackgroundColor(colors.white)
        myWindow.clear()
        paintutils.drawPixel(16, 17, colors.gray) 
        paintutils.drawPixel(16, 18, colors.gray) 
        paintutils.drawPixel(16, 19, colors.gray)
        logon () 
        end
    elseif x >= 2 and x <= 16 and y == 3 and button == 1 then
    setupmenu ()
	elseif x >= 2 and x <= 16 and y == 5 and button == 1 then
    password ()
    elseif x >= 2 and x <= 16 and y == 7 and button == 1 then
    logon ()
    elseif x >= 2 and x <= 16 and y == 9 and button == 1 then
     createuser ()
    elseif x >= 2 and x <= 16 and y == 11 and button == 1 then
    deleteuser ()
	elseif x >= 2 and x <= 16 and y == 13 and button == 1 then
    odhlasit ()
	else
	paintutils.drawLine(1, 1, 51, 1, colors.black)
	paintutils.drawPixel (51,1, colors.red)
    term.setTextColor(colors.white)
    term.setCursorPos (51,1)
	print "*"
    paintutils.drawPixel (50,1, colors.lightGray)
    term.setCursorPos (50,1)
    print "<"
    paintutils.drawPixel (49,1, colors.lightGray)
	term.setCursorPos (49,1)
	print "_"

			 while true do
		local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y
		
		if x == 51 and y == 1 then
			ukonceni ()
		elseif x == 50 and y == 1 then
			account ()
        elseif x == 49 and y == 1 then
			minimalizace ()
        else
		logon ()
			end
			end
end
end
end

 function password ()
 funkce = "password"
     
     if login == 1 then
         else
        passold = ""
        passoldp = ""
        pass1 = ""
        pass1p = ""
        pass2 = ""
        pass2p = ""
        end
        
        local n=fs.open("/system/.core/logon.cfg","r")
        preskoclog = n.readLine ()
        n.close ()
        
       term.setBackgroundColor(nastaveni.barva)
       term.setCursorPos(1,1)
       print "               "
       paintutils.drawPixel(16, 1, colors.gray)
        local myWindow = window.create(term.current(),17,1,37,19)
    myWindow.setBackgroundColor(colors.white)
    myWindow.clear()
    term.setTextColor(colors.blue)
    myWindow.setCursorPos (2,3)
    print "Change your password"
    term.setTextColor(colors.black)
    myWindow.setCursorPos(2, 5)
    print "Your old password:"
    myWindow.setCursorPos(2, 7)
    print "Your new password:"
    myWindow.setCursorPos(3, 9)
    print "Confirm password:"
    term.setBackgroundColor(colors.gray)
    term.setTextColor(colors.white)
    myWindow.setCursorPos(30, 16)
    print " Apply "
    term.setBackgroundColor(colors.lightGray)
    myWindow.setCursorPos(21, 5)
    print "              "
    myWindow.setCursorPos(21, 5)
    print (passoldp)
    myWindow.setCursorPos(21, 7)
    print "              "
    myWindow.setCursorPos(21, 7)
    print (pass1p)
    myWindow.setCursorPos(21, 9)
    print "              "
    myWindow.setCursorPos(21, 9)
        if pass2 == pass1 then
        term.setTextColor(colors.lime)   
        print "Valid"
        else
        term.setTextColor(colors.red)
        print "Invalid"
        end

    
    	while true do
		local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y
    if x >= 37 and x <= 50 and y == 5 and button == 1 then
    term.setBackgroundColor(colors.gray)
    term.setCursorPos(37, 5)
    print "              "
    term.setCursorPos(37, 5)
    term.setTextColor(colors.white)
    passold = read ("@")
    passoldp = "Old Password"
    login = 1
    password ()
    elseif x >= 37 and x <= 50 and y == 7 and button == 1 then
    term.setBackgroundColor(colors.gray)
    term.setCursorPos(37, 7)
    print "              "
    term.setCursorPos(37, 7)
    term.setTextColor(colors.white)
    pass1 = read ("@")
    pass1p = "New Password"
    login = 1
    password ()
    elseif x >= 37 and x <= 50 and y == 9 and button == 1 then
    term.setBackgroundColor(colors.gray)
    term.setCursorPos(37, 9)
    print "              "
    term.setCursorPos(37, 9)
    term.setTextColor(colors.white)
    pass2 = read ("@")
    password ()

    elseif x >= 44 and x <= 51 and y == 16 and button == 1 then
    
    o=fs.open ("/system/.ucet/"..user.."/.data", "r")
    user=o.readLine()
    passI=o.readLine()
    o.close()
    term.setBackgroundColor(colors.white)
        if passold == passI then
            if pass1 == pass2 then
                term.setCursorPos (20, 13)
            term.setTextColor(colors.lime)
            data = fs.open("/system/.ucet/"..user.."/.data","w")
            data.writeLine(user)
            data.writeLine(pass1)
            data.close()
            print "Your accound has been changed."
            login = 0
            sleep (1)
            password ()
            else
            term.setCursorPos (20, 13)
            term.setTextColor(colors.red)
            print "Invalid confirm password!"
            login = 1
            sleep (1)
            password ()
            end
    else
    term.setCursorPos (20, 13)
    term.setTextColor(colors.red)
    print "Invalid old password!"
    sleep (1)
    login = 1
    password ()
    end
          
    elseif x >= 2 and x <= 16 and y == 3 and button == 1 then
    login = 0
    setupmenu ()
	elseif x >= 2 and x <= 16 and y == 5 and button == 1 then
    login = 0
    password ()
    elseif x >= 2 and x <= 16 and y == 7 and button == 1 then
    login = 0
    logon ()
    elseif x >= 2 and x <= 16 and y == 9 and button == 1 then
     createuser ()
    elseif x >= 2 and x <= 16 and y == 11 and button == 1 then
    deleteuser ()
	elseif x >= 2 and x <= 16 and y == 13 and button == 1 then
    odhlasit ()
	else
	paintutils.drawLine(1, 1, 51, 1, colors.black)
	paintutils.drawPixel (51,1, colors.red)
    term.setTextColor(colors.white)
    term.setCursorPos (51,1)
	print "*"
    paintutils.drawPixel (50,1, colors.lightGray)
    term.setCursorPos (50,1)
    print "<"
    paintutils.drawPixel (49,1, colors.lightGray)
	term.setCursorPos (49,1)
	print "_"

			 while true do
		local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y
		
		if x == 51 and y == 1 then
        login = 0
			ukonceni ()
		elseif x == 50 and y == 1 then
        login = 0
			account ()
        elseif x == 49 and y == 1 then
        login = 1
			minimalizace ()
        else
        login = 1
		password ()
			end
			end
end
end
end

function network ()
funkce = "network"
    local myWindow = window.create(term.current(),1,1,16,19)
    myWindow.setBackgroundColor(colors.gray)
    myWindow.clear()
    local myWindow = window.create(term.current(),1,1,15,19)
    myWindow.setBackgroundColor(nastaveni.barva)
    myWindow.clear()
    term.setBackgroundColor (nastaveni.barva)
    term.setTextColor(colors.lime)
    term.setCursorPos(2,3)
    print "< Network"
    term.setTextColor(text.barva)
    term.setCursorPos(2,5)
    print "Modem"
    term.setCursorPos(2,7)
    print "Label"
    
    if fs.exists ("/system/RAM/setdata")then
     local data = fs.open ("/system/RAM/setdata", "r")
        funkce = data.readLine ()
        data.close ()
        end
        
        
        if funkce == "modem" then
            modem ()
        elseif funkce == "label" then
            label ()
        end
        
    modem ()
    end

function language ()
    funkce = "language"
        local myWindow = window.create(term.current(),16,1,37,19)
    myWindow.setBackgroundColor(colors.white)
    myWindow.clear()
        local myWindow = window.create(term.current(),1,1,16,19)
    myWindow.setBackgroundColor(colors.gray)
    local myWindow = window.create(term.current(),1,1,15,19)
    myWindow.setBackgroundColor(nastaveni.barva)
    myWindow.clear()
    term.setBackgroundColor (nastaveni.barva)
    term.setTextColor(colors.lime)
    term.setCursorPos(2,3)
    print "< Language"
    term.setTextColor(text.barva)
    term.setCursorPos(2,5)
    print "Account"
    term.setCursorPos(2,7)
    print "Primary"
    
      while true do
    local event, button, x, y = os.pullEvent("mouse_click")
    xy = x..","..y
     
    if x >= 2 and x <= 16 and y == 3 and button == 1 then
    setupmenu ()
    elseif x >= 2 and x <= 16 and y == 5 and button == 1 then
    fs.delete ("/system/RAM/jazyk1")
	shell.run ("pastebin get uVRBmFvy /system/RAM/jazyk1")
	shell.run ("/system/RAM/jazyk1")
	elseif x >= 2 and x <= 16 and y == 7 and button == 1 then
    fs.delete ("/system/RAM/jazyk2")
	shell.run ("pastebin get uVRBmFvy /system/RAM/jazyk2")
	shell.run ("/system/RAM/jazyk2")
	else
	paintutils.drawLine(1, 1, 51, 1, colors.black)
	paintutils.drawPixel (51,1, colors.red)
    term.setCursorPos (51,1)
	print "*"
    paintutils.drawPixel (50,1, colors.lightGray)
    term.setCursorPos (50,1)
    print "<"
    paintutils.drawPixel (49,1, colors.lightGray)
	term.setCursorPos (49,1)
	print "_"

			 while true do
		local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y
		
		if x == 51 and y == 1 then
			ukonceni ()
		elseif x == 50 and y == 1 then
			setupmenu ()
        elseif x == 49 and y == 1 then
			minimalizace ()
        else
		language ()
			end
			end
end
end
    end

function updates ()
funkce = "updates"
        local myWindow = window.create(term.current(),16,1,37,19)
    myWindow.setBackgroundColor(colors.white)
    myWindow.clear()
        local myWindow = window.create(term.current(),1,1,16,19)
    myWindow.setBackgroundColor(colors.gray)
    myWindow.clear()
    local myWindow = window.create(term.current(),1,1,15,19)
    myWindow.setBackgroundColor(nastaveni.barva)
    myWindow.clear()
    term.setBackgroundColor (nastaveni.barva)
    term.setTextColor(colors.lime)
    term.setCursorPos(2,3)
    print "< Update and"
    term.setCursorPos(2,4)
    print "  Recovery"
    term.setTextColor(text.barva)
    term.setCursorPos(2,6)
    print "Update"
    term.setCursorPos(2,8)
    print "Recovery"
        
      while true do
    local event, button, x, y = os.pullEvent("mouse_click")
    xy = x..","..y
     
    if x >= 2 and x <= 16 and y >= 3 and y <= 4 and button == 1 then
    setupmenu ()
    elseif x >= 2 and x <= 16 and y == 6 and button == 1 then
    update ()
    elseif x >= 2 and x <= 16 and y == 8 and button == 1 then
    term.setBackgroundColor(colors.lime)
    shell.run ("rename /startup startup1")
    myWindow.setCursorPos(2,9)
    shell.run ("pastebin get e7tTfKX3 /startup")
    restart ()
	else
	paintutils.drawLine(1, 1, 51, 1, colors.black)
	paintutils.drawPixel (51,1, colors.red)
    term.setCursorPos (51,1)
	print "*"
    paintutils.drawPixel (50,1, colors.lightGray)
    term.setCursorPos (50,1)
    print "<"
    paintutils.drawPixel (49,1, colors.lightGray)
	term.setCursorPos (49,1)
	print "_"

			 while true do
		local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y
		
		if x == 51 and y == 1 then
			ukonceni ()
		elseif x == 50 and y == 1 then
			setupmenu ()
        elseif x == 49 and y == 1 then
			minimalizace ()
        else
		updates ()
			end
			end
end
end
    end
    
function update ()
funkce = "updates"
    term.setBackgroundColor(nastaveni.barva)
       term.setCursorPos(1,1)
       print "               "
       paintutils.drawPixel(16, 1, colors.gray)
       if not fs.exists ("/system/.core/update") then
           data = fs.open ("/system/.core/update", "w")
           data.writeLine ("0")
           data.close ()
    local myWindow = window.create(term.current(),17,1,37,19)
    myWindow.setBackgroundColor(colors.white)
    myWindow.clear()
    term.setTextColor(colors.black)
    myWindow.setCursorPos (2,5)
    print "Update"
    while true do
		local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y

    if x >= 2 and x <= 16 and y == 3 and button == 1 then
    setupmenu ()
    elseif x >= 2 and x <= 16 and y == 6 and button == 1 then
    update ()
  elseif x >= 2 and x <= 16 and y == 8 and button == 1 then
     term.setBackgroundColor(colors.lime)
    shell.run ("rename /startup startup1")
    myWindow.setCursorPos(2,9)
    shell.run ("pastebin get e7tTfKX3 /startup")
    restart () 
	else
	paintutils.drawLine(1, 1, 51, 1, colors.black)
	paintutils.drawPixel (51,1, colors.red)
    term.setTextColor(colors.white)
    term.setCursorPos (51,1)
	print "*"
    paintutils.drawPixel (50,1, colors.lightGray)
    term.setCursorPos (50,1)
    print "<"
    paintutils.drawPixel (49,1, colors.lightGray)
	term.setCursorPos (49,1)
	print "_"

			 while true do
		local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y
		
		if x == 51 and y == 1 then
			ukonceni ()
		elseif x == 50 and y == 1 then
			updates ()
        elseif x == 49 and y == 1 then
			minimalizace ()
        else
		update ()
			end
			end
end
end
end
end
  
function apps ()
funkce = "apps"
        local myWindow = window.create(term.current(),16,1,37,19)
    myWindow.setBackgroundColor(colors.white)
    myWindow.clear()
        local myWindow = window.create(term.current(),1,1,16,19)
    myWindow.setBackgroundColor(colors.gray)
    myWindow.clear()
    local myWindow = window.create(term.current(),1,1,15,19)
    myWindow.setBackgroundColor(nastaveni.barva)
    myWindow.clear()
    term.setBackgroundColor (nastaveni.barva)
    term.setTextColor(colors.lime)
    term.setCursorPos(2,3)
    print "< Store"
    term.setTextColor(text.barva)
    term.setCursorPos(2,5)
    print "Apps"
    term.setCursorPos(2,7)
    print "Menu"
        
         if fs.exists ("/system/RAM/setdata")then
     local data = fs.open ("/system/RAM/setdata", "r")
        funkce = data.readLine ()
        data.close ()
        end
        
        
        if funkce == "downloader" then
            downloader ()
        elseif funkce == "setprograms" then
            setprograms ()
        end
        
    downloader ()
end

function setprograms ()
funkce = "setprograms"
    function apply ()
        data = fs.open ("/system/.core/lsprogram", "w")
        data.writeLine(nmenu1)
        data.writeLine(npath1)
        data.writeLine(nmenu2)
        data.writeLine(npath2)
        data.writeLine(nmenu3)
        data.writeLine(npath3)
        data.writeLine(nmenu4)
        data.writeLine(npath4)
        data.writeLine(nmenu5)
        data.writeLine(npath5)
        data.writeLine(nmenu6)
        data.writeLine(npath6)
        data.writeLine(nmenu7)
        data.writeLine(npath7)
        data.close ()
        
        term.setCursorPos (20, 17)
        term.setBackgroundColor(colors.white)
        term.setTextColor(colors.lime)
        print "Successfull"
        sleep (1)
        setprograms ()
        end

            local data = fs.open ("/system/.core/lsprogram", "r")
        menu1 = data.readLine ()
        path1 = data.readLine ()
        menu2 = data.readLine ()
        path2 = data.readLine ()
        menu3 = data.readLine ()
        path3 = data.readLine ()
        menu4 = data.readLine ()
        path4 = data.readLine ()
        menu5 = data.readLine ()
        path5 = data.readLine ()
        menu6 = data.readLine ()
        path6 = data.readLine ()
        menu7 = data.readLine ()
        path7 = data.readLine ()
        nmenu1 = menu1
        npath1 = path1
        nmenu2 = menu2
        npath2 = path2
        nmenu3 = menu3
        npath3 = path3
        nmenu4 = menu4
        npath4 = path4
        nmenu5 = menu5
        npath5 = path5
        nmenu6 = menu6
        npath6 = path6
        nmenu7 = menu7
        npath7 = path7

    
    term.setBackgroundColor(nastaveni.barva)
       term.setCursorPos(1,1)
       print "               "
       paintutils.drawPixel(16, 1, colors.gray)
    local myWindow = window.create(term.current(),17,1,37,19)
    myWindow.setBackgroundColor(colors.white)
    myWindow.clear()
    term.setTextColor(colors.black)
    term.setBackgroundColor(colors.white)
    myWindow.setCursorPos (1,3)
    print "1.position"
    myWindow.setCursorPos (1,5)
    print "2.position"
    myWindow.setCursorPos (1,7)
    print "3.position"
    myWindow.setCursorPos (1,9)
    print "4.position"
    myWindow.setCursorPos (1,11)
    print "5.position"
    myWindow.setCursorPos (1,13)
    print "6.position"
    myWindow.setCursorPos (1,15)
    print "7.position"
    term.setTextColor(colors.white)
    term.setBackgroundColor(colors.lightGray)
    myWindow.setCursorPos (12,3)
    print"            "
    myWindow.setCursorPos (12,5)
    print"            "
    myWindow.setCursorPos (12,7)
    print"            "
    myWindow.setCursorPos (12,9)
    print"            "
    myWindow.setCursorPos (12,11)
    print"            "
    myWindow.setCursorPos (12,13)
    print"            "
    myWindow.setCursorPos (12,15)
    print"            "
    myWindow.setCursorPos (12,3)
    print(nmenu1)
    myWindow.setCursorPos (12,5)
    print(nmenu2)
    myWindow.setCursorPos (12,7)
    print(nmenu3)
    myWindow.setCursorPos (12,9)
    print(nmenu4)
    myWindow.setCursorPos (12,11)
    print(nmenu5)
    myWindow.setCursorPos (12,13)
    print(nmenu6)
    myWindow.setCursorPos (12,15)
    print(nmenu7)
    term.setBackgroundColor(colors.red)
    term.setTextColor(colors.white)
    myWindow.setCursorPos (26,3)
    print "X"
    myWindow.setCursorPos (26,5)
    print "X"
    myWindow.setCursorPos (26,7)
    print "X"
    myWindow.setCursorPos (26,9)
    print "X"
    myWindow.setCursorPos (26,11)
    print "X"
    myWindow.setCursorPos (26,13)
    print "X"
    myWindow.setCursorPos (26,15)
    print "X"
    while true do
		local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y

    if x >= 2 and x <= 16 and y == 3 and button == 1 then
    setupmenu ()
	elseif x >= 2 and x <= 16 and y == 5 and button == 1 then
    downloader ()
    elseif x >= 2 and x <= 16 and y == 7 and button == 1 then
    setprograms ()
    elseif x == 42 and y == 3 and button == 1 then
    nmenu1 = ""
    npath1 = ""
    
    apply ()
    elseif x == 42 and y == 5 and button == 1 then
    nmenu2 = ""
    npath2 = ""
    apply ()
    elseif x == 42 and y == 7 and button == 1 then
    nmenu3 = ""
    npath3 = ""
    apply ()
    elseif x == 42 and y == 9 and button == 1 then
    nmenu4 = ""
    npath4 = ""
    apply ()
    elseif x == 42 and y == 11 and button == 1 then
    nmenu5 = ""
    npath5 = ""
    apply ()
    elseif x == 42 and y == 13 and button == 1 then
    nmenu6 = ""
    npath6 = ""
    apply ()
    elseif x == 42 and y == 15 and button == 1 then
    nmenu7 = ""
    npath7 = ""
    apply ()
    elseif x >= 29 and x <= 39 and y == 3 and button == 1 then
    local myWindow = window.create(term.current(),22,7,22,10)
    myWindow.setBackgroundColor(colors.gray)
    myWindow.clear()
    local myWindow = window.create(term.current(),21,6,22,10)
    myWindow.setBackgroundColor(colors.lime)
    myWindow.clear()
    local myWindow = window.create(term.current(),22,7,20,8)
    myWindow.setBackgroundColor(colors.white)
    myWindow.clear()
    paintutils.drawPixel (42,6, colors.red)
    term.setCursorPos(42,6)
    print "*"
    term.setBackgroundColor(colors.white)
    term.setTextColor(colors.black)
    myWindow.setCursorPos (6,1)
    print"1. Posion"
    myWindow.setCursorPos (2,3)
    print"Name"
    myWindow.setCursorPos (2,5)
    print"Path:"
    myWindow.setCursorPos (10,8)
    print"OK"
    term.setTextColor(colors.white)
    term.setBackgroundColor(colors.lightGray)
    myWindow.setCursorPos (2,4)
    print"            "
    myWindow.setCursorPos (2,4)
    print(menu1)
    myWindow.setCursorPos (2,6)
    print"                  "
    myWindow.setCursorPos (2,6)
    print(path1)
    term.setBackgroundColor(colors.gray)
    while true do
        local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y

            if x >= 23 and x <= 40 and y == 10 and button == 1 then
            myWindow.setCursorPos (2,4)
            print"            "
            myWindow.setCursorPos (2,4)
            nmenu1 = read ()
            elseif x >= 23 and x <= 40 and y == 12 and button == 1 then
            myWindow.setCursorPos (2,6)
            print"                  "
            myWindow.setCursorPos (2,6)
            npath1 = read ()
            elseif x == 42 and y == 6 and button == 1 then
            
            setprograms ()
            elseif x >= 30 and x <= 32 and y == 14 and button == 1 then
            
            apply ()
            end
            end
    elseif x >= 29 and x <= 39 and y == 5 and button == 1 then
    local myWindow = window.create(term.current(),22,7,22,10)
    myWindow.setBackgroundColor(colors.gray)
    myWindow.clear()
    local myWindow = window.create(term.current(),21,6,22,10)
    myWindow.setBackgroundColor(colors.lime)
    myWindow.clear()
    local myWindow = window.create(term.current(),22,7,20,8)
    myWindow.setBackgroundColor(colors.white)
    myWindow.clear()
    paintutils.drawPixel (42,6, colors.red)
    term.setCursorPos(42,6)
    print "*"
    term.setBackgroundColor(colors.white)
    term.setTextColor(colors.black)
    myWindow.setCursorPos (6,1)
    print"2. Posion"
    myWindow.setCursorPos (2,3)
    print"Name"
    myWindow.setCursorPos (2,5)
    print"Path:"
    myWindow.setCursorPos (10,8)
    print"OK"
    term.setTextColor(colors.white)
    term.setBackgroundColor(colors.lightGray)
    myWindow.setCursorPos (2,4)
    print"            "
    myWindow.setCursorPos (2,4)
    print(menu2)
    myWindow.setCursorPos (2,6)
    print"                  "
    myWindow.setCursorPos (2,6)
    print(path2)
    term.setBackgroundColor(colors.gray)
    while true do
        local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y

            if x >= 23 and x <= 40 and y == 10 and button == 1 then
            myWindow.setCursorPos (2,4)
            print"            "
            myWindow.setCursorPos (2,4)
            nmenu2 = read ()
            elseif x >= 23 and x <= 40 and y == 12 and button == 1 then
            myWindow.setCursorPos (2,6)
            print"                  "
            myWindow.setCursorPos (2,6)
            npath2 = read ()
            elseif x == 42 and y == 6 and button == 1 then
            
            setprograms ()
            elseif x >= 30 and x <= 32 and y == 14 and button == 1 then
            
            apply ()
            end
            end
    elseif x >= 29 and x <= 39 and y == 7 and button == 1 then
    local myWindow = window.create(term.current(),22,7,22,10)
    myWindow.setBackgroundColor(colors.gray)
    myWindow.clear()
    local myWindow = window.create(term.current(),21,6,22,10)
    myWindow.setBackgroundColor(colors.lime)
    myWindow.clear()
    local myWindow = window.create(term.current(),22,7,20,8)
    myWindow.setBackgroundColor(colors.white)
    myWindow.clear()
    paintutils.drawPixel (42,6, colors.red)
    term.setCursorPos(42,6)
    print "*"
    term.setBackgroundColor(colors.white)
    term.setTextColor(colors.black)
    myWindow.setCursorPos (6,1)
    print"3. Posion"
    myWindow.setCursorPos (2,3)
    print"Name"
    myWindow.setCursorPos (2,5)
    print"Path:"
    myWindow.setCursorPos (10,8)
    print"OK"
    term.setTextColor(colors.white)
    term.setBackgroundColor(colors.lightGray)
    myWindow.setCursorPos (2,4)
    print"            "
    myWindow.setCursorPos (2,4)
    print(menu3)
    myWindow.setCursorPos (2,6)
    print"                  "
    myWindow.setCursorPos (2,6)
    print(path3)
    term.setBackgroundColor(colors.gray)
    while true do
        local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y

            if x >= 23 and x <= 40 and y == 10 and button == 1 then
            myWindow.setCursorPos (2,4)
            print"            "
            myWindow.setCursorPos (2,4)
            nmenu3 = read ()
            elseif x >= 23 and x <= 40 and y == 12 and button == 1 then
            myWindow.setCursorPos (2,6)
            print"                  "
            myWindow.setCursorPos (2,6)
            npath3 = read ()
            elseif x == 42 and y == 6 and button == 1 then
            
            setprograms ()
            elseif x >= 30 and x <= 32 and y == 14 and button == 1 then
            
            apply ()
            end
            end
    elseif x >= 29 and x <= 39 and y == 9 and button == 1 then
    local myWindow = window.create(term.current(),22,7,22,10)
    myWindow.setBackgroundColor(colors.gray)
    myWindow.clear()
    local myWindow = window.create(term.current(),21,6,22,10)
    myWindow.setBackgroundColor(colors.lime)
    myWindow.clear()
    local myWindow = window.create(term.current(),22,7,20,8)
    myWindow.setBackgroundColor(colors.white)
    myWindow.clear()
    paintutils.drawPixel (42,6, colors.red)
    term.setCursorPos(42,6)
    print "*"
    term.setBackgroundColor(colors.white)
    term.setTextColor(colors.black)
    myWindow.setCursorPos (6,1)
    print"4. Posion"
    myWindow.setCursorPos (2,3)
    print"Name"
    myWindow.setCursorPos (2,5)
    print"Path:"
    myWindow.setCursorPos (10,8)
    print"OK"
    term.setTextColor(colors.white)
    term.setBackgroundColor(colors.lightGray)
    myWindow.setCursorPos (2,4)
    print"            "
    myWindow.setCursorPos (2,4)
    print(menu4)
    myWindow.setCursorPos (2,6)
    print"                  "
    myWindow.setCursorPos (2,6)
    print(path4)
    term.setBackgroundColor(colors.gray)
    while true do
        local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y

            if x >= 23 and x <= 40 and y == 10 and button == 1 then
            myWindow.setCursorPos (2,4)
            print"            "
            myWindow.setCursorPos (2,4)
            nmenu4 = read ()
            elseif x >= 23 and x <= 40 and y == 12 and button == 1 then
            myWindow.setCursorPos (2,6)
            print"                  "
            myWindow.setCursorPos (2,6)
            npath4 = read ()
            elseif x == 42 and y == 6 and button == 1 then
            
            setprograms ()
            elseif x >= 30 and x <= 32 and y == 14 and button == 1 then
            
            apply ()
            end
            end
    elseif x >= 29 and x <= 39 and y == 11 and button == 1 then
    local myWindow = window.create(term.current(),22,7,22,10)
    myWindow.setBackgroundColor(colors.gray)
    myWindow.clear()
    local myWindow = window.create(term.current(),21,6,22,10)
    myWindow.setBackgroundColor(colors.lime)
    myWindow.clear()
    local myWindow = window.create(term.current(),22,7,20,8)
    myWindow.setBackgroundColor(colors.white)
    myWindow.clear()
    paintutils.drawPixel (42,6, colors.red)
    term.setCursorPos(42,6)
    print "*"
    term.setBackgroundColor(colors.white)
    term.setTextColor(colors.black)
    myWindow.setCursorPos (6,1)
    print"5. Posion"
    myWindow.setCursorPos (2,3)
    print"Name"
    myWindow.setCursorPos (2,5)
    print"Path:"
    myWindow.setCursorPos (10,8)
    print"OK"
    term.setTextColor(colors.white)
    term.setBackgroundColor(colors.lightGray)
    myWindow.setCursorPos (2,4)
    print"            "
    myWindow.setCursorPos (2,4)
    print(menu5)
    myWindow.setCursorPos (2,6)
    print"                  "
    myWindow.setCursorPos (2,6)
    print(path5)
    term.setBackgroundColor(colors.gray)
    while true do
        local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y

            if x >= 23 and x <= 40 and y == 10 and button == 1 then
            myWindow.setCursorPos (2,4)
            print"            "
            myWindow.setCursorPos (2,4)
            nmenu5 = read ()
            elseif x >= 23 and x <= 40 and y == 12 and button == 1 then
            myWindow.setCursorPos (2,6)
            print"                  "
            myWindow.setCursorPos (2,6)
            npath5 = read ()
            elseif x == 42 and y == 6 and button == 1 then
            
            setprograms ()
            elseif x >= 30 and x <= 32 and y == 14 and button == 1 then
            
            apply ()
            end
            end     
    elseif x >= 29 and x <= 39 and y == 13 and button == 1 then
    local myWindow = window.create(term.current(),22,7,22,10)
    myWindow.setBackgroundColor(colors.gray)
    myWindow.clear()
    local myWindow = window.create(term.current(),21,6,22,10)
    myWindow.setBackgroundColor(colors.lime)
    myWindow.clear()
    local myWindow = window.create(term.current(),22,7,20,8)
    myWindow.setBackgroundColor(colors.white)
    myWindow.clear()
    paintutils.drawPixel (42,6, colors.red)
    term.setCursorPos(42,6)
    print "*"
    term.setBackgroundColor(colors.white)
    term.setTextColor(colors.black)
    myWindow.setCursorPos (6,1)
    print"6. Posion"
    myWindow.setCursorPos (2,3)
    print"Name"
    myWindow.setCursorPos (2,5)
    print"Path:"
    myWindow.setCursorPos (10,8)
    print"OK"
    term.setTextColor(colors.white)
    term.setBackgroundColor(colors.lightGray)
    myWindow.setCursorPos (2,4)
    print"            "
    myWindow.setCursorPos (2,4)
    print(menu6)
    myWindow.setCursorPos (2,6)
    print"                  "
    myWindow.setCursorPos (2,6)
    print(path6)
    term.setBackgroundColor(colors.gray)
    while true do
        local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y

            if x >= 23 and x <= 40 and y == 10 and button == 1 then
            myWindow.setCursorPos (2,4)
            print"            "
            myWindow.setCursorPos (2,4)
            nmenu6 = read ()
            elseif x >= 23 and x <= 40 and y == 12 and button == 1 then
            myWindow.setCursorPos (2,6)
            print"                  "
            myWindow.setCursorPos (2,6)
            npath6 = read ()
            elseif x == 42 and y == 6 and button == 1 then
            
            setprograms ()
            elseif x >= 30 and x <= 32 and y == 14 and button == 1 then
            
            apply ()
            end
            end
    elseif x >= 29 and x <= 39 and y == 15 and button == 1 then
    local myWindow = window.create(term.current(),22,7,22,10)
    myWindow.setBackgroundColor(colors.gray)
    myWindow.clear()
    local myWindow = window.create(term.current(),21,6,22,10)
    myWindow.setBackgroundColor(colors.lime)
    myWindow.clear()
    local myWindow = window.create(term.current(),22,7,20,8)
    myWindow.setBackgroundColor(colors.white)
    myWindow.clear()
    paintutils.drawPixel (42,6, colors.red)
    term.setCursorPos(42,6)
    print "*"
    term.setBackgroundColor(colors.white)
    term.setTextColor(colors.black)
    myWindow.setCursorPos (6,1)
    print"7. Posion"
    myWindow.setCursorPos (2,3)
    print"Name"
    myWindow.setCursorPos (2,5)
    print"Path:"
    myWindow.setCursorPos (10,8)
    print"OK"
    term.setTextColor(colors.white)
    term.setBackgroundColor(colors.lightGray)
    myWindow.setCursorPos (2,4)
    print"            "
    myWindow.setCursorPos (2,4)
    print(menu7)
    myWindow.setCursorPos (2,6)
    print"                  "
    myWindow.setCursorPos (2,6)
    print(path7)
    term.setBackgroundColor(colors.gray)
    while true do
        local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y

            if x >= 23 and x <= 40 and y == 10 and button == 1 then
            myWindow.setCursorPos (2,4)
            print"            "
            myWindow.setCursorPos (2,4)
            nmenu7 = read ()
            elseif x >= 23 and x <= 40 and y == 12 and button == 1 then
            myWindow.setCursorPos (2,6)
            print"                  "
            myWindow.setCursorPos (2,6)
            npath7 = read ()
            elseif x == 42 and y == 6 and button == 1 then
            
            setprograms ()
            elseif x >= 30 and x <= 32 and y == 14 and button == 1 then
            
            apply ()
            end
            end
	else
	paintutils.drawLine(1, 1, 51, 1, colors.black)
	paintutils.drawPixel (51,1, colors.red)
    term.setTextColor(colors.white)
    term.setCursorPos (51,1)
	print "*"
    paintutils.drawPixel (50,1, colors.lightGray)
    term.setCursorPos (50,1)
    print "<"
    paintutils.drawPixel (49,1, colors.lightGray)
	term.setCursorPos (49,1)
	print "_"

			 while true do
		local event, button, x, y = os.pullEvent("mouse_click")
		xy = x..","..y
		
		if x == 51 and y == 1 then
			ukonceni ()
		elseif x == 50 and y == 1 then
			apps ()
        elseif x == 49 and y == 1 then
			minimalizace ()
        else
		setprograms ()
			end
			end
end
end
end

function downloader ()
funkce = "downloader"
	fs.delete ("/system/RAM/store")
	term.setBackgroundColor(colors.white)
	term.setTextColor(colors.white)
	term.setCursorPos(18,9)
   shell.run ("pastebin get y4Xv9b1Y /system/RAM/store")
           local myWindow = window.create(term.current(),16,1,37,19)
    myWindow.setBackgroundColor(colors.white)
    myWindow.clear()
        local myWindow = window.create(term.current(),1,1,16,19)
    myWindow.setBackgroundColor(colors.gray)
    myWindow.clear()
    local myWindow = window.create(term.current(),1,1,15,19)
    myWindow.setBackgroundColor(nastaveni.barva)
    myWindow.clear()
    term.setBackgroundColor (nastaveni.barva)
    term.setTextColor(colors.lime)
    term.setCursorPos(2,3)
    print "< Store"
    term.setTextColor(text.barva)
    term.setCursorPos(2,5)
    print "Apps"
    term.setCursorPos(2,7)
    print "Menu"
	if fs.exists ("/system/RAM/store") then
   shell.run ("/system/RAM/store")
	else
	term.setTextColor(colors.red)
	term.setBackgroundColor(colors.white)
	term.setCursorPos (23,8)
	print "No internet connect!"
	term.setTextColor(colors.white)
	sleep (1)
	setprograms ()
	end
end

start ()