//function killErrors() {return true;}
//window.onerror = killErrors;
//去除左右两端的空格
function trim(s)  
{return  s.replace(/(^\s*)|(\s*$)/g,  "");} 

function postform(obj){
var obj2=document.getElementsByName("vote");
for(var i=0;i<obj2.length;i++){
	if(obj2[i].checked==true){
	temp=1;
	break;
	}else{
	temp=0;
	}
}
if(temp==0){alert("请选择");return false;}
}

function checksearch()
{
	if (trim(document.search.key.value)=='')
	{alert('关键字不能为空');
	document.search.key.focus();
	document.search.key.value='';
	return false
	}
	if (document.search.key.value=='请输入关键字')
	{alert('关键字不能为空');
	document.search.key.focus();
	document.search.key.value='';
	return false
	}
}

function checkcomment(theform)
{
	if (trim(theform.username.value)=='')
	{alert('姓名不能为空');
		theform.username.focus();
		theform.username.value='';
		return false
	}
	if (trim(theform.content.value)=='')
	{alert('评论内容不能为空');
		theform.content.focus();
		theform.content.value='';
		return false
	}
	var param;
	param=webdir+"plug/comment.asp?action=save";
	param += "&username=" + escape(trim(theform.username.value));
	param += "&content=" + escape(trim(theform.content.value));
	param += "&id=" + escape(trim(theform.id.value));
	$("showmsg").style.display='inline';
	$("showmsg").innerHTML="<img src="+webdir+"editor/loading.gif>　数据处理中";
	SendRequest(param, param, "POST", 
                function(responseText){
					var f	= responseText.substring(0,1);
					if (f == "1"){
						$("showmsg").innerHTML =responseText.substring(1);
						$("username").value='';
						$("content").value='';
						return false
					}
					if (f == "2"){
						$("showmsg").innerHTML =responseText.substring(1);
						$("username").value='';
						$("content").value='';
					}
					else{
                        $("showmsg").innerHTML =responseText.substring(1);
						$("username").value='';
						$("content").value='';
						load_comment(trim(theform.id.value));
					}
                });
	return false
}

function $(id){
    return document.getElementById(id);
}

function TryThese(){
    for (i = 0; i < arguments.length; i++){
        try{
            return arguments[i]();
        }catch(e){}
    }
    return false;
}

function CreateXMLHTTP(){
    return TryThese(
        function() {return new ActiveXObject("Msxml2.XMLHTTP");},
        function() {return new ActiveXObject("Microsoft.XMLHTTP");},
        function() {return new XMLHttpRequest();}
    ) || false;
}

function SendRequest(url, param, method, echofun) {
    var xmlHTTP = CreateXMLHTTP();
    if (xmlHTTP){
        xmlHTTP.onreadystatechange = function()
        {
            if (xmlHTTP.readyState == 4 && xmlHTTP.status == 200){
                if (echofun!= null){
                    echofun(xmlHTTP.responseText);
                }
            }
        }
        xmlHTTP.open(method, url, true);
        xmlHTTP.setRequestHeader("Content-Length",param.length); 
        xmlHTTP.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded");
        xmlHTTP.send(encodeURI(param));    
    }else{
        NoXMLHTTP();
    }
}

function NoXMLHTTP(){
    alert("Sorry, your browser doesn't support XMLHTTP");
}

function checkbook(theform)
{  
	if (trim(theform.username.value)=='')
	{   alert('姓名不能为空');
		theform.username.focus();
		theform.username.value='';
		return false
	}
	if (trim(theform.content.value)=='')
	{   alert('内容不能为空');
		theform.content.focus();
		theform.content.value='';
		return false
	}
	var param;
	param=webdir+"plug/book.asp?action=save";
	param += "&username=" + escape(trim(theform.username.value));
	param += "&content=" + escape(trim(theform.content.value));
	$("showaddmsg").innerHTML ="提交中…";
    SendRequest(param, param, "POST", 
                function(responseText){
					var f	= responseText.substring(0,1);
					if (f == "1"){
						$("showaddmsg").innerHTML =responseText.substring(1);
						$('showaddmsg').style.display = 'inline'
						return false
					}
					
					else{
                        $("showaddmsg").innerHTML =responseText.substring(1);;
						$("username").value='';
						$("content").value='';
						setTimeout("$('showaddmsg').innerHTML='';","5000");
						loadlist();
					}
                });
	return false
}



function loadlist()
{
	var param;
	param=webdir+"plug/book.asp";
	$("showmsg").innerHTML="载入中...";
	SendRequest(param, param, "POST", 
                function(responseText){
                        $("showmsg").innerHTML =responseText;   
                });
}

function chanagepage(t0)
{
	var param;
	param=webdir+"plug/book.asp";
	param += "?page=" + escape(t0);
	$("showmsg").innerHTML="载入中...";
	SendRequest(param, param, "POST", 
                function(responseText){
                        $("showmsg").innerHTML =responseText;   
                });
}

function get_hits(t0,t1,t2,t3)
{
	var param;
	param=webdir+"inc/gethits.asp";
	param += "?id=" + escape(t0);
	param += "&action=" + escape(t1);
	param += "&t=" + escape(t2);
	$(t3).innerHTML="<img src="+webdir+"editor/loading.gif>";
	SendRequest(param, param, "POST", 
                function(responseText){
					$(t3).innerHTML=responseText;
                });
}

function get_comment(t0)
{
	var param;
	param=webdir+"inc/gethits.asp";
	param += "?id=" + escape(t0);
	param += "&action=2";
	$("show_i_commentnum").innerHTML="<img src="+webdir+"editor/loading.gif>";
	
	SendRequest(param, param, "POST", 
                function(responseText){
				$("show_i_commentnum").innerHTML=responseText;
                });
}

function load_comment(t0)
{
	var param;
	param=webdir+"plug/comment.asp";
	param += "?id=" + escape(t0);
	$("comment_list").innerHTML="<img src="+webdir+"editor/loading.gif>";
	SendRequest(param, param, "POST", 
                function(responseText){
					var f	= responseText.substring(0,1);
					if (f == "1"){
						$("comment_list").innerHTML =responseText.substring(1);
						return false
					}
					
					else{
                      $("comment_list").innerHTML=responseText;
					}
				
                });
}
function load_comment_post(t0)
{
	var param;
	param=webdir+"plug/comment.asp";
	param += "?id=" + escape(t0);
	param += "&action=add";
	$("comment_post").innerHTML="<img src="+webdir+"editor/loading.gif>";
	
	SendRequest(param, param, "POST", 
                function(responseText){
				var f	= responseText.substring(0,1);
					if (f != "1"){
						$("comment_post").innerHTML=responseText;
						return false
					}
					
					else{
                      $("comment_post").innerHTML="";
					}
                });
}

function get_comment_page(t0,t1)
{
	var param;
	param=webdir+"plug/comment.asp";
	param += "?page=" + escape(t0);
	param += "&id=" + escape(t1);
	$("comment_list").innerHTML="载入中...";
	SendRequest(param, param, "POST", 
                function(responseText){
                        $("comment_list").innerHTML =responseText;   
                });
}