var C_VIP1000_Url="http://www.cqvip.com"
var ForeQuestionUrl=C_VIP1000_Url+"/qysearch/qysearch.asp?page=1&T=";
var isInitTopicLoad = false;
document.attachEvent("onmousedown",mouseDownEvent);
document.attachEvent("onclick",onclickEvent);

function mouseDownEvent(){
var whichIt = event.srcElement;
var tp = typeof(whichIt);
if(tp!="object"){
    return ;
}
if(whichIt.tagName == "IMG"){
    whichIt = whichIt.parentElement;
}
if(whichIt.tagName != "A"){
    return ;
}
var sss = whichIt.innerHTML;
sss = sss.toUpperCase();
var i,j;
var nn,mm;nn=0;
j = sss.indexOf("HTTP://");
i = sss.indexOf("HREF");

if(j>0 && j<i+9){
    if(sss.indexOf("SUID=")<1){
        for(mm=0;mm<hostnum;mm++){
            if(sss.indexOf(testhost[mm])>0){
                nn = 1 ;
                break;
            }
        }
        if(nn==1){
        if(whichIt.search=="") {
            whichIt.search = "?SUID=" + jssuid;
        }
        else{
            whichIt.search = whichIt.search + "&SUID=" + jssuid;
        }
        }
    }
}else{
    mm = sss.indexOf(".HTML");
		
    if(mm>0){
    if(sss.indexOf("SUID=")<1){
        if(whichIt.search=="") {
            whichIt.search = "?SUID=" + jssuid;
        }
        else{
            whichIt.search = whichIt.search + "&SUID=" + jssuid;
        }
    }
    }
	}
}

function onclickEvent()
{
	try
	{
		var itemDiv = document.getElementById("itemDiv");
		var optionDiv = document.getElementById("optionDiv");
		itemDiv.style.visibility = "hidden";
		optionDiv.style.visibility = "hidden";
	}
	catch(e)
	{}
}

function setCookie(name,value)
{
    var Days = 30;   
    var exp = new Date(); 
    exp.setTime(exp.getTime() + Days*24*60*60*1000);
    //document.cookie = name + "=" + escape(value) +";expires=" + exp.toGMTString();
	document.cookie  =  name  +    "=  "  +  escape(value)  +  ";expires=  "  +  exp.toGMTString()  +    ";path=/  "  ; 
}
function setCookieTJ(name,value)
{
    //var Days = 30;   
    var exp = new Date(); 
    exp.setTime(exp.getTime() + 5*60*1000);
    //document.cookie = name + "=" + escape(value) +";expires=" + exp.toGMTString();
	document.cookie  =  name  +    "=  "  +  escape(value)  +  ";expires=  "  +  exp.toGMTString()  +    ";path=/  "  ; 
}
function setCookieN(name,value)
{
	document.cookie  =  name  +    "=  "  +  escape(value)  +  ";path=/  "  ; 
}
function getCookie(name)
{
	var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
    if(arr != null) return unescape(arr[2]);
    return null;
}
function frmUserLogin()
{
	var nRet;
	if(navigator.appName=='Netscape')
	{
		nRet=event.which;
	}
	else
	{
		nRet=event.keyCode;
	}
	if(nRet==13)
	{
		userlogin.submit();
	}
}
function EnteryKey()
{
	var nRet;
	if(navigator.appName=='Netscape')
	{
		nRet=event.which;
	}
	else
	{
		nRet=event.keyCode;
	}
	if(nRet==13)
	{
		VipSearch();
	}
}
function EnteryKeyA()
{
	var nRet;
	if(navigator.appName=='Netscape')
	{
		nRet=event.which;
	}
	else
	{
		nRet=event.keyCode;
	}
	if(nRet==13)
	{
		VipSearchA();
	}
}

