var strpbkm = "";
var strTemp1 = "";
var strTemp2 = "";
var strTemp3 = "";
function AddField(strText, strEntry)
{
    var strMid;
    var strFlag = "";
    var strBracket = "";
    var str1;
		var s = "";
	//肯定不是关键词
  if(Len(strText) <= 2)
	{
    s = strEntry + "=" + strText;
  }
	else
	{
    //取出第一个关系表达式左边的串
    strMid = GetSubStr(strText, strFlag, 2);
		strText = strTemp1;
		strFlag = strTemp2;
    //去掉左边的括号
    str1 = Left(strMid, 1);
    while(str1 == "(")
		{
        strBracket += str1;
				strMid = Mid(strMid, 2);
        str1 = Left(strMid, 1);
    }

    //确定余下的是否是字段名，如果不是，则加上
    if(IsMyField(strMid, 0))
		{
        s = strBracket + strMid + strFlag + strText;
    }
		else
		{
    	s = strEntry + "=" + strBracket + strMid + strFlag + strText;
    }
	}
return(s);
}

function DO_JournalName(strKM)
{
	var s = "";
  if(strKM == "")
	{
    s = "";
  }
	else
	{
    
    var strRes;
    var arrKM, intI, intJ;
    var strTemp, strMid;
    var arrMidKM;
		arrKM = strKM.split("");
	
		for(intI=0;intI<arrKM.length;intI++)
		{
        strTemp = arrKM[intI];
        
				strTemp = Replace(strTemp, "(", "");
				strTemp = Replace(strTemp, ")", "");
				strTemp = Replace(strTemp, "+", "");
				strTemp = Replace(strTemp, "*", "");
				strTemp = Replace(strTemp, "-", "");
				
				arrMidKM = strTemp.split("");
				for(intJ=0;intJ<arrMidKM.length;intJ++)
				{
					strRes += "," + "'" + Trim(arrMidKM[intJ]) + "'";
				}
    }

    if(Len(strRes) > 0)
		{
				strRes = Mid(strRes, 2);
    }
    
    s = strRes;
	}
return(s);
}
//分隔字符串
function SeprateString(strChar,strseprator)
{
		var intPos;
    var sValue;
    var I;
    var nYHCount;
		var intOut = 0;
    nYHCount = 0;
		var s = "";
  if(InStr(strChar,strseprator) == 0)
	{
    s = strChar;
    strChar = "";
  }
	else
	{
    if(strseprator == "=")
		{
        sValue = strChar;
				for(I=1;I<=Len(sValue);I++)
				{
							if(Mid(sValue, I, 1) == "=")
							{
                if((nYHCount % 2) == 0)
								{
                    s = Left(strChar, I - 1);
                    strChar = Mid(strChar, I + Len(strseprator));
										intOut = 1;
                    break;
                }
							}
							else if(Mid(sValue, I, 1) == "")
							{
									nYHCount++;
							}
        }
				if(intOut == 0)
				{
					s = strChar;
					strChar = "";
				}
    }
		else
		{
        intPos = InStr(strChar,strseprator);
        s = Left(strChar, intPos - 1);
        strChar = Mid(strChar, intPos + Len(strseprator));
    }
	}
strTemp1 = strChar;
return(s);
}

function GetSubStr(strSource,strFlag,intIsLogic)
{
    var intPos;
    var strMid;
    var strLogic;
		var intOut = 0;
		var s = "";

    if(intIsLogic == 1)
		{
        strLogic = "*,+,-,=,>,<,>=,<=,<>,(,)";
		}
		else	if(intIsLogic == 2)
		{
				strLogic = "=,>,<,>=,<=,<>";
		}
		else	if(intIsLogic == 3)
		{
				strLogic = "(,)";
		}
		else	if(intIsLogic == 4)
		{
				strLogic = "*,+,-";
		}

    for(intPos=1;intPos<=Len(strSource);intPos++)
		{
        strMid = Mid(strSource, intPos, 1);

        if(InStr(strLogic, strMid) > 0)
				{
            if(strMid == ">" || strMid == "<")
						{
                if(InStr("=,>", Mid(strSource, intPos + 1, 1)) > 0)
								{
                    strMid = Mid(strSource, intPos, 2);
                    s = Left(strSource, intPos);
                    strSource = Mid(strSource, intPos + 3);
                    strFlag = strMid;
                }
								else
								{
                    s = Left(strSource, intPos);
                    strSource = Mid(strSource, intPos + 1);
                    strFlag = strMid;
                }
            }
						else
						{
                s = Left(strSource, intPos - 1);
                strSource = Mid(strSource, intPos + 1);
                strFlag = strMid;
            }
						intOut = 1;
            break;
        }
    }
		if(!intOut)
		{
			s = strSource;
			strSource = "";
			strFlag = "";
		}
strTemp1 = strSource;
strTemp2 = strFlag;
return(s);
}
//确定是否是库中定义的字段
//入口参数：要确定是否是字段的字母
//@@ 表示任意字段
function IsMyField(strChar,IsField)
{
    var strFF;
		var s = "";
    strChar = UCase(strChar);
    strFF = "KEYWORD_C,NAME_C,WRITER,FIRSTWRITER,ORGAN,TITLE_C,REMARK_C,CLASS,任意字段";
    if(Trim(strChar) == "")
		{
        s = 0;
    }
		else
		{
			if(!IsField)
			{
				strFF = "K,J,A,F,S,T,R,C,M,U,M,Y";
			}
			s = CBool(InStr("," + strFF + ",", "," + Trim(strChar) + ","));
		}
return(s);
}

