require "compat"
require "dialog"

function hotlink0()
	local n="0";
	local theurl=getpref(TYPE_STRING,"kmeleon.plugins.macros.hotlink"..n..".url")
	open(theurl)	
end
function hotlink1()
	local n="1";
	local theurl=getpref(TYPE_STRING,"kmeleon.plugins.macros.hotlink"..n..".url")
	open(theurl)	
end
function hotlink2()
	local n="2";
	local theurl=getpref(TYPE_STRING,"kmeleon.plugins.macros.hotlink"..n..".url")
	open(theurl)	
end
function hotlink3()
	local n="3";
	local theurl=getpref(TYPE_STRING,"kmeleon.plugins.macros.hotlink"..n..".url")
	open(theurl)	
end
function hotlink4()
	local n="4";
	local theurl=getpref(TYPE_STRING,"kmeleon.plugins.macros.hotlink"..n..".url")
	open(theurl)	
end
function hotlink5()
	local n="5";
	local theurl=getpref(TYPE_STRING,"kmeleon.plugins.macros.hotlink"..n..".url")
	open(theurl)	
end
function hotlink6()
	local n="6";
	local theurl=getpref(TYPE_STRING,"kmeleon.plugins.macros.hotlink"..n..".url")
	open(theurl)	
end
function hotlink7()
	local n="7";
	local theurl=getpref(TYPE_STRING,"kmeleon.plugins.macros.hotlink"..n..".url")
	open(theurl)	
end
function hotlink8()
	local n="8";
	local theurl=getpref(TYPE_STRING,"kmeleon.plugins.macros.hotlink"..n..".url")
	open(theurl)	
end
function hotlink9()
	local n="9";
	local theurl=getpref(TYPE_STRING,"kmeleon.plugins.macros.hotlink"..n..".url")
	open(theurl)	
end



