﻿function JudgeEmpty(){
	var title = document.getElementById("txtTitle").value ;
	var keyword = document.getElementById("txtKeyword").value ;
	var summary = document.getElementById("txtSummary").value ;
	var author = document.getElementById("txtAuthor").value ;
	var source = document.getElementById("txtSource").value ;
	var preYear = document.getElementById("txtPredate").value ;
	var nexYear = document.getElementById("txtNextdate").value ;
	
	var myregx = /^[1,2]{1}\d{3}$/ ;
	
	if(title == "" && keyword == "" && summary == "" && author == "" && source == "" && preYear == "" && nexYear == ""){
		alert("请输入检索词！！") ;
		return false ;
	}
	
	if(preYear != "" && nexYear == ""){
		alert("请输入日期！！") ;
		return false ;
	}
	
	if(preYear == "" && nexYear != ""){
		alert("请输入日期！！") ;
		return false ;
	}
	
	if(preYear != "" && nexYear != "" && title == "" && keyword == "" && summary == "" && author == "" && source == ""){
		alert("请输入检索词！！") ;
		return false ;
	}
	if(parseInt(preYear) > parseInt(nexYear)){
		alert("起始日期大于终止日期！！") ;
		return false ;
	}
	if(preYear != "" && nexYear != ""){
		if(myregx.test(preYear) == false || myregx.test(nexYear) == false){
			alert("年份格式不正确！！") ;
			return false 
		}
	}
	
	return true ;
}
function JudgeEmpty2(){
	var title = document.getElementById("txtTitle").value ;
	var keyword = document.getElementById("txtKeyword").value ;
	var summary = document.getElementById("txtSummary").value ;
	var author = document.getElementById("txtAuthor").value ;
	var source = document.getElementById("txtSource").value ;

	var all = document.getElementById("txtAll").value ;
	var found = document.getElementById("txtFound").value ;
	var unit = document.getElementById("txtUint").value ;

	if(title == "" && keyword == "" && summary == "" && author == "" && source == "" && all == "" && found == "" && unit == ""){
		alert("请输入检索词！！") ;
		return false ;
	}
	return true ;
}
function LinkOtherSearch(SearchType)
{

	if(SearchType == "search")
	{
		str = "http://search.cnki.net/";
		str1 = "search.aspx";
	}
	if(SearchType == "number")
	{
		str = "http://number.cnki.net/";
		str1 = "show_result.aspx";
	}
	if(SearchType == "define")
	{
		str = "http://define.cnki.net/";
		str1 = "define_result.aspx";
	}
	if(SearchType == "dict")
	{
		str = "http://dict.cnki.net/";
		str1 = "dict_result.aspx";
	}
	if(SearchType == "image")
	{
		str = "http://image.cnki.net/";
		str1 = "image_result.aspx";
	}
	if(SearchType == "trend")
	{
		str = "http://trend.cnki.net/";
		str1 = "trendshow.php";
	}

	var strSearch = document.getElementById("searchId").value ;
	if(strSearch=="")
	{
		window.location = str;
	}
	else
	{
		window.location = str + str1 + "?searchword=" + encodeURIComponent(strSearch);
	}
}


function searchDetail(searchValue, aValue)
{
	var strValue = document.getElementById(searchValue).value ;
	reg = /\+|,|\'|\"|\*|~|!|\@|#|\$|%|\^|\&|\(|\)|\{|\}|<|>|\?|\|/g;//'
	strValue = unescape(strValue).replace(reg,"");
					
	if(strValue=="")
	{															
		alert("请重新输入检索词进行查询!");
		return false;
	}
//	if(aValue != ""){
//		document.getElementById(aValue).style.background = "#0000ff" ;
//	}

//	document.getElementById("searchId").value = strValue ;
	document.getElementById("q").value = strValue ;//all
	//document.Form1.action = "search.aspx?q="+encodeURIComponent(strValue)+"&rank=relevant&cluster=all&val=&p=0&number=0";
	document.Form1.action = "search.aspx?q="+encodeURIComponent(strValue) ;
	document.Form1.submit() ; 
}

function Button1_onclick(searchValue, aValue) {
	var strValue = document.getElementById(searchValue).value ;
	reg = /\+|,|\'|\"|\*|~|!|\@|#|\$|%|\^|\&|\(|\)|\{|\}|<|>|\?|\|/g;//'
	strValue = unescape(strValue).replace(reg,"");
	
	if(strValue=="")
	{															
		alert("请输入检索词进行高级查询!");
		return false;
	}
//	if(aValue != ""){
//		document.getElementById(aValue).style.background = "#0000ff" ;
//	}

//	document.getElementById("searchId").value = strValue ;
	var t = document.getElementById("q").value;
	strValue = t + " " + strValue;
	document.getElementById("q").value = strValue ;//all
	//document.Form1.action = "search.aspx?q="+encodeURIComponent(strValue)+"&rank=relevant&cluster=all&val=&p=0&number=0";
	document.Form1.action = "search.aspx?q="+encodeURIComponent(strValue) ;
	document.Form1.submit() ; 
}

function searchDetail1(searchValue, aValue)
{
	var strValue = document.getElementById(searchValue).value ;
	reg = /\+|,|\'|\"|\*|~|!|\@|#|\$|%|\^|\&|\(|\)|\{|\}|<|>|\?|\|/g;//'
	strValue = unescape(strValue).replace(reg,"");
	
	if(strValue=="")
	{															
		alert("请重新输入检索词进行查询!");
		return false;
	}
//	if(aValue != ""){
//		document.getElementById(aValue).style.background = "#0000ff" ;
//	}

//	document.getElementById("searchId").value = strValue ;
	document.getElementById("q").value = strValue ;//all
	//document.Form1.action = "search.aspx?q="+encodeURIComponent(strValue)+"&rank=relevant&cluster=all&val=&p=0&number=0";
	document.Form1.action = "search.aspx?q="+encodeURIComponent(strValue) ;
	document.Form1.submit() ; 
}