//确定是否是关系运算符
function IsMyRelation( strChar)
{
		var s = "";
    if(Trim(strChar))
		{
			s = 0;
    }
		else
		{
			if(InStr(",=,>,<,>=,<=,<>,", "," + Trim(strChar) + ",") >0)
			{
				s = 1;
			}
			else
			{
				s = 0;
			}
		}
return(s);
}

//确定是否是括号
function IsBracket(strChar)
{
		var s = "";
    if(Trim(strChar) == "")
		{
      s = 0;
    }
		else
		{
			if(CBool(InStr(",),(,", "," + Trim(strChar) + ",")))
			{
				s = 1;
			}
			else
			{
				s = 0;
			}
		}
return(s);
}

function IsOperation(sChar)
{
   var sXX;
   var s = "";
	 
   sXX = ",*,+,-,";
   sChar = "," + sChar + ","
	 if(InStr(sXX,sChar)>0)
	 {
		s = 1;
	 }
	 else
	 {
		s = 0;
	 }
return(s);
}
function GetRigorExpress(sChar,bRigor)
{
	var s = "";
  	if(sChar != "")
	{
    var I,J,bFound,strMid,strNewChar;
    
    J = 1;
    strMid = Mid(sChar, J, 1);
    while(IsBracket(strMid) || IsMyRelation(strMid) || IsOperation(strMid))
		{
        strMid = Mid(sChar, J, 1);
        J++;
    }
    
    if(J == 1){J++}
    J = J - 1 - 1;
    if(bRigor)
		{
    	strNewChar = Left(sChar, J) + "[";
    }
		else
		{
    	strNewChar = Left(sChar, J) + "";
    }
    bFound = 0;
    for(I = J + 1;I<=Len(sChar);I++)
		{
        strMid = Mid(sChar, I, 1);
        
        if(IsBracket(strMid) || IsMyRelation(strMid) || IsOperation(strMid))
				{
            if(!bFound)
						{
								if(bRigor)
								{
                	strNewChar += "]" + strMid;
                }
								else
								{
                	strNewChar += "" + strMid;
                }
            }
						else
						{
                strNewChar += strMid;
            }
            
            bFound = 1;
        }
				else
				{
            if(bFound)
						{
								if(bRigor)
								{
                	strNewChar += "[" + Trim(strMid);
                }
								else
								{
                	strNewChar += "" + strMid;
                }
            }
						else
						{
                strNewChar += strMid;
            }
            bFound = 0;
        }
    }
    if(!bFound)
		{
				if(bRigor)
				{
        	strNewChar += "]";
        }
				else
				{
        	strNewChar += "";
        }
    }
    strNewChar = Replace(strNewChar,"[]","");
    
    s = strNewChar;
	}
return(s);
}