function VipSearch()
{
	var SearchText;
	if(document.getElementById("inputSel").value != "")
	{
        SearchText = document.getElementById("inputSel").value.trimBoth();
	}
	if( SearchText == null || SearchText == "undefined" )
	{
			SearchText = "";
	}
	if(SearchText == "搜尽8000余种期刊文章……"){
				SearchText = "";
				document.getElementById("inputSel").value="";
	}
    var seaType = getCookie("newSearchType");    
    if(seaType == null || seaType == "")
    {
        seaType = "Forum";
    }
    var SearchS = getCookie("SearchText");
    setCookie("newSearchWord",SearchText);
    setCookie("InSearch","In");
    if(SearchS == null || SearchS.trimBoth() == "")
    {
        setCookie("SearchText",SearchText);
    }
    else if(SearchS.indexOf(SearchText) == -1)
    {
        var SearchSS 
        SearchSS = SearchS.split("|");
        if(SearchSS.length > 11)
        {
            SearchS = SearchSS[SearchSS.length-11];
            for(var i = SearchSS.length-10;i<SearchSS.length;i++)
            {
                SearchS = SearchS + "|" + SearchSS[i];
            }
        }        
        setCookie("SearchText",SearchS+"|" + SearchText);
    }
    var strexp,strshow;
    strexp="";
    strshow="";
    var strX=document.getElementById("inputSel").value;
    var strsame = "";
	
	var strentry = document.getElementById("Entry0").value;
    var strKM="";
    var bFlag=false;
	
	if(strentry == "Q")
	{
		var Urlstr=ForeQuestionUrl+SearchText;
		location.replace(Urlstr);
		return;
	}
	
	strshow = GetShowExpress(strX,strentry);
	strX = preExpress(strX);
    strexp = GetExpress(strX,strsame,strentry,strshow,bFlag,strKM);
    if(strexp == "undefined") 
     { strexp="";}
    
    document.frm.E.value = strexp;
	document.frm.M.value = document.getElementById("inputSel").value;
	document.frm.H.value = document.getElementById("inputSel").value;
	document.frm.S.value = "2";
	document.frm.P.value = "1";	
	document.frm.From.value = "1";
	document.frm.Entry.value = strentry;
	if(document.frm.action == "")
		document.frm.action = C_VIP1000_Url+"/asp/vipsearch.asp";
	document.frm.target="_top";
	document.frm.submit();
}

function onSTypeSel()
{
	var entry = document.getElementById("Entry0").value;
	UpdateSearchShow(entry);
}

function UpdateSearchShow(entry)
{
	if(entry == "A" || entry == "K" || entry == "C" || entry == "J")
	{
		document.getElementById("searstyle").disabled = false;
	}
	else
	{
		document.getElementById("searstyle").disabled = true;
	}
	if(entry == "Y")
	{
		document.getElementById("BeginYear0").disabled = true;
		document.getElementById("EndYear0").disabled = true;	
	}
	else
	{
		document.getElementById("BeginYear0").disabled = false;
		document.getElementById("EndYear0").disabled = false;
	}
}

function GetEntityRange(startYear,endYear)
{
	if(startYear > endYear)
	{
		alert("结束年大于开始年,忽略年进行检索!");
		return "";
	}
	var sE = -1;
	var eE = -1;
	if(startYear == 2007)
		sE = 2;
	if(startYear <= 2006)
		sE = 1;
	if(startYear < 2001)
		sE = 0;
	if(endYear == 2007)
		eE = 4;
	if(endYear <= 2006)
		eE = 1;
	if(endYear < 2001)
		eE = 0;
		
	if(sE==-1 || eE==-1 || (sE==0 && eE==4))
			return "";
	return "<"+sE+","+eE+">";
}

function GetYearsRange(startYear,endYear)
{
	var yExpress="";
	if(startYear>endYear)
		return yExpress;
	if(startYear ==1989 && (endYear==2000 || endYear == 2006 || endYear== 2007))
		return yExpress;
	if(startYear == 2001 && (endYear == 2006 || endYear== 2007))
		return yExpress;
	if(startYear == 2007 && endYear == 2007)
		return "Years=2007"

	yExpress="(";
	for(var i=startYear ;i<=endYear;i++)
	{
		if(i != startYear)
			yExpress+="+";
		yExpress+="Years="+i;
	}
	yExpress+=")";
	return yExpress;
}