function searchBurlcontent(searchValue, aValue)
{
	var strValue = document.getElementById(searchValue).value ;

	reg = /\+|,|\'|\"|\*|~|!|\@|#|\$|%|\^|\&|\(|\)|\{|\}|<|>|\?|\|/g;//'
	strValue = unescape(strValue).replace(reg,"");
	
	if(strValue=="")
	{
		alert("请重新输入检索词进行查询!");
		return false;
	}
	//if(aValue != ""){
	//	document.getElementById(aValue).style.background = "#0000ff" ;
	//}

	//document.getElementById("searchId").value = strValue ;
	document.getElementById("searchburlId").value = strValue ;
	document.getElementById("q").value = strValue ;
	document.Form1.action = "search.aspx?q="+encodeURIComponent(strValue) ;
	document.Form1.submit() ;
}

function advancedSearch(advancedS, aValue, advancedId){
	var strValue = document.getElementById(advancedS).value ;
	
	reg = /\+|,|\'|\"|\*|~|!|\@|#|\$|%|\^|\&|\(|\)|\{|\}|<|>|\?|\|/g;//'
	strValue = unescape(strValue).replace(reg, "") ;
	
	if(strValue==""){
		alert("请重新输入检索词进行查询!") ;
		return false ;
	}
	document.getElementById("searchId").value = strValue ;
	document.getElementById("q").value = strValue ;
	document.getElementById("b").value = "true" ;
	document.Form1.action = "search.aspx?q="+encodeURIComponent(strValue) ;
	document.Form1.submit() ;
}

function advancedSearch1(advancedS, aValue){
	var strValue = document.getElementById(advancedS).value ;
	
	reg = /\+|,|\'|\"|\*|~|!|\@|#|\$|%|\^|\&|\(|\)|\{|\}|<|>|\?|\|/g;//'
	strValue = unescape(strValue).replace(reg, "") ;
	
	if(strValue==""){
		alert("请重新输入检索词进行查询!") ;
		return false ;
	}
	
	document.getElementById("searchId").value = strValue ;
	document.getElementById("q").value = strValue ;
	document.getElementById("b").value = "true" ;
	document.getElementById("searchfootId").value = strValue ;
	document.Form1.action = "search.aspx?q="+encodeURIComponent(strValue);
	document.Form1.submit() ;
}

function SetSearchPositionValue(searchPositionValue){
	switch(searchPositionValue){
		case "relevant" :
			var bool = AjaxClass.GetSearchStation(searchPositionValue).value ;
			break ;
		case "title" :
			var bool = AjaxClass.GetSearchStation(searchPositionValue).value ;		
			break ;
		case "keyword" :
			var bool = AjaxClass.GetSearchStation(searchPositionValue).value ;			
			break ;
		case "author_search" :
			var bool = AjaxClass.GetSearchStation(searchPositionValue).value ;		
			break ;
		case "abstract" :
			var bool = AjaxClass.GetSearchStation(searchPositionValue).value ;			
			break ;	
		default :
			break ;
	}
}

function SetCompositor(compositorValue){
	switch(compositorValue){
		case "relevant" :
			var bool = AjaxClass.GetCompositor(compositorValue).value ;
			break;
		case "citeNumber" :
			var bool = AjaxClass.GetCompositor(compositorValue).value ;		
			break ;
		case "exp" :
			var bool = AjaxClass.GetCompositor(compositorValue).value ;		
			break ;
		case "date" :
			var bool = AjaxClass.GetCompositor(compositorValue).value ;		
			break ;
		case "author_rank" :
			var bool = AjaxClass.GetCompositor(compositorValue).value ;
			break ;
		default :
			break ;
	}
}

function SetClusterValue(clusterValue, valValue){
	var searchValue = document.getElementById("searchId").value ;
	document.getElementById("hidden_keyword").value = searchValue ;
	document.getElementById("hidden_search").value = searchValue ;
	document.getElementById("hidden_cluster").value = clusterValue ;
	document.getElementById("hidden_val").value = valValue ;
	
	document.Form1.action = "search.aspx" ;
	document.Form1.submit() ;
}

function TurnPage(searchKeyword, searchRank, searchCluster, searchVal, searchP){
	var searchValue = document.getElementById("searchId").value ;
	alert(searchValue) ;
	
	document.getElementById("hidden_keyword").value = searchKeyword ;
	document.getElementById("hidden_search").value = searchValue ;
	document.getElementById("hidden_rank").value = searchRank ;
	document.getElementById("hidden_cluster").value = searchCluster ;
	document.getElementById("hidden_val").value = searchVal ;
	document.getElementById("hidden_p").value = searchP ;
	
	document.Form1.action = "search.aspx" ;
	document.Form1.submit() ;
}

function SetAuthorValue(authorValue){
	document.getElementById("hidden_keyword").value = authorValue ;
	document.getElementById("hidden_search").value = "author:" + authorValue ;
	document.Form1.action = "search.aspx" ;
	document.Form1.submit() ;
}

//法律部 点击上部链接跳转
function LinkLawSearch(dir)
{
	var link="/";
	link =link+dir+"/";
	var strSearch = document.getElementById("searchId").value ;
	if(strSearch=="")
	{
		window.location = link;
	}
	else
	{
		window.location = link + "search.aspx?q=" + encodeURIComponent(strSearch);
	}
}