function GetBlueValue(sValue)
{
var nLeftBracketCount, nRightBracketCount;
var sTempValue;
var I, nPos;
var IsInYH;
var s = "";

if(sValue == "")
{
    s = "";
}
else
{
sValue = Trim(sValue);
nLeftBracketCount = 0;
nRightBracketCount = 0;
IsInYH = 0;
for(I=1;I<=Len(sValue);I++)
{
    if(Mid(sValue, I, 1)  == "(")
		{
        if(!IsInYH)
				{
            nLeftBracketCount++;
        }
    }
		else if(Mid(sValue, I, 1) == ")")
		{
        if(!IsInYH)
				{
            nRightBracketCount++;
        }
    }
		else if(Mid(sValue, I, 1) == "")
		{
    	if(IsInYH)
			{
    		IsInYH = 0;
    	}
			else
			{
    		IsInYH = 1;
    	}
    }
	}
}

if(nLeftBracketCount != nRightBracketCount)
{
    if(nLeftBracketCount > nRightBracketCount)
		{
        for(I=1;I<=(nLeftBracketCount-nRightBracketCount);I++)
				{
            nPos = InStr(sValue, "(");
            sValue = Left(sValue, nPos - 1) + Mid(sValue, nPos + 1);
        }
    }
		else
		{
        sValue = StrReverse(sValue);
        for(I=1;I<=(nRightBracketCount - nLeftBracketCount);I++)
				{
            nPos = InStr(sValue, ")");
            sValue = sValue.substr(0,nPos - 1) + sValue.substr(nPos + 1);
        }
    	sValue = StrReverse(sValue);
    }
    sValue = Trim(sValue);
	while(IsBracket(Left(sValue, 1)))
	{
		sValue = Trim(Mid(sValue, 2));
	}
	while(IsBracket(Right(sValue, 1)))
	{
		sValue = Trim(Left(sValue, Len(sValue) - 1))
	}
}

sValue = Trim(sValue);
while(IsOperation(Left(sValue, 1)) || IsMyRelation(Left(sValue, 1)))
{
	sValue = Trim(Mid(sValue, 2));
}
while(IsOperation(Right(sValue, 1)) || IsMyRelation(Right(sValue, 1)))
{
	sValue = Trim(Left(sValue, Len(sValue) - 1));
}
s = Trim(sValue);
return(s);
}

function GetShowExpress(strText,strEntry)
{
var s = "";
	if(strText == "")
	{
		s = "";
	}
	else
	{
    strText = Replace(strText,"　"," ");
    strText = Replace(strText,"（","(");
    strText = Replace(strText,"）",")");
    strText = Replace(strText,"＋","+");
    strText = Replace(strText,"＊","*");
    strText = Replace(strText,"－","-");
    strText = Replace(strText,"＝","=");
    strText = UCase(strText);
    strText = AddField(strText,strEntry);
    strShow = strText;
    strShow = Replace(strShow,"M=","题名或关键词=");
    strShow = Replace(strShow,"U=","任意字段=");
    strShow = Replace(strShow,"A=","作者=");
    strShow = Replace(strShow,"F=","第一作者=");
    strShow = Replace(strShow,"C=","分类号=");
    strShow = Replace(strShow,"S=","机构=");
    strShow = Replace(strShow,"K=","关键词=");
    strShow = Replace(strShow,"Y=","参考文献=");
    strShow = Replace(strShow,"T=","题名=");
    strShow = Replace(strShow,"J=","刊名=");
    strShow = Replace(strShow,"R=","文摘=");
    strShow = Replace(strShow,"Z=","作者简介=");
    strShow = Replace(strShow,"I=","基金资助=");
    strShow = Replace(strShow,"L=","栏目信息=");
    strShow = Replace(strShow,"","");
    s = strShow;
	}
return(s);
}

