function killErrors() {
return true;
}
window.onerror = killErrors;
function login(username,password,yanzhengma)
{
   if(document.getElementById(username).value.length==0)
   {
      alert('用户名不能为空!');
      return;
   }
   if(document.getElementById(password).value.length==0)
   {
      alert('密码不能为空!');
      return;
   }
   var thestr;
   thestr=mycookie(thestr,"yanzhengma");
   if(thestr!=document.getElementById(yanzhengma).value.toUpperCase())
   {
      alert('错误的验证码!');
      document.getElementById(yanzhengma).value="";
      return;
   }
   CheckLogin();
}
function IsNull(str,strshow)
{
   if(document.getElementById(str).value.replace(/(^\s*)|(\s*$)/g,"").length==0)
   {
      alert(strshow);
      document.form1[str].focus();
      return 0;
   }
}
function gotoURL(theurl)
{
      var therefurl=this.location.pathname;
      if(therefurl.indexOf(theurl)==-1)
      {
         //上传网站时保持thepath="";
         var thepath="";
         //var thepath= document.location.pathname.substring(document.location.pathname.indexOf('/')+1) ;
         thepath= thepath.substring(0,thepath.indexOf('/')) ;
         
         location.replace('http://'+this.location.host+'/'+thepath+theurl+'RefUrl='+encodeURIComponent(this.location));
      }
      else
      {
         location.replace(this.location);
      }
}
function gotoURLhtml(theurl)
{
      var therefurl=this.location.pathname;
      if(therefurl.indexOf(theurl)==-1)
      {
         //上传网站时保持thepath="";
         var thepath="";
         //var thepath= document.location.pathname.substring(document.location.pathname.indexOf('/')+1) ;
         thepath= thepath.substring(0,thepath.indexOf('/')) ;
         
         location.replace('http://'+this.location.host+'/'+thepath+theurl+'.html?RefUrl='+encodeURIComponent(this.location));
      }
      else
      {
         location.replace(this.location);
      }
}
function replaceURL(addstr)
{
     var hrefstr=String(this.location).substring(0,String(this.location).indexOf('%23'))
     location.replace(hrefstr+addstr);
}
function mycookie(thestr,thecoostr)
{
   var strCookie=document.cookie;
   var arrCookie=strCookie.split(";")
   for(var i=0;i<arrCookie.length;i++)
   { 
       var arr=arrCookie[i].split("=")
       if(thecoostr==arr[0].replace(/(^\s*)|(\s*$)/g, ""))
       { 
          thestr=arr[1];
          break; 
       } 
   }
   return thestr;
}
function requestvalue(name)
{
   var value;
   var strArr = new Array();
   var allstr=this.location.search.substr(1).split('&');
   for(var i = 0;i<allstr.length;i++)
   {
       var everystr = allstr[i].split("=");
       if(everystr[0]==name)
       {
           value=everystr[1];
       }	
   }
   return value;
}
function strtolower(str)
{
   str=str.toLowerCase();
   return str;
}
function resizeimg()
{
   SetSize(700, 1200);
}
function SetSize(width, height) 
{ 
   for (j=0;j<document.images.length;j++) 
   { 
       myImage = document.images[j];  
       if (myImage.width>0 && myImage.height>0) 
       { 
          var rate=1;
          if (myImage.width>width || myImage.height>height) 
          { 
              if (myImage.width/myImage.height>=width/height) 
              { 
                  rate = width/myImage.width; 
              } 
              else 
              { 
                  rate = height/myImage.height; 
              } 
          } 
          if (window.navigator.appName == "Microsoft Internet Explorer") 
          { 
              document.images[j].style.zoom = rate; 
          } 
          else 
          { 
              document.images[j].width = myImage.width*rate; 
              document.images[j].height = myImage.height*rate; 
          } 
       } 
   } 
}
function chkpage()
{
   var inputpage=document.getElementById('choosepage').value;
   var allpage=document.getElementById('countp').value;
   if(IsNull("choosepage","页码不能为空!")==0){return false;}
   if(!/^\+?[1-9][0-9]*$/.test(inputpage))
   {
       alert('页码输入有误!');document.getElementById('choosepage').value='';
       return false;
   }
   
   if(Number(inputpage)>Number(allpage)){alert('输入超过最大值!');document.getElementById('choosepage').value='';return false;}
}
function checksearch()
{  
   if(document.getElementById("Search1_TextBox1").value=="多个关键字请用 | 隔开"){alert('请输入关键字');return false;}
   if(IsNull("Search1_TextBox1","关键字不能为空!")==0){return false;}
   if(!/^[0-9a-zA-Z\u4e00-\u9fa5|]*$/.test(document.getElementById("Search1_TextBox1").value))
   {
      alert('关键字只能是数字字母及和汉字!');
      return false;
   }
   document.form1['Search1_Button1'].click();
}
function getLength(str)
{
   var length = str.length;
   for(var i = 0; i < str.length; i++)
   if(/[\u4e00-\u9fa5]/.test(str.charAt(i)))
       length ++;
   return length;
}
function checkguestbook()
{  
   if(IsNull("neirong","留言内容不能为空!")==0){return false;}
   
   var thestr;
   thestr=mycookie(thestr,"yanzhengma");
   if(thestr!=document.getElementById('TextBox1').value.toUpperCase())
   {
      alert('错误的验证码!');
      document.getElementById(yanzhengma).value="";
      return;
   }
   
   if(CheckStrCountInput("neirong",1000,"留言内容字符数超过范围!\r\n\r\n允许字符数：1000个  当前字符数："+getLength(document.getElementById("neirong").value)+"个\r\n\r\n请检查您的输入内容字符数！\r\r\n\r\n注意：一个汉字算2个字符！换行也算字符！")==false)
   {
      return false;
   }
   
   document.form1['ok'].click();
}
function checkbbs()
{  
   if(IsNull("title","主题标题不能为空!")==0){return false;}
   if(IsNull("neirong","主题内容不能为空!")==0){return false;}
   
   var thestr;
   thestr=mycookie(thestr,"yanzhengma");
   if(thestr!=document.getElementById('TextBox1').value.toUpperCase())
   {
      alert('错误的验证码!');
      document.getElementById(yanzhengma).value="";
      return;
   }
   
   if(CheckStrCountInput("title",100,"主题标题字符数超过范围!\r\n\r\n允许字符数：100个  当前字符数："+getLength(document.getElementById("title").value)+"个\r\n\r\n请检查您的输入内容字符数！\r\r\n\r\n注意：一个汉字算2个字符！")==false)
   {
      return false;
   }
   
   //检查信息内容字数
   var strs=document.getElementById("neirong").value.toUpperCase().replace(/<P>/g,"<BR>");
   
   strs = strs.replace(/<[^<>]+>/g,"");
   strs = strs.replace(/&NBSP;/g,"");
   strs = strs.replace(/(^\s*)|(\s*$)/g,"");
   var a=getLength(strs);
   if(a==0)
   {
       alert("主题内容不能为空!");
      return false;
   }
   if (a > 100000)
   {
      alert("您输入的信息内容字符数超过范围!\r\n\r\n允许字符数：100000个  当前字符数："+a+"个\r\n\r\n请检查您的输入内容字符数！\r\r\n\r\n注意：一个汉字算2个字符！");
      return false;
   }
   
   document.form1['ok'].click();
}
function checkrbbs()
{  
   if(IsNull("neirong","主题内容不能为空!")==0){return false;}
   
   var thestr;
   thestr=mycookie(thestr,"yanzhengma");
   if(thestr!=document.getElementById('TextBox1').value.toUpperCase())
   {
      alert('错误的验证码!');
      document.getElementById(yanzhengma).value="";
      return;
   }
   
   var strs=document.getElementById("neirong").value.toUpperCase().replace(/<P>/g,"<BR>");
   
   strs = strs.replace(/<[^<>]+>/g,"");
   strs = strs.replace(/&NBSP;/g,"");
   strs = strs.replace(/(^\s*)|(\s*$)/g,"");
   var a=getLength(strs);
   if(a==0)
   {
       alert("主题内容不能为空!");
      return false;
   }
   if (a > 100000)
   {
      alert("您输入的信息内容字符数超过范围!\r\n\r\n允许字符数：100000个  当前字符数："+a+"个\r\n\r\n请检查您的输入内容字符数！\r\r\n\r\n注意：一个汉字算2个字符！");
      return false;
   }
   
   document.form1['ok'].click();
}
function CheckStrCountInput(objname,countnum,msg)
{
   var a=getLength(document.getElementById(objname).value);
   if(a>countnum)
   {
      alert(msg);
      return false;
   }
   return true;
}
function runCode(obj)
{var newWin=window.open('',"_blank",'');
newWin.document.open('text/html','replace');
newWin.opener=null
var testCode=document.getElementById(obj).value;
newWin.document.write(testCode);
newWin.document.close();
}

function copyCode(obj) {
var rng = document.body.createTextRange();
var obj1=document.getElementById(obj)
rng.moveToElementText(obj1);
rng.scrollIntoView();
rng.select();
rng.execCommand("Copy");
rng.collapse(false);
}

function saveCode(pTargetId)
{var newWin=window.open('','_blank','top=10000');
newWin.document.open('text/html','replace');
var testCode=document.getElementById(pTargetId).value;
newWin.document.write(testCode);
newWin.document.execCommand('saveas','','code.htm');
newWin.close();
}
