//window.onerror=function(){return true;};
String.prototype.trim = function() {
    return this.replace(/(^\s+)|(\s+$)/g, "");
}
function $(A){
    return document.getElementById(A)
}
  
 function Cookie(){
  this.SetValue=function(name,value,hours,path,domain){
    var str=new String();
    var nextTime=new Date();
    nextTime.setHours(nextTime.getHours()+hours);
    str=name+"="+escape(value);
    if(hours)
      str+=";expires="+nextTime.toGMTString();
    if(path)
      str+=";path="+path;
    if(domain)
      str+=";domain="+domain;
    document.cookie=str;
    }
  this.GetValues=function(name){
  	 var rs=new RegExp("(^|)"+name+"=([^;]*)(;|$)","gi").exec(document.cookie),tmp;
    if(tmp=rs)
      return unescape(tmp[2]);
    return null;
    }
  
  this.GetValue=function(name){
  	var cookies=this.GetValues("duxiu");
	  	if(cookies!=null){
	  		var arrCookie=cookies.split(",!");
  			for(var i=0;i<arrCookie.length;i++){
					if((arrCookie[i].split(",=")[0])== name ){
						return arrCookie[i].split(",=")[1];
						break;
					}
			  }
	  		return this.GetValues(name);
	  		}else{
	  			return this.GetValues(name);
	  		}
	  	
    }
  }
  
String.prototype.replaceAll = function(search, replace){
 var regex = new RegExp(search, "g");
 return this.replace(regex, replace);
}

function selectall(box,checkboxid){
	var che;
	if(box.checked == false)
		che = false;
	else
		che =true;
	var checkbox = document.getElementsByName(checkboxid);
	for(var i = 0 ; i < checkbox.length ; i ++)
		checkbox[i].checked = che;
}

function isSearch(obj) {
	var s=$("sw").value.trim();
	var patrn="\\||\\!|\\@|\\#|\\$|\\%|\\^|\\&|\\*|\\(|\\)|\\_|\\+|\\-|\\}|\\{|\\/|\\.|\\,|\\?|\\>|\\<|\\~|\\、|\\】|\\【|\\‘|\\；|\\’|\\、|\\。|\\，|\\￥|\\……|\\）|\\（|\\！";
	s=s.replaceAll(patrn,"");
	if($("topchannel")){
			$("topchannel").value=$("topchannel").value.replaceAll("searchF","search");
		if($("topchannel").value=="searchBook"){
			$("topchannel").value = "search";
		}
	}
	if(s=='')
	return false
	else
	return true
}
function istopSearch(obj) {
	if($("topbCon").value!="y")
		$("topallsw").value="";
	var s=$("topsw").value.trim();
	var patrn="\\||\\!|\\@|\\#|\\$|\\%|\\^|\\&|\\*|\\(|\\)|\\_|\\+|\\-|\\}|\\{|\\/|\\.|\\,|\\?|\\>|\\<|\\~|\\、|\\】|\\【|\\‘|\\；|\\’|\\、|\\。|\\，|\\￥|\\……|\\）|\\（|\\！";
	s=s.replaceAll(patrn,"");
	$("topchannel").value=$("topchannel").value.replaceAll("searchF","search");
	if($("topchannel").value=="searchBook"){
		$("topchannel").value = "search";
	}
	if(s=='')
	return false
	else
	return true
}

function bSearch(fenlei){
  $("topfenleiID").value=fenlei;
  //$("topallsw").value+=" "+$("topsw").value;
	$("topbCon").value='y';
	$("topuserinput").submit();
}
function seSearch(fenlei){
  $("topfenleiID").value=fenlei;
  //$("topallsw").value+=" "+$("topsw").value;
	$("topbCon").value='y';
	$("topuserinput").submit();
}

function search(){
	$("topallsw").value='';
	var s=$("topsw").value.trim();
	var patrn="\\||\\!|\\@|\\#|\\$|\\%|\\^|\\&|\\*|\\(|\\)|\\_|\\+|\\-|\\}|\\{|\\/|\\.|\\,|\\?|\\>|\\<|\\~|\\、|\\】|\\【|\\‘|\\；|\\’|\\、|\\。|\\，|\\￥|\\……|\\）|\\（|\\！";
	s=s.replaceAll(patrn,"");
	$("topchannel").value=$("topchannel").value.replaceAll("searchF","search");
	if($("topchannel").value=="searchBook"){
		$("topchannel").value = "search";
	}
	if(!s=='')
		$("topuserinput").submit();
}

function fsearch(){
	if($("topchannel").value=="search" || $("topchannel").value=="serchJour" || $("topchannel").value=="searchStd" || $("topchannel").value=="searchCP" || $("topchannel").value=="searchPatent"){
		if($("topchannel").value=="search"){
				$("topchannel").value="searchFBook";
		}else{
			$("topchannel").value="searchF"+$("topchannel").value.replaceAll("search","");
		}
			$("topuserinput").action="/gosearch.jsp";
		$("topallsw").value='';
		var s=$("topsw").value.trim();
		var patrn="\\||\\!|\\@|\\#|\\$|\\%|\\^|\\&|\\*|\\(|\\)|\\_|\\+|\\-|\\}|\\{|\\/|\\.|\\,|\\?|\\>|\\<|\\~|\\、|\\】|\\【|\\‘|\\；|\\’|\\、|\\。|\\，|\\￥|\\……|\\）|\\（|\\！";
		s=s.replaceAll(patrn,"");
		if(!s=='')
			$("topuserinput").submit();
	}
}

function topsubmit(tag,servlet,tempservlet){
	var s=$("topsw").value.trim();
	var patrn="\\||\\!|\\@|\\#|\\$|\\%|\\^|\\&|\\*|\\(|\\)|\\_|\\+|\\-|\\}|\\{|\\/|\\.|\\,|\\?|\\>|\\<|\\~|\\、|\\】|\\【|\\‘|\\；|\\’|\\、|\\。|\\，|\\￥|\\……|\\）|\\（|\\！";
	s=s.replaceAll(patrn,"");
	if(s==""){
		changeTag(tag,servlet,tempservlet);
		return;
	}
		$("topchannel").value=tempservlet;
		$("topuserinput").action="gosearch.jsp";
	$("topuserinput").submit();
	}

