

function edit1OnKeyDown(Sender,Key,KeyChar,Shift)
{
   if(Key==13)button1OnClick();
}

function baidu()
{
   if(edit1.text=="") return;
   var url = "http://www.baidu.com/s?wd=" + encodeURIComponent(edit1.text) + "&ie=UTF-8&oe=UTF-8";
   openURL(url);
   edit1.text = "search...";
}

function google()
{
   if(edit1.text=="") return;
   var url = "http://www.google.com/search?q=" + encodeURIComponent(edit1.text) + "&ie=UTF-8&oe=UTF-8";
   openURL(url);
   edit1.text = "search...";
}

function bing()
{
   if(edit1.text=="") return;
   var url = "http://www.bing.com/search?q=" + encodeURIComponent(edit1.text) + "&ie=UTF-8&oe=UTF-8";
   openURL(url);
   edit1.text = "search...";
}

function button1OnClick(Sender)
{
   if(menuitem1.checked)google()
   else if(menuitem2.checked)bing()
   else baidu()
}

function menuitem2OnClick(Sender)
{
   menuitem2.checked = true;
   menuitem1.checked = false;
   menuitem3.checked = false;
   Setvalue("engine",2);
   SaveIni();
}

function menuitem1OnClick(Sender)
{
   menuitem1.checked = true;
   menuitem2.checked = false;
   menuitem3.checked = false;
   Setvalue("engine",1);
   SaveIni();
}

function menuitem3OnClick(Sender)
{
   menuitem3.checked = true;
   menuitem2.checked = false;
   menuitem1.checked = false;
   Setvalue("engine",3);
   SaveIni();
}


function edit1OnEnterFocus(Sender)
{
  text1.visible = false;
}

function edit1OnKillFocus(Sender)
{
  text1.visible = true;
}


function widgetOnLoad()
{
  eval("menuitem"+getvalue("engine",1)).Checked = true;
}