function EnteryNewKey()
{
	var nRet;
	if(navigator.appName=='Netscape')
	{
		nRet=event.which;
	}
	else
	{
		nRet=event.keyCode;
	}
	if(nRet==13)
	{
		VipNewSearch();
	}
}

function VipNewSearch()
{
	//获取检索文字
	var SearchText;
	if(document.getElementById("inputSel").value != "")
		SearchText = document.getElementById("inputSel").value.trimBoth();
    if(SearchText == null || SearchText == "undefined")
		SearchText = "";
	if(SearchText == "搜尽8000余种期刊文章……"){
				SearchText = "";
				document.getElementById("inputSel").value="";
	}
		
	//增加检索信息到Cookie中
    var seaType = getCookie("newSearchType");
    if(seaType == null || seaType == "")
		seaType = "Forum";
    var SearchS = getCookie("SearchText");
    setCookie("newSearchWord",SearchText);
    setCookie("InSearch","In");
    if(SearchS == null || SearchS.trimBoth() == "")
        setCookie("SearchText",SearchText);
    else if(SearchS.indexOf(SearchText) == -1)
    {
        var SearchSS 
        SearchSS = SearchS.split("|");
        if(SearchSS.length > 11)
        {
            SearchS = SearchSS[SearchSS.length-11];
            for(var i = SearchSS.length-10;i<SearchSS.length;i++)
            {
                SearchS = SearchS + "|" + SearchSS[i];
            }
        }
        setCookie("SearchText",SearchS+"|" + SearchText);
    }
	
	var strexp,strshow;
    var strsame = "";
	var strentry = document.getElementById("Entry0").value;
    var strKM="";
    var bFlag=false;
	
	if(strentry == "Q")
	{
		var Urlstr=ForeQuestionUrl+SearchText;
		location.replace(Urlstr);
		return;
	}
	if(document.getElementById("searstyle").disabled == false)
	{
		if(document.getElementById("searstyle").value == "1")
		{
			if(SearchText != "")
				SearchText="["+SearchText+"]";
		}
	}
	
	strshow = GetShowExpress(SearchText,strentry);
	SearchText = preExpress(SearchText);
    strexp = GetExpress(SearchText,strsame,strentry,strshow,bFlag,strKM);
    
	if(strexp == "undefined")
    {
		strexp="";
	}
	
	var startYear = document.getElementById("BeginYear0").value;
	var endYear = document.getElementById("EndYear0").value;
	var saveInfo = startYear+"|"+endYear+"|"+strentry+"|";
	strshow = strshow+"*年="+startYear+"-"+endYear;
	var yearEs = GetYearsRange(startYear,endYear);
	var range = GetEntityRange(startYear,endYear);
	if(strentry == "Y")
	{
		yearEs = "";
		range = "";
	}
	if(yearEs != "")
	{
		if(strexp=="")
			strexp += yearEs;
		else
			strexp += "*"+yearEs;
	}
	if(document.getElementById("ResetSearch").checked)
	{
		saveInfo+="ResetSearch";
		if(strexp != "" && range != "")
			strexp = range+":"+strexp;
	}
	else if(document.getElementById("ResultSearch").checked)
	{
		saveInfo+="ResultSearch";
		strexp = document.frm.E.value+"*("+strexp+")";
		strshow = document.frm.H.value+"*"+strshow;
	}
	else if(document.getElementById("AddSearch").checked)
	{
		saveInfo+="AddSearch";
		strexp = document.frm.E.value+"+("+strexp+")";
		strshow = document.frm.H.value+"+"+strshow;
	}
	else if(document.getElementById("DelSearch").checked)
	{
		saveInfo+="DelSearch";
		strexp = document.frm.E.value+"-("+strexp+")";
		strshow = document.frm.H.value+"-"+strshow;
	}
	
    document.frm.E.value = strexp;
	document.frm.M.value = document.getElementById("inputSel").value;
	document.frm.H.value = strshow;
	document.frm.SaveInfo.value = saveInfo;
	document.frm.S.value = "2";
	document.frm.P.value = "1";
	document.frm.From.value = "1";
	document.frm.Entry.value = strentry;
	if(document.frm.action == "")
		document.frm.action = C_VIP1000_Url+"/asp/vipsearch.asp";
	document.frm.target="_top";
	document.frm.submit();
}


