function highlight()
	javascript.popup([[javascript:(function(){var count=0, text, dv;text=prompt(%22Find and Highlight the following:%22, %22%22);if(text==null || text.length==0)return;dv=document.defaultView;function searchWithinNode(node, te, len){var pos, skip, spannode, middlebit, endbit, middleclone;skip=0;if( node.nodeType==3 ){pos=node.data.toUpperCase().indexOf(te);if(pos>=0){spannode=document.createElement(%22SPAN%22);spannode.style.backgroundColor=%22yellow%22;middlebit=node.splitText(pos);endbit=middlebit.splitText(len);middleclone=middlebit.cloneNode(true);spannode.appendChild(middleclone);middlebit.parentNode.replaceChild(spannode,middlebit);++count;skip=1;}}else if( node.nodeType==1&& node.childNodes&& dv.getComputedStyle(node, null).getPropertyValue(%22display%22)!=%22none%22){for (var child=0; child < node.childNodes.length; ++child){child=child+searchWithinNode(node.childNodes[child], te, len);}}return skip;}window.status=%22Searching for '%22+text+%22'...%22;searchWithinNode(document.body, text.toUpperCase(), text.length);window.status=%22Found %22+count+%22 occurrence%22+(count==1?%22%22:%22s%22)+%22 of '%22+text+%22'.%22;})();]])
end

function viewallimages()
	javascript.popup([[javascript:Ai7Mg6P='';for (i7M1bQz=0;i7M1bQz<document.images.length;i7M1bQz++){Ai7Mg6P+='<img src='+document.images[i7M1bQz].src+'><br>'};if(Ai7Mg6P!=''){document.write('<center>'+Ai7Mg6P+'</center>');void(document.close())}else{alert('No images!')}]])
end

function continuous()
	javascript.popup([[javascript:(function(){var intv=prompt('Enter number of seconds between reloads. (Click Back button to stop)');if(intv&&!isNaN(intv)){with(document){write('<html><frameset rows=\"*,22\" framespacing=0 border=0 frameborder=no><frame noresize frameborder=no><frame scrolling=no noresize frameborder=no></frameset></html>');frames[0].location.href=document.location.href;var docstr='<html><body bgcolor=cyan style=\"margin-top:0px\">\n';docstr+='Reloading in <span id=\"caption\"></span>secs.</body>\n';docstr+='<script>\nvar reloadIntv='+intv+';\nvar secsLeft='+intv+';\nfunction reloadFrame(){secsLeft=reloadIntv+1;parent.frames[0].location.href=parent.frames[0].location.href;}\nfunction countDown(){secsLeft--;showTime();}\nfunction showTime(){document.getElementById(\"caption\").innerHTML=parseInt(secsLeft)+\" \";}\nsetInterval(\"reloadFrame()\",'+intv*1000+');\nsetInterval(\"countDown()\",1000);\nshowTime();\n</script>\n</html>';frames[1].document.write(docstr);}}})()]])
end

function sethome()
	local title,url=GetDocInfo(hwnd)
	setpref(TYPE_STRING,"browser.startup.homepage",url);
end 

function AutoDetect(str)
	setpref(TYPE_STRING,"intl.charset.detector",str); SetForceCharset(str);
end

function accel()
	local path=getpref(TYPE_STRING,"kmeleon.general.profileDir")
	exec("notepad.exe "..path.."accel.cfg");
end

function menus()
	local path=getpref(TYPE_STRING,"kmeleon.general.profileDir")
	exec("notepad.exe "..path.."menus.cfg");
end

function usercontent()
	local path=getpref(TYPE_STRING,"kmeleon.general.profileDir")
	exec("notepad.exe "..path.."\chrome\\userContent.css");
end

function prefs()
	local path=getpref(TYPE_STRING,"kmeleon.general.profileDir")
	exec("notepad.exe "..path.."prefs.js");
end

function rss()
	local xul="chrome://aggreg8/content/aggreg8.xul";
	opennew(xul)
end

function mimeedit()
	local xul="chrome://mtypes/content/pref/pref.xul";
	opennew(xul)
end

function prefpanel()
	local xul="chrome://kmprefs/content/pref.xul";
	opennew(xul)
end


function allprefs()
	opennew("about:config");
end

function jsconsole()
	opennew("javascript:");
end

function openinie()
	local title,url=GetDocInfo(hwnd)
	local ie=getpref(TYPE_STRING,"kmeleon.external.browser.position")
	--local ie="C:\\Program Files\\Internet Explorer\\iexplore.exe"
	exec(ie.." "..url)
end

function sendhotkey()
	local title, url = GetDocInfo(hwnd)
	local hotkey=prompt("Enter Hotkey # for this page", "Hotkey #","1")
	if (hotkey) then
		setpref(TYPE_STRING, "kmeleon.plugins.macros.hotlink"..hotkey..".url", url)
	end
end

function sendhotkeylink()
	local linkurl=GetGlobalVar(TYPE_STRING, "LinkURL")
	local hotkey=prompt("Enter Hotkey # for this page", "Hotkey #","1")
	if (hotkey) then
		setpref(TYPE_STRING, "kmeleon.plugins.macros.hotlink"..hotkey..".url", linkurl)
	end
end