function numAleatori(a, b){
  return ( Math.round(Math.random()*(b-a)+a));
}


function mostraIAmagaXifres(aleatori_avantatge, aleatori_desavantatge){
  //posem a hidden totes les xifres positives
  jq('.avantatges .banner_positiu').each(function(){
     jq(this).attr('class', 'banner_xifres banner banner_positiu hidden');
  });
  //afegim un banner positiu de forma random
  jq('.avantatges .banner_positiu:eq(' + aleatori_avantatge + ')').attr('class', 'banner_xifres banner banner_positiu');

  //posem a hidden totes les xifres negatives
  jq('.desavantatges .banner_negatiu').each(function(){
     jq(this).attr('class', 'banner_xifres banner banner_negatiu hidden');
  });
  //afegim un banner de forma random
  jq('.desavantatges .banner_negatiu:eq(' + aleatori_desavantatge + ')').attr('class', 'banner_xifres banner banner_negatiu');
};


jq(document).ready(function(){
  //agafar la quantitat de xifres que tinc

  var num_avantatges = jq('#num_avantatges').attr('num_avantatges');
  var num_desavantatges = jq('#num_desavantatges').attr('num_desavantatges');

  aleatori_avantatge = numAleatori(0, num_avantatges-1);
  aleatori_desavantatge = numAleatori(0, num_desavantatges-1);

  //mostrem les dues primeres xifres
  mostraIAmagaXifres(aleatori_avantatge, aleatori_desavantatge);


  //anem canviant les xifres
  jq(this).everyTime(12000, function() {
   aleatori_avantatge = (aleatori_avantatge + 1)%num_avantatges;
   aleatori_desavantatge = (aleatori_desavantatge + 1)%num_desavantatges;
   mostraIAmagaXifres(aleatori_avantatge, aleatori_desavantatge);
  });
});