function VipSearchA()
{
	var SearchText;
    if(document.getElementById("searchtxt").value != "")
        SearchText = document.getElementById("searchtxt").value.trimBoth();
    if( SearchText == null || SearchText == "undefined" )
    {
        SearchText = "";
    }
	if(SearchText == "搜尽8000余种期刊文章……"){
				SearchText = "";
				document.getElementById("inputSel").value="";
	}
    var seaType = getCookie("newSearchType");    
    if(seaType == null || seaType == "")
    {
        seaType = "Forum";
    }
    var SearchS = getCookie("SearchText");
    
    //document.cookie  =  "newSearchWord=  "  +  escape(SearchText)  +  ";path=/  "  ;
    setCookie("newSearchWord",SearchText);
    setCookie("InSearch","In");
    if(SearchS == null || SearchS.trimBoth() == "")
    {
        setCookie("SearchText",SearchText);
    }
    else if(SearchS.indexOf(SearchText) == -1)
    {
        var SearchSS 
        SearchSS = SearchS.split("|");
        if(SearchSS.length > 11)
        {
            SearchS = SearchSS[SearchSS.length-11];
            for(var i = SearchSS.length-10;i<SearchSS.length;i++)
            {
                SearchS = SearchS + "|" + SearchSS[i];
            }
        }        
        setCookie("SearchText",SearchS+"|" + SearchText);
    }
    var strexp,strshow,stroldexp;
    strexp="";
    strshow="";
    stroldexp=document.frm.E.value;
    var strX=document.getElementById("searchtxt").value;    
    var strsame = "";    		
    var strentry = document.getElementById("Entry0").value;
    var strKM="";
    var bFlag=false;
	
	if(strentry == "Q")
	{
		var Urlstr=ForeQuestionUrl+strexp;
		location.replace(Urlstr);
		return;
	}
	
	
	strshow = GetShowExpress(strX,strentry);
	strX = preExpress(strX);
    strexp = GetExpress(strX,strsame,strentry,strshow,bFlag,strKM);
    if(strexp == "undefined")
    {
    	strexp="";
    }
    
    if(document.getElementById("rdo1").checked)
    {
    	document.frm.E.value = strexp;
    }
	else
	{
		if((stroldexp !="undefined") && (stroldexp !=""))
		{
			document.frm.E.value = "(" + stroldexp + ")*(" + strexp + ")";
		}
		else
		{
			document.frm.E.value = strexp;
		}
	}
	document.frm.M.value = document.getElementById("searchtxt").value;
	document.frm.H.value = document.getElementById("searchtxt").value;
	document.frm.S.value = "2";
	document.frm.P.value = "1";	
	document.frm.From.value = "1";
	document.frm.Entry.value = strentry;
	document.frm.action = C_VIP1000_Url+"/asp/vipsearch.asp";
	document.frm.target="_top";
	document.frm.submit();
}

