function addtoblacklist(hwnd)
	local folder=GetFolder(ProfileFolder)
	local fname=folder.."\\hostperm.1"
	url=GetGlobalVar(TYPE_STRING, "ImageURL")
	pos=string.find(url,"//")
	a=string.sub(url,1,pos+1)
	b=string.sub(url,pos+2)
	pos1=string.find(b,"/")
	c=string.sub(b,1,pos1-1)
	url2=c
	d=confirm("block images from "..c.."?","Block Image from domain",BUTTONS_YESNO,ICON_QUESTION)
	if d==IDYES then
		blacklist="host	image	2	"..url2.."\n"
		-- pluginmsg("utils","append", path.."hostperm.1", blacklist);
		local f = assert(io.open(fname,"a"))
		f:write(blacklist)
		f:close()
		confirm("Images from domain "..c.." is blocked","Images blocked",BUTTONS_OK,ICON_INFO)
	end
end

function blockframe(hwnd)
	local folder=GetFolder(ProfileFolder)
	local fname=folder.."\\hostperm.1"
	url=GetGlobalVar(TYPE_STRING, "FrameURL")
	pos=string.find(url,"//")
	a=string.sub(url,1,pos+1)
	b=string.sub(url,pos+2)
	pos1=string.find(b,"/")
	c=string.sub(b,1,pos1-1)
	url2=c
	d=confirm("block iframe from "..c.."?","Block iframe from domain",BUTTONS_YESNO,ICON_QUESTION)
	if d==IDYES then
		blacklist="host	subdocument	2	"..url2.."\n"
		--pluginmsg("utils","append", path.."hostperm.1", blacklist);
		local f = assert(io.open(fname,"a"))
		f:write(blacklist)
		f:close()
		confirm("Iframe from domain "..c.." is blocked","Iframe blocked",BUTTONS_OK,ICON_INFO)
	end
end

function flashblock()
	local flashcfg=getpref(TYPE_BOOL,"kmeleon.flash.enable")
--	local flash="@import url(chrome://flashblock/content/flashblock.css);"
	local flash="@import url(flashblock.css);"
	local len=string.len(flash)
	local path = getpref(TYPE_STRING, "kmeleon.general.profileDir")
	local usercontent = path.."chrome\\userContent.css"
	local css1=pluginmsgex("utils","read",usercontent,TYPE_STRING)	
	if flashcfg==false then
		local p=string.find(css1,"@import")
		if p then
			css1=string.sub(css1,1,p-1)..string.sub(css1,p+len)
			setpref(TYPE_BOOL,"kmeleon.flash.enable",true)
		end
	else
		css1=flash..css1
		setpref(TYPE_BOOL,"kmeleon.flash.enable",false)
	end
	--pluginmsg("utils","write",usercontent,css1)
	alert("Please restart to take effect")
	sync()
end

function zapplugin(hwnd)
	local fname=BROWSERPATH.."lua\\zapplugin.js"
	local f = assert(io.open(fname,"r"))
	local js = f:read("*all")
	f:close()
 	--alert(js)
	km.InjectJS(js,true)
	-- open(js)
end