function GetExpress(strText,strSameMean,strEntry,strShow,bFlag,strKM)
{
	if(bFlag=="true")
	{
		bFlag=1;
	}
	else
	{
		bFlag=0;
	}
	var s = "";
 if(strText == "")
 {
		s = "";
 }
 else
 {
		strText = Replace(strText,/　/g," ");
		strText = Replace(strText,/（/g,"(");
		strText = Replace(strText,/）/g,")");
		strText = Replace(strText,/＋/g,"+");
		strText = Replace(strText,/＊/g,"*");
		strText = Replace(strText,/－/g,"-");
		strText = Replace(strText,/＝/g,"=");
		strText = Replace(strText,/(^(\s|\*|\+|\-|\=)*)|((\s|\*|\+|\-|\=)*$)/g,"");//去掉表达式两边的运算符
		strText = Replace(strText,/\s[\s\*\+\-]*/g,"*");//
		strText = Replace(strText,/\*[\s\*\+\-]*/g,"*");//
		strText = Replace(strText,/\+[\s\*\+\-]*/g,"+");
		strText = Replace(strText,/\-[\s\*\+\-]*/g,"-");
    strText = UCase(strText);
    strText = AddField(strText,strEntry);
    strShow = strText;
    strShow = Replace(strShow,"M=","题名或关键词=");
    strShow = Replace(strShow,"U=","任意字段=");
    strShow = Replace(strShow,"A=","作者=");
    strShow = Replace(strShow,"F=","第一作者=");
    strShow = Replace(strShow,"C=","分类号=");
    strShow = Replace(strShow,"S=","机构=");
    strShow = Replace(strShow,"K=","关键词=");
    strShow = Replace(strShow,"Y=","参考文献=");
    strShow = Replace(strShow,"T=","题名=");
    strShow = Replace(strShow,"J=","刊名=");
    strShow = Replace(strShow,"R=","文摘=");
    strShow = Replace(strShow,"Z=","作者简介=");
    strShow = Replace(strShow,"I=","基金资助=");
    strShow = Replace(strShow,"L=","栏目信息=");
    
	var sField,sExpress,sMid,I,J,K,sNewExpress,sValue,sXX,sXY;
	var sNewField,bFound,sExtractValue,sBracket;
	var sOldValue, sBlueValue;
	var blnDoSameWriter, blnDoSameMean;
	sNewExpress = "";
	sField = "";
	sExpress = "";
	sBracket = "";
	blnDoSameWriter = 0;
	blnDoSameMean = 0;
	sOldValue = "";
	sBlueValue = "";
	I = 0;
	sMid = SeprateString(strText,"=");
	strText = strTemp1;
	while(sMid != "")
	{
		if(I == 0)
		{
			sField = sField + "\\~" + sMid;
		}
		else
		{
			if(strText != "")
			{
				sXX = Trim(sMid);
				if(Len(sXX)>1)
				{
					for(J=Len(sXX)-1;J>=0;J--)
					{
						if(Mid(sXX,J,1) != " ")
						{
							if(IsOperation(Mid(sXX,J,1)) || IsBracket(Mid(sXX,J,1)))
							{
								sField = sField + "\\~" + Right(sXX,1);
								sExpress=sExpress + "\\~" + Left(sXX,Len(sXX)-1);
							}
							else
							{
								sExpress=sExpress + "\\~" + sMid + "=" + SeprateString(strText,"=");
								strText = strTemp1;
							}
							break;
						}
					}
				}
				else
				{
					sField = sField + "\\~" + Right(RTrim(sMid),1);
					sExpress=sExpress + "\\~" + Left(RTrim(sMid),Len(RTrim(sMid))-1);
				}
			}
			else
			{
				if(sMid != "")
				{
					sExpress=sExpress + "\\~" + sMid;
				}
			}
		}
		I+=1;
		sMid = SeprateString(strText,"=");
		strText = strTemp1;
	}
	if(sField != "")
	{
		sField = Mid(sField,3);
	}
	if(sExpress != "")
	{
		sExpress = Mid(sExpress,3);
	}
	sMid = SeprateString(sField,"\\~");
	sField = strTemp1;
	sValue = SeprateString(sExpress,"\\~");
	sExpress = strTemp1;
	while(sMid != "")
	{
		if(InStr(sMid,"U")>0)
		{
			if(IsOperation(Right(RTrim(sValue),1)))
			{
				sField = Right(RTrim(sValue),1) + sField;
				sValue = Left(sValue,len(RTrim(sValue))-1);
			}
			nJ = Len(sValue);
			for(J=nJ;J>=1;J--)
			{
				sXX = Mid(sValue,J,1);
				if(sXX == ")")
				{
					nK = Len(sMid);
					for(K=1;K<=nK;K++)
					{
						sXY = Mid(sMid,K,1);
						if(sXY == "(")
						{
							sBracket = sXY + sBracket;
							sMid = Left(sMid,K-1) & Mid(sMid,K+1);
						}
					}
				}
			}
			sValue = sBracket + sValue;
			sValue = Trim(sValue);
			sValue = Replace(sValue," ","*");
			while(InStr(sValue,"**")>0)
			{
				sValue = Replace(sValue,"**","*");
			}
			while(InStr(sValue,"*+")>0)
			{
				sValue = Replace(sValue,"*+","+");
			}
			while(InStr(sValue,"+*")>0)
			{
				sValue = Replace(sValue,"+*","*");
			}
			while(InStr(sValue,"*-")>0)
			{
				sValue = Replace(sValue,"*-","-");
			}
			while(InStr(sValue,"-*")>0)
			{
				sValue = Replace(sValue,"-*","*");
			}
			
			if(sValue != "")
			{
				sNewExpress = sNewExpress + Replace(sMid,"U","任意字段") + "=" + sValue;
			}
		}
		else
		{
			if(bFlag)
			{
				if(InStr(sMid,"R")>0)
				{
					sExtractValue = GetRigorExpress(sValue,0);
				}
				else if(InStr(sMid,"T")>0)
				{
					sExtractValue = GetRigorExpress(sValue,0);
				}
				else
				{
					sValue = Replace(sValue, "(", "%0x0028%");
			    	sValue = Replace(sValue, ")", "%0x0029%");
					sExtractValue = GetRigorExpress(sValue,1);
				}
			}
			else
			{
				if(InStr(sMid,"J")>0)
				{
					sValue = Replace(sValue, "(", "%0x0028%");
			   	 	sValue = Replace(sValue, ")", "%0x0029%");
					sExtractValue = GetRigorExpress(sValue,0);
				}
				else
				{
					sExtractValue = GetRigorExpress(sValue,0);
				}
			}
			if(InStr(sMid, "M") > 0)
			{
				sExtractValue = Trim(sExtractValue);
				sExtractValue = Replace(sExtractValue," ","*");
				while(InStr(sExtractValue,"**")>0)
				{
					sExtractValue = Replace(sExtractValue,"**","*");
				}
				while(InStr(sExtractValue,"*+")>0)
				{
					sExtractValue = Replace(sExtractValue,"*+","+");
				}
				while(InStr(sExtractValue,"+*")>0)
				{
					sExtractValue = Replace(sExtractValue,"+*","*");
				}
				while(InStr(sExtractValue,"*-")>0)
				{
					sExtractValue = Replace(sExtractValue,"*-","-");
				}
				while(InStr(sExtractValue,"-*")>0)
				{
					sExtractValue = Replace(sExtractValue,"-*","*");
				}
			}
			sBlueValue = GetBlueValue(GetRigorExpress(sValue,0));
			if(InStr(sMid, "J") > 0)
			{
                strKM = strKM + "" + sBlueValue;
                strKM = Replace(strKM,"&quot;&quot;","");
     		 }
			if(blnDoSameWriter)
			{
				if(InStr(sMid, "A") > 0 || InStr(sMid, "F") > 0)
				{
					if(strSameWriter == "")
					{
						strSameWriter = "A=" + sBlueValue; 
					}
					else
					{
						strSameWriter += sOldValue + sBlueValue;
					}
				}
			}
			if(blnDoSameMean)
			{
				if(InStr(sMid, "K") > 0)
				{
					if(strSameMean == "")
					{
						strSameMean = "K=" + sBlueValue;
					}
					else
					{
						strSameMean += sOldValue + sBlueValue;
					}
				}
				else if(InStr(sMid, "T") > 0)
				{
					if(strSameMean == "")
					{
						strSameMean = "K=" + sBlueValue;
					}
					else
					{
						strSameMean += sOldValue + sBlueValue;
					}
				}
				else if(InStr(sMid, "M") > 0)
				{
					if(strSameMean == "")
					{
						strSameMean = "K=" + sBlueValue;
					}
					else
					{
						strSameMean += sOldValue + sBlueValue;
					}
				}
			}
			if(InStr(sMid,"K")>0)
			{
				sMid = Replace(sMid,"K","Keyword_C");
			}
			else if(InStr(sMid,"A")>0)
			{
				sMid = Replace(sMid,"A","Writer");
			}
			else if(InStr(sMid,"F")>0)
			{
				sMid = Replace(sMid,"F","FirstWriter");
			}
			else if(InStr(sMid,"J")>0)
			{
				sMid = Replace(sMid,"J","Name_C");
			}
			else if(InStr(sMid,"S")>0)
			{
				sMid = Replace(sMid,"S","Organ");
			}
			else if(InStr(sMid,"T")>0)
			{
				sMid = Replace(sMid,"T","Title_C");
			}
			else if(InStr(sMid,"Z")>0)
			{
				sMid = Replace(sMid,"Z","Introduce");
			}
			else if(InStr(sMid,"I")>0)
			{
				sMid = Replace(sMid,"I","Imburse");
			}
			else if(InStr(sMid,"L")>0)
			{
				sMid = Replace(sMid,"L","MuInfo");
			}
			else if(InStr(sMid,"R")>0)
			{
				sMid = Replace(sMid,"R","Remark_C");
			}
			else if(InStr(sMid,"C")>0)
			{
				sMid = Replace(sMid,"C","Class");
			}
			else if(InStr(sMid,"Y")>0)
			{
				sMid = Replace(sMid,"Y","strRef");
			}
			else
			{
				sMid = Replace(sMid,"U","任意字段");
			}
			if(InStr(sMid,"Class")>0)
			{
				if(IsOperation(Right(sExtractValue, 1)))
				{
          sExtractValue = Replace(Left(sExtractValue, Len(sExtractValue) - 1), "-", "%0x002D%") + Right(sExtractValue, 1);
        }
				else
				{
          sExtractValue = Replace(sExtractValue, "-", "%0x002D%");
        }
                if(bFlag)
								{
                    if(sExtractValue != ""){sNewExpress += sMid + "=" + sExtractValue}
                }
								else
								{
                    if(sExtractValue != "")
										{
                        if(IsOperation(Right(sExtractValue, 1)))
												{
                            sExtractValue = Replace(Left(sExtractValue, Len(sExtractValue) - 1), "+", "+[") + Right(sExtractValue, 1);
                        }
												else
												{
                            sExtractValue = Replace(sExtractValue, "+", "+[");
                        }
                        sNewExpress += sMid + "=[" + sExtractValue;
                    }
                }
			}
			else
			{
				if(InStr(sMid, "M") > 0 && InStr(sMid,"MuInfo") <=0)
				{
                	if(sExtractValue != "")
					{								
						sNewExpress += Trim(Left(sMid, Len(RTrim(sMid)) - 1)) + Trim(Left(sExtractValue, InStr(sExtractValue, sBlueValue) - 1)) + "(Keyword_C=(" + Replace(sBlueValue,/(\s){1,}/g,"*") + ")+Title_C=(" + Replace(sBlueValue,/(\s){1,}/g,"*") + "))" + Trim(Mid(sExtractValue, InStr(sExtractValue, sBlueValue) + Len(sBlueValue) + 0));
					}
				}
				else
				{
                	if(sExtractValue != "")
					{
						sNewExpress += sMid + "=" + sExtractValue;
					}
				}
			}
		}
		
		if(IsOperation(Right(sExtractValue, 1))){sOldValue = Right(sExtractValue, 1);}
		I++;
		
		sMid = SeprateString(sField,"\\~");
		sField = strTemp1;
		sValue = SeprateString(sExpress,"\\~");
		sExpress = strTemp1;
	}
	var strMid, strDeal;
	var nTemp, nBegin, nEnd, strRes;
	nBegin = 0;
	nEnd = 0;
	strRes = "";
	for(nTemp=1;nTemp<=Len(sNewExpress);nTemp++)
	{
	    strMid = Mid(sNewExpress, nTemp, 1);
	    if(strMid == "")
			{
	        if(nBegin > 0)
					{
	            nEnd = nTemp;
	            strDeal = Mid(sNewExpress, nBegin + 1, nEnd - nBegin - 1);
	            strDeal = Replace(strDeal, "+", "%0x002B%");
	            strDeal = Replace(strDeal, "-", "%0x002D%");
	            strDeal = Replace(strDeal, "*", "%0x002A%");
	            strDeal = Replace(strDeal, "(", "%0x0028%");
	            strDeal = Replace(strDeal, ")", "%0x0029%");
	            strDeal = Replace(strDeal, "{", "%0x007B%");
	            strDeal = Replace(strDeal, "}", "%0x007D%");
	            strDeal = Replace(strDeal, "=", "%0x003D%");
	            strRes = strRes & strDeal;
	            nBegin = 0;
	            nEnd = 0;
	        }
					else
					{
	            nBegin = nTemp;
	        }
	    }
			else
			{
	        if(nBegin == 0)
					{
	            strRes += strMid;
	        }
	    }
	}
	if(nBegin > 0 && nEnd == 0)
	{
	    strRes += Mid(sNewExpress, nBegin);
	}
	strKM = DO_JournalName(strKM);
	strpbkm = strKM;
	strRes = Replace(strRes,"[[","[");
	strRes = Replace(strRes,"]]","]");
  s = strRes;
	}

strTemp1 = strSameMean;
strTemp2 = strShow;
strTemp3 = strKM;
return(s);
}