function WebSearch()
{
	var SearchText;
    if(document.getElementById("inputSel").value != "")
        SearchText = document.getElementById("inputSel").value.trimBoth();
    if( SearchText == null || SearchText == "undefined" )
    {
        SearchText = "";
    }
    var seaType = getCookie("newSearchType");    
    if(seaType == null || seaType == "")
    {
        seaType = "Forum";
    }
    
    var SearchS = getCookie("SearchText");
    
    //document.cookie  =  "newSearchWord=  "  +  escape(SearchText)  +  ";path=/  "  ;
    setCookie("newSearchWord",SearchText);
    setCookie("InSearch","In");
    if(SearchS == null || SearchS.trimBoth() == "")
    {
        setCookie("SearchText",SearchText);
    }
    else if(SearchS.indexOf(SearchText) == -1)
    {
        var SearchSS 
        SearchSS = SearchS.split("|");
        if(SearchSS.length > 11)
        {
            SearchS = SearchSS[SearchSS.length-11];
            for(var i = SearchSS.length-10;i<SearchSS.length;i++)
            {
                SearchS = SearchS + "|" + SearchSS[i];
            }
        }        
        setCookie("SearchText",SearchS+"|" + SearchText);
    }
    var strexp,strshow;
    strexp="";
    strshow="";
    var strX=document.getElementById("inputSel").value;
    var strsame = "";    		
    var strentry = document.getElementById("Entry0").value;
    var strKM="";
    var bFlag=false;
	if(strentry == "Q")
	{
		var Urlstr=ForeQuestionUrl+strexp;
		location.replace(Urlstr);
		return;
	}
	
	strshow = GetShowExpress(strX,strentry);
	strX = preExpress(strX);
    strexp = GetExpress(strX,strsame,strentry,strshow,bFlag,strKM);
    if(strexp == "undefined")
    { strexp="";}
    
    document.frm.E.value = strexp;
	//document.frm.E.value = document.getElementById("inputSel").value;
	document.frm.M.value = document.getElementById("inputSel").value;
	document.frm.H.value = document.getElementById("inputSel").value;
	document.frm.S.value = document.getElementById("ShowStyle").value;
	document.frm.P.value = "1";	
	document.frm.From.value = "1";
	document.frm.Entry.value = strentry;
	document.frm.action = C_VIP1000_Url+"/asp/vipsearch.asp";
	document.frm.target="_top";
	document.frm.submit();
}

function SelectShow()
{
	setCookie("InSearch","In");
	document.frm.S.value = document.getElementById("ShowStyle").value;
	document.frm.action = "/search/sear.dll?NEW_SearchZK";
	document.frm.target="_self";
	document.frm.submit();
}
function SelectSJ()
{
	setCookie("InSearch","In");
	document.frm.SJ.value = document.getElementById("ShowSJ").value;
	document.frm.action = "/search/sear.dll?NEW_SearchZK";
	document.frm.target="_self";
	document.frm.submit();
}
function Href(f,p)
{
	setCookie("InSearch","In");
	document.frm.P.value = p;
	document.frm.action = "/search/sear.dll?NEW_SearchZK";
	document.frm.target="_self";
	document.frm.submit();
}

function WriterSearch(writer)
{	
	setCookie("newSearchWord",writer);
	setCookie("InSearch","In");
	document.frm.Entry.value="A";
	document.frm.E.value = "Writer=" + writer;
	document.frm.M.value = writer;
	document.frm.H.value = writer;
	document.frm.From.value = "1";
	document.frm.action = C_VIP1000_Url+"/asp/vipsearch.asp";
	document.frm.target="_top";
	document.frm.submit();
}
function JGSearch(jg)
{
	setCookie("newSearchWord",jg);
	setCookie("InSearch","In");
	document.frm.Entry.value="S";
	document.frm.E.value = "Organ=" + jg;
	document.frm.M.value = jg;
	document.frm.H.value = jg;
	document.frm.From.value = "1";
	document.frm.action = C_VIP1000_Url+"/asp/vipsearch.asp";
	document.frm.target="_top";
	document.frm.submit();
}
function GJCSearch(gjc)
{
	setCookie("newSearchWord",gjc);
	setCookie("InSearch","In");
	document.frm.Entry.value="K";
	document.frm.E.value = "KeyWord_C=" + gjc;
	document.frm.M.value = gjc;
	document.frm.H.value = gjc;
	document.frm.From.value = "1";
	document.frm.action = C_VIP1000_Url+"/asp/vipsearch.asp";
	document.frm.target="_top";
	document.frm.submit();
}
function SameSearch(gjc)
{
	setCookie("newSearchWord",gjc);
	setCookie("InSearch","In");
	document.frm.Entry.value="K";
	document.frm.E.value =  "KeyWord_C=" + gjc;
	document.frm.M.value = gjc;
	document.frm.H.value = gjc;
	document.frm.From.value = "";
	document.frm.action = C_VIP1000_Url+"/asp/vipsearch.asp";
	document.frm.target="_top";
	document.frm.submit();
}
function FLHSearch(flh)
{
	var strFL = null;
	strFL = flh.replace(/-/g,"%0X002D%");
	setCookie("newSearchWord",flh);
	setCookie("InSearch","In");
	document.frm.Entry.value="C";
	document.frm.E.value = "Class=[" + strFL;
	document.frm.M.value = flh;
	document.frm.H.value = flh;
	document.frm.From.value = "1";
	document.frm.action = C_VIP1000_Url+"/asp/vipsearch.asp";
	document.frm.target="_top";
	document.frm.submit();
}

