function uploadPdf(litId,litType){
	modalDlg('../softscience/uploadPdf.jsp?litId='+litId+'&litType='+litType,'上传',780,500,
		function(re){
			if(re){
			}
		}
	);
}
//-------2008 lucene search
function clickCheckBoxDiscipline(checkbox){
	var childTree = xNextSib(xParentNode(checkbox,1));
	var childTreeList = xGetElementsByTagName('INPUT',childTree);
	for(var i=0;i<childTreeList.length;i++){
		childTreeList[i].checked = checkbox.checked
	}
	var parent = xPrevSib(xParentNode(checkbox,2));
	var parentInput = xGetElementsByTagName('INPUT',parent);
	if(parentInput.length>0){
		var sibling = xParentNode(checkbox,2)
		var siblingList = xGetElementsByTagName('INPUT',sibling);
		var allUnChecked = true;
		for(var i=0;i<siblingList.length;i++){
			if(siblingList[i].checked)allUnChecked=false;
		}
		if(allUnChecked)parentInput[0].checked = false
		if(checkbox.checked)parentInput[0].checked = true
	}
	var disciplineIds=getAllCheckBoxValues('disciplineIds');
	if(disciplineIds=='')disciplineIds='0';
	window.location.href=replaceUrl(location.href,'disciplineIds',disciplineIds)
}
function luceneDateFromTo(input){
	if(ge('publishDateFrom').value!=''&&ge('publishDateTo').value!=''){
		var url = replaceUrl(location.href,'publishDateFrom',ge('publishDateFrom').value)
		window.location=replaceUrl(url,'publishDateTo',ge('publishDateTo').value)
	}
	if(ge('publishDateFrom').value==''&&ge('publishDateTo').value==''){
		var url = replaceUrl(location.href,'publishDateFrom',ge('publishDateFrom').value)
		window.location=replaceUrl(url,'publishDateTo',ge('publishDateTo').value)
	}
	return;
}
function luceneAddSearchField(){
	var searchFieldCount = request('searchFieldCount')?request('searchFieldCount'):1
	var searchField = (request('searchField')?request('searchField'):'title')+',title';
	var andOrNot = (request('andOrNot')?request('andOrNot'):'AND')+',AND';
	var keyword = jsEncode(jsDecode(request('keyword'))+',')
	var url = replaceUrl(location.href,'searchFieldCount',++searchFieldCount);
	var url = replaceUrl(url,'searchField',searchField);
	var url = replaceUrl(url,'andOrNot',andOrNot);
	var url = replaceUrl(url,'keyword',keyword);
	window.location=url;
}
function luceneSearchDateOnchange(value){
	if(value==''){
		var url = replaceUrl(location.href,'publishDateOption','')
		url = replaceUrl(url,'publishDateFrom','')
		window.location=replaceUrl(url,'publishDateTo','')
	}else if(value==1){
		var url = replaceUrl(location.href,'publishDateOption','1')
		url = replaceUrl(url,'publishDateFrom',ge('lastMonthToday').value)
		window.location=replaceUrl(url,'publishDateTo',ge('today').value)
	}else if(value==2){
		var url = replaceUrl(location.href,'publishDateOption','2')
		url = replaceUrl(url,'publishDateFrom',ge('lastYearToday').value)
		window.location=replaceUrl(url,'publishDateTo',ge('today').value)
	}
}
function luceneDelSearchField(){
	var searchFieldCount = request('searchFieldCount')?request('searchFieldCount'):1
	if(searchFieldCount>1){
		var searchField = request('searchField');
		searchFieldArr = searchField.split(',')
		var newSearchField = '';
		for(var i=0;i<searchFieldArr.length-1;i++){
			newSearchField += searchFieldArr[i] + (i==searchFieldArr.length-2?'':',')
		}
		
		var andOrNot = request('andOrNot');
		andOrNotArr = andOrNot.split(',')
		var newAndOrNot = '';
		for(var i=0;i<andOrNotArr.length-1;i++){
			newAndOrNot += andOrNotArr[i] + (i==andOrNotArr.length-2?'':',')
		}
		
		var keyword = jsDecode(request('keyword'));
		keywordArr = keyword.split(',')
		var newKeyword = '';
		for(var i=0;i<keywordArr.length-1;i++){
			newKeyword += keywordArr[i] + (i==keywordArr.length-2?'':',')
		}
		var url = replaceUrl(location.href,'searchFieldCount',--searchFieldCount)
		url = replaceUrl(url,'searchField',newSearchField)
		url = replaceUrl(url,'andOrNot',newAndOrNot)
		url = replaceUrl(url,'keyword',jsEncode(newKeyword))
		window.location=url
	}
}
function luceneSearch(){
	var searchFieldCount = request('searchFieldCount')?request('searchFieldCount'):1
	var searchField = ''
	for(var i=0;i<searchFieldCount;i++)
		searchField += (i>0?',':'') + ge('searchField'+i).value
	var url=replaceUrl(location.href,'searchField',searchField)
	
	var andOrNot = ''
	for(var i=0;i<searchFieldCount;i++){
		andOrNot += (i>0?',':'') + ge('andOrNot'+i).value
	}
	url=replaceUrl(url,'andOrNot',andOrNot)
	
	var keyword = ''
	for(var i=0;i<searchFieldCount;i++){
		keyword += (i>0?',':'') + encode64(ge('keyword'+i).value)
	}
	url=replaceUrl(url,'pageNo',1)
	window.location=replaceUrl(url,'keyword',jsEncode(keyword))
}