function GetSameValue(sValue)
{
	var s = "";
  if(sValue == "")
	{
		s = "";
  }
	else
	{
		var sMid, sField, sNewValue, sNewExpress;
    var nI;
    
    sNewValue = "";
    sField = SeprateString(sValue, "=");
		sField = strTemp1;
    sField = Replace(sField, "(", "");
		sField = Replace(sField, "（", "");
    for(nI=1;nI<=Len(sValue);nI++)
		{
        sMid = Mid(sValue, nI, 1);
        if(IsOperation(sMid) || IsMyRelation(sMid) || IsBracket(sMid))
				{
            if(sNewValue != "")
						{
                if(sMid != "=")
								{
									sNewExpress += "/@/" + sField + "=" + sNewValue;
								}
								sNewValue = "";
            }
        }
				else
				{
            sNewValue += sMid;
        }
    }
    if(sNewValue != "")
		{
        if(sMid != "=")
				{
					sNewExpress += "/@/" + sField + "=" + sNewValue;
				}
        sNewValue = "";
    }
    if(sNewExpress != "")
		{
			sNewExpress = Mid(sNewExpress, 4);
		}
    s = sNewExpress;
	}
return(s);
}

function ChangeChk()
{
    var strChk,blnAdd,i,bF,j,strValue,sNo;
    var strName,mmmmchkCount;
    //On Error Resume Next
    strName = window.event.srcElement.name;
  if(strName != "")
	{
    if(Left(strName, 1) == "B" && IsNumeric(Mid(strName,2)))
		{
        if(!CBool(document.getElementsByName(strName)[0].Disabled))
				{
            parent.frames["Search"].ScrollPage(Mid(strName,2));
        }
    }
		else if(strName == "Jump")
		{
        parent.frames["Search"].ScrollPage(document.getElementsByName("PageNo")[0].value);
    }
		else if(strName == "All")
		{
        for(i=0;i<document.getElementsByTagName("INPUT").length;i++)
				{
                if(!CBool(document.getElementsByTagName("INPUT")[i].disabled))
								{
                  if(Left(document.getElementsByTagName("INPUT")[i].name,1) == "C" && IsNumeric(Mid(document.getElementsByTagName("INPUT")[i].name,2)))
									{
                    	strValue = document.getElementsByTagName("INPUT")[i].value;
											sNo = SeprateString(strValue,"=");
											strValue = strTemp1;
                        if(!document.getElementsByTagName("INPUT")[i].Checked)
												{
												
													if(CInt(parent.frames["Search"].lngChkRecords)>=50)
														{
															alert("对不起，您最多一次只能选择50条信息！");
															document.getElementsByName(strName)[0].Checked = 0;
															return;
														}
												}
												if(document.getElementsByTagName("INPUT")[i].checked != document.getElementsByName("All")[0].checked)
												{
													document.getElementsByTagName("INPUT")[i].checked=document.getElementsByName("All")[0].checked;
                        	strChk = Mid(document.getElementsByTagName("INPUT")[i].name, 2);
                        	blnAdd=document.getElementsByName("All")[0].checked;
                        	if(document.getElementsByTagName("INPUT")[i].checked)
													{
	                            	if(document.getElementsByName("All")[0].checked)
																{
	                                	document.getElementsByName("All")[0].Title="全部取消";
	                            	}
																else
																{
	                                	document.getElementsByName("All")[0].Title="全部选取";
	                            	}
	                            	parent.frames["Search"].CheckRecord(strChk,blnAdd);
													}
													else
													{
													
														//mmmmchkCount.innerText = CStr(CInt(mmmmchkCount.innerText) - 1);
														document.getElementsByName("All")[0].Title="全部选取";
														parent.frames["Search"].CheckRecord(strChk,blnAdd);
													}
													//处理电子书架所需数据
													bF=0;
													for(j=0;j<=50;j++)
													{
														if(parent.frames["Search"].arrDZSJDetail[j] != null && parent.frames["Search"].arrDZSJDetail[j] != "undefined")
														{
															strTemp = parent.frames["Search"].arrDZSJDetail[j];
															if(SeprateString(strTemp,"=") == sNo)
															{
																if(document.getElementsByTagName("INPUT")[i].checked)
																{
																	parent.frames["Search"].arrDZSJDetail[j]=sNo + "=" + strValue;
																}
																else
																{
																	parent.frames["Search"].arrDZSJDetail[j]=sNo;
																}
																bF=1;
																return;
															}
														}
													}
													if(!bF)
													{
														if(document.getElementsByTagName("INPUT")[i].checked)
														{
															for(j=0;j<=50;j++)
															{
																if(parent.frames["Search"].arrDZSJDetail[j] == "")
																{
																	parent.frames["Search"].arrDZSJDetail[j]=sNo + "=" + strValue;
																	return;
																}
															}
														}
													}
                        }
                  }
                }
        }
    }
		else if(Left(strName,1) == "C" && IsNumeric(Mid(strName,2)))
		{
        strChk = Mid(strName, 2);
        blnAdd = document.getElementsByName(strName)[0].checked;
        if(blnAdd)
				{
        	if(CInt(parent.frames["Search"].lngChkRecords) >= 50)
					{
						alert("对不起，您最多一次只能选择50条信息！");
						document.getElementsByName(strName)[0].checked = 0;
						//break;
					}
			parent.frames["Search"].CheckRecord(strChk,blnAdd);
			bF=0;
			strValue=document.getElementsByName(strName)[0].value;
			sNo=SeprateString(strValue,"=");
			strValue = strTemp1;
			for(i=0;i<=50;i++)
			{
				strTemp = parent.frames["Search"].arrDZSJDetail[i];
				if(SeprateString(strTemp,"=") == sNo)
				{
					if(document.getElementsByName(strName)[0].checked)
					{
						parent.frames["Search"].arrDZSJDetail[i]=sNo + "=" + strValue;
					}
					else
					{
						parent.frames["Search"].arrDZSJDetail[i]=sNo;
					}
					bF=1;
					break;
				}
			}
			if(!bF)
			{
				if(document.getElementsByName(strName)[0].checked)
				{
					for(j=0;j<=50;j++)
					{
						if(parent.frames["Search"].arrDZSJDetail[j] == "")
						{
							parent.frames["Search"].arrDZSJDetail[j] = sNo + "=" + strValue;
							break;
						}
					}
				}
			}
		}
		else
		{
        	//mmmmchkCount.innerText = CStr(CInt(mmmmchkCount.innerText) - 1);
					parent.frames["Search"].CheckRecord(strChk,blnAdd);
		}
    }
	}
}