/*通用函数*/
//获取对象坐标
function getSelectPosition(obj)
{
	var objLeft = getObjLeft(obj);
	var objTop = getObjTop(obj);
	return([objLeft,objTop]);
}
function getObjLeft(obj)
{
	var topnum = 0;
	var parentObj = obj.parentNode;
	while (!isNaN(parentObj.offsetLeft))
	{
		topnum += parentObj.offsetLeft;
		parentObj = parentObj.parentNode;
	}
	return topnum;
}

function getObjTop(obj)
{
	var topnum = 0;
	var parentObj = obj.parentNode;
	while (!isNaN(parentObj.offsetTop))
	{
		topnum += parentObj.offsetTop;
		parentObj = parentObj.parentNode;
		if(parentObj.id == "pD") break;
	}
	return topnum;
}

// *********************************************************************************** //
// 头部控件专用 function 
// --------------
// 功能：控制下拉菜单
// 传入参数：
//              
// 传出结果：    

// *********************************************************************************** //

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 setSelInput(seltype)
{   	
    if(!optionDiv)
    {
        return;
    }
    var SearchS = getCookie(seltype);
    var SearchStr = SearchS;
    if(SearchS != null)
    {
        var OptionText = SearchS.split("|");
    }
    else
    {
        SearchS = "";
        var OptionText = SearchS.split("|");
    }
    //下拉菜单主体
    var selectDiv = document.getElementById("imgSel1");
	if(!selectDiv)
		return;
    //外层Div
    if(optionDiv && optionDiv.childNodes.length>0)
    {
        for(var i=optionDiv.childNodes.length-1;i>=0;i--)
        {
            var DelOption = optionDiv.childNodes[i];
            optionDiv.removeChild(DelOption);
        }
    }
    //设置下拉菜单选项的坐标和宽度
    with(optionDiv.style)
	{
	    optionDiv.className = "optionDiv";
		var inputsel = document.getElementById("inputSel");
		if(!inputsel)
			return;
		var x = moveXbySlicePos(0,inputsel);
		var y = moveYbySlicePos(inputsel.offsetHeight?inputsel.offsetHeight:20,inputsel);
		optionDiv.style.width = inputsel.offsetWidth+"px";
		optionDiv.style.left = x+1+"px";
		optionDiv.style.top = y+"px";
    }
    //下拉菜单内容
    var OptionUl = optionDiv.appendChild(document.createElement("ul"));
    var Options = new Array(); 
    if(SearchStr != null)
    {
    	for (var i=0;i<OptionText.length;i++)
		{
	    	Options[i] = OptionUl.appendChild(document.createElement("li"));
    	}    
    }
	else
	{
		for (var i=0;i<OptionText.length-1;i++)
		{
	    	Options[i] = OptionUl.appendChild(document.createElement("li"));
    	}    
	}
    for (i=0;i<Options.length;i++)
	{
	    Options[i].innerHTML = "<i><a href=\"javascript:deloption('" + OptionText[i] + "','" + seltype +   "')\"><img src='/images/delcookie.gif' alt='' border='0'></a></i>" + OptionText[OptionText.length-i-1];
    }
    
    /*事件*/
    //禁止选择文本
    selectDiv.onselectstart = function() {return false;}
    optionDiv.onselectstart = function() {return false;}

    for (i=0;i<Options.length;i++) 
    {
	    Options[i].attachEvent("onmouseover",function(){moveWithOptions("highlight","white")});
	    Options[i].attachEvent("onmouseout",function(){moveWithOptions("","")});
	    Options[i].attachEvent("onmouseup",selectedText);
    }
	isInitTopicLoad = true;
}

