﻿//切换搜索选项
function switchSearch(type, obj)
{
  $("#hiSearch").val(type);
  $("#search_sort").children().removeClass("current");
  $(obj).addClass("current");
}

//搜索跳转
function searchRedirect()
{
  var key = $("#txtSearch").val();
  if (key == "") return;
  key = encodeURIComponent(key);

  var langs = $("#lstType").val();
  var type = $("#hiSearch").val();
  var url = "";
  switch (type)
  {
    case "word":
      url = "http://dict.yeshj.com/app/w/" + key;
      break;
    case "sent":
      url = "http://dict.yeshj.com/app/sent/" + key;
      break;
    case "book":
      url = "http://www.hjbook.net/search.aspx?kw=" + key;
      break;
    case "link":
      if (langs == "en")
        url = "http://en.yeshj.com/new/search/" + key + "/";
      else if (langs == "jp")
        url = "http://jp.yeshj.com/new/search/" + key + "/";
      else if (langs == "fr")
          url = "http://fr.yeshj.com/new/search/" + key + "/";
      else if (langs == "kr")
          url = "http://kr.yeshj.com/new/search/" + key + "/";
      break;
    case "down":
      if (langs == "en")
        url = "http://en.yeshj.com/dl/search/" + key + "/";
      else if (langs == "jp")
        url = "http://jp.yeshj.com/dl/search/" + key + "/";
      else if (langs == "fr")
          url = "http://fr.yeshj.com/dl/search/" + key + "/";
      else if (langs == "kr")
          url = "http://kr.yeshj.com/dl/search/" + key + "/";
      break;
  }
  window.open(url, "_blank");
}

//搜索框 回车键 搜索
function txtEnter(eventobject)
{
  if (eventobject.keyCode == 13)
  {
    searchRedirect();
  }
}
