/// SearchEngine

var lpSearchEngine={
  "Baidu"         : ["http://www.baidu.com/s?wd="                                 ,""],
  "Baidu_mp3"     : ["http://mp3.baidu.com/m?tn=baidump3&ct=134217728&lm=-1&word=",""],
  "Baidu_zhidao"  : ["http://zhidao.baidu.com/q?word="                            ,"&ct=17&pn=0&tn=ikaslist&rn=10&lm=0&fr=search"],
  "ip138"         : ["http://www.ip138.com/ips138.asp?ip="                        ,"&action=2"],
  "iCIBA"         : ["http://www.iciba.com/"                                      ,""],
  "zdic"          : ["http://www.zdic.net/search/?q="                             ,""],
  "Google"        : ["http://www.google.com.hk/search?q="                         ,""]
};

try
{
  var hMainWnd=AkelPad.GetMainWnd();
}
catch (oError)
{
  WScript.Quit();
}

var nSelStart=AkelPad.GetSelStart();
var nSelEnd  =AkelPad.GetSelEnd();

if (nSelStart == nSelEnd) WScript.Quit();
var WshShell   =new ActiveXObject("WScript.shell");

var SE="Google";
if (WScript.Arguments.length) SE=WScript.Arguments(0);

var pSelText=AkelPad.GetSelText().replace(/\n/g," ");

pSelText=pSelText.replace(/\s{2+}/g," ");
if (pSelText.length>64)
{
  pSelText=pSelText.substr(0,64);
  AkelPad.MessageBox(hMainWnd, "您要搜索的内容太长，将搜索前面64个字节！\n"+pSelText, "搜索引擎", 0 /*MB_OK*/);
}

pSelText=encodeURIComponent(pSelText);

WshShell.Exec('rundll32.exe shell32,ShellExec_RunDLL "' + lpSearchEngine[SE][0] + pSelText + lpSearchEngine[SE][1] + '"');