function cpsEnteryKey(){
	var nRet;
	if(navigator.appName=='Netscape'){
		nRet=event.which;
	}else{
		nRet=event.keyCode;
	}
	if(nRet==13){
		gosear();
	}
}
function ophrdown(urls){
	document.getElementById("alertdiv").style.display='block';
	document.getElementById("huiruiurl").value = urls;
}
function closehr(){
	document.getElementById("alertdiv").style.display='none';
}
function downhr(){
	document.getElementById("alertdiv").style.display='none';
	var url = document.getElementById("huiruiurl").value;
	window.open(url);
}

function Replace(str,strExp,strReText){
	var s;
	if(str == "" || str == null){
		s = "";
	}else{
		s = str.replace(strExp,strReText);
	}
	return(s);
}
function gosear(){
	var SearchText;
	if(document.getElementById("exp").value != ""){
		SearchText = document.getElementById("exp").value.trim();
	}
	if( SearchText == null || SearchText == "undefined"){
		SearchText = "";
	}	
	if(SearchText.length<1){
		alert("请输入检索关键词！");
		document.getElementById("exp").focus();
		return;
	}
	var strshow='';
	var strexp='';
	var strX=document.getElementById("exp").value;
	var strentry = document.getElementById("Entry").value;
	strshow = GetShowExpress(strX,strentry);
	strX = preExpress(strX);
	strexp = GetExpress(strX,'',strentry,strshow,false,'');
	if(strexp == "undefined"){ strexp="";}
	
	var eobj = document.getElementById("e");
	var sobj = document.getElementById("s");
	var pobj = document.getElementById("p");
	var hobj = document.getElementById("h");
	hobj.value=SearchText;
	eobj.value=strexp;
	sobj.value=strshow;
	pobj.value=1;
	document.searchit.CP.value =0;
	document.searchit.CC.value =0;
	document.searchit.LC.value =0;
	document.searchit.submit();
}
function SelSelect(){
	//event.cancelBubble = true;
	var itemDiv = document.getElementById("itemDiv");
	if(!itemDiv){return;}
	//alert(itemDiv);return;
	itemDiv.Flag="header";
	itemDiv.style.visibility = itemDiv.style.visibility=="visible"?"hidden":"visible";
	var itemsel = document.getElementById("selectSel");
	if(itemsel!=null){
		var x = moveXbySlicePos(0,itemsel);
		var y = moveYbySlicePos(itemsel.offsetHeight?itemsel.offsetHeight:20,itemsel);
		itemDiv.style.width = itemsel.offsetWidth+"px";
		itemDiv.style.left = x+10+"px";
		itemDiv.style.top = y-3+"px";
	}
}
function moveXbySlicePos(xoffset,obj){
	var curleft = 0;
	if(obj.offsetParent){
		while(obj.offsetParent){
			curleft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	}else if(obj.x){
		curleft += obj.x;
	}
	return curleft+xoffset;
}	
function moveYbySlicePos(yoffset,obj){
	var curtop = 0;
	if(obj.offsetParent){
		while (obj.offsetParent) 
		{
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	}else if(obj.y){
		curtop += obj.y;
	}
	return curtop+yoffset;
}
function OnSelSearchItem(curEle){
	if(curEle){
		var itemDiv = document.getElementById("itemDiv");
		var entry0 = document.getElementById("Entry");
		if(!itemDiv || !entry0){return;}
		var itemEls = itemDiv.getElementsByTagName("div");
		if(!itemEls){return;}
		
		for(var i=0;i<itemEls.length;i++){
			itemEls.className = "S_Item_Normal";
		}
		curEle.className = "S_ItemSelected";
		entry0.value=curEle.value;
		
		if(itemDiv.Flag=="header"){
			var selEle = document.getElementById("selectSel");
			if(selEle){				
				selEle.value = curEle.innerHTML;
			}
		}else{
			var selEle = document.getElementById("selectSel_t");
			if(selEle){
				selEle.value = curEle.innerHTML;
			}
		}
		itemDiv.style.visibility="hidden";
	}
	return false;
}
String.prototype.trim = function(){
	return this.replace(/(^\s*)|(\s*$)/g, "");
}
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 = 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 preExpress(Express){
	Express = Express.replace(/　/g," ");
	Express = Express.replace(/（/g,"(");
	Express = Express.replace(/）/g,")");
	Express = Express.replace(/＋/g,"+");
	Express = Express.replace(/＊/g,"*");
	Express = Express.replace(/－/g,"-");
	Express = Express.replace(/＝/g,"=");
	Express = Express.replace(/“/g,'"');
	Express = Express.replace(/”/g,'"');
	Express = Express.replace(/\-/g,"%0x002D%");
	Express = Express.replace(/\+/g,"%0x002B%");
	Express = Express.replace(/\*/g,"%0x002A%");
	Express = Express.replace(/\(/g,"%0x0028%");
	Express = Express.replace(/\)/g,"%0x0029%");
	var len = Express.length;
	
	var newExpress="";
	var segment="";
	var statusx = 0;
	for(var i=0;i<len;i++){
		if(statusx == 0){
			if(Express.charAt(i)=='"'){
				statusx = 1;
				segment = "";
			}else{
				newExpress += Express.charAt(i);
			}
		}else if(statusx == 1){
			if(Express.charAt(i) == '"'){
				segment = segment.replace(/\-/g,"%0x002D%");
				segment = segment.replace(/\+/g,"%0x002B%");
				segment = segment.replace(/\*/g,"%0x002A%");
				segment = segment.replace(/\(/g,"%0x0028%");
				segment = segment.replace(/\)/g,"%0x0029%");
				newExpress+=segment;
				segment = "";
				statusx=0;
			}else{
				segment+=Express.charAt(i);
			}
		}
	}
	if(segment != ""){
		newExpress+=segment;
	}
	return newExpress;
}