//-------2008 tab
function exclude(id){
	var excludeIds = request('excludeIds')
	excludeIds += id+','
	window.location = replaceUrl(window.location.href,'excludeIds',excludeIds)
}
function statsVisit(infoTypeId,infoId,infoTitle){
	ajax('../stats.do?action=visit','infoTypeId='+infoTypeId+'&infoId='+infoId+'&infoTitle='+infoTitle,null,
		function(re){},
		function(re){}
		)
}
function statsDownloadFile(url,infoTypeId,infoId,infoTitle){
	ajax('../stats.do?action=download','infoTypeId='+infoTypeId+'&infoId='+infoId+'&infoTitle='+jsEncode(infoTitle),null,
		function(re){},
		function(re){}
		)
	window.location = url
}
function statsDownload(url,infoTypeId,infoId,infoTitle){
	ajax('../stats.do?action=download','infoTypeId='+infoTypeId+'&infoId='+infoId+'&infoTitle='+jsEncode(infoTitle),null,
		function(re){},
		function(re){}
		)
	window.location = url
}
function validateEmpty(){
	for(var i=0; i<arguments.length; i++) {
		var e = arguments[i]
	    if(xTrim(e.value)==''){
	    	alert(e.getAttribute("emptyInfo"));
	    	try{e.focus();}catch(err){}
	    	return false;
	    }
	}
	return true;
}
function clickTab(href){
	var li = xParentNode(href,1)
	li.className = 'current'
	var nextLi = xNextSib(li); 
	var totalCount=1,currentIndex=1;
	while(nextLi && nextLi.tagName=='LI'){
		nextLi.className = '';
		nextLi = xNextSib(nextLi);
		totalCount++;
		currentIndex++;
	}
	var prevLi = xPrevSib(li); 
	while(prevLi && prevLi.tagName=='LI'){
		prevLi.className = '';
		prevLi = xPrevSib(prevLi);
		totalCount++;
	}
	currentIndex = totalCount - currentIndex
	var contentDIV = xNextSib(xParentNode(xParentNode(li,1),1))
	var contentDivList = xGetElementsByTagName('DIV',contentDIV)
	for(var i=0;i<contentDivList.length;i++){
		contentDivList[i].className = (i==currentIndex?'':'dn')
	}
}
//-------2008 弹出窗口
function modalDlgDiv(){
	ajax('list.jsp',null,null,function(responseText){
	theWindow = createWindow('window1','选择物品',
	'<DIV style="width:100%;margin-top:10px;height:400px;border-bottom:1px solid #CCCCCC;overflow:auto;" id=contentDIV>'+responseText+'</DIV>',600,400,function(){})
	},function(){})
}
function modalDlgWin(funcClose){
	var width=900, height=540, title="选单录入", url='../user/deptAdd.jsp';
	modalDlg(url,title,width,height,funcClose)
	
}	
function modalDlg(url,title,width,height,funcClose){
    if(window.showModalDialog){
       var returnVal = window.showModalDialog("../public/select.jsp?pageTitle="+jsEncode(title)+"&url="+jsEncode(url)+'&time='+(new Date()).getTime(), "", "dialogWidth:"+width+"px; dialogHeight:"+height+"px; status:no;scrollbars:yes;resizable=yes;");
       funcClose(returnVal);
    }else{//Firefox unable to get return value
       var w=window.screen.width;   
       var h= window.screen.height;   
       var wintop= (h - height)/2;   
       var winleft= (w- width)/2;   
       window.myAction=this; 
       var DialogWin = window.open(url, 'write',"top="+wintop+",left="+winleft+',width='+width+'px,height='+height+'px,modal=yes,resizable=yes,scrollbars=yes');
       window.onclick=function (){DialogWin.focus()}; 
       DialogWin.onbeforeunload = function(){funcClose(DialogWin.returnValue)}
    }
}
//-------2008 列表
function fillList(div,listUrl){
	//listUrl += '?showAt='+div;
	listUrl = replaceUrl(listUrl,'showAt',div);
	listUrl += '&' + jsDecode(request(div))
	ajax(listUrl,null,div,
		function(responseText){
			xGetElementById(div).innerHTML = responseText
			//xGetElementById(div).scrollIntoView()
		},
		function(responseText){
			xGetElementById(div).innerHTML = '<img src="../images/warn.gif">服务器响应出错<br><img src="../images/div_expand.gif" onclick="showDiv(this.nextSibling)" ><a href="javascript:void(0)" onclick="showDiv(this)">显示错误原因</a><DIV style="display:none;height:200px;overflow:auto">'+responseText+'</DIV>'
			//xGetElementById(div).scrollIntoView()
		}
	)
}
function searchByKeyword(searchField, keyword,div,listUrl){
	var url = location.href;
	if(div){
		if(location.href.indexOf('#section')==-1)
			url += '#section=listDIV';
		url = url.replace('#','?')
		url = replaceUrl(url,div,jsEncode('pageNo=1&searchField='+searchField+'&keyword='+jsEncode(keyword)))
		url = url.replace('?','#')
		window.location = url
		fillList(div,listUrl)
	}else{
		url = replaceUrl(url,'pageNo',1);
		url = replaceUrl(url,'searchField',searchField);
		url = replaceUrl(url,'keyword',jsEncode(keyword));
		window.location = url
	}
}
function sort(sortName,sortDirection,div,listUrl){
	var url = location.href;
	if(div){
		if(location.href.indexOf('#section')==-1)
			url += '#section=listDIV';
		url = url.replace('#','?')
		url = replaceUrl(url,div,jsEncode('pageNo=1&sortName='+sortName+'&sortDirection='+sortDirection))
		url = url.replace('?','#')
		window.location = url
		fillList(div,listUrl)
	}else{
		url = replaceUrl(url,'pageNo',1);
		url = replaceUrl(url,'sortName',sortName);
		url = replaceUrl(url,'sortDirection',sortDirection);
		window.location = url
	}
}
function pageTo(pageNo,div,listUrl){
	var url = location.href;
	if(div){
		if(location.href.indexOf('#section')==-1)
			url += '#section=listDIV';
		url = url.replace('#','?')
		url = replaceUrl(url,div,jsEncode('pageNo='+pageNo))
		url = url.replace('?','#')
		window.location = url
		fillList(div,listUrl)
	}else{
		url = replaceUrl(url,'pageNo',pageNo)
		window.location = url
	}
}
function showWaitingDiv(div){
	try{
		var waitingDiv = xGetElementById('waitingDivOf'+div)
		if(!waitingDiv){
			waitingDiv = xCreateElement('DIV');
			waitingDiv.innerHTML = '<img src="../images/waiting_green.gif">';
			xStyle('position','absolute',waitingDiv)
			document.body.appendChild(waitingDiv);
			waitingDiv.id = 'waitingDivOf'+div
			xZIndex(waitingDiv,99)
		}else{
			xDisplay(waitingDiv,'')
		}
		waitingDiv.startTime = (new Date()).getTime();
		xMoveTo(waitingDiv,xPageX(div)+xWidth(div)/2-xWidth(waitingDiv)/2,xPageY(div)+xHeight(div)/2-100)
	}catch(ex){}
}
function colseWaitingDiv(div){
	try{
		var consumeTime = ((new Date()).getTime() - xGetElementById('waitingDivOf'+div).startTime)
		if(500>consumeTime)
			window.setTimeout("xDisplay('waitingDivOf"+div+"','none')",500-consumeTime)
		else
			xDisplay('waitingDivOf'+div,'none')
	}catch(ex){}
}
function showAdvanceSearch(href,div){
	xGetElementById(href).className += "_selected"
	var abtop = parseInt(GetAbsoluteLocationEx(xGetElementById(href)).absoluteTop) + parseInt(xGetElementById(href).offsetHeight);
   	var ableft = GetAbsoluteLocationEx(xGetElementById(href)).absoluteLeft-200;	
	xGetElementById(div).style.top = abtop;
	xGetElementById(div).style.left = ableft;
	xMoveTo(div,ableft,abtop)
	xDisplay(div,'')
	//xZIndex(div,1000)
//	alert(xGetElementById(div).innerHTML)
	
}
function hideAdvanceSearch(href,div){
	xGetElementById(href).className = xGetElementById(href).className.replace('_selected','')
	xDisplay(div,'none')
}
function ajax(URL,parameter,waitingDiv,func200,funcError) {
	var timerId = waitingDiv ? setTimeout('showWaitingDiv("'+waitingDiv+'")',100) : null;
	var xmlhttp = createXmlHttp();
	if(xmlhttp){
		xmlhttp.open("post", URL);
        xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8"); 
        xmlhttp.onreadystatechange=function(){
            if(xmlhttp.readyState==4){
                if(waitingDiv){
                	window.clearTimeout(timerId);
					colseWaitingDiv(waitingDiv);
				}
                if(xmlhttp.status == '200'){
                	func200(xmlhttp.responseText)
                }else{
		        	funcError(xmlhttp.responseText)
		        }
	        }
        };
        xmlhttp.send(parameter);
   	}
}
function ajaxCover(URL,parameter,waitingDiv,func200,funcError) {
	var timerId = waitingDiv ? setTimeout('showCoverBody(null,0.01);showWaitingDiv("'+waitingDiv+'")',100) : null;
	var xmlhttp = createXmlHttp();
	if(xmlhttp){
		xmlhttp.open("post", URL);
        xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8"); 
        xmlhttp.onreadystatechange=function(){
            if(xmlhttp.readyState==4){
                if(waitingDiv){
                	window.clearTimeout(timerId);
					colseWaitingDiv(waitingDiv);
				}
                if(xmlhttp.status == '200'){
                	hideCoverBody()
                	func200(xmlhttp.responseText)
                }else{
                	hideCoverBody()
                	funcError(xmlhttp.responseText)
		        }
	        }
        };
        xmlhttp.send(parameter);
   	}
}
function ajaxSync(URL,parameter,waitingDiv,func200,funcError) {
	var timerId = waitingDiv ? setTimeout('showWaitingDiv("'+waitingDiv+'")',100) : null;
	var xmlhttp = createXmlHttp();
	if(xmlhttp){
		xmlhttp.open("post", URL, false);
        xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8"); 
        xmlhttp.send(parameter); 
       	if(xmlhttp.readyState==4){
           	if(waitingDiv){
            	window.clearTimeout(timerId);
				colseWaitingDiv(waitingDiv);
			}
           	if(xmlhttp.status == '200'){
           		func200(xmlhttp.responseText)
           	}else{
     			funcError(xmlhttp.responseText)
     		}
    	}
	}
} 
function createXmlHttp(){
    var xmlhttp,alerted;
    /*@cc_on @*/
    /*@if (@_jscript_version >= 5)
        try {
            xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
        }catch (e) {
        try {
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
        } catch (E) {
            alert("You must have Microsofts XML parsers available")
        }
    }
    @else
        alert("You must have JScript version 5 or above.")
        xmlhttp=false
        alerted=true
    @end @*/
    if (!xmlhttp && !alerted) {
       try {
          xmlhttp = new XMLHttpRequest();
       } catch (e) {
          alert("????????????xmlhttp?")
       }
    }
    return xmlhttp;
}
function request(paras,url){ 
	if(!url) url = location.href; 
	var paraString = url.substring(url.indexOf("?")+1,url.length).split("&"); 
	var paraObj = {} 
	for (i=0; j=paraString[i]; i++){ 
		paraObj[j.substring(0,j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=")+1,j.length); 
	} 
	var returnValue = paraObj[paras.toLowerCase()]; 
	if(typeof(returnValue)=="undefined"){ 
		return ""; 
	}else{ 
		return returnValue; 
	} 
} 
function replaceUrl(oldurl,paramname,pvalue){   
	var   flag=1
	var   reg   =   new   RegExp("(\\?|&)"+   paramname   +"=([^&]*)(&|$)","gi");   
	var   pst=oldurl.match(reg);   
	if((pst==undefined)   ||   (pst==null))   return   (flag==0)?oldurl:(oldurl+((oldurl.indexOf("?")==-1)?"?":"&")+paramname+"="+pvalue);   
	var   t=pst[0];   
	var   retxt=t.substring(0,t.indexOf("=")+1)+pvalue;   
	if(t.charAt(t.length-1)=='&')   retxt+="&";   
	return   oldurl.replace(reg,retxt);  
	//alert(replaceUrl("http://servername/virturlpath/index.asp?a4=123&p2=aa&p3=hh&p4=1","a4","cxz",1));    
} 


//********2007
function Personalize(item,id)
{ 
	var abtop = parseInt(GetAbsoluteLocationEx(item).absoluteTop) + parseInt(item.offsetHeight)+1;
   	var ableft = GetAbsoluteLocationEx(item).absoluteLeft-164;	
	ge('buttonMenu').style.top = abtop;
	ge('buttonMenu').style.left = ableft;
	ge('buttonMenu').style.visibility = 'visible';	
	ge('buttonMenu').innerHTML = getPersonlizeDIV(id); 
	//ge(id).style.cssText="border:2x solid #FF9A00;"
	ge('pageSize').focus();
	ge('pageSize').select();
	
} 
function savePersonalize()
{
	if(ge('pageSize').value!='')
	{
		if(IsInteger(ge('pageSize').value,'+'))
			setMyCookie("pageSize",ge('pageSize').value);
		
	}
	pageRefresh()
}
function getPersonlizeDIV(id){
	var pageSize=getMyCookie('pageSize')
	pageSize = pageSize!=null && pageSize!='' ? pageSize:10; 
	var strHTML = '<DIV class=d4><SPAN class=SelectASize_close><A href="javascript:hideButtonMenu(\''+id+'\');"><IMG src="../Images/close.gif"></A></span></DIV>';
	strHTML +=  '<DIV class=d3>每页显示<input id="pageSize" onkeydown="personalizeOnkeydown()" type="text" value="'+pageSize+'" size=6 class="textboxAlignR1">行</DIV>';
	strHTML +=  '<DIV style="padding:0 10 20 120px"><a class=linkbg href="javascript:savePersonalize()">确定</a>    <A class=linkbg href="javascript:hideButtonMenu(\''+id+'\');">取消</a></DIV>';
	return strHTML;
}  
function personalizeOnkeydown()
{
	if(window.event.keyCode==13)
		savePersonalize()
}
function hideButtonMenu(id)
{ 
	ge('buttonMenu').style.visibility = 'hidden'; 
	ge(id).style.cssText="BORDER-RIGHT: #555555 1px solid;BORDER-BOTTOM: #555555 1px solid;"	
}
