fum.util.password={
  pasData : '',
  uidData : '',
  resError : 'none',
  meterDiv : '',
  showMeter : false,
  result : '',
  min_len : 8 ,
  error_str : {  
    none:'',len:'طول فیلد باید بزگتر از ۸ باشد',
    order:'از کاراکترهای مرتب استفاده ننمایید',
    repeat:'از کاراکترهای تکراری استفاده ننمایید',
    uname:'از نام کاربری خود استفاده ننمایید',
    weak:'رمز عبور انتخابی شما نامناسب است',
    mediocre : 'رمز عبور انتخابی شما مناسب نیست'
  },
  init : function(){
   }, 
  drawMeter : function(){
    this.showMeter=true;
    meter_div=document.createElement('div');meter_div.id='meter';
    this.meterDiv.appendChild(meter_div);
    
    for(i=4;i>0;i--){
     newdiv=document.createElement('div');
     newdiv.id='meter'+i;newdiv.style.backgroundColor='white';
     meter_div.appendChild(newdiv);
    }
    span=document.createElement('span');this.meterDiv.appendChild(span);
  },
  checkPass : function(){
    if(!this.pasData){
      alert('خطای پیش بینی نشده');
      return false; 
    }
    str=this.pasData.value;
    this.uname=this.len=this.letter=this.number=this.special=this.repeatchar=this.order=false
    if(this.uidData&&this.uidData.value){
      re='/'+this.uidData.value+'/i';re=eval(re);
      if(str.match(re)){this.uname=true;}
    }
    if((str.length>(this.min_len-1))){this.len=true;}
    if(str.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)){this.letter=true;}
    if(str.match(/\d+/)&&str.match(/[a-z].*/i)){this.number=true;}
    if(str.match(/[!,@,#,\$,%,^,&,\*,?,_,~]/)){this.special=true;}
    str_chars='abcdefghijklmnopqrstuvwxyz012345678909876543210zyxwvutsrqponmlkjihgfedcba';
    str_chars='012345678909876543210';
    for(i=0;i<str_chars.length;i++){cmd='/['+str_chars.substr(i,1)+']+/i';cmd=eval(cmd);if(str.match(cmd)){newstr=new String(str.match(cmd));if(newstr.length>3){this.repeatchar=true;}}}
    for(i=0;i<str_chars.length;i++){nc=str_chars.substr(i+1,3);if(nc.length==3){cmd='/'+str_chars.substr(i,1)+'(?='+nc+')/i';cmd=eval(cmd);if(str.match(cmd)){this.order=true;}}}
    for(i=0;i<str_chars.length;i++){nc=str_chars.substr(i+1,3);if(nc.length==3){cmd='/'+str_chars.substr(i,1)+'(?='+nc+')/i';cmd=eval(cmd);if(str.match(cmd)){this.order=true;}}}
    str_chars='qwertyuiopasdfghjklzxcvbnm012345678909876543210mnbvcxzlkjhgfdsapoiuytrewq';
    for(i=0;i<str_chars.length;i++){nc=str_chars.substr(i+1,3);if(nc.length==3){cmd='/'+str_chars.substr(i,1)+'(?='+nc+')/i';cmd=eval(cmd);if(str.match(cmd)){this.order=true;}}}
    result='weak';
    this.resError='none';
    if(this.uname){this.resError='uname';result='weak';}
    else if(this.repeatchar){this.resError='repeat';result='weak';}
    else if(this.order){this.resError='order';result='weak';}
    else if(!this.len){this.resError='len';result='weak';}
    else if(!this.len&&!this.letter&&!this.number&&!this.special){this.resError='weak';result='weak';}
    else if(this.len&&!this.letter&&!this.number&&!this.special){this.resError='mediocre';result='mediocre';}
    else if(this.len&&!this.letter&&this.number&&!this.special){result='strong';}
    else if(this.len&&!this.letter&&!this.number&&this.special){result='strong';}
    else if(this.len&&this.letter&&!this.number&&!this.special){result='strong';}
    else if(this.len&&!this.letter&&this.number&&this.special){result='strongest';}
    else if(this.len&&this.letter&&!this.number&&this.special){result='strongest';}
    else if(this.len&&this.letter&&this.number&&!this.special){result='strongest';}
    else if(this.len&&this.letter&&this.number&&this.special){result='strongest';}
    else{result='weak';} 
    this.result=result;
    if(this.showMeter) this.drawResult();
  }, 
  getErrorMes : function (){ return this.error_str[this.resError];},
  drawResult:function(){//#4AE817
    bgcolor='#25F8E9';boxes=0;// alert(this.uname+"-"+this.repeatchar+"-"+this.order+"-"+this.len+"-"+this.letter+"-"+this.number+"-"+this.special); 
    switch(this.result){
     case'strongest': boxes=4;break;
     case'strong': boxes=3;break;
     case'mediocre':boxes=2;break;
     case'weak': boxes=1;break;}
    var ob; 
    for(i=1;i<5;i++){
    ob=document.getElementById('meter'+i)
     if(ob){
     if(i>boxes){bgcolor='white';}
      ob.style.backgroundColor= bgcolor}}
      }


}