// JavaScript Document





//function changeBBSimage(obj){
//imgname=obj.value;
//imgname2="/bbsimage/"+imgname+".gif";
//	 document.getElementById("imglocation").src=imgname2;
	
//}
function openWindow(){
 window.open("/cn/bbsimages.jsp","Select_BBS_Image","height=600, width=550,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");

}


function checkRegform(){ 
   document.regform.username.focus();
   f=document.regform;

   
   var namelen=strLength(f.username.value);
   if(namelen>20 || namelen<4){
	   
	   alert("用户名不能为空并且长度在4-20个字符之间！"); 
       f.username.focus(); 
       return; 
   }

   if(!(/^[a-zA-Z0-9]*$/g.test(f.username.value))){
	   alert("用户名必须由英文、数字和下划线组成！"); 
       f.username.focus(); 
       return;
   }
   
   var psd1=f.pwd1.value;
   if((psd1.length<6)||(psd1.length>20)||(psd1=="")) 
   { 
       alert("请输入6-20个字符的密码！"); 
       f.pwd1.focus(); 
       return; 
   }
   
   var psd2=f.pwd2.value;
   if(psd2.length<6||psd2.length>20||psd2=="") 
   { 
       alert("请输入6-20个字符的密码！"); 
       f.pwd2.focus(); 
       return; 
   }
   
   if(psd2!=psd1){
	   alert("两次密码输入不一致！");
	   f.pwd1.focus();
	   return;
   }
   
    e=f.email.value;
	if ((e == "") || (e.length<6)||(e.indexOf("@") == -1) || (e.indexOf(".") == -1)){
		alert("电子信箱无效!");
		f.email.focus();
		return;
	}
	
	
	a=f.answer.value;
	if(a==""||a.length<2){
		alert("问题答案不能为空并至少2个字");
		f.answer.focus();
		return;
	}
	
	sign=f.signature.value;
	if(sign.length>100){
		alert("签名不能超过100个字符");
		f.signature.focus();
		return;
	}
	
	if(f.agree.checked==false){
	    alert("你还没有阅读并同意注册条款!");
		return;
	}
	

	f.submit();
 }
  
  
  function strLength(str){
　　var byteLen=0;
    var len=str.length;
　　if(str){
　　　　for(var i=0; i<len; i++){
　　　　　　if(str.charCodeAt(i)>255){
　　　　　　　　byteLen += 2;
　　　　　　}
　　　　　　else{
　　　　　　　　byteLen++;
　　　　　　}
　　　　}
　　　　return byteLen;
　　}
　　else{
　　　　return 0;
　　}
}