//登陆
function CheckLogin(){
 document.formlogin.submit();
}
//注册
function CheckReg(){
        if(document.theForm.Username.value==""){
                alert("请输入用户名。");
                document.theForm.Username.focus();
                return false;
        }
	for( var i=0;i<document.theForm.Username.value.length;i++ ){
		var ch = document.theForm.Username.value.charAt(i);
		if(!(ch>='a'&&ch<='z'||ch>='A'&&ch<='Z'||ch>='0'&&ch<='9'||ch=='_')){
			alert("用户名中含有非法字符!");
                        document.theForm.Username.focus();
			return false;
		}
	} 
        if(document.theForm.Username.value.length<4){
                alert("用户名不能小于4位");
                document.theForm.Username.focus();
                return false;
        }
         if(document.theForm.Password.value==""){
                alert("请输入秘密。");
                document.theForm.Password.focus();
                return false;
        }
	for( var i=0;i<document.theForm.Password.value.length;i++ ){
		var ch = document.theForm.Password.value.charAt(i);
		if(!(ch>='a'&&ch<='z'||ch>='A'&&ch<='Z'||ch>='0'&&ch<='9'||ch=='_')){
			alert("秘密中含有非法字符!");
                        document.theForm.Password.focus();
			return false;
		}
	} 
        if(document.theForm.Password.value.length<4){
                alert("秘密不能小于4位");
                document.theForm.Password.focus();
                return false;
        }
        if(document.theForm.Password.value !=document.theForm.Password2.value){
                alert("两次输入的密码不一样");
                document.theForm.Password.focus();
                return false;
        }
 
        if(document.theForm.Name.value==""){
                alert("请输入姓名，建议填写网名");
                document.theForm.Name.focus();
                return false;
        }
       if(document.theForm.Birthy.value!=""&&document.theForm.Birthm.value==""){
                alert("请选择出生年月。");
                document.theForm.Birthm.focus();
                return false;
        }
      if(document.theForm.Birthy.value==""&&document.theForm.Birthm.value!=""){
                alert("请选择出生年月。");
                document.theForm.Birthy.focus();
                return false;
        }
       if(document.theForm.Province.value==""){
                alert("请选择所在省份。");
                document.theForm.Province.focus();
                return false;
        }
       if(document.theForm.City.value==""){
                alert("请选择所在城市。");
                document.theForm.City.focus();
                return false;
        }
        if(document.theForm.accept.checked==false)
        {
                alert("请认真阅读《中国律师维权网会员网络服务协议》。");
                return false;
        }

	document.theForm.submit();
}
//留言
function CheckBook(){
        if(document.formbook.title.value==""){
                alert("请输入主题。");
                document.formbook.title.focus();
                return false;
        }
        if(document.formbook.text.value==""){
                alert("请输入内容。");
                document.formbook.text.focus();
                return false;
        }
        if(document.formbook.contact.value==""){
                alert("请输入联系方式。");
                document.formbook.contact.focus();
                return false;
        }
        if(document.formbook.name.value==""){
                alert("请输入姓名。");
                document.formbook.name.focus();
                return false;
        }
        if(document.formbook.code.value==""){
                alert("请输入验证码。");
                document.formbook.code.focus();
                return false;
        }
	 document.formbook.submit();
}
//咨询
var a=0;
function CheckOnline(){
        if(a==1){return false;}
        if(document.onForm.title.value==""){
                alert("请输入咨询主题。");
                document.onForm.title.focus();
                return false;
        }
         if(document.onForm.text.value==""){
                alert("请输入咨询内容。");
                document.onForm.text.focus();
                return false;
        }
		a=1;
	document.onForm.submit();
}
function textCounter(field,counter,maxlimit,linecounter) {
	var fieldWidth =  parseInt(field.offsetWidth);
	var charcnt = field.value.length;        
	if (charcnt > maxlimit) { 
		field.value = field.value.substring(0, maxlimit);
	}
	else { 
	var percentage = parseInt(100 - (( maxlimit - charcnt) * 100)/maxlimit) ;
	document.getElementById(counter).style.width =  parseInt((fieldWidth*percentage)/100)+"px";
	}
}
