// JavaScript Document
function GEId(sID){return document.getElementById(sID);}

function EvalPwdStrength(name){
    if (name.length>5){
	var Level=PasswordStrength.StrengthLevel(name);
	//不允许空格,肖一兵 添加2007-02-27 10:19
	if (name.split(" ").length>1){
	Level="1";	
	}
	
	if(Level=="3"){	
		GEId("idSMT1").style.display="none";
		GEId("idSMT2").style.display="none";
		DispPwdStrength(3,'reg_pws3');
		return true;
		}else if(Level=="2"){
		GEId("idSMT3").style.display="none";
		GEId("idSMT1").style.display="none";
		DispPwdStrength(2,'reg_pws2');
		return true;
		}else if(Level=="1"){
		GEId("idSMT3").style.display="none";
		GEId("idSMT2").style.display="none";
		DispPwdStrength(1,'reg_pws1');
		return false;
		}else{
		GEId("idSMT3").style.display="none";
		GEId("idSMT2").style.display="none";
		DispPwdStrength(0,'reg_pws0');
		return false;
		}
	}else{
		GEId("idSMT3").style.display="none";
		GEId("idSMT2").style.display="none";
		GEId("idSMT1").style.display="none";
		GEId("idSM1").className="reg_pws0";
		GEId("idSM2").className="reg_pws0";
		GEId("idSM3").className="reg_pws0";
		return false;
	}
	return true;
	}
	var PasswordStrength ={
            Level : ["3","2","1"],
            LevelValue : [30,20,0],//强度值
            Factor : [1,2,5],//字符加数,分别为字母，数字，其它
            KindFactor : [0,0,10,20],//密码含几种组成的加数 
            //Regex : [/[a-zA-Z]/g,/\d/g,/\S/g/[^a-zA-Z0-9]/g] //字符正则数字正则其它正则
			Regex : [/[a-zA-Z]/g,/\d/g,/[^a-zA-Z0-9\s]/g] //字符正则数字正则其它正则
            }
        PasswordStrength.StrengthValue = function(pwd)
        {
            var strengthValue = 0;
            var ComposedKind = 0;
            for(var i = 0 ; i < this.Regex.length;i++)
            {
                var chars = pwd.match(this.Regex[i]);
                if(chars != null)
                {
                    strengthValue += chars.length * this.Factor[i];
                    ComposedKind ++;
                }
            }
            strengthValue += this.KindFactor[ComposedKind];
            return strengthValue;
        } 
        PasswordStrength.StrengthLevel = function(pwd)
        {
            var value = this.StrengthValue(pwd);
            for(var i = 0 ; i < this.LevelValue.length ; i ++)
            {
                if(value >= this.LevelValue[i] )
                    return this.Level[i];
            }
        }


function DispPwdStrength(iN,sHL){
	if(iN>3){ iN=3;}
	for(var i=1;i<4;i++){
		var sHCR="reg_pws0";
		if(i<=iN){ sHCR=sHL;}
		if(iN>0){
		GEId("idSM"+i).className=sHCR;
		}
		//GEId("idSMT"+i).className="ob_pwfont2";
		if (iN>0){
			if (i<=iN){
			GEId("idSMT"+i).style.display=((i==iN)?"inline":"none");
			}
		}
		else{
		GEId("idSMT"+i).style.display=((i==iN)?"none":"inline");
		}
	}
}