function Len(str)
{
	var s;
	if(str == "" || str == null)
	{
		s = 0;
	}
	else
	{
		s = str.length;
	}
	return(s);
}

function Mid(str,strStart,intLen)
{
	var s;
	if(str == "" || str == null)
	{
		s = "";
	}
	else
	{
		if(intLen == "" || intLen == null)
		{
			s = str.substr(strStart-1);
		}
		else
		{
			s = str.substr(strStart-1,intLen);
		}
	}
	return(s);
}

function Left(str, intLen)
{
	var s;
	if(str == "" || str == null)
	{
		s = "";
	}
	else
	{
		s = str.substr(0,intLen);
	}
	return(s);
}

function Right(str, intLen)
{
	var s;
	if(str == "" || str == null)
	{
		s = "";
	}
	else
	{
		s = str.substr(str.length - 1,intLen);
	}
	return(s);
}

function InStr(str1, str2)
{
	var s = "";
	if(Trim(str1) == "")
	{
		return(0);
	}
	else
	{
		s = str1.indexOf(str2) + 1;
		return(s);
	}
}

function UCase(str)
{
	var s;
	if(str == "" || str == null)
	{
		s = "";
	}
	else
	{
		s = str.toUpperCase();
	}
	return(s);
}

function CBool(intNum)
{
	if(parseInt(intNum))
	{
		s = 1;
	}
	else
	{
		s = 0;
	}
	return(s);
}

