var mo = {

    ar : '',

    tmb : '',

    sth : '',

    hx : {},
    hnext : '',
    dnext : '',
    hcurr : '',

    tv : [],

    tvc : 0,


    ars : function(st) {

       var i;

    let dr = /viewtopic\.php\?t\=(?<trc>[0-9]{4,})\"\>(?<titr>[\S|\s]{2,}?)\<\/a\>[\S|\s]{2,}\<b class\=\"seedmed\"\>(?<seeds>\d{1,})[\S|\s]{2,}data\-ts_text\=\"(?<tm>\d{10})/;

    mo.sth = st; 

    mo.hnext = '';

     mo.hx = mo.sth.match(/\<a class\=\"pg\" href\=\"([\S|\s]{1,60})?\"\>Ρλεδ\.\<\/a>/);

   if( mo.hx != null ) 
     {

       mo.hnext  = mo.hx[1].replace('amp;','');

     }


      mo.ar = st.match(/\<tr id\=\"trs\-tr\-(\d{1,})\" [\S|\s]{1,}?\<\/tr/g);

      for(i=0; i<mo.ar.length; i++)
       {

        mo.ar[i] = mo.trm('<span class="brackets-pair">', mo.ar[i]);
        mo.ar[i] = mo.trm('</span>', mo.ar[i]);
        mo.ar[i] = mo.trm('<wbr>', mo.ar[i]);

//        mo.tv[i] = new Vls(0, 0, '', 0);




        try {

           let groups = mo.ar[i].match(dr).groups;

           if( groups != null )
            {


              if( mo.tvc == 0 )
               {


                  mo.tv[mo.tvc] = new Vls(groups.trc, groups.tm, groups.titr, groups.seeds);

                  mo.tvc++;

                }
              else
                {
                   var snv = groups.titr.substring(0, 11);


                   var k = mo.tv.findIndex( val => val.sn == snv );


/*
                   var j, k;

                   k = -1;

                   for(j=0; j<mo.tvc; j++)
                    {

                      if( mo.tv[j].sn == snv ) 
                       {
                         k = j;
                         break;
                       }

                    }

*/

                   if( k == -1 )
                    {

                      mo.tv[mo.tvc] = new Vls(groups.trc, groups.tm, groups.titr, groups.seeds);

                      mo.tvc++;
       
                    }
                   else
                    {


                      try {

                         var seeds = Number(groups.seeds);

                         mo.tv[k].seeds = mo.tv[k].seeds + seeds;

                       }
                      catch(e){

                      }






//                      alert(snv);

                    }
                      

                }

            }

          }
          catch(e){

           }

        }


//      alert("popupf mo.tvc = "+mo.tvc);

    },

    trm : function(sp, st)
   {

     var s1 = st;

     var ps = s1.indexOf(sp,0);

     while( ps > 0 )
     {
       s1 = s1.replace(sp,'');
       ps = s1.indexOf(sp ,0);
     }
   

    return s1;
  }




};

