﻿//CharMode函数 
//测试某个字符是属于哪一类. 
function CharMode(iN){ 
if (iN>=48 && iN <=57) //数字 
return 1; 
if (iN>=65 && iN <=90) //大写字母 
return 2; 
if (iN>=97 && iN <=122) //小写 
return 4; 
else 
return 8; //特殊字符 
} 

//bitTotal函数 
//计算出当前密码当中一共有多少种模式 
function bitTotal(num){ 
modes=0; 
for (i=0;i<4;i++){ 
if (num & 1) modes++; 
num>>>=1; 
} 
return modes; 
} 

//checkStrong函数 
//返回密码的强度级别 

function checkStrong(sPW){ 
if (sPW.length<=4) 
return 0; //密码太短 
Modes=0; 
for (i=0;i<sPW.length;i++){ 
//测试每一个字符的类别并统计一共有多少种模式. 
Modes|=CharMode(sPW.charCodeAt(i)); 
} 

return bitTotal(Modes); 

} 

//pwStrength函数 
//当用户放开键盘或密码输入框失去焦点时,根据不同的级别显示不同的颜色 

function pwStrength(pwd){ 
O_color="#eeeeee"; 
L_color="#FF0000"; 
M_color="#FF9900"; 
H_color="#33CC00"; 
if (pwd==null||pwd==''){ 
Lcolor=Mcolor=Hcolor=O_color; 
} 
else{ 
S_level=checkStrong(pwd); 
switch(S_level) { 
case 0: 
Lcolor=Mcolor=Hcolor=O_color; 
case 1: 
Lcolor=L_color; 
Mcolor=Hcolor=O_color; 
break; 
case 2: 
Lcolor=Mcolor=M_color; 
Hcolor=O_color; 
break; 
default: 
Lcolor=Mcolor=Hcolor=H_color; 
} 
} 

document.getElementById("strength_L").style.background=Lcolor; 
document.getElementById("strength_M").style.background=Mcolor; 
document.getElementById("strength_H").style.background=Hcolor; 
return; 
}

//noteclick函数
//当用户点击各个输入框时，根据不同的数字显示高亮显示不同的说明文字
function noteclick(type,num)
{
	var s="n"+num;
        var i="i"+num;
	if(type=="f")
	{
		document.getElementById(s).style.background='#E7FBFF';
		document.getElementById(s).style.border='#00AAFF 1 solid';
		document.getElementById(i).style.display="";
		
	}
	else
	{
		document.getElementById(s).style.background='#fff';
		document.getElementById(s).style.border='#00AAFF 0 solid';
		document.getElementById(i).style.display="none";	
	}
	
}
function rnd()
{ 
    rnd.today=new Date(); 
　　rnd.seed=rnd.today.getTime();
　　rnd.seed = (rnd.seed*9301+49297) % 233280; 

　　return rnd.seed/(233280.0); 

　　}

function rand(number)
{ 

　　return Math.ceil(rnd()*number); 

}
function checkpass()
{
	
    if(document.getElementById("pass").value=="")
{
	
	document.getElementById("passnote").innerHTML="<img src='images/jingshi.png'>  密码不能为空！";
}
}
function docheck() 
{
	Anthem_InvokePageMethod('check',[],takeresult);
}
function takeresult(result)
{
	var s="";
        var str=new Array();
	str=result.value.split(",");
	for(i=0;i<str.length;i++)
	{
		if(str[i]!="ok"&&str[i]!="")
		{
			s+="*"+str[i]+"<br>";
		}
	}
	if(s!="")
	{
		sAlert(s);
	}
	else
	{
		alert("恭喜您已注册成功！");
		document.location="users/index.aspx";
	}

}
function sAlert(str){
            var msgw,msgh,bordercolor;
            msgw=400;//提示窗口的宽度
            msgh=100;//提示窗口的高度
            bordercolor="#336699";//提示窗口的边框颜色
            titlecolor="#99CCFF";//提示窗口的标题颜色
            
            var sWidth,sHeight;
            sWidth=document.body.offsetWidth;
            sHeight=document.body.offsetHeight;
            if(sWidth<1024)
            {
				sWidth=1024;
            }
			if(sHeight<768)
			{
				sHeight=768;
			}

            var bgObj=document.createElement("div");
            bgObj.setAttribute('id','bgDiv');
            bgObj.style.position="absolute";
            bgObj.style.top="0";
            bgObj.style.background="#777";
            bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
            bgObj.style.opacity="0.6";
            bgObj.style.left="0";
            bgObj.style.width=sWidth + "px";
            bgObj.style.height=sHeight + "px";
            document.body.appendChild(bgObj);
            var msgObj=document.createElement("div")
            msgObj.setAttribute("id","msgDiv");
            msgObj.setAttribute("align","center");
            msgObj.style.position="absolute";
            msgObj.style.background="white";
            msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
            msgObj.style.border="1px solid " + bordercolor;
            msgObj.style.width=msgw + "px";
            msgObj.style.height=msgh + "px";
          msgObj.style.top=(document.documentElement.scrollTop + (sHeight-msgh)/2) + "px";
          msgObj.style.left=(sWidth-msgw)/2 + "px";
          var title=document.createElement("h4");
          title.setAttribute("id","msgTitle");
          title.setAttribute("align","right");
          title.style.margin="0";
          title.style.padding="3px";
          title.style.background=bordercolor;
          title.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";
          title.style.opacity="0.75";
          title.style.border="1px solid " + bordercolor;
          title.style.height="18px";
          title.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif";
          title.style.color="white";
          title.style.cursor="pointer";
          title.innerHTML="关闭";
          title.onclick=function(){
            document.body.removeChild(bgObj);
        document.getElementById("msgDiv").removeChild(title);
        document.body.removeChild(msgObj);
        }
          document.body.appendChild(msgObj);
          document.getElementById("msgDiv").appendChild(title);
          var txt=document.createElement("p");
          txt.style.margin="1em 0"
          txt.setAttribute("id","msgTxt");
          txt.innerHTML=str;
      document.getElementById("msgDiv").appendChild(txt);
      }