var bemotion = new Array();

function Emote(pnumber, enumber, pname, emotes)
{
  this.picnumber = pnumber;
  this.emotenumber = enumber;
  this.picsname = pname;
  this.emotesarr = emotes;
  this.database = null;
}

x = ['apathetic', 'sleepy', 'tired', 'indifferent', 'lethargic', 'numb', 
     'pensive', 'contemplative', 'calm', 'bored', 'drained', 'exhausted', 
     'lonely', 'melancholy', 'sad', 'moody', 'nostalgic', 'rejected', 
     'disapointed', 'depressed', 'gloomy', 'crushed'];
bemotion['sad'] = new Emote(19, x.length, 'sad', x);

x = ['annoyed', 'morose', 'sulky', 'sullen', 'discontent', 'displeased', 
     'cranky', 'grumpy', 'indignant', 'vexed', 'cross', 'angry', 'enraged', 
     'infuriated', 'irate', 'furious'];
bemotion['angry'] = new Emote(15, x.length, 'frown', x);

x = ['uncomfortable', 'confused', 'pessimistic', 'restless', 'surprised', 
     'startled', 'stressed', 'anxious', 'intimidated', 'nervous', 'worried', 
     'scared', 'afraid', 'fearful', 'distressed', 'shocked', 'aghast', 
     'panicked', 'shaken', 'terrified'];
bemotion['scared'] = new Emote(15, x.length, 'scare', x);

x = ['lazy', 'okay', 'mellow', 'content', 'peaceful', 'relaxed', 'relieved', 
     'refreshed', 'silly', 'curious', 'optimistic', 'pleased', 'impressed', 
     'flirty', 'miscievous', 'naughty', 'amused', 'cheerful', 'chipper', 
     'energetic', 'excited', 'giddy', 'giggly', 'entralled', 'loved', 
     'happy', 'ecstatic', 'jubilant'];
bemotion['happy'] = new Emote(13, x.length, 'smile', x);

x = ['busy', 'cold', 'hot', 'warm', 'thirsty', 'hungry', 'busy', 'productive', 
     'sick', 'sympathetic', 'touched', 'geeky', 'nerdy', 'working', 'weird'];
bemotion['other'] = new Emote(9, x.length, '', x);


var feel_emotes = ['moody', 'rejected', 'pessimistic', 'lazy', 'okay', 
                   'miscievous', 'naughty', 'loved', 'cold', 'hot', 'geeky', 
                   'nerdy', 'weird', 'sick', 'drained'];

x = [29, 30, 44, 102, 108, 135, 165, 178, 258, 259, 266, 333, 347, 386, 
     434, 445, 446, 449, 493, 505, 516, 530, 543, 566, 596, 623, 679, 
     689, 696, 710, 739, 741, 744, 748, 769, 783, 786, 789, 802, 820, 
     829, 830, 831, 890, 911, 964];
bemotion['sad'].database = x;

x = [14, 16, 22, 38, 42, 43, 47, 76, 80, 84, 85, 88, 89, 90, 163, 222, 247,
     340, 347, 357, 383, 605, 609, 610, 614, 619, 641, 669, 673, 676, 745,
     753, 762, 764, 765, 770, 870, 938];
bemotion['angry'].database = x;

x = [1, 4, 5, 23, 50, 58, 71, 110, 133, 134, 214, 273, 308, 311, 328, 382, 
     425, 430, 438, 504, 541, 578, 579, 621, 731, 732, 771, 816, 835, 863, 
     869, 897];
bemotion['scared'].database = x;

x = [10, 41, 45, 69, 86, 95, 96, 99, 118, 139, 141, 153, 189, 202, 205, 228, 
     300, 305, 318, 322, 397, 443, 488, 489, 510, 525, 535, 561, 627, 640, 
     664, 699, 712, 714, 740, 761, 797, 813, 828, 934, 939, 955, 965, 966];
bemotion['happy'].database = x;

function gen_emote(a_window, number)
{
  var z;
  var y;
  var em;
  for (i in bemotion) {
    if (in_array(bemotion[i].database, number) >= 0) {
      z = intRandLim(0, bemotion[i].picnumber-1);
      lim1 = Math.round(0.8*z*bemotion[i].emotesarr.length/bemotion[i].picnumber);
      lim2 = Math.round(1.2*z*bemotion[i].emotesarr.length/bemotion[i].picnumber);
      y = intRandLim(lim1, lim2);
      if (y < 0)
        y = 0;
      if (y >= bemotion[i].emotesarr.length)
        y = bemotion[i].emotesarr.length - 1;
      em = bemotion[i].emotesarr[y];
      titlename = "Birky ";
      if (in_array(feel_emotes, em) >= 0)
        titlename = titlename + "feels ";
      else
        titlename = titlename + "is ";
      titlename = titlename + em;
      select_pic_title(a_window, bemotion[i].picsname, z, titlename);
      return;
    }
  }
  z = intRandLim(0, bemotion['other'].emotesarr.length-1);
  em = bemotion['other'].emotesarr[z];
  titlename = "Birky ";
  if (in_array(feel_emotes, em) >= 0)
    titlename = titlename + "feels ";
  else
    titlename = titlename + "is ";
  titlename = titlename + em;
  random_pic_title(a_window, titlename);
}

