﻿// JScript 文件
function   trim(str)   
{   
    var   par   =   /^\s+/;   
    var   strRes   =   str.replace(par,'');     //Trim   the   font   blank
    
    par   =   /\s+$/;   
    strRes   =   strRes.replace(par,'');       //   Trim   the   end   blank
    return   strRes;       
}

function search()
{
    var word = "";
    if ( searchId.length == 0 )
    {
        alert( "请填写检索词" );
        return false;
    }
	var obj = getElement( searchId );
	if( obj == null )
	{
		alert( "未找到元素！" );
		return false;
	}
	
	if( obj.value.length == 0 )
	{
		alert( '请填写检索词！' );
		return false;
	}
	word = obj.value;
	
	word = word.replace('#', ' ');
	word = word.replace('&', ' ');
	word = trim(word);
	if( word.length==0 )
	{
	    alert("不允许输入空字符串");
	    return false;
	}
	
	if ( qclass.length == 0 || dbsid.length == 0 )
	{
	    alert( '没有选取分类!' );
	    return false;
	}
	
	var url = "";
	var dbs = getselectdb(dbsid);
	
	if ( dbs != '' )
	{
	    url = "PreDeal.aspx?resdb=" + encodeURI(dbs) + "&keyword=" + encodeURI(word) + "&selclass=" + encodeURI(qclass);
	}
	else
	{
	   url = "PreDeal.aspx?quickclass=" + encodeURI(qclass) + "&keyword=" + encodeURI(word);
	}
	//是否根据语种自动翻译 
    obj = getElement( checkId );
    if ( obj != null )
    {
        if ( ! obj.checked )
        {
            url +="&autotrans=false";
        }
    }
	window.location.href = url;
	return true;
}

function selectdblist()
{
    var str = "dbs_div" + TabbedPanels1.currentTabIndex;
    var obj = TabbedPanels1.getElement(str);
    if ( obj != null )
    {
        if( TabbedPanels1.showdblist )
        {
            TabbedPanels1.showdblist = false;
            obj.style.display = "none";
        }
        else
        {
            TabbedPanels1.showdblist = true;
            obj.style.display = "block";
        }   
    }
}

function checkall(obj)
{
    var parent = getParent(obj);
    while( parent!=null && parent.tagName!="TABLE" )
    {
        parent = getParent(parent);
    }
    if( parent==null )
    {
        return;
    }
    selectalldb(parent,true);
}

function removeall(obj)
{
    var parent = getParent(obj);
    while( parent!=null && parent.tagName!="TABLE" )
    {
        parent = getParent(parent);
    }
    if( parent==null )
    {
        return;
    }
    selectalldb(parent,false);
}

