﻿/// <summary>
///	页面提交的函数
/// </summary>
/// <param name="search_ci">页面提交的查询词</param>
/// <param name="search_type">页面提交的查询类型</param>
/// <returns>Code.by.Web.DNA.2006.11.08</returns> 
function tj(search_ci,search_type)
{
	//document.getElementById("searchword").value = search_ci;
	document.getElementById("tjType").value = search_type;
	document.forms[0].submit();
}

/// <summary>
///	用正则表达式匹配掉不符合规格的符号
/// </summary>
/// <returns>Code.by.Web.DNA.2006.9.20</returns>
function checkData()
{
	var t = document.getElementById("txt2").value ;
//	reg =/\^\w+\b*\w*$/g;
//	t = unescape(t).replace(reg,"");
//	if(t=="")
//	{
//		alert("请重新输入检索词进行查询!");
//		return false;
//	}
//	document.getElementById("txt2").value = t;
	document.getElementById("searchword").value = t;
	return true;
}

/// <summary>
///	从通用检索框里直接链接到其它搜索产品的函数
/// </summary>
/// <returns>Code.by.Web.DNA.2006.9.20</returns>
function LinkOtherSearch(SearchType)
{
	if(SearchType == "search")
	{
		str = "http://search.cnki.net/";
		str1 = "SearchResult.aspx?";
	}
	if(SearchType == "number")
	{
		str = "http://number.cnki.net/";
		str1 = "show_result.aspx?tjType=zhishiyuan_search&";
	}
	if(SearchType == "define")
	{
		str = "http://define.cnki.net/";
		str1 = "define_result.aspx?tjType=define_search&";
	}
	if(SearchType == "dict")
	{
		str = "http://dict.cnki.net/";
		str1 = "dict_result.aspx?tjType=translate_search&";
	}
	if(SearchType == "image")
	{
		str = "http://image.cnki.net/";
		str1 = "image_result.aspx?tjType=image_search&";
	}
	if(SearchType == "trend")
	{
		str = "http://trend.cnki.net/";
		str1 = "trendshow.php?";
	}
	var t = document.getElementById("txt2").value ;//获值
	if(t=="")
	{
		window.location = str;
	}
	else
	{
		window.location = str + str1 + "searchword=" + encodeURIComponent(t);//传值给searchword
	}
}

/// <summary>
///	通用检索框里的文本框在页面加载的时候自动获得焦点
/// </summary>
function Getfocus()
{		   
	//document.getElementById("txt2").focus();
   // document.Form1.txt2.focus();
    document.getElementById("txt2").focus();
}



/// <summary>
///	通用检索框里的检索按钮的 Click 事件
/// </summary>
function function_click()
{//debugger;
      try
       {
       document.forms[0].__EVENTTARGET.value="";
       }
       catch(e)
       {
       
       }

    document.forms[0].target="_self";
    document.forms[0].action="dict_result.aspx";

    if(document.getElementById('tjType') != null)
	    document.getElementById('tjType').value = "translate_search";

        var t = document.getElementById("txt2").value ;
        t = t.replace(/(^\s*)|(\s*$)/g, "");//去两端空格
        if(t.length <= 0)
        {
            alert("检索词为空");
            return false;
        }
        //new code cc 2011-7-27 14:37:23
        if (t.length > 20) {
            alert("检索词不得大于20个字");
            return false;
        }

	    document.getElementById("searchword").value = t;
	    var para = "";

	    t = escape(t);

	        //para = "dict_result_en.aspx?tjType=all&searchword="+t;
	    para = "dict_result.aspx?searchword="+t;

	    window.location = para;
	    return false;
}

function function_en_click()
{//debugger;
      try
       {
       document.forms[0].__EVENTTARGET.value="";
       }
       catch(e)
       {
       
       }

    document.forms[0].target="_self";
    document.forms[0].action="dict_result_en.aspx";

	document.getElementById('tjType').value = "all";

        var t = document.getElementById("txt2").value ;
        t = t.replace(/(^\s*)|(\s*$)/g, "");//去两端空格
        if(t.length <= 0)
        {
            alert("Search Word is Empty!");
            return false;
        }
        
	    document.getElementById("searchword").value = t;
	    var para = "";

	    t = escape(t);

	    para = "dict_result_en.aspx?tjType=all&searchword="+t;

	    window.location = para;
	    return false;
}

function writeUP(name,code)
{
    opener.document.getElementById('clsname').value = name;
    opener.document.getElementById('clsid').value = code;
    window.close();
}