function deloption(opt,seltype)
{
    var SearchS = getCookie(seltype);
    if(SearchS != null)
    {
        var reg;
        if(SearchS.lastIndexOf("|")>0)
        {    
        	if(SearchS.lastIndexOf(opt) == 0)
        	{
            	reg = new RegExp(opt + "\\|");
        	}
        	else
        	{
            	reg = new RegExp( "\\|" + opt);
        	}
        }
    	else
    	{
    		reg = new RegExp(opt);
    	}
        SearchS = SearchS.replace(reg,"");
        setCookie(seltype,SearchS);
        setSelInput(seltype);
    }
}

function SelOptions()
{
	try
	{
		if(!isInitTopicLoad)
			InitTopicTop();
		event.cancelBubble = true;
		optionDiv.style.visibility = optionDiv.style.visibility=="visible"?"hidden":"visible";
		var inputsel = document.getElementById("inputSel");
		if(inputsel!=null)
		{
			var x = moveXbySlicePos(0,inputsel);
			var y = moveYbySlicePos(inputsel.offsetHeight?inputsel.offsetHeight:20,inputsel);
			optionDiv.style.width = inputsel.offsetWidth-10+"px";
			optionDiv.style.left = x+1+"px";
			optionDiv.style.top = y-2+"px";
		}
	}
	catch(e)
	{}
}
//移动Option时的动态效果

function moveWithOptions(bg,color)
{
	with(event.srcElement)
	{
		style.backgroundColor = bg;
		style.color = color;
	}
}

function selectedText()
{
	with(event.srcElement)
	{
		document.getElementById("inputSel").value = innerText;
	}
}


String.prototype.trimBoth = function()
{
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

//根据属性设置选择显示初始的页头
function InitTopicTop()
{
	var itemDiv = document.getElementById("itemDiv");
	if(!itemDiv || isInitTopicLoad)
		return;
    var seaType = getCookie("newSearchType");
    var seaInSearch = getCookie("InSearch");
    var seaValue = getCookie("newSearchWord");
		
    if(seaValue != null && seaValue != "")
    {
    	if(seaInSearch =="In")
    	{
        	document.getElementById("inputSel").value = seaValue;
      }
    }
	
    setCookie("InSearch","Out");
    setSelInput("SearchText");
	itemDiv.style.visibility="hidden";
	var itemEls = itemDiv.getElementsByTagName("div");
	if(itemEls)
		OnSelSearchItem(itemEls[0]);
	SetSelText();
	RestoreInfo();
}

function RestoreInfo()
{
	try
	{
		SaveInfo = document.frm.SaveInfo.value;
		var saveInfo=SaveInfo.split("|");
		if(saveInfo.length>0 && saveInfo[0] !="")
		{
			document.getElementById("BeginYear0").value = saveInfo[0];
		}
		if(saveInfo.length>1 && saveInfo[1] !="")
		{
			document.getElementById("EndYear0").value = saveInfo[1];
		}
		if(saveInfo.length>2 && saveInfo[2] !="")
		{
			document.getElementById("Entry0").value = saveInfo[2];
		}
		if(saveInfo.length>3 && saveInfo[3] !="")
		{
			if(saveInfo[3] =="ResetSearch")
			{
				document.getElementById("ResetSearch").checked = true;
			}
			else if(saveInfo[3] == "ResultSearch")
			{
				document.getElementById("ResultSearch").checked = true;
			}
			else if(saveInfo[3] == "AddSearch")
			{
				document.getElementById("AddSearch").checked = true;
			}
			else if(saveInfo[3] == "DelSearch")
			{
				document.getElementById("DelSearch").checked
			}
		}
	}
	catch(e)
	{}
}

function SetSelText()
{
	try
	{
		var entry0 = document.getElementById("Entry0");
		if(!entry0)
			return;
		var selIndex = entry0.selectedIndex;
		var selEle = document.getElementById("selectSel");
		selEle.value = entry0.options[selIndex].text;
		selEle = document.getElementById("selectSel_t");
		if(selEle)
			selEle.value = entry0.options[selIndex].text;
	}
	catch(e)
	{}
}


function ResetPosition()
{
	var itemDiv = document.getElementById("itemDiv");
	if(itemDiv.style.visibility == "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+"px";
			itemDiv.style.top = y+"px";
		}
	}
	
	if(optionDiv && optionDiv.style.visibility == "visible")
	{
		var inputsel = document.getElementById("inputSel");
		if(inputsel!=null)
		{
			var x = moveXbySlicePos(0,inputsel);
			var y = moveYbySlicePos(inputsel.offsetHeight?inputsel.offsetHeight:20,inputsel);
			optionDiv.style.width = inputsel.offsetWidth+14+"px";
			optionDiv.style.left = x+"px";
			optionDiv.style.top = y+"px";
		}
	}
}

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,'"');	
	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)=='"')
			{//状态变为1
				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;
}