function CStr(str)
{
	var s;
	if(str == "" || str == null)
	{
		s = "";
	}
	else
	{
		s = str.toString();
	}
	return(s);
}

function CInt(intNum)
{
	var s;
	s = parseInt(intNum);
	return(s);
}

function CLng(intNum)
{
	var s;
	s = parseInt(intNum);
	return(s);
}

function IsNumeric(intNum)
{
	var s;
	if(intNum == "")
	{
		return(0);
	}
	else
	{
		s = isFinite(intNum);
		return(s);
	}
}

function Replace(str,strExp,strReText)
{
	var s;
	if(str == "" || str == null)
	{
		s = "";
	}
	else
	{
		s = str.replace(strExp,strReText);
	}
	return(s);
}

function Trim(str)
{
	var s;
	if(str == "" || str == null)
	{
		s = "";
	}
	else
	{
		s = str.replace(/(^\s*)|(\s*$)/g,"");
	}
	return(s);
}
function RTrim(str)
{
	var s;
	if(str == "" || str == null)
	{
		s = "";
	}
	else
	{
		s = str.replace(/(\s*$)/g,"");
	}
	return(s);
}

function StrReverse(str)
{
	var s = "";
	if(str == "" || str == null)
	{
		s = "";
	}
	else
	{
		for(i=str.length;i>0;i--)
		{
			s += Mid(str,i,1);
		}
	}
	return(s);
}
