searchbarpref="kmeleon.plugins.searchbar.openurl";
searchbarengine="kmeleon.general.searchEngine";
searchbartitle="kmeleon.plugins.searchbar.title";
searchenginname="kmeleon.general.searchEngineName";
google="http://www.google.com/search?q=";
yahoo="http://search.yahoo.com/bin/search?p=";
wikipedia="http://en.wikipedia.org/wiki/";
scholar="http://www.scholar.google.com/scholar?q=";
imdb="http://www.imdb.com/find?q=";
baidu="http://www.baidu.com/s?ie=utf-8&wd=";
dictcn="http://www.dict.cn/search/?q=";
shooter="http://www.shooter.cn/sub/?searchword=";
mw="http://www.m-w.com/dictionary/";

function searchbarsync()
	local searchbar_pref=getpref(TYPE_STRING,searchbarengine)
	SetCheck("luamacro(searchbargoogle)",false)
	SetCheck("luamacro(searchbaryahoo)",false)
	SetCheck("luamacro(searchbarwikipedia)",false)
	SetCheck("luamacro(searchbarscholar)",false)
	SetCheck("luamacro(searchbarimdb)",false)
	SetCheck("luamacro(searchbarbaidu)",false)
	SetCheck("luamacro(searchbardictcn)",false)
	SetCheck("luamacro(searchbarshooter)",false)
	SetCheck("luamacro(searchbarmw)",false)

	if searchbar_pref==google then
		SetCheck("luamacro(searchbargoogle)",true)
	elseif searchbar_pref==yahoo then
		SetCheck("luamacro(searchbaryahoo)",true)
	elseif searchbar_pref==wikipedia then
		SetCheck("luamacro(searchbarwikipedia)",true)
	elseif searchbar_pref==scholar then
		SetCheck("luamacro(searchbarscholar)",true)
	elseif searchbar_pref==imdb then
		SetCheck("luamacro(searchbarimdb)",true)
	elseif searchbar_pref==baidu then
		SetCheck("luamacro(searchbarbaidu)",true)
	elseif searchbar_pref==dictcn then
		SetCheck("luamacro(searchbardictcn)",true)
	elseif searchbar_pref==shooter then
		SetCheck("luamacro(searchbarshooter)",true)
	elseif searchbar_pref==mw then
		SetCheck("luamacro(searchbarmw)",true)
	end
end

function searchbargoogle()
	setpref(TYPE_STRING,searchbarengine,google)
	setpref(TYPE_STRING,searchenginname,"Google")
	plugin("searchbarext","update")
	searchbarsync()
end

function searchbaryahoo()
	setpref(TYPE_STRING,searchbarengine,yahoo)
	setpref(TYPE_STRING,searchenginname,"Yahoo")
	plugin("searchbar","update")
	searchbarsync()
end

function searchbarwikipedia()
	setpref(TYPE_STRING,searchbarengine,wikipedia)
	setpref(TYPE_STRING,searchenginname,"Wikipedia")
	plugin("searchbar","update")
	searchbarsync()
end

function searchbarscholar()
	setpref(TYPE_STRING,searchbarengine,scholar)
	setpref(TYPE_STRING,searchenginname,"Scholar")
	plugin("searchbar","update")
	searchbarsync()
end

function searchbarimdb()
	setpref(TYPE_STRING,searchbarengine,imdb)
	setpref(TYPE_STRING,searchenginname,"IMDB")
	plugin("searchbar","update")
	searchbarsync()
end


function searchbarbaidu()
	setpref(TYPE_STRING,searchbarengine,baidu)
	setpref(TYPE_STRING,searchenginname,"Baidu")
	plugin("searchbar","update")
	searchbarsync()
end

function searchbardictcn()
	setpref(TYPE_STRING,searchbarengine,dictcn)
	setpref(TYPE_STRING,searchenginname,"Dict.cn")
	plugin("searchbar","update")
	searchbarsync()
end	

function searchbarshooter()
	setpref(TYPE_STRING,searchbarengine,shooter)
	setpref(TYPE_STRING,searchenginname,"shooter")
	plugin("searchbar","update")
	searchbarsync()
end

function searchbarmw()
	setpref(TYPE_STRING,searchbarengine,mw)
	setpref(TYPE_STRING,searchenginname,"merriam-webster")
	plugin("searchbar","update")
	searchbarsync()
end

		