﻿    var isRealDisconn = true;
    //var currentSessionID = "<%=session.getId()%>";
    
   //自定义扩展方法，去除字符串两头的空格
   String.prototype.trim = function()
   {
     return this.replace(/(^\s*)|(\s*$)/g, "");
   }
   //自定义扩展方法，去除字符串前方的空格
   String.prototype.lTrim = function()
   {
     return this.replace(/(^[\\s]*)/g, "");
   }
   //自定义扩展方法，去除字符串尾部的空格
   String.prototype.rTrim = function()
   {
     return this.replace(/([\\s]*$)/g, "");
   }
   
    function DoSearch()
    {
      var w = searchForm.anyWord.value.trim();
      if (!w)
      {
         alert("请输入查询词"); return;
      }
      var cmd = getWcrCmd( "", w );
      if( cmd == "error" ) 
      {
         alert("查询命令错"); return;
      }
      searchForm.anyWord.value = w;
      searchForm.db.value = "A1/A2/A3/B5/C1/C2/C3/C4/C5/C7/D1/D3/D2/D5/D6/D7/D9/E1/D4/C9/E2/E3/A5/A6/A7/A8/A9/E4/E5/E6/F2/E7/E9/F1/F3/D8/F4/F5";
      searchForm.searchFields.value = "TI/AB";
      searchForm.mycmd.value = cmd;
      searchForm.submit();
    }    

  function getWcrCmd( _o_cmd, el )
  {
    if( el.length > 0 )
    {
        el = textFieldCmdFilter( el );
        if( el == "" ) return _o_cmd;
        if( el == "error" ) return "error";
        if( _o_cmd.length > 0 ) _o_cmd += "*";
        el = myreplace(el,"+","\"+\"");
        el = myreplace(el,"-","\"-\"");
        el = myreplace(el,"*","\"*\"");
        el = myreplace(el,"\"\"+\"\"","+");
        el = myreplace(el,"\"\"-\"\"","-");
        el = myreplace(el,"\"\"*\"\"","*");
        el = "\"" + el + "\"";
        //alert( el );
        //支持 - 号开头的命令
        el = myreplace(el,"\"\"-","-");
        //alert( el );
        _o_cmd += "(@A=" + el + ")";
    }
    if( _o_cmd == "error" ) alert( "发现错误，请修改" );
    return _o_cmd;
  }

    function textFieldCmdFilter( el )
    {
      var re = /\"[*|+|-]{1}\"/
    
      var loop = true;
      while( loop )
      {
        el = el.replace(re,"");
        if( el.search( re ) < 0 ) loop = false;
      }
      if( el.indexOf("\"") >= 0 )
      {
        alert("出错了！\n除了在消除 + - * 号的运算符意义以外，普通文字不需要引号括起来，引号本身不可以作为检索词");
        return "error";
      }
    
      re = /^(\s*)/
      el = el.replace(re,"");
      re = /(\s*)$/
      el = el.replace(re,"");
    
      if( el == "" )  return "";
    
      var startChar = "";
      re = /^[-]/
      if( re.test( el ) == true )	startChar = "-";
    
      loop = true;
      while( loop )
      {
        loop = false;
    
        re = /^[*|+|-]/
        if( re.test( el ) == true )	el = el.substring( 1, el.length );
        if( re.test( el ) == true )	loop = true;
    
        re = /[*|+|-]$/
        if( re.test( el ) == true )	el = el.substring( 0, el.length - 1 );
        if( re.test( el ) == true )	loop = true;
      }
      return (startChar + el);
    }
    
    function myreplace( inputString,str_old,str_new )
    {
       var tp = inputString.split( str_old );
       return tp.join( str_new );
    }
    
    function advSearch()
    {
      // var dbids = document.all.sortDbids.value;
       var dbids = "A1/A2/A3/B5/C1/C2/C3/C4/C5/C7/D1/D3/D2/D5/D6/D7/D9/E1/D4/C9/E2/E3/A5/A6/A7/A8/A9/E4/E5/E6/F2/E7/E9/F1/F3/D8/F4/F5";
      canSearch = (dbids =="")?false:true;
      if (!canSearch)
      {
        alert("当前没有可查询资源"); return;
      }

      if (dbids.length<1)
      {
        alert("当前没有可查询资源"); return;
      }
      var urlString = "http://search.hangzhou.com.cn/wse/cgwse/advSearchShow.jsp?dbids=" + dbids;
      var attrString = "toolbar=no,menubar=no,status=no,scrollbars=yes,resizable=yes,location=no,width=600,height=420";
      var advW = window.open(urlString, "advSearch", attrString);
      if( !advW )
      {
        alert("是否阻止了弹出窗口？");
      }
    }  
 