//字符串替换函数
function replace(expression,find,replacewith)   
{   
    var   blnFlag;
    if(expression=="")
        blnFlag=false;
    else   
    {   
        var loc=expression.indexOf(find);
        var findLen=find.length;
        var replaceWithLen=replacewith.length;

        if(loc!=-1)
            blnFlag = true;
        else
            blnFlag =false;

        while(blnFlag)   
        {   
            expression = expression.substr(0,loc)+replacewith+expression.substr(loc+findLen);   
            loc = expression.indexOf(find,loc+replaceWithLen);   
            if(loc == -1)  blnFlag   =   false;   
        }   
    }   
    return expression;   
}

function SelSelect()
{
	event.cancelBubble = true;
	var itemDiv = document.getElementById("itemDiv");
	if(!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 TailSel()
{
	event.cancelBubble = true;
	var itemDiv = document.getElementById("itemDiv");
	itemDiv.Flag="tail";
	itemDiv.style.visibility = itemDiv.style.visibility=="visible"?"hidden":"visible";
	var itemsel_t = document.getElementById("selectSel_t");
	if(itemsel_t!=null)
	{
		var x = moveXbySlicePos(0,itemsel_t);
		var y = moveYbySlicePos(itemsel_t.offsetHeight?itemsel_t.offsetHeight:20,itemsel_t);
		itemDiv.style.width = itemsel_t.offsetWidth+"px";
		itemDiv.style.left = x+"px";
		itemDiv.style.top = y+"px";
	}
}

function OnSelSearchItem(curEle)
{
	if(curEle)
	{
		var itemDiv = document.getElementById("itemDiv");
		var entry0 = document.getElementById("Entry0");
		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";
		for(var i=0;i<entry0.length;i++)
		{
			if(entry0.options[i].value==curEle.value)
			{
				entry0.options[i].selected=true;
				break;
			}
		}
		if(itemDiv.Flag=="header")
		{
			var selEle = document.getElementById("selectSel");
			if(selEle)
				selEle.value = curEle.innerText;
		}
		else
		{
			var selEle = document.getElementById("selectSel_t");
			if(selEle)
				selEle.value = curEle.innerText;
		}
		itemDiv.style.visibility="hidden";
	}
	return false;
}

function OnSItemMouseOver(curEle)
{
	var itemDiv = document.getElementById("itemDiv");
	var itemEls = itemDiv.getElementsByTagName("div");
	if(itemEls)
	{
		for(var i=0;i<itemEls.length;i++)
		{
			if(itemEls[i].className != "S_ItemSelected")
				itemEls[i].className = "S_Item_Normal";
		}
	}
	curEle.className="S_Item_Focus";
}

function OnSItemMouseOut(curEle)
{
	curEle.className="S_Item_Normal";
}

function ClearInputSel(){
	if(typeof(document.getElementById("inputSel"))!='undefined'){
		var inputSel = document.getElementById("inputSel");
		if(inputSel.value.trimBoth() == "搜尽8000余种期刊文章……"){
			inputSel.value = "";
		}
	}
}