function utf8_1251(aa)
{
 var s = '', c = 0;
 
 for( var i = 0; i < aa.length; i++ )
  {
   c = aa.charCodeAt(i);
   if( c > 127 )
    {
     if(c > 1024)
      {
       if (c == 1025)
        {
         c = 1016;
        }
       else if (c == 1105)
        {
         c = 1032;
        }
        
       s += '%'+(c-848).toString(16).toUpperCase();
      }
    }
   else if( ('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ').indexOf(String.fromCharCode(c))!=-1 )
    {
     s += String.fromCharCode(c); 
    }
   else if( c==32 )
    {
     s += '+'; 
    }    
   else
    {
     s += '%'+c.toString(16).toUpperCase();
    }
  }
   
 return s;
}