local hotlinks=create_dialog({
	width=180,
	height=180,
	caption="Hotlinks",

	{
		type="button",
		style=w32dlg.BS_DEFPUSHBUTTON,
		x=40,
		y=135,
		width = 40,
		height = 15,
		id = "IDOK",
		caption = "OK"
	},
	
	{
		type="button",
		style=w32dlg.BS_DEFPUSHBUTTON,
		x=100,
		y=135,
		width = 40,
		height = 15,
		id = "IDCANCEL",
		caption = "CANCEL"
	},

	{
		type = "edit",     -- control type
		style = w32dlg.WS_BORDER,
		x = 30,            -- x position
		y = 10,            -- y position
		width = 120,        -- width
		height = 10,       -- height
		id = "IDEDIT1",    -- ID
		caption = "EDIT"   -- caption
	},

	{
		type = "edit",     -- control type
		style = w32dlg.WS_BORDER,
		x = 30,            -- x position
		y = 23,            -- y position
		width = 120,        -- width
		height = 10,       -- height
		id = "IDEDIT2",    -- ID
		caption = "EDIT"   -- caption
	},

	{
		type = "edit",     -- control type
		style = w32dlg.WS_BORDER,
		x = 30,            -- x position
		y = 36,            -- y position
		width = 120,        -- width
		height = 10,       -- height
		id = "IDEDIT3",    -- ID
		caption = "EDIT"   -- caption
	},

	{
		type = "edit",     -- control type
		style = w32dlg.WS_BORDER,
		x = 30,            -- x position
		y = 49,            -- y position
		width = 120,        -- width
		height = 10,       -- height
		id = "IDEDIT4",    -- ID
		caption = "EDIT"   -- caption
	},

	{
		type = "edit",     -- control type
		style = w32dlg.WS_BORDER,
		x = 30,            -- x position
		y = 62,            -- y position
		width = 120,        -- width
		height = 10,       -- height
		id = "IDEDIT5",    -- ID
		caption = "EDIT"   -- caption
	},

	{
		type = "edit",     -- control type
		style = w32dlg.WS_BORDER,
		x = 30,            -- x position
		y = 75,            -- y position
		width = 120,        -- width
		height = 10,       -- height
		id = "IDEDIT6",    -- ID
		caption = "EDIT"   -- caption
	},

	{
		type = "edit",     -- control type
		style = w32dlg.WS_BORDER,
		x = 30,            -- x position
		y = 88,            -- y position
		width = 120,        -- width
		height = 10,       -- height
		id = "IDEDIT7",    -- ID
		caption = "EDIT"   -- caption
	},

	{
		type = "edit",     -- control type
		style = w32dlg.WS_BORDER,
		x = 30,            -- x position
		y = 101,            -- y position
		width = 120,        -- width
		height = 10,       -- height
		id = "IDEDIT8",    -- ID
		caption = "EDIT"   -- caption
	},

	{
		type = "edit",     -- control type
		style = w32dlg.WS_BORDER,
		x = 30,            -- x position
		y = 114,            -- y position
		width = 120,        -- width
		height = 10,       -- height
		id = "IDEDIT9",    -- ID
		caption = "EDIT"   -- caption
	},

	{
		type = "static",        -- control type
		x = 20,                 -- x position
		y = 10,                -- y position
		width = 10,             -- width
		height = 10,            -- height
		id = "IDSTATIC1",       -- ID
		caption = "1:"
	},

	{
		type = "static",        -- control type
		x = 20,                 -- x position
		y = 23,                -- y position
		width = 10,             -- width
		height = 10,            -- height
		id = "IDSTATIC2",       -- ID
		caption = "2:"
	},

	{
		type = "static",        -- control type
		x = 20,                 -- x position
		y = 36,                -- y position
		width = 10,             -- width
		height = 10,            -- height
		id = "IDSTATIC3",       -- ID
		caption = "3:"
	},

	{
		type = "static",        -- control type
		x = 20,                 -- x position
		y = 49,                -- y position
		width = 10,             -- width
		height = 10,            -- height
		id = "IDSTATIC4",       -- ID
		caption = "4:"
	},

	{
		type = "static",        -- control type
		x = 20,                 -- x position
		y = 62,                -- y position
		width = 10,             -- width
		height = 10,            -- height
		id = "IDSTATIC5",       -- ID
		caption = "5:"
	},

	{
		type = "static",        -- control type
		x = 20,                 -- x position
		y = 75,                -- y position
		width = 10,             -- width
		height = 10,            -- height
		id = "IDSTATIC6",       -- ID
		caption = "6:"
	},

	{
		type = "static",        -- control type
		x = 20,                 -- x position
		y = 88,                -- y position
		width = 10,             -- width
		height = 10,            -- height
		id = "IDSTATIC7",       -- ID
		caption = "7:"
	},

	{
		type = "static",        -- control type
		x = 20,                 -- x position
		y = 101,                -- y position
		width = 10,             -- width
		height = 10,            -- height
		id = "IDSTATIC8",       -- ID
		caption = "8:"
	},

	{
		type = "static",        -- control type
		x = 20,                 -- x position
		y = 114,                -- y position
		width = 10,             -- width
		height = 10,            -- height
		id = "IDSTATIC9",       -- ID
		caption = "9:"
	},

})

function hotlink_dialog()
	local h={"none","none","none","none","none","none","none","none","none",}
	for i,v in ipairs(h) do
		h[i]=getpref(TYPE_STRING,"kmeleon.plugins.macros.hotlink"..i..".url")
	end
	local r,rr=hotlinks("Hotlinks",{
				IDEDIT1=h[1],
				IDEDIT2=h[2],
				IDEDIT3=h[3],
				IDEDIT4=h[4],
				IDEDIT5=h[5],
				IDEDIT6=h[6],
				IDEDIT7=h[7],
				IDEDIT8=h[8],
				IDEDIT9=h[9],
	})
	if r=="IDOK" then
		setpref(TYPE_STRING,"kmeleon.plugins.macros.hotlink1.url",rr.IDEDIT1)
		setpref(TYPE_STRING,"kmeleon.plugins.macros.hotlink2.url",rr.IDEDIT2)
		setpref(TYPE_STRING,"kmeleon.plugins.macros.hotlink3.url",rr.IDEDIT3)
		setpref(TYPE_STRING,"kmeleon.plugins.macros.hotlink4.url",rr.IDEDIT4)
		setpref(TYPE_STRING,"kmeleon.plugins.macros.hotlink5.url",rr.IDEDIT5)
		setpref(TYPE_STRING,"kmeleon.plugins.macros.hotlink6.url",rr.IDEDIT6)
		setpref(TYPE_STRING,"kmeleon.plugins.macros.hotlink7.url",rr.IDEDIT7)
		setpref(TYPE_STRING,"kmeleon.plugins.macros.hotlink8.url",rr.IDEDIT8)
		setpref(TYPE_STRING,"kmeleon.plugins.macros.hotlink9.url",rr.IDEDIT9)
	end				
end

