var _levels_normal = [
  {n: "Begin", w: [
    {x: 2, y: 2, t: 1, lx: 160, ly: 230},
    {x: 2, y: 3, t: 1, lx: 130, ly: 215},
    {x: 3, y: 2, t: 1, lx: 190, ly: 215},
    {x: 3, y: 3, t: 1, lx: 160, ly: 200},
    {x: 2, y: 4, t: 1, lx: 100, ly: 200},
    {x: 4, y: 2, t: 1, lx: 220, ly: 200},
    {x: 3, y: 4, t: 1, lx: 130, ly: 185},
    {x: 2, y: 5, t: 1, lx: 70, ly: 185},
    {x: 4, y: 3, t: 1, lx: 190, ly: 185},
    {x: 5, y: 2, t: 1, lx: 250, ly: 185},
    {x: 4, y: 4, t: 2, lx: 160, ly: 170},
    {x: 3, y: 5, t: 1, lx: 100, ly: 170},
    {x: 2, y: 6, t: 3, lx: 40, ly: 170},
    {x: 5, y: 3, t: 1, lx: 220, ly: 170},
    {x: 6, y: 2, t: 4, lx: 280, ly: 170},
    {x: 4, y: 5, t: 1, lx: 130, ly: 155},
    {x: 3, y: 6, t: 1, lx: 70, ly: 155},
    {x: 5, y: 4, t: 1, lx: 190, ly: 155},
    {x: 6, y: 3, t: 1, lx: 250, ly: 155},
    {x: 5, y: 5, t: 1, lx: 160, ly: 140},
    {x: 4, y: 6, t: 1, lx: 100, ly: 140},
    {x: 6, y: 4, t: 1, lx: 220, ly: 140},
    {x: 5, y: 6, t: 1, lx: 130, ly: 125},
    {x: 6, y: 5, t: 1, lx: 190, ly: 125},
    {x: 6, y: 6, t: 1, lx: 160, ly: 110},
    {x: 1, y: 1, t: 0, lx: 0, ly: 0},
    {x: 1, y: 2, t: 0, lx: 0, ly: 0},
    {x: 1, y: 3, t: 0, lx: 0, ly: 0},
    {x: 1, y: 4, t: 0, lx: 0, ly: 0},
    {x: 1, y: 5, t: 0, lx: 0, ly: 0},
    {x: 1, y: 6, t: 0, lx: 0, ly: 0},
    {x: 1, y: 7, t: 0, lx: 0, ly: 0},
    {x: 2, y: 1, t: 0, lx: 0, ly: 0},
    {x: 2, y: 7, t: 0, lx: 0, ly: 0},
    {x: 3, y: 1, t: 0, lx: 0, ly: 0},
    {x: 3, y: 7, t: 0, lx: 0, ly: 0},
    {x: 4, y: 1, t: 0, lx: 0, ly: 0},
    {x: 4, y: 7, t: 0, lx: 0, ly: 0},
    {x: 5, y: 1, t: 0, lx: 0, ly: 0},
    {x: 5, y: 7, t: 0, lx: 0, ly: 0},
    {x: 6, y: 1, t: 0, lx: 0, ly: 0},
    {x: 6, y: 7, t: 0, lx: 0, ly: 0},
    {x: 7, y: 1, t: 0, lx: 0, ly: 0},
    {x: 7, y: 2, t: 0, lx: 0, ly: 0},
    {x: 7, y: 3, t: 0, lx: 0, ly: 0},
    {x: 7, y: 4, t: 0, lx: 0, ly: 0},
    {x: 7, y: 5, t: 0, lx: 0, ly: 0},
    {x: 7, y: 6, t: 0, lx: 0, ly: 0},
    {x: 7, y: 7, t: 0, lx: 0, ly: 0},
  ]},

  {n: "Islands", w: [
    {x: 0, y: 1, t: 1, lx: 130, ly: 275},
    {x: 1, y: 0, t: 4, lx: 190, ly: 275},
    {x: 1, y: 1, t: 1, lx: 160, ly: 260},
    {x: 0, y: 2, t: 1, lx: 100, ly: 260},
    {x: 2, y: 0, t: 4, lx: 220, ly: 260},
    {x: 1, y: 2, t: 1, lx: 130, ly: 245},
    {x: 0, y: 3, t: 1, lx: 70, ly: 245},
    {x: 2, y: 1, t: 1, lx: 190, ly: 245},
    {x: 2, y: 2, t: 1, lx: 160, ly: 230},
    {x: 1, y: 3, t: 1, lx: 100, ly: 230},
    {x: 3, y: 1, t: 1, lx: 220, ly: 230},
    {x: 2, y: 3, t: 1, lx: 130, ly: 215},
    {x: 1, y: 4, t: 3, lx: 70, ly: 215},
    {x: 3, y: 2, t: 1, lx: 190, ly: 215},
    {x: 3, y: 3, t: 1, lx: 160, ly: 200},
    {x: 2, y: 4, t: 1, lx: 100, ly: 200},
    {x: 5, y: 5, t: 1, lx: 160, ly: 140},
    {x: 6, y: 4, t: 1, lx: 220, ly: 140},
    {x: 5, y: 6, t: 1, lx: 130, ly: 125},
    {x: 6, y: 5, t: 1, lx: 190, ly: 125},
    {x: 7, y: 4, t: 3, lx: 250, ly: 125},
    {x: 6, y: 6, t: 1, lx: 160, ly: 110},
    {x: 5, y: 7, t: 1, lx: 100, ly: 110},
    {x: 7, y: 5, t: 1, lx: 220, ly: 110},
    {x: 6, y: 7, t: 1, lx: 130, ly: 95},
    {x: 7, y: 6, t: 1, lx: 190, ly: 95},
    {x: 8, y: 5, t: 1, lx: 250, ly: 95},
    {x: 7, y: 7, t: 1, lx: 160, ly: 80},
    {x: 6, y: 8, t: 4, lx: 100, ly: 80},
    {x: 8, y: 6, t: 1, lx: 220, ly: 80},
    {x: 7, y: 8, t: 4, lx: 130, ly: 65},
    {x: 8, y: 7, t: 1, lx: 190, ly: 65},
    {x: -1, y: 0, t: 0, lx: 0, ly: 0},
    {x: -1, y: 1, t: 0, lx: 0, ly: 0},
    {x: -1, y: 2, t: 0, lx: 0, ly: 0},
    {x: -1, y: 3, t: 0, lx: 0, ly: 0},
    {x: -1, y: 4, t: 0, lx: 0, ly: 0},
    {x: 0, y: -1, t: 0, lx: 0, ly: 0},
    {x: 0, y: 0, t: 0, lx: 0, ly: 0},
    {x: 0, y: 4, t: 0, lx: 0, ly: 0},
    {x: 0, y: 5, t: 0, lx: 0, ly: 0},
    {x: 1, y: -1, t: 0, lx: 0, ly: 0},
    {x: 1, y: 5, t: 0, lx: 0, ly: 0},
    {x: 2, y: -1, t: 0, lx: 0, ly: 0},
    {x: 2, y: 5, t: 0, lx: 0, ly: 0},
    {x: 3, y: -1, t: 0, lx: 0, ly: 0},
    {x: 3, y: 0, t: 0, lx: 0, ly: 0},
    {x: 3, y: 4, t: 0, lx: 0, ly: 0},
    {x: 3, y: 5, t: 0, lx: 0, ly: 0},
    {x: 4, y: 0, t: 0, lx: 0, ly: 0},
    {x: 4, y: 1, t: 0, lx: 0, ly: 0},
    {x: 4, y: 2, t: 0, lx: 0, ly: 0},
    {x: 4, y: 3, t: 0, lx: 0, ly: 0},
    {x: 4, y: 4, t: 0, lx: 0, ly: 0},
    {x: 4, y: 5, t: 0, lx: 0, ly: 0},
    {x: 4, y: 6, t: 0, lx: 0, ly: 0},
    {x: 4, y: 7, t: 0, lx: 0, ly: 0},
    {x: 4, y: 8, t: 0, lx: 0, ly: 0},
    {x: 5, y: 3, t: 0, lx: 0, ly: 0},
    {x: 5, y: 4, t: 0, lx: 0, ly: 0},
    {x: 5, y: 8, t: 0, lx: 0, ly: 0},
    {x: 5, y: 9, t: 0, lx: 0, ly: 0},
    {x: 6, y: 3, t: 0, lx: 0, ly: 0},
    {x: 6, y: 9, t: 0, lx: 0, ly: 0},
    {x: 7, y: 3, t: 0, lx: 0, ly: 0},
    {x: 7, y: 9, t: 0, lx: 0, ly: 0},
    {x: 8, y: 3, t: 0, lx: 0, ly: 0},
    {x: 8, y: 4, t: 0, lx: 0, ly: 0},
    {x: 8, y: 8, t: 0, lx: 0, ly: 0},
    {x: 8, y: 9, t: 0, lx: 0, ly: 0},
    {x: 9, y: 4, t: 0, lx: 0, ly: 0},
    {x: 9, y: 5, t: 0, lx: 0, ly: 0},
    {x: 9, y: 6, t: 0, lx: 0, ly: 0},
    {x: 9, y: 7, t: 0, lx: 0, ly: 0},
    {x: 9, y: 8, t: 0, lx: 0, ly: 0},
  ]},

  {n: "Home Alone", w: [
    {x: 0, y: 0, t: 4, lx: 160, ly: 290},
    {x: 0, y: 1, t: 1, lx: 130, ly: 275},
    {x: 1, y: 0, t: 1, lx: 190, ly: 275},
    {x: 1, y: 1, t: 1, lx: 160, ly: 260},
    {x: 0, y: 2, t: 1, lx: 100, ly: 260},
    {x: 2, y: 0, t: 1, lx: 220, ly: 260},
    {x: 1, y: 2, t: 1, lx: 130, ly: 245},
    {x: 0, y: 3, t: 1, lx: 70, ly: 245},
    {x: 2, y: 1, t: 1, lx: 190, ly: 245},
    {x: 3, y: 0, t: 1, lx: 250, ly: 245},
    {x: 2, y: 2, t: 1, lx: 160, ly: 230},
    {x: 1, y: 3, t: 1, lx: 100, ly: 230},
    {x: 0, y: 4, t: 4, lx: 40, ly: 230},
    {x: 3, y: 1, t: 1, lx: 220, ly: 230},
    {x: 4, y: 0, t: 4, lx: 280, ly: 230},
    {x: 2, y: 3, t: 1, lx: 130, ly: 215},
    {x: 1, y: 4, t: 1, lx: 70, ly: 215},
    {x: 3, y: 2, t: 1, lx: 190, ly: 215},
    {x: 4, y: 1, t: 1, lx: 250, ly: 215},
    {x: 3, y: 3, t: 1, lx: 160, ly: 200},
    {x: 2, y: 4, t: 1, lx: 100, ly: 200},
    {x: 1, y: 5, t: 1, lx: 40, ly: 200},
    {x: 4, y: 2, t: 1, lx: 220, ly: 200},
    {x: 5, y: 1, t: 1, lx: 280, ly: 200},
    {x: 3, y: 4, t: 1, lx: 130, ly: 185},
    {x: 2, y: 5, t: 1, lx: 70, ly: 185},
    {x: 4, y: 3, t: 1, lx: 190, ly: 185},
    {x: 5, y: 2, t: 1, lx: 250, ly: 185},
    {x: 4, y: 4, t: 3, lx: 160, ly: 170},
    {x: 3, y: 5, t: 1, lx: 100, ly: 170},
    {x: 2, y: 6, t: 1, lx: 40, ly: 170},
    {x: 5, y: 3, t: 1, lx: 220, ly: 170},
    {x: 6, y: 2, t: 1, lx: 280, ly: 170},
    {x: 4, y: 5, t: 1, lx: 130, ly: 155},
    {x: 3, y: 6, t: 1, lx: 70, ly: 155},
    {x: 5, y: 4, t: 1, lx: 190, ly: 155},
    {x: 6, y: 3, t: 1, lx: 250, ly: 155},
    {x: 5, y: 5, t: 1, lx: 160, ly: 140},
    {x: 4, y: 6, t: 1, lx: 100, ly: 140},
    {x: 3, y: 7, t: 1, lx: 40, ly: 140},
    {x: 6, y: 4, t: 1, lx: 220, ly: 140},
    {x: 7, y: 3, t: 1, lx: 280, ly: 140},
    {x: 5, y: 6, t: 1, lx: 130, ly: 125},
    {x: 4, y: 7, t: 1, lx: 70, ly: 125},
    {x: 6, y: 5, t: 1, lx: 190, ly: 125},
    {x: 7, y: 4, t: 1, lx: 250, ly: 125},
    {x: 6, y: 6, t: 1, lx: 160, ly: 110},
    {x: 5, y: 7, t: 1, lx: 100, ly: 110},
    {x: 4, y: 8, t: 4, lx: 40, ly: 110},
    {x: 7, y: 5, t: 1, lx: 220, ly: 110},
    {x: 8, y: 4, t: 4, lx: 280, ly: 110},
    {x: 6, y: 7, t: 1, lx: 130, ly: 95},
    {x: 5, y: 8, t: 1, lx: 70, ly: 95},
    {x: 7, y: 6, t: 1, lx: 190, ly: 95},
    {x: 8, y: 5, t: 1, lx: 250, ly: 95},
    {x: 7, y: 7, t: 1, lx: 160, ly: 80},
    {x: 6, y: 8, t: 1, lx: 100, ly: 80},
    {x: 8, y: 6, t: 1, lx: 220, ly: 80},
    {x: 7, y: 8, t: 1, lx: 130, ly: 65},
    {x: 8, y: 7, t: 1, lx: 190, ly: 65},
    {x: 8, y: 8, t: 4, lx: 160, ly: 50},
    {x: -1, y: -1, t: 0, lx: 0, ly: 0},
    {x: -1, y: 0, t: 0, lx: 0, ly: 0},
    {x: -1, y: 1, t: 0, lx: 0, ly: 0},
    {x: -1, y: 2, t: 0, lx: 0, ly: 0},
    {x: -1, y: 3, t: 0, lx: 0, ly: 0},
    {x: -1, y: 4, t: 0, lx: 0, ly: 0},
    {x: -1, y: 5, t: 0, lx: 0, ly: 0},
    {x: 0, y: -1, t: 0, lx: 0, ly: 0},
    {x: 0, y: 5, t: 0, lx: 0, ly: 0},
    {x: 0, y: 6, t: 0, lx: 0, ly: 0},
    {x: 1, y: -1, t: 0, lx: 0, ly: 0},
    {x: 1, y: 6, t: 0, lx: 0, ly: 0},
    {x: 1, y: 7, t: 0, lx: 0, ly: 0},
    {x: 2, y: -1, t: 0, lx: 0, ly: 0},
    {x: 2, y: 7, t: 0, lx: 0, ly: 0},
    {x: 2, y: 8, t: 0, lx: 0, ly: 0},
    {x: 3, y: -1, t: 0, lx: 0, ly: 0},
    {x: 3, y: 8, t: 0, lx: 0, ly: 0},
    {x: 3, y: 9, t: 0, lx: 0, ly: 0},
    {x: 4, y: -1, t: 0, lx: 0, ly: 0},
    {x: 4, y: 9, t: 0, lx: 0, ly: 0},
    {x: 5, y: -1, t: 0, lx: 0, ly: 0},
    {x: 5, y: 0, t: 0, lx: 0, ly: 0},
    {x: 5, y: 9, t: 0, lx: 0, ly: 0},
    {x: 6, y: 0, t: 0, lx: 0, ly: 0},
    {x: 6, y: 1, t: 0, lx: 0, ly: 0},
    {x: 6, y: 9, t: 0, lx: 0, ly: 0},
    {x: 7, y: 1, t: 0, lx: 0, ly: 0},
    {x: 7, y: 2, t: 0, lx: 0, ly: 0},
    {x: 7, y: 9, t: 0, lx: 0, ly: 0},
    {x: 8, y: 2, t: 0, lx: 0, ly: 0},
    {x: 8, y: 3, t: 0, lx: 0, ly: 0},
    {x: 8, y: 9, t: 0, lx: 0, ly: 0},
    {x: 9, y: 3, t: 0, lx: 0, ly: 0},
    {x: 9, y: 4, t: 0, lx: 0, ly: 0},
    {x: 9, y: 5, t: 0, lx: 0, ly: 0},
    {x: 9, y: 6, t: 0, lx: 0, ly: 0},
    {x: 9, y: 7, t: 0, lx: 0, ly: 0},
    {x: 9, y: 8, t: 0, lx: 0, ly: 0},
    {x: 9, y: 9, t: 0, lx: 0, ly: 0},
  ]},

  {n: "Fenced In", w: [
    {x: 0, y: 0, t: 2, lx: 160, ly: 290},
    {x: 0, y: 1, t: 2, lx: 130, ly: 275},
    {x: 1, y: 0, t: 2, lx: 190, ly: 275},
    {x: 1, y: 1, t: 4, lx: 160, ly: 260},
    {x: 0, y: 2, t: 2, lx: 100, ly: 260},
    {x: 2, y: 0, t: 2, lx: 220, ly: 260},
    {x: 1, y: 2, t: 3, lx: 130, ly: 245},
    {x: 0, y: 3, t: 2, lx: 70, ly: 245},
    {x: 2, y: 1, t: 3, lx: 190, ly: 245},
    {x: 3, y: 0, t: 2, lx: 250, ly: 245},
    {x: 1, y: 3, t: 1, lx: 100, ly: 230},
    {x: 0, y: 4, t: 2, lx: 40, ly: 230},
    {x: 3, y: 1, t: 1, lx: 220, ly: 230},
    {x: 4, y: 0, t: 2, lx: 280, ly: 230},
    {x: 2, y: 3, t: 1, lx: 130, ly: 215},
    {x: 1, y: 4, t: 1, lx: 70, ly: 215},
    {x: 3, y: 2, t: 1, lx: 190, ly: 215},
    {x: 4, y: 1, t: 1, lx: 250, ly: 215},
    {x: 3, y: 3, t: 1, lx: 160, ly: 200},
    {x: 2, y: 4, t: 1, lx: 100, ly: 200},
    {x: 1, y: 5, t: 2, lx: 40, ly: 200},
    {x: 4, y: 2, t: 1, lx: 220, ly: 200},
    {x: 5, y: 1, t: 2, lx: 280, ly: 200},
    {x: 3, y: 4, t: 1, lx: 130, ly: 185},
    {x: 2, y: 5, t: 4, lx: 70, ly: 185},
    {x: 4, y: 3, t: 1, lx: 190, ly: 185},
    {x: 5, y: 2, t: 4, lx: 250, ly: 185},
    {x: 4, y: 4, t: 1, lx: 160, ly: 170},
    {x: 3, y: 5, t: 1, lx: 100, ly: 170},
    {x: 2, y: 6, t: 2, lx: 40, ly: 170},
    {x: 5, y: 3, t: 1, lx: 220, ly: 170},
    {x: 6, y: 2, t: 2, lx: 280, ly: 170},
    {x: 4, y: 5, t: 1, lx: 130, ly: 155},
    {x: 3, y: 6, t: 4, lx: 70, ly: 155},
    {x: 5, y: 4, t: 1, lx: 190, ly: 155},
    {x: 6, y: 3, t: 4, lx: 250, ly: 155},
    {x: 5, y: 5, t: 1, lx: 160, ly: 140},
    {x: 4, y: 6, t: 1, lx: 100, ly: 140},
    {x: 3, y: 7, t: 2, lx: 40, ly: 140},
    {x: 6, y: 4, t: 1, lx: 220, ly: 140},
    {x: 7, y: 3, t: 2, lx: 280, ly: 140},
    {x: 5, y: 6, t: 1, lx: 130, ly: 125},
    {x: 4, y: 7, t: 1, lx: 70, ly: 125},
    {x: 6, y: 5, t: 1, lx: 190, ly: 125},
    {x: 7, y: 4, t: 1, lx: 250, ly: 125},
    {x: 5, y: 7, t: 1, lx: 100, ly: 110},
    {x: 4, y: 8, t: 2, lx: 40, ly: 110},
    {x: 7, y: 5, t: 1, lx: 220, ly: 110},
    {x: 8, y: 4, t: 2, lx: 280, ly: 110},
    {x: 6, y: 7, t: 1, lx: 130, ly: 95},
    {x: 5, y: 8, t: 2, lx: 70, ly: 95},
    {x: 7, y: 6, t: 1, lx: 190, ly: 95},
    {x: 8, y: 5, t: 2, lx: 250, ly: 95},
    {x: 7, y: 7, t: 1, lx: 160, ly: 80},
    {x: 6, y: 8, t: 2, lx: 100, ly: 80},
    {x: 8, y: 6, t: 2, lx: 220, ly: 80},
    {x: 7, y: 8, t: 2, lx: 130, ly: 65},
    {x: 8, y: 7, t: 2, lx: 190, ly: 65},
    {x: 8, y: 8, t: 2, lx: 160, ly: 50},
    {x: -1, y: -1, t: 0, lx: 0, ly: 0},
    {x: -1, y: 0, t: 0, lx: 0, ly: 0},
    {x: -1, y: 1, t: 0, lx: 0, ly: 0},
    {x: -1, y: 2, t: 0, lx: 0, ly: 0},
    {x: -1, y: 3, t: 0, lx: 0, ly: 0},
    {x: -1, y: 4, t: 0, lx: 0, ly: 0},
    {x: -1, y: 5, t: 0, lx: 0, ly: 0},
    {x: 0, y: -1, t: 0, lx: 0, ly: 0},
    {x: 0, y: 5, t: 0, lx: 0, ly: 0},
    {x: 0, y: 6, t: 0, lx: 0, ly: 0},
    {x: 1, y: -1, t: 0, lx: 0, ly: 0},
    {x: 1, y: 6, t: 0, lx: 0, ly: 0},
    {x: 1, y: 7, t: 0, lx: 0, ly: 0},
    {x: 2, y: -1, t: 0, lx: 0, ly: 0},
    {x: 2, y: 2, t: 0, lx: 0, ly: 0},
    {x: 2, y: 7, t: 0, lx: 0, ly: 0},
    {x: 2, y: 8, t: 0, lx: 0, ly: 0},
    {x: 3, y: -1, t: 0, lx: 0, ly: 0},
    {x: 3, y: 8, t: 0, lx: 0, ly: 0},
    {x: 3, y: 9, t: 0, lx: 0, ly: 0},
    {x: 4, y: -1, t: 0, lx: 0, ly: 0},
    {x: 4, y: 9, t: 0, lx: 0, ly: 0},
    {x: 5, y: -1, t: 0, lx: 0, ly: 0},
    {x: 5, y: 0, t: 0, lx: 0, ly: 0},
    {x: 5, y: 9, t: 0, lx: 0, ly: 0},
    {x: 6, y: 0, t: 0, lx: 0, ly: 0},
    {x: 6, y: 1, t: 0, lx: 0, ly: 0},
    {x: 6, y: 6, t: 0, lx: 0, ly: 0},
    {x: 6, y: 9, t: 0, lx: 0, ly: 0},
    {x: 7, y: 1, t: 0, lx: 0, ly: 0},
    {x: 7, y: 2, t: 0, lx: 0, ly: 0},
    {x: 7, y: 9, t: 0, lx: 0, ly: 0},
    {x: 8, y: 2, t: 0, lx: 0, ly: 0},
    {x: 8, y: 3, t: 0, lx: 0, ly: 0},
    {x: 8, y: 9, t: 0, lx: 0, ly: 0},
    {x: 9, y: 3, t: 0, lx: 0, ly: 0},
    {x: 9, y: 4, t: 0, lx: 0, ly: 0},
    {x: 9, y: 5, t: 0, lx: 0, ly: 0},
    {x: 9, y: 6, t: 0, lx: 0, ly: 0},
    {x: 9, y: 7, t: 0, lx: 0, ly: 0},
    {x: 9, y: 8, t: 0, lx: 0, ly: 0},
    {x: 9, y: 9, t: 0, lx: 0, ly: 0},
  ]},

  {n: "Stalkers", w: [
    {x: 0, y: 0, t: 2, lx: 160, ly: 290},
    {x: -1, y: 1, t: 2, lx: 100, ly: 290},
    {x: 1, y: -1, t: 2, lx: 220, ly: 290},
    {x: 0, y: 1, t: 1, lx: 130, ly: 275},
    {x: -1, y: 2, t: 2, lx: 70, ly: 275},
    {x: 1, y: 0, t: 1, lx: 190, ly: 275},
    {x: 2, y: -1, t: 2, lx: 250, ly: 275},
    {x: 1, y: 1, t: 3, lx: 160, ly: 260},
    {x: 0, y: 2, t: 1, lx: 100, ly: 260},
    {x: -1, y: 3, t: 2, lx: 40, ly: 260},
    {x: 2, y: 0, t: 1, lx: 220, ly: 260},
    {x: 3, y: -1, t: 2, lx: 280, ly: 260},
    {x: 1, y: 2, t: 1, lx: 130, ly: 245},
    {x: 0, y: 3, t: 1, lx: 70, ly: 245},
    {x: 2, y: 1, t: 1, lx: 190, ly: 245},
    {x: 3, y: 0, t: 1, lx: 250, ly: 245},
    {x: 2, y: 2, t: 7, lx: 160, ly: 230},
    {x: 1, y: 3, t: 1, lx: 100, ly: 230},
    {x: 0, y: 4, t: 2, lx: 40, ly: 230},
    {x: 3, y: 1, t: 1, lx: 220, ly: 230},
    {x: 4, y: 0, t: 2, lx: 280, ly: 230},
    {x: 2, y: 3, t: 1, lx: 130, ly: 215},
    {x: 1, y: 4, t: 1, lx: 70, ly: 215},
    {x: 3, y: 2, t: 1, lx: 190, ly: 215},
    {x: 4, y: 1, t: 1, lx: 250, ly: 215},
    {x: 3, y: 3, t: 1, lx: 160, ly: 200},
    {x: 2, y: 4, t: 1, lx: 100, ly: 200},
    {x: 1, y: 5, t: 2, lx: 40, ly: 200},
    {x: 4, y: 2, t: 1, lx: 220, ly: 200},
    {x: 5, y: 1, t: 2, lx: 280, ly: 200},
    {x: 3, y: 4, t: 1, lx: 130, ly: 185},
    {x: 2, y: 5, t: 1, lx: 70, ly: 185},
    {x: 4, y: 3, t: 1, lx: 190, ly: 185},
    {x: 5, y: 2, t: 1, lx: 250, ly: 185},
    {x: 4, y: 4, t: 1, lx: 160, ly: 170},
    {x: 3, y: 5, t: 1, lx: 100, ly: 170},
    {x: 2, y: 6, t: 2, lx: 40, ly: 170},
    {x: 5, y: 3, t: 1, lx: 220, ly: 170},
    {x: 6, y: 2, t: 2, lx: 280, ly: 170},
    {x: 4, y: 5, t: 1, lx: 130, ly: 155},
    {x: 3, y: 6, t: 1, lx: 70, ly: 155},
    {x: 5, y: 4, t: 1, lx: 190, ly: 155},
    {x: 6, y: 3, t: 1, lx: 250, ly: 155},
    {x: 5, y: 5, t: 4, lx: 160, ly: 140},
    {x: 4, y: 6, t: 1, lx: 100, ly: 140},
    {x: 3, y: 7, t: 2, lx: 40, ly: 140},
    {x: 6, y: 4, t: 1, lx: 220, ly: 140},
    {x: 7, y: 3, t: 2, lx: 280, ly: 140},
    {x: 5, y: 6, t: 4, lx: 130, ly: 125},
    {x: 4, y: 7, t: 1, lx: 70, ly: 125},
    {x: 6, y: 5, t: 4, lx: 190, ly: 125},
    {x: 7, y: 4, t: 1, lx: 250, ly: 125},
    {x: 6, y: 6, t: 4, lx: 160, ly: 110},
    {x: 5, y: 7, t: 4, lx: 100, ly: 110},
    {x: 4, y: 8, t: 2, lx: 40, ly: 110},
    {x: 7, y: 5, t: 4, lx: 220, ly: 110},
    {x: 8, y: 4, t: 2, lx: 280, ly: 110},
    {x: 6, y: 7, t: 4, lx: 130, ly: 95},
    {x: 7, y: 6, t: 4, lx: 190, ly: 95},
    {x: -2, y: 0, t: 0, lx: 0, ly: 0},
    {x: -2, y: 1, t: 0, lx: 0, ly: 0},
    {x: -2, y: 2, t: 0, lx: 0, ly: 0},
    {x: -2, y: 3, t: 0, lx: 0, ly: 0},
    {x: -2, y: 4, t: 0, lx: 0, ly: 0},
    {x: -1, y: -1, t: 0, lx: 0, ly: 0},
    {x: -1, y: 0, t: 0, lx: 0, ly: 0},
    {x: -1, y: 4, t: 0, lx: 0, ly: 0},
    {x: -1, y: 5, t: 0, lx: 0, ly: 0},
    {x: 0, y: -2, t: 0, lx: 0, ly: 0},
    {x: 0, y: -1, t: 0, lx: 0, ly: 0},
    {x: 0, y: 5, t: 0, lx: 0, ly: 0},
    {x: 0, y: 6, t: 0, lx: 0, ly: 0},
    {x: 1, y: -2, t: 0, lx: 0, ly: 0},
    {x: 1, y: 6, t: 0, lx: 0, ly: 0},
    {x: 1, y: 7, t: 0, lx: 0, ly: 0},
    {x: 2, y: -2, t: 0, lx: 0, ly: 0},
    {x: 2, y: 7, t: 0, lx: 0, ly: 0},
    {x: 2, y: 8, t: 0, lx: 0, ly: 0},
    {x: 3, y: -2, t: 0, lx: 0, ly: 0},
    {x: 3, y: 8, t: 0, lx: 0, ly: 0},
    {x: 3, y: 9, t: 0, lx: 0, ly: 0},
    {x: 4, y: -2, t: 0, lx: 0, ly: 0},
    {x: 4, y: -1, t: 0, lx: 0, ly: 0},
    {x: 4, y: 9, t: 0, lx: 0, ly: 0},
    {x: 5, y: -1, t: 0, lx: 0, ly: 0},
    {x: 5, y: 0, t: 0, lx: 0, ly: 0},
    {x: 5, y: 8, t: 0, lx: 0, ly: 0},
    {x: 5, y: 9, t: 0, lx: 0, ly: 0},
    {x: 6, y: 0, t: 0, lx: 0, ly: 0},
    {x: 6, y: 1, t: 0, lx: 0, ly: 0},
    {x: 6, y: 8, t: 0, lx: 0, ly: 0},
    {x: 7, y: 1, t: 0, lx: 0, ly: 0},
    {x: 7, y: 2, t: 0, lx: 0, ly: 0},
    {x: 7, y: 7, t: 0, lx: 0, ly: 0},
    {x: 7, y: 8, t: 0, lx: 0, ly: 0},
    {x: 8, y: 2, t: 0, lx: 0, ly: 0},
    {x: 8, y: 3, t: 0, lx: 0, ly: 0},
    {x: 8, y: 5, t: 0, lx: 0, ly: 0},
    {x: 8, y: 6, t: 0, lx: 0, ly: 0},
    {x: 8, y: 7, t: 0, lx: 0, ly: 0},
    {x: 9, y: 3, t: 0, lx: 0, ly: 0},
    {x: 9, y: 4, t: 0, lx: 0, ly: 0},
    {x: 9, y: 5, t: 0, lx: 0, ly: 0},
  ]},

  {n: "Zoombies", w: [
    {x: 0, y: 2, t: 3, lx: 100, ly: 260},
    {x: 1, y: 2, t: 1, lx: 130, ly: 245},
    {x: 0, y: 3, t: 1, lx: 70, ly: 245},
    {x: 2, y: 2, t: 1, lx: 160, ly: 230},
    {x: 1, y: 3, t: 1, lx: 100, ly: 230},
    {x: 0, y: 4, t: 1, lx: 40, ly: 230},
    {x: 2, y: 3, t: 1, lx: 130, ly: 215},
    {x: 1, y: 4, t: 1, lx: 70, ly: 215},
    {x: 3, y: 2, t: 1, lx: 190, ly: 215},
    {x: 3, y: 3, t: 1, lx: 160, ly: 200},
    {x: 2, y: 4, t: 1, lx: 100, ly: 200},
    {x: 1, y: 5, t: 1, lx: 40, ly: 200},
    {x: 4, y: 2, t: 1, lx: 220, ly: 200},
    {x: 3, y: 4, t: 1, lx: 130, ly: 185},
    {x: 2, y: 5, t: 1, lx: 70, ly: 185},
    {x: 4, y: 3, t: 1, lx: 190, ly: 185},
    {x: 5, y: 2, t: 1, lx: 250, ly: 185},
    {x: 4, y: 4, t: 1, lx: 160, ly: 170},
    {x: 3, y: 5, t: 1, lx: 100, ly: 170},
    {x: 2, y: 6, t: 1, lx: 40, ly: 170},
    {x: 5, y: 3, t: 1, lx: 220, ly: 170},
    {x: 6, y: 2, t: 1, lx: 280, ly: 170},
    {x: 4, y: 5, t: 1, lx: 130, ly: 155},
    {x: 3, y: 6, t: 1, lx: 70, ly: 155},
    {x: 5, y: 4, t: 1, lx: 190, ly: 155},
    {x: 6, y: 3, t: 2, lx: 250, ly: 155},
    {x: 5, y: 5, t: 4, lx: 160, ly: 140},
    {x: 4, y: 6, t: 1, lx: 100, ly: 140},
    {x: 3, y: 7, t: 1, lx: 40, ly: 140},
    {x: 6, y: 4, t: 4, lx: 220, ly: 140},
    {x: 7, y: 3, t: 2, lx: 280, ly: 140},
    {x: 5, y: 6, t: 1, lx: 130, ly: 125},
    {x: 4, y: 7, t: 1, lx: 70, ly: 125},
    {x: 6, y: 5, t: 4, lx: 190, ly: 125},
    {x: 7, y: 4, t: 2, lx: 250, ly: 125},
    {x: 6, y: 6, t: 4, lx: 160, ly: 110},
    {x: 5, y: 7, t: 1, lx: 100, ly: 110},
    {x: 4, y: 8, t: 1, lx: 40, ly: 110},
    {x: 7, y: 5, t: 2, lx: 220, ly: 110},
    {x: 8, y: 4, t: 1, lx: 280, ly: 110},
    {x: 6, y: 7, t: 2, lx: 130, ly: 95},
    {x: 5, y: 8, t: 1, lx: 70, ly: 95},
    {x: 7, y: 6, t: 2, lx: 190, ly: 95},
    {x: 8, y: 5, t: 3, lx: 250, ly: 95},
    {x: 7, y: 7, t: 2, lx: 160, ly: 80},
    {x: 6, y: 8, t: 1, lx: 100, ly: 80},
    {x: 8, y: 6, t: 1, lx: 220, ly: 80},
    {x: 7, y: 8, t: 1, lx: 130, ly: 65},
    {x: 8, y: 7, t: 1, lx: 190, ly: 65},
    {x: 8, y: 8, t: 1, lx: 160, ly: 50},
    {x: -1, y: 1, t: 0, lx: 0, ly: 0},
    {x: -1, y: 2, t: 0, lx: 0, ly: 0},
    {x: -1, y: 3, t: 0, lx: 0, ly: 0},
    {x: -1, y: 4, t: 0, lx: 0, ly: 0},
    {x: -1, y: 5, t: 0, lx: 0, ly: 0},
    {x: 0, y: 1, t: 0, lx: 0, ly: 0},
    {x: 0, y: 5, t: 0, lx: 0, ly: 0},
    {x: 0, y: 6, t: 0, lx: 0, ly: 0},
    {x: 1, y: 1, t: 0, lx: 0, ly: 0},
    {x: 1, y: 6, t: 0, lx: 0, ly: 0},
    {x: 1, y: 7, t: 0, lx: 0, ly: 0},
    {x: 2, y: 1, t: 0, lx: 0, ly: 0},
    {x: 2, y: 7, t: 0, lx: 0, ly: 0},
    {x: 2, y: 8, t: 0, lx: 0, ly: 0},
    {x: 3, y: 1, t: 0, lx: 0, ly: 0},
    {x: 3, y: 8, t: 0, lx: 0, ly: 0},
    {x: 3, y: 9, t: 0, lx: 0, ly: 0},
    {x: 4, y: 1, t: 0, lx: 0, ly: 0},
    {x: 4, y: 9, t: 0, lx: 0, ly: 0},
    {x: 5, y: 1, t: 0, lx: 0, ly: 0},
    {x: 5, y: 9, t: 0, lx: 0, ly: 0},
    {x: 6, y: 1, t: 0, lx: 0, ly: 0},
    {x: 6, y: 9, t: 0, lx: 0, ly: 0},
    {x: 7, y: 1, t: 0, lx: 0, ly: 0},
    {x: 7, y: 2, t: 0, lx: 0, ly: 0},
    {x: 7, y: 9, t: 0, lx: 0, ly: 0},
    {x: 8, y: 2, t: 0, lx: 0, ly: 0},
    {x: 8, y: 3, t: 0, lx: 0, ly: 0},
    {x: 8, y: 9, t: 0, lx: 0, ly: 0},
    {x: 9, y: 3, t: 0, lx: 0, ly: 0},
    {x: 9, y: 4, t: 0, lx: 0, ly: 0},
    {x: 9, y: 5, t: 0, lx: 0, ly: 0},
    {x: 9, y: 6, t: 0, lx: 0, ly: 0},
    {x: 9, y: 7, t: 0, lx: 0, ly: 0},
    {x: 9, y: 8, t: 0, lx: 0, ly: 0},
    {x: 9, y: 9, t: 0, lx: 0, ly: 0},
  ]},

  {n: "Boss", w: [
    {x: 0, y: 0, t: 1, lx: 160, ly: 290},
    {x: 0, y: 1, t: 1, lx: 130, ly: 275},
    {x: 1, y: 0, t: 1, lx: 190, ly: 275},
    {x: 1, y: 1, t: 1, lx: 160, ly: 260},
    {x: 0, y: 2, t: 1, lx: 100, ly: 260},
    {x: 2, y: 0, t: 1, lx: 220, ly: 260},
    {x: 1, y: 2, t: 1, lx: 130, ly: 245},
    {x: 0, y: 3, t: 1, lx: 70, ly: 245},
    {x: 2, y: 1, t: 1, lx: 190, ly: 245},
    {x: 3, y: 0, t: 1, lx: 250, ly: 245},
    {x: 2, y: 2, t: 1, lx: 160, ly: 230},
    {x: 1, y: 3, t: 3, lx: 100, ly: 230},
    {x: 0, y: 4, t: 1, lx: 40, ly: 230},
    {x: 3, y: 1, t: 3, lx: 220, ly: 230},
    {x: 4, y: 0, t: 1, lx: 280, ly: 230},
    {x: 2, y: 3, t: 1, lx: 130, ly: 215},
    {x: 1, y: 4, t: 2, lx: 70, ly: 215},
    {x: 3, y: 2, t: 1, lx: 190, ly: 215},
    {x: 4, y: 1, t: 2, lx: 250, ly: 215},
    {x: 3, y: 3, t: 1, lx: 160, ly: 200},
    {x: 2, y: 4, t: 1, lx: 100, ly: 200},
    {x: 1, y: 5, t: 1, lx: 40, ly: 200},
    {x: 4, y: 2, t: 1, lx: 220, ly: 200},
    {x: 5, y: 1, t: 1, lx: 280, ly: 200},
    {x: 3, y: 4, t: 1, lx: 130, ly: 185},
    {x: 2, y: 5, t: 1, lx: 70, ly: 185},
    {x: 4, y: 3, t: 1, lx: 190, ly: 185},
    {x: 5, y: 2, t: 1, lx: 250, ly: 185},
    {x: 4, y: 4, t: 5, lx: 160, ly: 170},
    {x: 3, y: 5, t: 1, lx: 100, ly: 170},
    {x: 2, y: 6, t: 1, lx: 40, ly: 170},
    {x: 5, y: 3, t: 1, lx: 220, ly: 170},
    {x: 6, y: 2, t: 1, lx: 280, ly: 170},
    {x: 4, y: 5, t: 1, lx: 130, ly: 155},
    {x: 3, y: 6, t: 1, lx: 70, ly: 155},
    {x: 5, y: 4, t: 1, lx: 190, ly: 155},
    {x: 6, y: 3, t: 1, lx: 250, ly: 155},
    {x: 5, y: 5, t: 1, lx: 160, ly: 140},
    {x: 4, y: 6, t: 1, lx: 100, ly: 140},
    {x: 3, y: 7, t: 1, lx: 40, ly: 140},
    {x: 6, y: 4, t: 1, lx: 220, ly: 140},
    {x: 7, y: 3, t: 1, lx: 280, ly: 140},
    {x: 5, y: 6, t: 1, lx: 130, ly: 125},
    {x: 4, y: 7, t: 2, lx: 70, ly: 125},
    {x: 6, y: 5, t: 1, lx: 190, ly: 125},
    {x: 7, y: 4, t: 2, lx: 250, ly: 125},
    {x: 6, y: 6, t: 1, lx: 160, ly: 110},
    {x: 5, y: 7, t: 3, lx: 100, ly: 110},
    {x: 4, y: 8, t: 1, lx: 40, ly: 110},
    {x: 7, y: 5, t: 3, lx: 220, ly: 110},
    {x: 8, y: 4, t: 1, lx: 280, ly: 110},
    {x: 6, y: 7, t: 1, lx: 130, ly: 95},
    {x: 5, y: 8, t: 1, lx: 70, ly: 95},
    {x: 7, y: 6, t: 1, lx: 190, ly: 95},
    {x: 8, y: 5, t: 1, lx: 250, ly: 95},
    {x: 7, y: 7, t: 1, lx: 160, ly: 80},
    {x: 6, y: 8, t: 1, lx: 100, ly: 80},
    {x: 8, y: 6, t: 1, lx: 220, ly: 80},
    {x: 7, y: 8, t: 1, lx: 130, ly: 65},
    {x: 8, y: 7, t: 1, lx: 190, ly: 65},
    {x: 8, y: 8, t: 1, lx: 160, ly: 50},
    {x: -1, y: -1, t: 0, lx: 0, ly: 0},
    {x: -1, y: 0, t: 0, lx: 0, ly: 0},
    {x: -1, y: 1, t: 0, lx: 0, ly: 0},
    {x: -1, y: 2, t: 0, lx: 0, ly: 0},
    {x: -1, y: 3, t: 0, lx: 0, ly: 0},
    {x: -1, y: 4, t: 0, lx: 0, ly: 0},
    {x: -1, y: 5, t: 0, lx: 0, ly: 0},
    {x: 0, y: -1, t: 0, lx: 0, ly: 0},
    {x: 0, y: 5, t: 0, lx: 0, ly: 0},
    {x: 0, y: 6, t: 0, lx: 0, ly: 0},
    {x: 1, y: -1, t: 0, lx: 0, ly: 0},
    {x: 1, y: 6, t: 0, lx: 0, ly: 0},
    {x: 1, y: 7, t: 0, lx: 0, ly: 0},
    {x: 2, y: -1, t: 0, lx: 0, ly: 0},
    {x: 2, y: 7, t: 0, lx: 0, ly: 0},
    {x: 2, y: 8, t: 0, lx: 0, ly: 0},
    {x: 3, y: -1, t: 0, lx: 0, ly: 0},
    {x: 3, y: 8, t: 0, lx: 0, ly: 0},
    {x: 3, y: 9, t: 0, lx: 0, ly: 0},
    {x: 4, y: -1, t: 0, lx: 0, ly: 0},
    {x: 4, y: 9, t: 0, lx: 0, ly: 0},
    {x: 5, y: -1, t: 0, lx: 0, ly: 0},
    {x: 5, y: 0, t: 0, lx: 0, ly: 0},
    {x: 5, y: 9, t: 0, lx: 0, ly: 0},
    {x: 6, y: 0, t: 0, lx: 0, ly: 0},
    {x: 6, y: 1, t: 0, lx: 0, ly: 0},
    {x: 6, y: 9, t: 0, lx: 0, ly: 0},
    {x: 7, y: 1, t: 0, lx: 0, ly: 0},
    {x: 7, y: 2, t: 0, lx: 0, ly: 0},
    {x: 7, y: 9, t: 0, lx: 0, ly: 0},
    {x: 8, y: 2, t: 0, lx: 0, ly: 0},
    {x: 8, y: 3, t: 0, lx: 0, ly: 0},
    {x: 8, y: 9, t: 0, lx: 0, ly: 0},
    {x: 9, y: 3, t: 0, lx: 0, ly: 0},
    {x: 9, y: 4, t: 0, lx: 0, ly: 0},
    {x: 9, y: 5, t: 0, lx: 0, ly: 0},
    {x: 9, y: 6, t: 0, lx: 0, ly: 0},
    {x: 9, y: 7, t: 0, lx: 0, ly: 0},
    {x: 9, y: 8, t: 0, lx: 0, ly: 0},
    {x: 9, y: 9, t: 0, lx: 0, ly: 0},
  ]},

  {n: "Striker", w: [
    {x: 1, y: 1, t: 1, lx: 160, ly: 260},
    {x: 1, y: 2, t: 1, lx: 130, ly: 245},
    {x: 2, y: 1, t: 1, lx: 190, ly: 245},
    {x: 2, y: 2, t: 1, lx: 160, ly: 230},
    {x: 1, y: 3, t: 1, lx: 100, ly: 230},
    {x: 3, y: 1, t: 1, lx: 220, ly: 230},
    {x: 2, y: 3, t: 1, lx: 130, ly: 215},
    {x: 1, y: 4, t: 1, lx: 70, ly: 215},
    {x: 3, y: 2, t: 1, lx: 190, ly: 215},
    {x: 4, y: 1, t: 1, lx: 250, ly: 215},
    {x: 3, y: 3, t: 1, lx: 160, ly: 200},
    {x: 2, y: 4, t: 1, lx: 100, ly: 200},
    {x: 4, y: 2, t: 1, lx: 220, ly: 200},
    {x: 3, y: 4, t: 1, lx: 130, ly: 185},
    {x: 2, y: 5, t: 3, lx: 70, ly: 185},
    {x: 4, y: 3, t: 1, lx: 190, ly: 185},
    {x: 5, y: 2, t: 3, lx: 250, ly: 185},
    {x: 4, y: 4, t: 1, lx: 160, ly: 170},
    {x: 3, y: 5, t: 2, lx: 100, ly: 170},
    {x: 5, y: 3, t: 2, lx: 220, ly: 170},
    {x: 4, y: 5, t: 1, lx: 130, ly: 155},
    {x: 3, y: 6, t: 2, lx: 70, ly: 155},
    {x: 5, y: 4, t: 1, lx: 190, ly: 155},
    {x: 6, y: 3, t: 2, lx: 250, ly: 155},
    {x: 5, y: 5, t: 1, lx: 160, ly: 140},
    {x: 4, y: 6, t: 1, lx: 100, ly: 140},
    {x: 6, y: 4, t: 1, lx: 220, ly: 140},
    {x: 5, y: 6, t: 1, lx: 130, ly: 125},
    {x: 4, y: 7, t: 1, lx: 70, ly: 125},
    {x: 6, y: 5, t: 1, lx: 190, ly: 125},
    {x: 7, y: 4, t: 1, lx: 250, ly: 125},
    {x: 6, y: 6, t: 6, lx: 160, ly: 110},
    {x: 5, y: 7, t: 1, lx: 100, ly: 110},
    {x: 7, y: 5, t: 1, lx: 220, ly: 110},
    {x: 6, y: 7, t: 1, lx: 130, ly: 95},
    {x: 7, y: 6, t: 1, lx: 190, ly: 95},
    {x: 7, y: 7, t: 1, lx: 160, ly: 80},
    {x: 0, y: 0, t: 0, lx: 0, ly: 0},
    {x: 0, y: 1, t: 0, lx: 0, ly: 0},
    {x: 0, y: 2, t: 0, lx: 0, ly: 0},
    {x: 0, y: 3, t: 0, lx: 0, ly: 0},
    {x: 0, y: 4, t: 0, lx: 0, ly: 0},
    {x: 0, y: 5, t: 0, lx: 0, ly: 0},
    {x: 1, y: 0, t: 0, lx: 0, ly: 0},
    {x: 1, y: 5, t: 0, lx: 0, ly: 0},
    {x: 1, y: 6, t: 0, lx: 0, ly: 0},
    {x: 2, y: 0, t: 0, lx: 0, ly: 0},
    {x: 2, y: 6, t: 0, lx: 0, ly: 0},
    {x: 2, y: 7, t: 0, lx: 0, ly: 0},
    {x: 3, y: 0, t: 0, lx: 0, ly: 0},
    {x: 3, y: 7, t: 0, lx: 0, ly: 0},
    {x: 3, y: 8, t: 0, lx: 0, ly: 0},
    {x: 4, y: 0, t: 0, lx: 0, ly: 0},
    {x: 4, y: 8, t: 0, lx: 0, ly: 0},
    {x: 5, y: 0, t: 0, lx: 0, ly: 0},
    {x: 5, y: 1, t: 0, lx: 0, ly: 0},
    {x: 5, y: 8, t: 0, lx: 0, ly: 0},
    {x: 6, y: 1, t: 0, lx: 0, ly: 0},
    {x: 6, y: 2, t: 0, lx: 0, ly: 0},
    {x: 6, y: 8, t: 0, lx: 0, ly: 0},
    {x: 7, y: 2, t: 0, lx: 0, ly: 0},
    {x: 7, y: 3, t: 0, lx: 0, ly: 0},
    {x: 7, y: 8, t: 0, lx: 0, ly: 0},
    {x: 8, y: 3, t: 0, lx: 0, ly: 0},
    {x: 8, y: 4, t: 0, lx: 0, ly: 0},
    {x: 8, y: 5, t: 0, lx: 0, ly: 0},
    {x: 8, y: 6, t: 0, lx: 0, ly: 0},
    {x: 8, y: 7, t: 0, lx: 0, ly: 0},
    {x: 8, y: 8, t: 0, lx: 0, ly: 0},
  ]},

  {n: "Dilemma", w: [
    {x: 0, y: 0, t: 3, lx: 160, ly: 290},
    {x: 0, y: 1, t: 1, lx: 130, ly: 275},
    {x: 1, y: 0, t: 1, lx: 190, ly: 275},
    {x: 1, y: 1, t: 1, lx: 160, ly: 260},
    {x: 1, y: 2, t: 1, lx: 130, ly: 245},
    {x: 2, y: 1, t: 1, lx: 190, ly: 245},
    {x: 2, y: 2, t: 1, lx: 160, ly: 230},
    {x: 2, y: 3, t: 1, lx: 130, ly: 215},
    {x: 3, y: 2, t: 1, lx: 190, ly: 215},
    {x: 3, y: 3, t: 1, lx: 160, ly: 200},
    {x: 2, y: 4, t: 1, lx: 100, ly: 200},
    {x: 4, y: 2, t: 1, lx: 220, ly: 200},
    {x: 3, y: 4, t: 1, lx: 130, ly: 185},
    {x: 2, y: 5, t: 1, lx: 70, ly: 185},
    {x: 4, y: 3, t: 1, lx: 190, ly: 185},
    {x: 5, y: 2, t: 1, lx: 250, ly: 185},
    {x: 4, y: 4, t: 1, lx: 160, ly: 170},
    {x: 3, y: 5, t: 1, lx: 100, ly: 170},
    {x: 2, y: 6, t: 6, lx: 40, ly: 170},
    {x: 5, y: 3, t: 1, lx: 220, ly: 170},
    {x: 6, y: 2, t: 6, lx: 280, ly: 170},
    {x: 4, y: 5, t: 1, lx: 130, ly: 155},
    {x: 3, y: 6, t: 1, lx: 70, ly: 155},
    {x: 5, y: 4, t: 1, lx: 190, ly: 155},
    {x: 6, y: 3, t: 1, lx: 250, ly: 155},
    {x: 5, y: 5, t: 1, lx: 160, ly: 140},
    {x: 4, y: 6, t: 1, lx: 100, ly: 140},
    {x: 6, y: 4, t: 1, lx: 220, ly: 140},
    {x: 5, y: 6, t: 2, lx: 130, ly: 125},
    {x: 6, y: 5, t: 2, lx: 190, ly: 125},
    {x: 6, y: 6, t: 2, lx: 160, ly: 110},
    {x: -1, y: -1, t: 0, lx: 0, ly: 0},
    {x: -1, y: 0, t: 0, lx: 0, ly: 0},
    {x: -1, y: 1, t: 0, lx: 0, ly: 0},
    {x: -1, y: 2, t: 0, lx: 0, ly: 0},
    {x: 0, y: -1, t: 0, lx: 0, ly: 0},
    {x: 0, y: 2, t: 0, lx: 0, ly: 0},
    {x: 0, y: 3, t: 0, lx: 0, ly: 0},
    {x: 1, y: -1, t: 0, lx: 0, ly: 0},
    {x: 1, y: 3, t: 0, lx: 0, ly: 0},
    {x: 1, y: 4, t: 0, lx: 0, ly: 0},
    {x: 1, y: 5, t: 0, lx: 0, ly: 0},
    {x: 1, y: 6, t: 0, lx: 0, ly: 0},
    {x: 1, y: 7, t: 0, lx: 0, ly: 0},
    {x: 2, y: -1, t: 0, lx: 0, ly: 0},
    {x: 2, y: 0, t: 0, lx: 0, ly: 0},
    {x: 2, y: 7, t: 0, lx: 0, ly: 0},
    {x: 3, y: 0, t: 0, lx: 0, ly: 0},
    {x: 3, y: 1, t: 0, lx: 0, ly: 0},
    {x: 3, y: 7, t: 0, lx: 0, ly: 0},
    {x: 4, y: 1, t: 0, lx: 0, ly: 0},
    {x: 4, y: 7, t: 0, lx: 0, ly: 0},
    {x: 5, y: 1, t: 0, lx: 0, ly: 0},
    {x: 5, y: 7, t: 0, lx: 0, ly: 0},
    {x: 6, y: 1, t: 0, lx: 0, ly: 0},
    {x: 6, y: 7, t: 0, lx: 0, ly: 0},
    {x: 7, y: 1, t: 0, lx: 0, ly: 0},
    {x: 7, y: 2, t: 0, lx: 0, ly: 0},
    {x: 7, y: 3, t: 0, lx: 0, ly: 0},
    {x: 7, y: 4, t: 0, lx: 0, ly: 0},
    {x: 7, y: 5, t: 0, lx: 0, ly: 0},
    {x: 7, y: 6, t: 0, lx: 0, ly: 0},
    {x: 7, y: 7, t: 0, lx: 0, ly: 0},
  ]},

  {n: "Battle", w: [
    {x: 0, y: 1, t: 3, lx: 130, ly: 275},
    {x: -1, y: 2, t: 3, lx: 70, ly: 275},
    {x: 1, y: 0, t: 3, lx: 190, ly: 275},
    {x: 2, y: -1, t: 3, lx: 250, ly: 275},
    {x: 1, y: 1, t: 1, lx: 160, ly: 260},
    {x: 0, y: 2, t: 1, lx: 100, ly: 260},
    {x: -1, y: 3, t: 1, lx: 40, ly: 260},
    {x: 2, y: 0, t: 1, lx: 220, ly: 260},
    {x: 3, y: -1, t: 1, lx: 280, ly: 260},
    {x: 1, y: 2, t: 1, lx: 130, ly: 245},
    {x: 0, y: 3, t: 1, lx: 70, ly: 245},
    {x: 2, y: 1, t: 1, lx: 190, ly: 245},
    {x: 3, y: 0, t: 1, lx: 250, ly: 245},
    {x: 2, y: 2, t: 1, lx: 160, ly: 230},
    {x: 1, y: 3, t: 1, lx: 100, ly: 230},
    {x: 0, y: 4, t: 1, lx: 40, ly: 230},
    {x: 3, y: 1, t: 1, lx: 220, ly: 230},
    {x: 4, y: 0, t: 1, lx: 280, ly: 230},
    {x: 2, y: 3, t: 1, lx: 130, ly: 215},
    {x: 1, y: 4, t: 1, lx: 70, ly: 215},
    {x: 3, y: 2, t: 1, lx: 190, ly: 215},
    {x: 4, y: 1, t: 1, lx: 250, ly: 215},
    {x: 3, y: 3, t: 1, lx: 160, ly: 200},
    {x: 2, y: 4, t: 1, lx: 100, ly: 200},
    {x: 1, y: 5, t: 1, lx: 40, ly: 200},
    {x: 4, y: 2, t: 1, lx: 220, ly: 200},
    {x: 5, y: 1, t: 1, lx: 280, ly: 200},
    {x: 3, y: 4, t: 1, lx: 130, ly: 185},
    {x: 2, y: 5, t: 1, lx: 70, ly: 185},
    {x: 4, y: 3, t: 1, lx: 190, ly: 185},
    {x: 5, y: 2, t: 1, lx: 250, ly: 185},
    {x: 4, y: 4, t: 1, lx: 160, ly: 170},
    {x: 3, y: 5, t: 1, lx: 100, ly: 170},
    {x: 2, y: 6, t: 1, lx: 40, ly: 170},
    {x: 5, y: 3, t: 1, lx: 220, ly: 170},
    {x: 6, y: 2, t: 1, lx: 280, ly: 170},
    {x: 4, y: 5, t: 1, lx: 130, ly: 155},
    {x: 3, y: 6, t: 1, lx: 70, ly: 155},
    {x: 5, y: 4, t: 1, lx: 190, ly: 155},
    {x: 6, y: 3, t: 1, lx: 250, ly: 155},
    {x: 5, y: 5, t: 1, lx: 160, ly: 140},
    {x: 4, y: 6, t: 1, lx: 100, ly: 140},
    {x: 3, y: 7, t: 1, lx: 40, ly: 140},
    {x: 6, y: 4, t: 1, lx: 220, ly: 140},
    {x: 7, y: 3, t: 1, lx: 280, ly: 140},
    {x: 5, y: 6, t: 1, lx: 130, ly: 125},
    {x: 4, y: 7, t: 1, lx: 70, ly: 125},
    {x: 6, y: 5, t: 1, lx: 190, ly: 125},
    {x: 7, y: 4, t: 1, lx: 250, ly: 125},
    {x: 6, y: 6, t: 1, lx: 160, ly: 110},
    {x: 5, y: 7, t: 1, lx: 100, ly: 110},
    {x: 4, y: 8, t: 1, lx: 40, ly: 110},
    {x: 7, y: 5, t: 1, lx: 220, ly: 110},
    {x: 8, y: 4, t: 1, lx: 280, ly: 110},
    {x: 6, y: 7, t: 1, lx: 130, ly: 95},
    {x: 5, y: 8, t: 1, lx: 70, ly: 95},
    {x: 7, y: 6, t: 1, lx: 190, ly: 95},
    {x: 8, y: 5, t: 1, lx: 250, ly: 95},
    {x: 7, y: 7, t: 6, lx: 160, ly: 80},
    {x: 6, y: 8, t: 6, lx: 100, ly: 80},
    {x: 5, y: 9, t: 6, lx: 40, ly: 80},
    {x: 8, y: 6, t: 6, lx: 220, ly: 80},
    {x: 9, y: 5, t: 6, lx: 280, ly: 80},
    {x: -2, y: 1, t: 0, lx: 0, ly: 0},
    {x: -2, y: 2, t: 0, lx: 0, ly: 0},
    {x: -2, y: 3, t: 0, lx: 0, ly: 0},
    {x: -2, y: 4, t: 0, lx: 0, ly: 0},
    {x: -1, y: 0, t: 0, lx: 0, ly: 0},
    {x: -1, y: 1, t: 0, lx: 0, ly: 0},
    {x: -1, y: 4, t: 0, lx: 0, ly: 0},
    {x: -1, y: 5, t: 0, lx: 0, ly: 0},
    {x: 0, y: -1, t: 0, lx: 0, ly: 0},
    {x: 0, y: 0, t: 0, lx: 0, ly: 0},
    {x: 0, y: 5, t: 0, lx: 0, ly: 0},
    {x: 0, y: 6, t: 0, lx: 0, ly: 0},
    {x: 1, y: -2, t: 0, lx: 0, ly: 0},
    {x: 1, y: -1, t: 0, lx: 0, ly: 0},
    {x: 1, y: 6, t: 0, lx: 0, ly: 0},
    {x: 1, y: 7, t: 0, lx: 0, ly: 0},
    {x: 2, y: -2, t: 0, lx: 0, ly: 0},
    {x: 2, y: 7, t: 0, lx: 0, ly: 0},
    {x: 2, y: 8, t: 0, lx: 0, ly: 0},
    {x: 3, y: -2, t: 0, lx: 0, ly: 0},
    {x: 3, y: 8, t: 0, lx: 0, ly: 0},
    {x: 3, y: 9, t: 0, lx: 0, ly: 0},
    {x: 4, y: -2, t: 0, lx: 0, ly: 0},
    {x: 4, y: -1, t: 0, lx: 0, ly: 0},
    {x: 4, y: 9, t: 0, lx: 0, ly: 0},
    {x: 4, y: 10, t: 0, lx: 0, ly: 0},
    {x: 5, y: -1, t: 0, lx: 0, ly: 0},
    {x: 5, y: 0, t: 0, lx: 0, ly: 0},
    {x: 5, y: 10, t: 0, lx: 0, ly: 0},
    {x: 6, y: 0, t: 0, lx: 0, ly: 0},
    {x: 6, y: 1, t: 0, lx: 0, ly: 0},
    {x: 6, y: 9, t: 0, lx: 0, ly: 0},
    {x: 6, y: 10, t: 0, lx: 0, ly: 0},
    {x: 7, y: 1, t: 0, lx: 0, ly: 0},
    {x: 7, y: 2, t: 0, lx: 0, ly: 0},
    {x: 7, y: 8, t: 0, lx: 0, ly: 0},
    {x: 7, y: 9, t: 0, lx: 0, ly: 0},
    {x: 8, y: 2, t: 0, lx: 0, ly: 0},
    {x: 8, y: 3, t: 0, lx: 0, ly: 0},
    {x: 8, y: 7, t: 0, lx: 0, ly: 0},
    {x: 8, y: 8, t: 0, lx: 0, ly: 0},
    {x: 9, y: 3, t: 0, lx: 0, ly: 0},
    {x: 9, y: 4, t: 0, lx: 0, ly: 0},
    {x: 9, y: 6, t: 0, lx: 0, ly: 0},
    {x: 9, y: 7, t: 0, lx: 0, ly: 0},
    {x: 10, y: 4, t: 0, lx: 0, ly: 0},
    {x: 10, y: 5, t: 0, lx: 0, ly: 0},
    {x: 10, y: 6, t: 0, lx: 0, ly: 0},
  ]},

  {n: "Flakes", w: [
    {x: 0, y: 0, t: 1, lx: 160, ly: 290},
    {x: 0, y: 1, t: 1, lx: 130, ly: 275},
    {x: 1, y: 0, t: 1, lx: 190, ly: 275},
    {x: 1, y: 1, t: 1, lx: 160, ly: 260},
    {x: 0, y: 2, t: 1, lx: 100, ly: 260},
    {x: 2, y: 0, t: 1, lx: 220, ly: 260},
    {x: 1, y: 2, t: 1, lx: 130, ly: 245},
    {x: 0, y: 3, t: 1, lx: 70, ly: 245},
    {x: 2, y: 1, t: 1, lx: 190, ly: 245},
    {x: 3, y: 0, t: 1, lx: 250, ly: 245},
    {x: 2, y: 2, t: 3, lx: 160, ly: 230},
    {x: 1, y: 3, t: 1, lx: 100, ly: 230},
    {x: 0, y: 4, t: 1, lx: 40, ly: 230},
    {x: 3, y: 1, t: 1, lx: 220, ly: 230},
    {x: 4, y: 0, t: 1, lx: 280, ly: 230},
    {x: 2, y: 3, t: 3, lx: 130, ly: 215},
    {x: 1, y: 4, t: 1, lx: 70, ly: 215},
    {x: 3, y: 2, t: 3, lx: 190, ly: 215},
    {x: 4, y: 1, t: 1, lx: 250, ly: 215},
    {x: 3, y: 3, t: 7, lx: 160, ly: 200},
    {x: 2, y: 4, t: 1, lx: 100, ly: 200},
    {x: 1, y: 5, t: 1, lx: 40, ly: 200},
    {x: 4, y: 2, t: 1, lx: 220, ly: 200},
    {x: 5, y: 1, t: 1, lx: 280, ly: 200},
    {x: 3, y: 4, t: 7, lx: 130, ly: 185},
    {x: 2, y: 5, t: 1, lx: 70, ly: 185},
    {x: 4, y: 3, t: 7, lx: 190, ly: 185},
    {x: 5, y: 2, t: 1, lx: 250, ly: 185},
    {x: 4, y: 4, t: 1, lx: 160, ly: 170},
    {x: 3, y: 5, t: 1, lx: 100, ly: 170},
    {x: 2, y: 6, t: 1, lx: 40, ly: 170},
    {x: 5, y: 3, t: 1, lx: 220, ly: 170},
    {x: 6, y: 2, t: 1, lx: 280, ly: 170},
    {x: 4, y: 5, t: 1, lx: 130, ly: 155},
    {x: 3, y: 6, t: 1, lx: 70, ly: 155},
    {x: 5, y: 4, t: 1, lx: 190, ly: 155},
    {x: 6, y: 3, t: 1, lx: 250, ly: 155},
    {x: 5, y: 5, t: 1, lx: 160, ly: 140},
    {x: 4, y: 6, t: 1, lx: 100, ly: 140},
    {x: 3, y: 7, t: 1, lx: 40, ly: 140},
    {x: 6, y: 4, t: 1, lx: 220, ly: 140},
    {x: 7, y: 3, t: 1, lx: 280, ly: 140},
    {x: 5, y: 6, t: 1, lx: 130, ly: 125},
    {x: 4, y: 7, t: 1, lx: 70, ly: 125},
    {x: 6, y: 5, t: 1, lx: 190, ly: 125},
    {x: 7, y: 4, t: 1, lx: 250, ly: 125},
    {x: 6, y: 6, t: 1, lx: 160, ly: 110},
    {x: 5, y: 7, t: 1, lx: 100, ly: 110},
    {x: 4, y: 8, t: 1, lx: 40, ly: 110},
    {x: 7, y: 5, t: 1, lx: 220, ly: 110},
    {x: 8, y: 4, t: 1, lx: 280, ly: 110},
    {x: 6, y: 7, t: 6, lx: 130, ly: 95},
    {x: 5, y: 8, t: 1, lx: 70, ly: 95},
    {x: 7, y: 6, t: 6, lx: 190, ly: 95},
    {x: 8, y: 5, t: 1, lx: 250, ly: 95},
    {x: 7, y: 7, t: 6, lx: 160, ly: 80},
    {x: 6, y: 8, t: 1, lx: 100, ly: 80},
    {x: 8, y: 6, t: 1, lx: 220, ly: 80},
    {x: 7, y: 8, t: 1, lx: 130, ly: 65},
    {x: 8, y: 7, t: 1, lx: 190, ly: 65},
    {x: 8, y: 8, t: 1, lx: 160, ly: 50},
    {x: -1, y: -1, t: 0, lx: 0, ly: 0},
    {x: -1, y: 0, t: 0, lx: 0, ly: 0},
    {x: -1, y: 1, t: 0, lx: 0, ly: 0},
    {x: -1, y: 2, t: 0, lx: 0, ly: 0},
    {x: -1, y: 3, t: 0, lx: 0, ly: 0},
    {x: -1, y: 4, t: 0, lx: 0, ly: 0},
    {x: -1, y: 5, t: 0, lx: 0, ly: 0},
    {x: 0, y: -1, t: 0, lx: 0, ly: 0},
    {x: 0, y: 5, t: 0, lx: 0, ly: 0},
    {x: 0, y: 6, t: 0, lx: 0, ly: 0},
    {x: 1, y: -1, t: 0, lx: 0, ly: 0},
    {x: 1, y: 6, t: 0, lx: 0, ly: 0},
    {x: 1, y: 7, t: 0, lx: 0, ly: 0},
    {x: 2, y: -1, t: 0, lx: 0, ly: 0},
    {x: 2, y: 7, t: 0, lx: 0, ly: 0},
    {x: 2, y: 8, t: 0, lx: 0, ly: 0},
    {x: 3, y: -1, t: 0, lx: 0, ly: 0},
    {x: 3, y: 8, t: 0, lx: 0, ly: 0},
    {x: 3, y: 9, t: 0, lx: 0, ly: 0},
    {x: 4, y: -1, t: 0, lx: 0, ly: 0},
    {x: 4, y: 9, t: 0, lx: 0, ly: 0},
    {x: 5, y: -1, t: 0, lx: 0, ly: 0},
    {x: 5, y: 0, t: 0, lx: 0, ly: 0},
    {x: 5, y: 9, t: 0, lx: 0, ly: 0},
    {x: 6, y: 0, t: 0, lx: 0, ly: 0},
    {x: 6, y: 1, t: 0, lx: 0, ly: 0},
    {x: 6, y: 9, t: 0, lx: 0, ly: 0},
    {x: 7, y: 1, t: 0, lx: 0, ly: 0},
    {x: 7, y: 2, t: 0, lx: 0, ly: 0},
    {x: 7, y: 9, t: 0, lx: 0, ly: 0},
    {x: 8, y: 2, t: 0, lx: 0, ly: 0},
    {x: 8, y: 3, t: 0, lx: 0, ly: 0},
    {x: 8, y: 9, t: 0, lx: 0, ly: 0},
    {x: 9, y: 3, t: 0, lx: 0, ly: 0},
    {x: 9, y: 4, t: 0, lx: 0, ly: 0},
    {x: 9, y: 5, t: 0, lx: 0, ly: 0},
    {x: 9, y: 6, t: 0, lx: 0, ly: 0},
    {x: 9, y: 7, t: 0, lx: 0, ly: 0},
    {x: 9, y: 8, t: 0, lx: 0, ly: 0},
    {x: 9, y: 9, t: 0, lx: 0, ly: 0},
  ]},

  {n: "Quest", w: [
    {x: 1, y: -1, t: 1, lx: 220, ly: 290},
    {x: 1, y: 0, t: 1, lx: 190, ly: 275},
    {x: 2, y: -1, t: 1, lx: 250, ly: 275},
    {x: 1, y: 1, t: 1, lx: 160, ly: 260},
    {x: 2, y: 0, t: 1, lx: 220, ly: 260},
    {x: 3, y: -1, t: 3, lx: 280, ly: 260},
    {x: 2, y: 1, t: 1, lx: 190, ly: 245},
    {x: 3, y: 0, t: 1, lx: 250, ly: 245},
    {x: 2, y: 2, t: 1, lx: 160, ly: 230},
    {x: 1, y: 3, t: 1, lx: 100, ly: 230},
    {x: 3, y: 1, t: 1, lx: 220, ly: 230},
    {x: 2, y: 3, t: 1, lx: 130, ly: 215},
    {x: 1, y: 4, t: 1, lx: 70, ly: 215},
    {x: 3, y: 3, t: 1, lx: 160, ly: 200},
    {x: 2, y: 4, t: 1, lx: 100, ly: 200},
    {x: 1, y: 5, t: 1, lx: 40, ly: 200},
    {x: 3, y: 4, t: 1, lx: 130, ly: 185},
    {x: 2, y: 5, t: 1, lx: 70, ly: 185},
    {x: 4, y: 4, t: 1, lx: 160, ly: 170},
    {x: 3, y: 5, t: 1, lx: 100, ly: 170},
    {x: 5, y: 3, t: 1, lx: 220, ly: 170},
    {x: 5, y: 4, t: 1, lx: 190, ly: 155},
    {x: 6, y: 3, t: 1, lx: 250, ly: 155},
    {x: 5, y: 5, t: 1, lx: 160, ly: 140},
    {x: 6, y: 4, t: 1, lx: 220, ly: 140},
    {x: 7, y: 3, t: 1, lx: 280, ly: 140},
    {x: 5, y: 6, t: 1, lx: 130, ly: 125},
    {x: 6, y: 5, t: 1, lx: 190, ly: 125},
    {x: 7, y: 4, t: 1, lx: 250, ly: 125},
    {x: 6, y: 6, t: 1, lx: 160, ly: 110},
    {x: 5, y: 7, t: 1, lx: 100, ly: 110},
    {x: 7, y: 5, t: 1, lx: 220, ly: 110},
    {x: 6, y: 7, t: 1, lx: 130, ly: 95},
    {x: 5, y: 8, t: 1, lx: 70, ly: 95},
    {x: 7, y: 6, t: 1, lx: 190, ly: 95},
    {x: 7, y: 7, t: 1, lx: 160, ly: 80},
    {x: 6, y: 8, t: 1, lx: 100, ly: 80},
    {x: 7, y: 8, t: 1, lx: 130, ly: 65},
    {x: 6, y: 9, t: 5, lx: 70, ly: 65},
    {x: 0, y: -2, t: 0, lx: 0, ly: 0},
    {x: 0, y: -1, t: 0, lx: 0, ly: 0},
    {x: 0, y: 0, t: 0, lx: 0, ly: 0},
    {x: 0, y: 1, t: 0, lx: 0, ly: 0},
    {x: 0, y: 2, t: 0, lx: 0, ly: 0},
    {x: 0, y: 3, t: 0, lx: 0, ly: 0},
    {x: 0, y: 4, t: 0, lx: 0, ly: 0},
    {x: 0, y: 5, t: 0, lx: 0, ly: 0},
    {x: 0, y: 6, t: 0, lx: 0, ly: 0},
    {x: 1, y: -2, t: 0, lx: 0, ly: 0},
    {x: 1, y: 2, t: 0, lx: 0, ly: 0},
    {x: 1, y: 6, t: 0, lx: 0, ly: 0},
    {x: 2, y: -2, t: 0, lx: 0, ly: 0},
    {x: 2, y: 6, t: 0, lx: 0, ly: 0},
    {x: 3, y: -2, t: 0, lx: 0, ly: 0},
    {x: 3, y: 2, t: 0, lx: 0, ly: 0},
    {x: 3, y: 6, t: 0, lx: 0, ly: 0},
    {x: 4, y: -2, t: 0, lx: 0, ly: 0},
    {x: 4, y: -1, t: 0, lx: 0, ly: 0},
    {x: 4, y: 0, t: 0, lx: 0, ly: 0},
    {x: 4, y: 1, t: 0, lx: 0, ly: 0},
    {x: 4, y: 2, t: 0, lx: 0, ly: 0},
    {x: 4, y: 3, t: 0, lx: 0, ly: 0},
    {x: 4, y: 5, t: 0, lx: 0, ly: 0},
    {x: 4, y: 6, t: 0, lx: 0, ly: 0},
    {x: 4, y: 7, t: 0, lx: 0, ly: 0},
    {x: 4, y: 8, t: 0, lx: 0, ly: 0},
    {x: 4, y: 9, t: 0, lx: 0, ly: 0},
    {x: 5, y: 2, t: 0, lx: 0, ly: 0},
    {x: 5, y: 9, t: 0, lx: 0, ly: 0},
    {x: 5, y: 10, t: 0, lx: 0, ly: 0},
    {x: 6, y: 2, t: 0, lx: 0, ly: 0},
    {x: 6, y: 10, t: 0, lx: 0, ly: 0},
    {x: 7, y: 2, t: 0, lx: 0, ly: 0},
    {x: 7, y: 9, t: 0, lx: 0, ly: 0},
    {x: 7, y: 10, t: 0, lx: 0, ly: 0},
    {x: 8, y: 2, t: 0, lx: 0, ly: 0},
    {x: 8, y: 3, t: 0, lx: 0, ly: 0},
    {x: 8, y: 4, t: 0, lx: 0, ly: 0},
    {x: 8, y: 5, t: 0, lx: 0, ly: 0},
    {x: 8, y: 6, t: 0, lx: 0, ly: 0},
    {x: 8, y: 7, t: 0, lx: 0, ly: 0},
    {x: 8, y: 8, t: 0, lx: 0, ly: 0},
    {x: 8, y: 9, t: 0, lx: 0, ly: 0},
  ]},

  {n: "Holes", w: [
    {x: 0, y: 0, t: 1, lx: 160, ly: 290},
    {x: 0, y: 1, t: 1, lx: 130, ly: 275},
    {x: 1, y: 0, t: 1, lx: 190, ly: 275},
    {x: 0, y: 2, t: 3, lx: 100, ly: 260},
    {x: 2, y: 0, t: 3, lx: 220, ly: 260},
    {x: 1, y: 2, t: 1, lx: 130, ly: 245},
    {x: 0, y: 3, t: 1, lx: 70, ly: 245},
    {x: 2, y: 1, t: 1, lx: 190, ly: 245},
    {x: 3, y: 0, t: 1, lx: 250, ly: 245},
    {x: 2, y: 2, t: 1, lx: 160, ly: 230},
    {x: 0, y: 4, t: 1, lx: 40, ly: 230},
    {x: 4, y: 0, t: 1, lx: 280, ly: 230},
    {x: 2, y: 3, t: 1, lx: 130, ly: 215},
    {x: 1, y: 4, t: 1, lx: 70, ly: 215},
    {x: 3, y: 2, t: 1, lx: 190, ly: 215},
    {x: 4, y: 1, t: 1, lx: 250, ly: 215},
    {x: 2, y: 4, t: 1, lx: 100, ly: 200},
    {x: 4, y: 2, t: 1, lx: 220, ly: 200},
    {x: 3, y: 4, t: 1, lx: 130, ly: 185},
    {x: 2, y: 5, t: 1, lx: 70, ly: 185},
    {x: 4, y: 3, t: 1, lx: 190, ly: 185},
    {x: 5, y: 2, t: 1, lx: 250, ly: 185},
    {x: 4, y: 4, t: 7, lx: 160, ly: 170},
    {x: 2, y: 6, t: 1, lx: 40, ly: 170},
    {x: 6, y: 2, t: 1, lx: 280, ly: 170},
    {x: 4, y: 5, t: 1, lx: 130, ly: 155},
    {x: 3, y: 6, t: 1, lx: 70, ly: 155},
    {x: 5, y: 4, t: 1, lx: 190, ly: 155},
    {x: 6, y: 3, t: 1, lx: 250, ly: 155},
    {x: 4, y: 6, t: 1, lx: 100, ly: 140},
    {x: 6, y: 4, t: 1, lx: 220, ly: 140},
    {x: 5, y: 6, t: 1, lx: 130, ly: 125},
    {x: 4, y: 7, t: 1, lx: 70, ly: 125},
    {x: 6, y: 5, t: 1, lx: 190, ly: 125},
    {x: 7, y: 4, t: 1, lx: 250, ly: 125},
    {x: 6, y: 6, t: 1, lx: 160, ly: 110},
    {x: 4, y: 8, t: 1, lx: 40, ly: 110},
    {x: 8, y: 4, t: 1, lx: 280, ly: 110},
    {x: 6, y: 7, t: 1, lx: 130, ly: 95},
    {x: 5, y: 8, t: 1, lx: 70, ly: 95},
    {x: 7, y: 6, t: 1, lx: 190, ly: 95},
    {x: 8, y: 5, t: 1, lx: 250, ly: 95},
    {x: 6, y: 8, t: 1, lx: 100, ly: 80},
    {x: 8, y: 6, t: 1, lx: 220, ly: 80},
    {x: 7, y: 8, t: 1, lx: 130, ly: 65},
    {x: 8, y: 7, t: 1, lx: 190, ly: 65},
    {x: 8, y: 8, t: 6, lx: 160, ly: 50},
    {x: -1, y: -1, t: 0, lx: 0, ly: 0},
    {x: -1, y: 0, t: 0, lx: 0, ly: 0},
    {x: -1, y: 1, t: 0, lx: 0, ly: 0},
    {x: -1, y: 2, t: 0, lx: 0, ly: 0},
    {x: -1, y: 3, t: 0, lx: 0, ly: 0},
    {x: -1, y: 4, t: 0, lx: 0, ly: 0},
    {x: -1, y: 5, t: 0, lx: 0, ly: 0},
    {x: 0, y: -1, t: 0, lx: 0, ly: 0},
    {x: 0, y: 5, t: 0, lx: 0, ly: 0},
    {x: 1, y: -1, t: 0, lx: 0, ly: 0},
    {x: 1, y: 1, t: 0, lx: 0, ly: 0},
    {x: 1, y: 3, t: 0, lx: 0, ly: 0},
    {x: 1, y: 5, t: 0, lx: 0, ly: 0},
    {x: 1, y: 6, t: 0, lx: 0, ly: 0},
    {x: 1, y: 7, t: 0, lx: 0, ly: 0},
    {x: 2, y: -1, t: 0, lx: 0, ly: 0},
    {x: 2, y: 7, t: 0, lx: 0, ly: 0},
    {x: 3, y: -1, t: 0, lx: 0, ly: 0},
    {x: 3, y: 1, t: 0, lx: 0, ly: 0},
    {x: 3, y: 3, t: 0, lx: 0, ly: 0},
    {x: 3, y: 5, t: 0, lx: 0, ly: 0},
    {x: 3, y: 7, t: 0, lx: 0, ly: 0},
    {x: 3, y: 8, t: 0, lx: 0, ly: 0},
    {x: 3, y: 9, t: 0, lx: 0, ly: 0},
    {x: 4, y: -1, t: 0, lx: 0, ly: 0},
    {x: 4, y: 9, t: 0, lx: 0, ly: 0},
    {x: 5, y: -1, t: 0, lx: 0, ly: 0},
    {x: 5, y: 0, t: 0, lx: 0, ly: 0},
    {x: 5, y: 1, t: 0, lx: 0, ly: 0},
    {x: 5, y: 3, t: 0, lx: 0, ly: 0},
    {x: 5, y: 5, t: 0, lx: 0, ly: 0},
    {x: 5, y: 7, t: 0, lx: 0, ly: 0},
    {x: 5, y: 9, t: 0, lx: 0, ly: 0},
    {x: 6, y: 1, t: 0, lx: 0, ly: 0},
    {x: 6, y: 9, t: 0, lx: 0, ly: 0},
    {x: 7, y: 1, t: 0, lx: 0, ly: 0},
    {x: 7, y: 2, t: 0, lx: 0, ly: 0},
    {x: 7, y: 3, t: 0, lx: 0, ly: 0},
    {x: 7, y: 5, t: 0, lx: 0, ly: 0},
    {x: 7, y: 7, t: 0, lx: 0, ly: 0},
    {x: 7, y: 9, t: 0, lx: 0, ly: 0},
    {x: 8, y: 3, t: 0, lx: 0, ly: 0},
    {x: 8, y: 9, t: 0, lx: 0, ly: 0},
    {x: 9, y: 3, t: 0, lx: 0, ly: 0},
    {x: 9, y: 4, t: 0, lx: 0, ly: 0},
    {x: 9, y: 5, t: 0, lx: 0, ly: 0},
    {x: 9, y: 6, t: 0, lx: 0, ly: 0},
    {x: 9, y: 7, t: 0, lx: 0, ly: 0},
    {x: 9, y: 8, t: 0, lx: 0, ly: 0},
    {x: 9, y: 9, t: 0, lx: 0, ly: 0},
  ]},

  {n: "Maze", w: [
    {x: -1, y: 1, t: 2, lx: 100, ly: 290},
    {x: 0, y: 1, t: 1, lx: 130, ly: 275},
    {x: -1, y: 2, t: 2, lx: 70, ly: 275},
    {x: 1, y: 1, t: 1, lx: 160, ly: 260},
    {x: 0, y: 2, t: 1, lx: 100, ly: 260},
    {x: -1, y: 3, t: 1, lx: 40, ly: 260},
    {x: 1, y: 2, t: 1, lx: 130, ly: 245},
    {x: 0, y: 3, t: 1, lx: 70, ly: 245},
    {x: 2, y: 1, t: 1, lx: 190, ly: 245},
    {x: 2, y: 2, t: 1, lx: 160, ly: 230},
    {x: 1, y: 3, t: 1, lx: 100, ly: 230},
    {x: 0, y: 4, t: 1, lx: 40, ly: 230},
    {x: 3, y: 1, t: 1, lx: 220, ly: 230},
    {x: 2, y: 3, t: 1, lx: 130, ly: 215},
    {x: 1, y: 4, t: 1, lx: 70, ly: 215},
    {x: 3, y: 2, t: 1, lx: 190, ly: 215},
    {x: 4, y: 1, t: 1, lx: 250, ly: 215},
    {x: 3, y: 3, t: 1, lx: 160, ly: 200},
    {x: 2, y: 4, t: 1, lx: 100, ly: 200},
    {x: 1, y: 5, t: 2, lx: 40, ly: 200},
    {x: 4, y: 2, t: 1, lx: 220, ly: 200},
    {x: 5, y: 1, t: 3, lx: 280, ly: 200},
    {x: 3, y: 4, t: 1, lx: 130, ly: 185},
    {x: 2, y: 5, t: 2, lx: 70, ly: 185},
    {x: 4, y: 3, t: 1, lx: 190, ly: 185},
    {x: 5, y: 2, t: 1, lx: 250, ly: 185},
    {x: 4, y: 4, t: 1, lx: 160, ly: 170},
    {x: 3, y: 5, t: 1, lx: 100, ly: 170},
    {x: 2, y: 6, t: 1, lx: 40, ly: 170},
    {x: 5, y: 3, t: 2, lx: 220, ly: 170},
    {x: 6, y: 2, t: 1, lx: 280, ly: 170},
    {x: 4, y: 5, t: 1, lx: 130, ly: 155},
    {x: 3, y: 6, t: 1, lx: 70, ly: 155},
    {x: 5, y: 4, t: 1, lx: 190, ly: 155},
    {x: 6, y: 3, t: 2, lx: 250, ly: 155},
    {x: 5, y: 5, t: 1, lx: 160, ly: 140},
    {x: 4, y: 6, t: 1, lx: 100, ly: 140},
    {x: 3, y: 7, t: 6, lx: 40, ly: 140},
    {x: 6, y: 4, t: 1, lx: 220, ly: 140},
    {x: 7, y: 3, t: 1, lx: 280, ly: 140},
    {x: 5, y: 6, t: 1, lx: 130, ly: 125},
    {x: 4, y: 7, t: 6, lx: 70, ly: 125},
    {x: 6, y: 5, t: 2, lx: 190, ly: 125},
    {x: 7, y: 4, t: 1, lx: 250, ly: 125},
    {x: 6, y: 6, t: 2, lx: 160, ly: 110},
    {x: 5, y: 7, t: 6, lx: 100, ly: 110},
    {x: 4, y: 8, t: 2, lx: 40, ly: 110},
    {x: 7, y: 5, t: 1, lx: 220, ly: 110},
    {x: 8, y: 4, t: 2, lx: 280, ly: 110},
    {x: 6, y: 7, t: 7, lx: 130, ly: 95},
    {x: 5, y: 8, t: 2, lx: 70, ly: 95},
    {x: 7, y: 6, t: 1, lx: 190, ly: 95},
    {x: 8, y: 5, t: 2, lx: 250, ly: 95},
    {x: 7, y: 7, t: 1, lx: 160, ly: 80},
    {x: 6, y: 8, t: 2, lx: 100, ly: 80},
    {x: 8, y: 6, t: 1, lx: 220, ly: 80},
    {x: 7, y: 8, t: 1, lx: 130, ly: 65},
    {x: 8, y: 7, t: 1, lx: 190, ly: 65},
    {x: 8, y: 8, t: 1, lx: 160, ly: 50},
    {x: -2, y: 0, t: 0, lx: 0, ly: 0},
    {x: -2, y: 1, t: 0, lx: 0, ly: 0},
    {x: -2, y: 2, t: 0, lx: 0, ly: 0},
    {x: -2, y: 3, t: 0, lx: 0, ly: 0},
    {x: -2, y: 4, t: 0, lx: 0, ly: 0},
    {x: -1, y: 0, t: 0, lx: 0, ly: 0},
    {x: -1, y: 4, t: 0, lx: 0, ly: 0},
    {x: -1, y: 5, t: 0, lx: 0, ly: 0},
    {x: 0, y: 0, t: 0, lx: 0, ly: 0},
    {x: 0, y: 5, t: 0, lx: 0, ly: 0},
    {x: 0, y: 6, t: 0, lx: 0, ly: 0},
    {x: 1, y: 0, t: 0, lx: 0, ly: 0},
    {x: 1, y: 6, t: 0, lx: 0, ly: 0},
    {x: 1, y: 7, t: 0, lx: 0, ly: 0},
    {x: 2, y: 0, t: 0, lx: 0, ly: 0},
    {x: 2, y: 7, t: 0, lx: 0, ly: 0},
    {x: 2, y: 8, t: 0, lx: 0, ly: 0},
    {x: 3, y: 0, t: 0, lx: 0, ly: 0},
    {x: 3, y: 8, t: 0, lx: 0, ly: 0},
    {x: 3, y: 9, t: 0, lx: 0, ly: 0},
    {x: 4, y: 0, t: 0, lx: 0, ly: 0},
    {x: 4, y: 9, t: 0, lx: 0, ly: 0},
    {x: 5, y: 0, t: 0, lx: 0, ly: 0},
    {x: 5, y: 9, t: 0, lx: 0, ly: 0},
    {x: 6, y: 0, t: 0, lx: 0, ly: 0},
    {x: 6, y: 1, t: 0, lx: 0, ly: 0},
    {x: 6, y: 9, t: 0, lx: 0, ly: 0},
    {x: 7, y: 1, t: 0, lx: 0, ly: 0},
    {x: 7, y: 2, t: 0, lx: 0, ly: 0},
    {x: 7, y: 9, t: 0, lx: 0, ly: 0},
    {x: 8, y: 2, t: 0, lx: 0, ly: 0},
    {x: 8, y: 3, t: 0, lx: 0, ly: 0},
    {x: 8, y: 9, t: 0, lx: 0, ly: 0},
    {x: 9, y: 3, t: 0, lx: 0, ly: 0},
    {x: 9, y: 4, t: 0, lx: 0, ly: 0},
    {x: 9, y: 5, t: 0, lx: 0, ly: 0},
    {x: 9, y: 6, t: 0, lx: 0, ly: 0},
    {x: 9, y: 7, t: 0, lx: 0, ly: 0},
    {x: 9, y: 8, t: 0, lx: 0, ly: 0},
    {x: 9, y: 9, t: 0, lx: 0, ly: 0},
  ]},

  {n: "Big Boss", w: [
    {x: 0, y: 0, t: 2, lx: 160, ly: 290},
    {x: 0, y: 1, t: 1, lx: 130, ly: 275},
    {x: 1, y: 0, t: 1, lx: 190, ly: 275},
    {x: 1, y: 1, t: 3, lx: 160, ly: 260},
    {x: 0, y: 2, t: 2, lx: 100, ly: 260},
    {x: 2, y: 0, t: 2, lx: 220, ly: 260},
    {x: 1, y: 2, t: 1, lx: 130, ly: 245},
    {x: 0, y: 3, t: 1, lx: 70, ly: 245},
    {x: 2, y: 1, t: 1, lx: 190, ly: 245},
    {x: 3, y: 0, t: 1, lx: 250, ly: 245},
    {x: 2, y: 2, t: 7, lx: 160, ly: 230},
    {x: 1, y: 3, t: 1, lx: 100, ly: 230},
    {x: 0, y: 4, t: 2, lx: 40, ly: 230},
    {x: 3, y: 1, t: 1, lx: 220, ly: 230},
    {x: 4, y: 0, t: 2, lx: 280, ly: 230},
    {x: 2, y: 3, t: 1, lx: 130, ly: 215},
    {x: 1, y: 4, t: 4, lx: 70, ly: 215},
    {x: 3, y: 2, t: 1, lx: 190, ly: 215},
    {x: 4, y: 1, t: 4, lx: 250, ly: 215},
    {x: 3, y: 3, t: 1, lx: 160, ly: 200},
    {x: 2, y: 4, t: 1, lx: 100, ly: 200},
    {x: 1, y: 5, t: 1, lx: 40, ly: 200},
    {x: 4, y: 2, t: 7, lx: 220, ly: 200},
    {x: 5, y: 1, t: 1, lx: 280, ly: 200},
    {x: 3, y: 4, t: 1, lx: 130, ly: 185},
    {x: 2, y: 5, t: 1, lx: 70, ly: 185},
    {x: 4, y: 3, t: 1, lx: 190, ly: 185},
    {x: 5, y: 2, t: 1, lx: 250, ly: 185},
    {x: 4, y: 4, t: 8, lx: 160, ly: 170},
    {x: 3, y: 5, t: 1, lx: 100, ly: 170},
    {x: 2, y: 6, t: 2, lx: 40, ly: 170},
    {x: 5, y: 3, t: 1, lx: 220, ly: 170},
    {x: 6, y: 2, t: 2, lx: 280, ly: 170},
    {x: 4, y: 5, t: 1, lx: 130, ly: 155},
    {x: 3, y: 6, t: 1, lx: 70, ly: 155},
    {x: 5, y: 4, t: 1, lx: 190, ly: 155},
    {x: 6, y: 3, t: 1, lx: 250, ly: 155},
    {x: 5, y: 5, t: 1, lx: 160, ly: 140},
    {x: 4, y: 6, t: 7, lx: 100, ly: 140},
    {x: 3, y: 7, t: 1, lx: 40, ly: 140},
    {x: 6, y: 4, t: 1, lx: 220, ly: 140},
    {x: 7, y: 3, t: 1, lx: 280, ly: 140},
    {x: 5, y: 6, t: 1, lx: 130, ly: 125},
    {x: 4, y: 7, t: 4, lx: 70, ly: 125},
    {x: 6, y: 5, t: 1, lx: 190, ly: 125},
    {x: 7, y: 4, t: 4, lx: 250, ly: 125},
    {x: 6, y: 6, t: 7, lx: 160, ly: 110},
    {x: 5, y: 7, t: 1, lx: 100, ly: 110},
    {x: 4, y: 8, t: 2, lx: 40, ly: 110},
    {x: 7, y: 5, t: 1, lx: 220, ly: 110},
    {x: 8, y: 4, t: 2, lx: 280, ly: 110},
    {x: 6, y: 7, t: 1, lx: 130, ly: 95},
    {x: 5, y: 8, t: 1, lx: 70, ly: 95},
    {x: 7, y: 6, t: 1, lx: 190, ly: 95},
    {x: 8, y: 5, t: 1, lx: 250, ly: 95},
    {x: 7, y: 7, t: 3, lx: 160, ly: 80},
    {x: 6, y: 8, t: 2, lx: 100, ly: 80},
    {x: 8, y: 6, t: 2, lx: 220, ly: 80},
    {x: 7, y: 8, t: 1, lx: 130, ly: 65},
    {x: 8, y: 7, t: 1, lx: 190, ly: 65},
    {x: 8, y: 8, t: 2, lx: 160, ly: 50},
    {x: -1, y: -1, t: 0, lx: 0, ly: 0},
    {x: -1, y: 0, t: 0, lx: 0, ly: 0},
    {x: -1, y: 1, t: 0, lx: 0, ly: 0},
    {x: -1, y: 2, t: 0, lx: 0, ly: 0},
    {x: -1, y: 3, t: 0, lx: 0, ly: 0},
    {x: -1, y: 4, t: 0, lx: 0, ly: 0},
    {x: -1, y: 5, t: 0, lx: 0, ly: 0},
    {x: 0, y: -1, t: 0, lx: 0, ly: 0},
    {x: 0, y: 5, t: 0, lx: 0, ly: 0},
    {x: 0, y: 6, t: 0, lx: 0, ly: 0},
    {x: 1, y: -1, t: 0, lx: 0, ly: 0},
    {x: 1, y: 6, t: 0, lx: 0, ly: 0},
    {x: 1, y: 7, t: 0, lx: 0, ly: 0},
    {x: 2, y: -1, t: 0, lx: 0, ly: 0},
    {x: 2, y: 7, t: 0, lx: 0, ly: 0},
    {x: 2, y: 8, t: 0, lx: 0, ly: 0},
    {x: 3, y: -1, t: 0, lx: 0, ly: 0},
    {x: 3, y: 8, t: 0, lx: 0, ly: 0},
    {x: 3, y: 9, t: 0, lx: 0, ly: 0},
    {x: 4, y: -1, t: 0, lx: 0, ly: 0},
    {x: 4, y: 9, t: 0, lx: 0, ly: 0},
    {x: 5, y: -1, t: 0, lx: 0, ly: 0},
    {x: 5, y: 0, t: 0, lx: 0, ly: 0},
    {x: 5, y: 9, t: 0, lx: 0, ly: 0},
    {x: 6, y: 0, t: 0, lx: 0, ly: 0},
    {x: 6, y: 1, t: 0, lx: 0, ly: 0},
    {x: 6, y: 9, t: 0, lx: 0, ly: 0},
    {x: 7, y: 1, t: 0, lx: 0, ly: 0},
    {x: 7, y: 2, t: 0, lx: 0, ly: 0},
    {x: 7, y: 9, t: 0, lx: 0, ly: 0},
    {x: 8, y: 2, t: 0, lx: 0, ly: 0},
    {x: 8, y: 3, t: 0, lx: 0, ly: 0},
    {x: 8, y: 9, t: 0, lx: 0, ly: 0},
    {x: 9, y: 3, t: 0, lx: 0, ly: 0},
    {x: 9, y: 4, t: 0, lx: 0, ly: 0},
    {x: 9, y: 5, t: 0, lx: 0, ly: 0},
    {x: 9, y: 6, t: 0, lx: 0, ly: 0},
    {x: 9, y: 7, t: 0, lx: 0, ly: 0},
    {x: 9, y: 8, t: 0, lx: 0, ly: 0},
    {x: 9, y: 9, t: 0, lx: 0, ly: 0},
  ]},

];
// ScreenLayout.js

// As seen on mediatemple account center. Thanks (mt)!

// The following code is courtesy of Joe Hewitt http://www.joehewitt.com
var _current_width = 0;

var _orientation = "profile";
    
function updateLayout() {
  if (window.innerWidth != _current_width) {  
    _current_width = window.innerWidth; var agent = navigator.userAgent.toLowerCase(); var isIphone = agent.indexOf('iphone') != -1 || agent.indexOf('ipod') != -1;
    if (isIphone) { var orient = _current_width == 320 ? "profile" : (_current_width > 1000 ? "profile" : "landscape"); document.body.setAttribute("orient", orient); _orientation = orient;
    } else { document.body.setAttribute("orient", "profile"); }
    setTimeout(function() { window.scrollTo(0, 1); }, 100);            
  }  
}

// end Joe Hewitt code. Thanks Joe!

// Helpers.js

// Helpers: cookie access.
function createCookie(name,value,days) { name = "peng" + name; var expires = ""; if (days) { var date = new Date(); date.setDate(date.getDate() + days); expires = "; expires=" + date.toGMTString(); } document.cookie = name + "=" + value + expires + "; path=/"; }
function readCookie(name) { name = "peng" + name; var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') c = c.substring(1, c.length); if (c.indexOf(nameEQ) == 0) { var v = c.substring(nameEQ.length, c.length); return v; } } return null; }
function eraseCookie(name) { createCookie(name, "" , -1); }
// Helpers: string builder.
function StringBuilder(value) { this.strings = [""]; if (value) this.append(value); }
StringBuilder.prototype.append = function(v) { this.strings.push(v); }
StringBuilder.prototype.appendList = function() { for (var i = 0; i < arguments.length; i++) this.strings.push(arguments[i]); }
StringBuilder.prototype.clear = function() { this.strings.length = 1; }
StringBuilder.prototype.toString = function() { return this.strings.join(""); }

String.prototype.reverse = function() { splitext = this.split(""); revertext = splitext.reverse(); reversed = revertext.join(""); return reversed; }

// Trace.js

function trace() { var sb = new StringBuilder(); for (var i = 0; i < arguments.length; ++i) sb.appendList(arguments[i], " "); alert(sb.toString()); }

// Physics.js

function v_(x, y) { return {x:x, y:y}; }
function v_c(a) { return {x:a.x, y:a.y}; }
function v_add(a, b) { return {x:a.x + b.x, y:a.y + b.y}; }
function v_sub(a, b) { return {x:a.x - b.x, y:a.y - b.y}; }
function v_mul(a, b) { return {x:a.x * b, y:a.y * b}; }
function v_madd(a, b, c) { return {x:a.x + b.x * c, y: a.y + b.y * c}; }
function v_madd_ref(a, b, c) { a.x += b.x * c; a.y += b.y * c; }
function v_dot(a, b) { return a.x * b.x + a.y * b.y; }
function v_len(a) { return Math.sqrt(v_dot(a, a)); }
function v_nor(a) { var inv_len = 1.0 / Math.sqrt(a.x * a.x + a.y * a.y); return {x:a.x * inv_len, y:a.y * inv_len}; }
function v_nor_2(a, b) { var inv_len = 1.0 / Math.sqrt(a * a + b * b); return {x:a * inv_len, y:b * inv_len}; }
function p_(x, y, z) { return {x:x, y:y, z:z}; }
function p_dot(p, v) { return p.x * v.x + p.y * v.y + p.z; }
function v_crs(a) { return {x:-a.y, y:a.x}; }
function v_dist(a, b) { return Math.sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)); }
function v_dir(a, b, c) { return v_mul(v_nor_2(b.x - a.x, b.y - a.y), c); }

var instance_type = {ball: 1, wall: 2, trigger: 3};

function ph_plane_sphere(plane, begin, delta, radius) {
  var n_dot_d = plane.x * delta.x + plane.y * delta.y;
  var dist_b = plane.x * begin.x + plane.y * begin.y + plane.z;

  var ta, tb;

  if (n_dot_d == 0.0) {
    if (Math.abs(dist_b) > radius)
      return null;

    ta = 0;
    tb = 1;
  } else {
    ta = (radius - dist_b) / n_dot_d;
    tb = (-radius - dist_b) / n_dot_d;

    if (ta > tb) { var tc = ta; ta = tb; tb = tc; }      
    if (ta > 1 || tb < 0) return null;
    if (ta < 0) ta = 0;
    if (tb > 1) tb = 1;
  }  

  return v_(ta, tb);
}

function ph_1d_intersect(line_begin, line_end, center, radius_squared) {  
  if (center > line_begin && center < line_end)
    return center;

  var d_begin = (center - line_begin) * (center - line_begin);
  if (d_begin < radius_squared)
    return line_begin;

  var d_end = (center - line_end) * (center - line_end);
  if (d_end < radius_squared)
    return line_end;

  return null
}		

function root(a, b, c, bound) {
  var determinant = b * b - 4.0 * a * c;
  if (determinant < 0.0)
    return null;

  var q = -0.5 * (b + (b < 0.0 ? -1.0 : 1.0) * Math.sqrt(determinant));

  var x1 = q / a;
  var x2 = c / q;

  if (x2 < x1) { var x3 = x1; x1 = x2; x2 = x3; }

  if (x1 >= 0.0 && x1 <= bound)
    return x1;
  if (x2 >= 0.0 && x2 <= bound)
    return x2;

  return null;
}

function ph_1d_swept_intersect(line_begin, line_end, begin, delta, a, b, c) {
  var upper_bound = 1.0;
  var collision = false;
  var point = null;

  var b_to_v = line_begin - begin;
  var a1 = a - delta * delta;
  var b1 = b + 2.0 * delta * b_to_v;
  var c1 = c - b_to_v * b_to_v;

  var t = root(a1, b1, c1, upper_bound);
  if (t) {
    collision = true;
    upper_bound = t;
    point = line_begin;
  }

  b_to_v = line_end - begin;
  a1 = a - delta * delta;
  b1 = b + 2.0 * delta * b_to_v;
  c1 = c - b_to_v * b_to_v;

  var t = root(a1, b1, c1, upper_bound);
  if (t) {
    collision = true;
    upper_bound = t;
    point = line_end;
  }

  return collision ? v_(upper_bound, point) : null;
}

function ph_line_sphere(line_plane, line_begin, line_end, begin, delta, radius) {
  var t = ph_plane_sphere(line_plane, begin, delta, radius);
  if (t == null)
    return null;

  var n_dot_d = v_dot(line_plane, delta);
  var dist_b = p_dot(line_plane, begin);
  var a = -n_dot_d * n_dot_d;
  var b = -2 * n_dot_d * dist_b;
  var c = radius * radius - dist_b * dist_b;

  var u = v_crs(line_plane);
  var begin_plane = v_dot(u, begin);
  var delta_plane = v_dot(u, delta);

  var p = ph_1d_intersect(line_begin, line_end, begin_plane + delta_plane * t.x, a * t.x * t.x + b * t.x + c);
  if (p) {
    return v_(t.x, 
      v_(u.x * p - line_plane.x * line_plane.z, u.y * p - line_plane.y * line_plane.z));
  }

  var p = ph_1d_swept_intersect(line_begin, line_end, begin_plane, delta_plane, a, b, c);
  if (p) {
    return v_(p.x, 
      v_(u.x * p.y - line_plane.x * line_plane.z, u.y * p.y - line_plane.y * line_plane.z));
  }

  return null;
}

function ph_ray_sphere(ray_start, ray_direction, length, center, radius) {
  var offset_x = center.x - ray_start.x;
  var offset_y = center.y - ray_start.y;
  var ray_distance = ray_direction.x * offset_x + ray_direction.y * offset_y;
  if (ray_distance <= 0 || (ray_distance - length) > radius)
    return null;

  var offset_squared = offset_x * offset_x + offset_y * offset_y;
  var radius_squared = radius * radius;
  if (offset_squared <= radius_squared)
    return v_(0.0, ray_start);
  var d = radius_squared - (offset_squared - ray_distance * ray_distance);
  if (d < 0)
    return null;
  var fraction = ray_distance - Math.sqrt(d);
  if (fraction > length)
    return null;

  return v_(fraction / length, v_madd(ray_start, ray_direction, fraction));
}

function ph_sphere_sphere(static_center, static_radius, begin, delta, radius)	{
  var length = v_len(delta);

  if (length == 0.0)
    return null;

  var t = ph_ray_sphere(begin, v_mul(delta, 1.0 / length), length, static_center, static_radius + radius);
  if (t) {
    var intersection_point = v_madd(begin, delta, t.x);
    var d = v_sub(static_center, intersection_point);

    return v_(t.x, v_madd(intersection_point, d, radius));
  } else 
    return null;
}

function ph_moving_spheres(begin_a, delta_a, radius_a, begin_b, delta_b, radius_b) {
  var a_to_b_x = begin_b.x - begin_a.x;
  var a_to_b_y = begin_b.y - begin_a.y;
  var delta_ab_x = delta_b.x - delta_a.x;
  var delta_ab_y = delta_b.y - delta_a.y;
  
  var radius = radius_a + radius_b;

  var c = a_to_b_x * a_to_b_x + a_to_b_y * a_to_b_y - radius * radius;

  if (c <= 0.0) {
    var t = radius_a / radius;
    return v_(0.0, v_(begin_a.x * (1.0 - t) + begin_b.x * t, begin_a.y * (1.0 - t) + begin_b.y * t));
  }

  var b = 2.0 * (delta_ab_x * a_to_b_x + delta_ab_y * a_to_b_y);
  if (b >= 0.0)
    return null;

  var a = delta_ab_x * delta_ab_x + delta_ab_y * delta_ab_y;

	var t = root(a, b, c, 1.0);	
	if (t) {
	  var begin_a_time_x = begin_a.x + delta_a.x * t;
	  var begin_a_time_y = begin_a.y + delta_a.y * t;
	  var begin_b_time_x = begin_b.x + delta_b.x * t;
	  var begin_b_time_y = begin_b.y + delta_b.y * t;

	  var f = radius_a / radius;

	  return v_(t, v_(begin_a_time_x * (1.0 - f) + begin_b_time_x * f, begin_a_time_y * (1.0 - f) + begin_b_time_y * f));
	}

	return null;
}

var _walls = [];

function add_wall(x1, y1, x2, y2) {
  var a = v_(x1, y1);
  var b = v_(x2, y2);
  var n = v_crs(v_nor(v_sub(b, a)));
  var d = -v_dot(n, a);

  var u = v_crs(n);

  var ua = v_dot(u, a);
  var ub = v_dot(u, b);

  if (ua > ub) { var uc = ua; ua = ub; ub = uc; }

  _walls.push({type: instance_type.wall, normal:v_(n.x, n.y), p:p_(n.x, n.y, d), b:ua, e: ub, v: v_(0.0, 0.0), m: 0.0, f: v_(0.0, 0.0), center: v_((x1 + x2) * 0.5, (y1 + y2) * 0.5) });
}

var _triggers = [];

function add_trigger(x, y, r, n) {  
  _triggers.push({type: instance_type.trigger, c: v_(x, y), x: x, y: y, r: r, n: n, v: v_(0.0, 0.0), m: 0.0, f: v_(0.0, 0.0)});
}

function remove_trigger(n) {
  for (var i = 0; i < _triggers.length; ++i)
    if (_triggers[i].n == n) {
      if (_triggers.length > 1) 
        _triggers[i] = _triggers[_triggers.length - 1];
      _triggers.pop();

      break;
    }
}

var _attractors = [];

function add_attractor(x, y, m) {
  _attractors.push({x: x, y: y, m: m});
}

var _balls = [];

function add_ball(id, center, radius, mass) {
  var b = {type: instance_type.ball, c:center, r:radius, v:v_(0, 0), f:v_(0, 0), m:1.0 / mass, id: id, active: true};

  _balls.push(b);

  return b;
}

var _time;

function reset_simulation() {
  _time = 0.0;
  _walls = [];
  _triggers = [];
  _attractors = [];
  _balls = [];
}

var _on_trigger = null;

function set_on_trigger(fn) {
  _on_trigger = fn;
}

var _pairs = [];

function trace_intersection(ball, c, r, delta) {
  var collision_time = null;
  var collition_type = null;

  for (var i = 0; i < _walls.length; ++i) {
    var w = _walls[i];
      
    var t = ph_line_sphere(w.p, w.b, w.e, c, delta, r);
    if (t) {
      var valid = false;
      
      var intersection_time = t.x;
      if (intersection_time == 0.0) {
        var normal_direction = v_sub(c, t.y);
        if (v_dot(delta, normal_direction) < 0.0)
          valid = true;
      } else
        valid = true;
      
      if (valid) {
        if (!collision_time || intersection_time <= collision_time) {
          collision_time = intersection_time;
          collision_type = "wall";
        }
      }
    }
  }      

  for (var i = 0; i < _triggers.length; ++i) {
    var d = _triggers[i];
    var t = ph_sphere_sphere(d, d.r, c, delta, r);
    if (t) {
      var intersection_time = t.x;

      if ((collision_time && intersection_time <= collision_time) || !collision_time) {
        var valid = false;

        if (intersection_time == 0.0) {
          var a_to_b_x = ball.c.x - d.c.x;
          var a_to_b_y = ball.c.y - another_ball.c.y;
          var rel_v_x = ball.v.x - another_ball.v.x;
          var rel_v_y = ball.v.y - another_ball.v.y;

          if ((a_to_b_x * rel_v_x + a_to_b_y * rel_v_y) < - 0.01)
            valid = true;
        } else
          valid = true;

        if (valid) {
          collision_time = intersection_time;
          collision_type = "trigger";
        }
      }
    }
  }

  for (var i = 0; i < _balls.length; ++i) {
    var another_ball = _balls[i];
    if (!another_ball.active || another_ball == ball)
      continue;

    var t = ph_moving_spheres(c, delta, r, another_ball.c, another_ball.delta, another_ball.r);
    if (t) {
      var valid = false;

      var intersection_time = t.x;
      if (intersection_time == 0.0) {
        var a_to_b_x = ball.c.x - another_ball.c.x;
        var a_to_b_y = ball.c.y - another_ball.c.y;
        var rel_v_x = ball.v.x - another_ball.v.x;
        var rel_v_y = ball.v.y - another_ball.v.y;           

        if ((a_to_b_x * rel_v_x + a_to_b_y * rel_v_y) < - 0.01)
          valid = true;
      } else
        valid = true;

      if (valid) {
        if (!collision_time || intersection_time <= collision_time) {
          collision_time = intersection_time;
          collision_type = another_ball.penguin ? "penguin" : "ball";
        }
      }
    }
  }  

  return v_(collision_time, collision_type);
}

function step_simulation(step) {
  target = _time + step;

  _pairs.length = 0;
  
  while (_time < target) {
    var was_collision = false;  

    var obj_one = null;
    var obj_two = null;
  
    var seconds = target - _time;

    for (var i = 0; i < _balls.length; ++i) {
      _balls[i].delta = v_mul(_balls[i].v, seconds);
    }

    var collision_time = null;

    for (var current_ball = 0; current_ball < _balls.length; ++current_ball) {
      var ball = _balls[current_ball];      

      if (!ball.active)
        continue;

      var stopped = ball.v.x == 0.0 && ball.v.y == 0.0;

      var delta = ball.delta;

      if (!stopped) {        
        for (var i = 0; i < _walls.length; ++i) {
          var w = _walls[i];
      
          //Optimization: don't check walls that are too far.
          var center_x = w.center.x - ball.c.x;
          var center_y = w.center.y - ball.c.y;
          if (center_x * center_x + center_y * center_y > 3600)
            continue;
      
          var t = ph_line_sphere(w.p, w.b, w.e, ball.c, delta, ball.r);
          if (t) {
            var valid = false;
      
            var intersection_time = t.x * seconds;
            if (intersection_time == 0.0) {
              var normal_direction = v_sub(ball.c, t.y);
              if (v_dot(ball.v, normal_direction) < 0.0)
                valid = true;
            } else
              valid = true;
      
            if (valid) {
              if (!collision_time || intersection_time <= collision_time) {
                if (collision_time != intersection_time)
                  _pairs.length = 0;
      
                collision_time = intersection_time;
      
                _pairs.push({one: ball, two: w, v_one: v_c(ball.v), v_two: v_c(w.v), point: t.y, normal: v_nor_2(ball.c.x + ball.v.x * collision_time - t.y.x, ball.c.y + ball.v.y * collision_time - t.y.y) });
              }
            }
          }
        }      
        
        for (var i = 0; i < _triggers.length; ++i) {
          var d = _triggers[i];

          //Optimization: don't check triggers that are too far.
          var center_x = d.x - ball.c.x;
          var center_y = d.y - ball.c.y;
          if (center_x * center_x + center_y * center_y > 3600)
            continue;
          
          var t = ph_sphere_sphere(d, d.r, ball.c, delta, ball.r);
          if (t) {
            var intersection_time = t.x * seconds;
      
            if ((collision_time && intersection_time <= collision_time) || !collision_time) {
              if (_on_trigger && !_on_trigger(ball, d)) {                
                var valid = false;
      
                if (intersection_time == 0.0) {
                  var a_to_b_x = ball.c.x - d.c.x;
                  var a_to_b_y = ball.c.y - another_ball.c.y;
                  var rel_v_x = ball.v.x - another_ball.v.x;
                  var rel_v_y = ball.v.y - another_ball.v.y;           
      
                  if ((a_to_b_x * rel_v_x + a_to_b_y * rel_v_y) < - 0.01)
                    valid = true;
                } else
                  valid = true;
      
                if (valid) {
                  if (collision_time != intersection_time)
                    _pairs.length = 0;
      
                  collision_time = intersection_time;
      
                 _pairs.push({one: ball, two: d, v_one: v_c(ball.v), v_two: v_c(d.v), point: t.y, normal: v_nor_2(ball.c.x + ball.v.x * collision_time - d.c.x - d.v.x * collision_time, ball.c.y + ball.v.y * collision_time - d.c.y - d.v.y * collision_time) });
                }             
              }
            }
          }
        }
      }
      
      for (var i = current_ball + 1; i < _balls.length; ++i) {
        var another_ball = _balls[i];
        if (!another_ball.active)
          continue;

        if (stopped && another_ball.v.x == 0 && another_ball.v.y == 0)
          continue;

        var center_x = another_ball.c.x - ball.c.x;        
        var center_y = another_ball.c.y - ball.c.y;
        if (center_x * center_x + center_y * center_y > 1600)
          continue;

        var t = ph_moving_spheres(ball.c, delta, ball.r, another_ball.c, another_ball.delta, another_ball.r);
        if (t) {
          var valid = false;

          var intersection_time = t.x * seconds;
          if (intersection_time == 0.0) {
            var a_to_b_x = ball.c.x - another_ball.c.x;
            var a_to_b_y = ball.c.y - another_ball.c.y;
            var rel_v_x = ball.v.x - another_ball.v.x;
            var rel_v_y = ball.v.y - another_ball.v.y;           

            if ((a_to_b_x * rel_v_x + a_to_b_y * rel_v_y) < - 0.01)
              valid = true;
          } else
            valid = true;

          if (valid) {
            if (!collision_time || intersection_time <= collision_time) {
              if (collision_time != intersection_time)
                _pairs.length = 0;

              collision_time = intersection_time;

              _pairs.push({one: ball, two: another_ball, v_one: v_c(ball.v), v_two: v_c(another_ball.v), point: t.y, normal: v_nor_2(ball.c.x + ball.v.x * collision_time - another_ball.c.x - another_ball.v.x * collision_time, ball.c.y + ball.v.y * collision_time - another_ball.c.y - another_ball.v.y * collision_time) });
            }
          }
        }
      }      
    }

    if (collision_time != null)
      was_collision = true;

    // Integrate up to the moment of collision.
    var step_time = collision_time != null ? collision_time : seconds;

    for (var i = 0; i < _balls.length; ++i) {
      var ball = _balls[i];

      v_madd_ref(ball.c, ball.v, step_time);
      v_madd_ref(ball.v, ball.f, step_time * ball.m);
    }

    if (collision_time != null && _pairs.length > 0) {
      // Check for identical points.
      for (var i = 0; i < _pairs.length; ++i) {
        var a = _pairs[i];
        for (var j = i + 1; j < _pairs.length; ++j) {
          var b = _pairs[j];

          if (b.skip)
            continue;
          if (a.point.x == b.point.x && a.point.y == b.point.y && a.normal.x == b.normal.x && a.normal.y == b.normal.y)
            b.skip = true;
        }
      }

      for (var i = 0; i < _pairs.length; ++i) {
        var v = _pairs[i];
        if (v.skip)
          continue;
           
        var obj_one = v.one;
        var obj_two = v.two;

        var c = -1.9;

        if (obj_two.type == instance_type.wall) 
          c = -1.7;
        if (obj_two.type == instance_type.trigger)
          c = -1.5;

        var impulse = v_mul(v.normal, c * v_dot(v_sub(v.v_one, v.v_two), v.normal) / (obj_one.m + obj_two.m));

        v_madd_ref(obj_one.v, impulse, obj_one.m);
        v_madd_ref(obj_two.v, impulse, - obj_two.m);

        obj_one.f = v_(0.0, 0.0);
        obj_two.f = v_(0.0, 0.0);
      }
    }

    _time += step_time;
  }  

  for (var i = 0; i < _balls.length; ++i) {
    var ball = _balls[i];

    var velocity = ball.v;
    var vel = v_dot(velocity, velocity);
    if (vel > 1.5) {
      velocity = v_nor(velocity);
      ball.f = v_mul(velocity, - 90 * (1 / ball.m) / 10);
    } else {
      ball.v = v_(0.0, 0.0);
    }    
  }
}

// Main game.

var _game_mode = 0;
var _current_level = [0, 0];
var _max_level = [0, 0];
var _total_levels = 0;
var _score = 0;
var _score_last_message = "";
var _multiplier = 1;
var _pocketed = 0;
var _kicks = 1;
var _hi_score = 0;
var _ajax_seed = 0;
var _selected;
var _click_direction;
var _click_position;
var _click_dist;
var _sortables = [];
var _next_effect = -1;
var _turn_penguins = false;
var _previous_successful = null;
var _previous_score = 0;

function game_start(game_mode) {
  _previous_successful = null;
  _previous_score = 0;

  $("#digger").css("display", "none");

  _game_mode = game_mode;

  window.scrollTo(0, 1);

  $("#logo").animate({opacity: 0}, 400, function() {
    $("#logo").css("display", "none"); 

    level_begin();
  });  
}

function level_begin() {
  level_initialize(_current_level[_game_mode]);

  $("#game-container").css("opacity", "0").css("display", "block");
  $("#game-container").animate({opacity: 1}, 400, function() {
    level_begin_continue();
  });
}

function level_begin_continue() {
  if (readCookie("rulesShown") != "1") {
    $("#digger").css("display", "none");

    $("#help-container").css("opacity", "0").css("display", "block").animate(
      {opacity: 1}, 400);

    createCookie("rulesShown", "1", 365);
  }
}        

function level_initialize(level) {
  ++_ajax_seed;

  _current_level[_game_mode] = level;
  _kicks = 1;
  _score = 0;
  _score_last_message = "";
  _multiplier = 1;
  _pocketed = 0;
  _hi_score = 10000000;
  _turn_penguins = false;

  reset_simulation();

  $("#game-canvas").css("display", "none");
  $("#game-canvas-clicker").css("display", "none");

  var canvas = $("#game-canvas").get(0).getContext("2d");
  canvas.clearRect(0, 0, 320, 320);

  if (_current_level[_game_mode] >= _total_levels || !_levels_normal[level])
  {
    _current_level[_game_mode] = _total_levels;

    $("#btn-tap").css("display", "block");
    set_image("#btn-tap-img", _ui.sprites.safe);
    $("#tap-name").get(0).innerHTML = "All levels completed!";
    $("#tap-score").get(0).innerHTML = "tap prev to play<br/>favorite levels again";

    return;
  }

  var sb = new StringBuilder();
  var sb_movables = new StringBuilder();

  var dots = _levels_normal[level].w;

  _sortables = [];

  for (var i = dots.length - 1; i >= 0; --i) {
    var d = dots[i];
    
    if (!d)
      continue;

    if (d.t == 0) {
      add_trigger(d.x * 60, d.y * 60, 22, i);
    } else if (d.t == 1) {
      sb.appendList("<div class='l dyn-css-land' style='left: ", d.lx - 30, "px; top: ", d.ly - 25, "px;'></div>");
    } else if (d.t == 2) {
      sb.appendList("<div class='lb dyn-css-blocker' style='left: ", d.lx - 30, "px; top: ", d.ly - 39, "px;'></div>");

      var cx = d.x * 60;
      var cy = d.y * 60;

      add_wall(cx - 30, cy - 30, cx + 30, cy - 30);
      add_wall(cx + 30, cy - 30, cx + 30, cy + 30);
      add_wall(cx + 30, cy + 30, cx - 30, cy + 30);
      add_wall(cx - 30, cy + 30, cx - 30, cy - 30);

    } else if (d.t == 3) {
      sb.appendList("<div class='l dyn-css-land' style='left: ", d.lx - 30, "px; top: ", d.ly - 25, "px;'></div>");

      var ball = add_ball("dot" + i, v_(d.x * 60, d.y * 60), 12.0, 10.0);

      ball.penguin = true;
      ball.el_id = "#dot" + i;
      ball.sortable = {id: ball.el_id, active: true, x: d.lx, y: d.ly, ball: ball};
      _sortables.push(ball.sortable);

      sb_movables.appendList("<img class='ball dyn-css-penguin' id='dot", i, "' src='dot.gif' style=''/>");

    } else if (d.t == 4) {
      sb.appendList("<div class='l dyn-css-land' style='left: ", d.lx - 30, "px; top: ", d.ly - 25, "px;'></div>");

      var ball = add_ball("dot" + i, v_(d.x * 60, d.y * 60), 12.0, 10.0);

      ball.bad_type = 0;
      ball.bad_multiplier = 1;
      ball.el_id = "#dot" + i;
      ball.sortable = {id: ball.el_id, active: true, x: d.lx, y: d.ly, ball: ball};
      _sortables.push(ball.sortable);

      sb_movables.appendList("<img class='ball dyn-css-bad' id='dot", i, "' src='dot.gif' style=''/>");
    } else if (d.t == 5) {
      sb.appendList("<div class='l dyn-css-land' style='left: ", d.lx - 30, "px; top: ", d.ly - 25, "px;'></div>");

      var ball = add_ball("dot" + i, v_(d.x * 60, d.y * 60), 13.0, 50.0);

      ball.bad_type = 4;
      ball.bad_multiplier = 5;
      ball.el_id = "#dot" + i;
      ball.sortable = {id: ball.el_id, active: true, x: d.lx, y: d.ly, ball: ball};
      _sortables.push(ball.sortable);

      sb_movables.appendList("<img class='ball-big dyn-css-bad-big' id='dot", i, "' src='dot.gif' style=''/>");
    } else if (d.t == 6) {
      sb.appendList("<div class='l dyn-css-land' style='left: ", d.lx - 30, "px; top: ", d.ly - 25, "px;'></div>");

      var ball = add_ball("dot" + i, v_(d.x * 60, d.y * 60), 13.0, 18.0);

      ball.bad_type = 5;
      ball.bad_multiplier = 2;
      ball.el_id = "#dot" + i;
      ball.sortable = {id: ball.el_id, active: true, x: d.lx, y: d.ly, ball: ball};
      _sortables.push(ball.sortable);

      sb_movables.appendList("<img class='ball dyn-css-striker' id='dot", i, "' src='dot.gif' style=''/>");
    } else if (d.t == 7) {
      sb.appendList("<div class='l dyn-css-land' style='left: ", d.lx - 30, "px; top: ", d.ly - 25, "px;'></div>");

      var ball = add_ball("dot" + i, v_(d.x * 60, d.y * 60), 25.0, 10.0);

      ball.flake = true;
      ball.el_id = "#dot" + i;
      ball.sortable = {id: ball.el_id, active: true, x: d.lx, y: d.ly, ball: ball};
      _sortables.push(ball.sortable);

      sb_movables.appendList("<img class='ball-flake dyn-css-flake' id='dot", i, "' src='dot.gif' style=''/>");
    } else if (d.t == 8) {
      sb.appendList("<div class='l dyn-css-land' style='left: ", d.lx - 30, "px; top: ", d.ly - 25, "px;'></div>");

      var ball = add_ball("dot" + i, v_(d.x * 60, d.y * 60), 13.0, 30.0);

      add_trigger(d.x * 60, d.y * 60, 13, "boss");

      ball.bad_type = 7;
      ball.bad_multiplier = 10;
      ball.el_id = "#dot" + i;
      ball.sortable = {id: ball.el_id, active: true, x: d.lx, y: d.ly, ball: ball};
      _sortables.push(ball.sortable);

      sb_movables.appendList("<img class='ball-big dyn-css-very-bad-big' id='dot", i, "' src='dot.gif' style=''/>");
    }
  }

  sb.appendList("<div id='info' style='position: absolute;'></div>");

  $("#game-field").get(0).innerHTML = sb.toString();
  $("#game-field-movables").get(0).innerHTML = sb_movables.toString();
 
  $("#info").css("opacity", "0");

  for (var i = 0; i < _balls.length; ++i) {
    _balls[i].el = $(_balls[i].el_id).get(0);
    _balls[i].this_index = i;
  }

  for (var i = 0; i < _sortables.length; ++i) {
    _sortables[i].el = $(_sortables[i].id).get(0);
  }

  sync_simulator();

  $("#btn-tap").css("display", "block");
  set_image("#btn-tap-img", _ui.sprites.tap);
  $("#tap-name").get(0).innerHTML = "Level: " + _levels_normal[_current_level[_game_mode]].n;
      
  $("#tap-score").get(0).innerHTML = "loading scores";
  $.post("score.php", 
    { seed: ++_ajax_seed, level: _current_level[_game_mode], mode: _game_mode }, function(xml) {
      var seed = $(xml).attr("s") * 1;
      var n = $(xml).attr("n");
      var score = $(xml).attr("v") * 1;

      if (seed == _ajax_seed) {
        if (n && n.length) {
          _hi_score = score;

          var tip = "be a hero, safe the penguins!";
          var tip_rnd = Math.random();
          if (tip_rnd < 0.25)
            tip = "bigger enemies need more pushing";
          else if (tip_rnd < 0.50)
            tip = "try push two enemies at once";
          else if (tip_rnd < 0.75)
            tip = "use snowflakes as your weapon";

          $("#tap-score").get(0).innerHTML = score + "&nbsp;points<br/>by " + $('<div/>').text(n).html() + "<div id='tap-info'>" + tip + "</div>";
        } else {
          _hi_score = 0;

          $("#tap-score").get(0).innerHTML = "be the first to<br/>get the topscore!";
        }
      }
    });

  set_on_trigger(on_out);
  
  if (_current_level[_game_mode] > 0)
    $("#btn-prev").css("opacity", "1");
  else
    $("#btn-prev").css("opacity", "0.4");

  if (_current_level[_game_mode] < _max_level[_game_mode])
    $("#btn-next").css("opacity", "1");
  else
    $("#btn-next").css("opacity", "0.4");

  update_score();
}

function on_out(b, t) { 
  if (t.n == "boss" && b.flake)
    return true;
  if (t.n == "boss" && b.bad_type == 7)
    return true;

  b.active = false;

  var c = ball_c(b.c);

  b.c = v_(1000, 1000);
  b.v = v_(0.0, 0.0);

  if (_turn_penguins) {
    if (b.penguin) {
      _multiplier = 1;
      _score_last_message = "Lost a penguin.";

      update_score();
    } else if (b.bad_multiplier) {
      ++_pocketed;

      _score += 1000 * _multiplier * b.bad_multiplier + (_pocketed - 1) * 2000;
      _multiplier++;
      _score_last_message = "Enemy defeated";
      if (_multiplier > 2)
        _score_last_message += " x " + (_multiplier - 1);
      _score_last_message += ".";

      update_score();
    }
  } else {
    if (b.penguin) {
      _score_last_message = "We are being attacked!";
    } else if (b.bad_multiplier) {
      ++_pocketed;

      _score += 1000 * _multiplier * b.bad_multiplier + (_pocketed - 1) * 2000;
      _multiplier++;
      _score_last_message = "Enemy defeated";
      if (_multiplier > 2)
        _score_last_message += " x " + (_multiplier - 1);
      _score_last_message += ".";

      update_score();
    }
  }

  _next_effect++;
  if (_next_effect == 8) 
    _next_effect = 0;

  $("#eff" + _next_effect).attr("src", "imgs/1/puff.gif").css("left", (Math.round(c.x) - 20) + "px").css("top", (Math.round(c.y) - 30) + "px").css("display", "block");

  setTimeout(function(e) { return function() {
    $(e).css("display", "none");
  }}("#eff" + _next_effect), 1000);

  return true;
}

function update_score() {
  var turns = "Turn " + _kicks + ". ";
  if (_score_last_message == "")
    $("#game-score").get(0).innerHTML = turns + "Current Score " + _score;
  else
    $("#game-score").get(0).innerHTML = turns + _score_last_message + " Score " + _score;
}

function sync_simulator() {
  var stopped = 0;

  $("#game-field-movables").css("display", "none");

  for (var i = 0; i < _balls.length; ++i) {
    var b = _balls[i];

    var cx = b.c.x;
    var cy = b.c.y;

    b.sortable.x = 160 + Math.round((cx - cy) * 0.5 * 60 / 60 - 20.0);
    b.sortable.y = 280 - Math.round((cx + cy) * 0.5 * 29 / 60 + 25.0);

    if ((b.v.x == 0.0 && b.v.y == 0.0) || !b.active)
      ++stopped;
  }

  // Sort all movable pieces.
            
  for (;;) {
    var changes = false;
   
    for (var i = 0; i < _sortables.length - 1; ++i) {
      var a = _sortables[i];
      var b = _sortables[i + 1];

      if (b.y < a.y) {
        _sortables[i + 1] = a;
        _sortables[i] = b;
        changes = true;
      }
    }

    if (!changes)
      break;  
  }
           
  var sb = new StringBuilder();

  for (var i = 0; i < _sortables.length; ++i) {
    var s = _sortables[i];

    if (s.last_x != s.x || s.last_y != s.y || s.last_z != i) {
      sb.appendList('left:', s.x, 'px; top:', s.y, 'px; z-index: ', i + 100, ';');
      s.el.style.cssText = sb.toString();

      s.last_x = s.x;
      s.lasy_y = s.y;
      s.last_z = i;
    }
  }

  $("#game-field-movables").css("display", "block");

  return stopped == _balls.length;
}

var _simulator_running = null;

function start_simulator() {
  $("#btn-tap").css("display", "none");

  _simulator_running = setTimeout(process_simulator, 50);
}

function stop_simulator() {
  if (_simulator_running) {
    clearTimeout(_simulator_running);
  
    _simulator_running = null;
  }
}

function process_simulator() {
  if (!_simulator_running)
    return;

  step_simulation(0.1);

  if (sync_simulator()) {
    // Proceed to the player's part.
    stop_simulator();

    turn_begin();
  }
  else
    setTimeout(process_simulator, 50); 
}

function turn_begin() {

  // Place big boss trigger.
  for (var i = 0; i < _balls.length; ++i) {
    var b = _balls[i];

    if (b.bad_type == 7) {
      for (var j = 0; j < _triggers.length; ++j) {
        var t = _triggers[j];

        if (t.n == "boss") {
          t.x = b.c.x; 
          t.y = b.c.y;
          break;
        }
      }
    }
  }

  _selected = null;

  var penguins = 0;
  var bad_guys = 0;
  for (var i = 0; i < _balls.length; ++i) {
    var b = _balls[i];
    if (b.active) {
      if (b.penguin)
        ++penguins;
      else if (b.bad_type != null)
        ++bad_guys;
    }
  }

  if (bad_guys == 0 || penguins == 0) {
    var level_bonus = false;
    if (penguins > 0) {
      if (_previous_successful == _current_level[_game_mode] - 1)
        level_bonus = true;

      _previous_successful = _current_level[_game_mode];

      if (_current_level[_game_mode] < _max_level[_game_mode])
        ++_current_level[_game_mode];
      else {
        ++_max_level[_game_mode];
        ++_current_level[_game_mode];
      }
    } else
      _previous_successful = null;

    if (_max_level[_game_mode] >= _total_levels)
      _max_level[_game_mode] = _total_levels;
    if (_current_level[_game_mode] >= _total_levels)
      _current_level[_game_mode] = _total_levels;

    createCookie("max_level", "" + _max_level[_game_mode], 365);
    createCookie("current_level", "" + _current_level[_game_mode], 365);

    var _turn_bonus = Math.round(10000 / (_kicks + 3) * 5);
    var _penguin_bonus = 0;
    var _sequence_bonus = level_bonus ? Math.round(_previous_score * 0.2) : 0;
    for (var i = 0; i < _balls.length; ++i)
      if (_balls[i].active && _balls[i].penguin)
        _penguin_bonus += 1000;

    var _start_score = _score;
    _score += _turn_bonus + _penguin_bonus + _sequence_bonus;

    _previous_score = _score;

    var best = _score > _hi_score;

    if (penguins == 0) {
      set_image("#grats", _ui.sprites.lost);
    }
    else {
      if (best) {
        set_image("#grats", _ui.sprites.hi);
      } else {
        set_image("#grats", _ui.sprites.complete);
      }    
    }

    var sb = new StringBuilder();

    sb.appendList("total score ", _score);
    sb.appendList("<div class='small-score'>turn bonus ", _turn_bonus, "</div>");
    sb.appendList("<div class='small-score'>penguin bonus ", _penguin_bonus, "</div>");
    sb.appendList("<div class='small-score'>level sequence bonus ", _sequence_bonus, "</div>");


    if (!best && (_hi_score < 10000000 && _hi_score > 0)) {
      sb.appendList("<br/>top score ", _hi_score);
    }

    $("#grats-score").get(0).innerHTML = sb.toString();

    if (!best || penguins == 0) {
      $("#grats-record").css("display", "none");

      $("#grats-container").css("display", "block").css("opacity", "1");
      $("#grats").css("opacity", "0").animate({opacity: 1}, 600);    

      setTimeout(function() {
        $("#grats-container").animate({opacity: 0}, 400, function() {
          $("#grats-container").css("display", "none");

          level_begin();
        });
      }, 5000);
    } else {
      $("#grats-record").css("display", "block");

      $("#grats-container").css("display", "block").css("opacity", "1");
      $("#grats").css("opacity", "0").animate({opacity: 1}, 600);
    }
  } else {
    _turn_penguins = !_turn_penguins;

    if (_turn_penguins) {
      $("#game-canvas").css("display", "block");
      $("#game-canvas-clicker").css("display", "block");

      var canvas = $("#game-canvas").get(0).getContext("2d");
      canvas.clearRect(0, 0, 320, 320);

      canvas.drawImage(_img_combined_obj,
        _ui.sprites.your_turn.x, _ui.sprites.your_turn.y, _ui.sprites.your_turn.width, _ui.sprites.your_turn.height, Math.round((320 - _ui.sprites.your_turn.width) / 2), Math.round((320 - _ui.sprites.your_turn.height) / 2), _ui.sprites.your_turn.width, _ui.sprites.your_turn.height);

      _click_direction = null;
      _click_position = null;

      if (_pocketed == 0)
        _multiplier = 1;
      _pocketed = 0;
    } else {
      turn_computer();
    }
  }
}

function turn_computer() {
  var best_shot = null;

  for (var i = 0; i < _balls.length; ++i) {
    var e = _balls[i];
    if (!e.active || e.penguin)
      continue;

    var shot = null;
    if (e.bad_type == 0)
      shot = turn_computer_strategy_zombie(e);
    if (e.bad_type == 4)
      shot = turn_computer_strategy_boss(e);
    if (e.bad_type == 5)
      shot = turn_computer_strategy_pest(e);
    if (shot)
      shot.e.f = shot.f;
  }

  start_simulator();
}

function turn_computer_strategy_pest(e) {
  var best_shot = null;

  for (var i = 0; i < _balls.length; ++i) {
    var p = _balls[i];
    if (!p.active || !p.penguin)
      continue;

    var d = v_sub(p.c, e.c);

    var c = trace_intersection(e, e.c, e.r, d);

    if (c.x && c.y == "penguin") {
      d = v_dist(p.c, e.c);

      var shot = {score: 1000.0 / d, e: e, f: v_dir(e.c, p.c, 17000)};
      if (best_shot == null || shot.score > best_shot.score)
        best_shot = shot;
    }
  }

  return best_shot;
}

function turn_computer_strategy_boss(e) {
}

function turn_computer_strategy_zombie(e) {
  var best_shot = null;

  for (var i = 0; i < _balls.length; ++i) {
    var p = _balls[i];
    if (!p.active || !p.penguin)
      continue;
    
    var d = v_dist(p.c, e.c);    

    var shot = {score: 1000.0 / d, e: e, f: v_dir(e.c, p.c, 5000)}; 

    if (best_shot == null || shot.score > best_shot.score)
      best_shot = shot;
  }

  return best_shot;
}

function mouse_position(current, event) {
  var x = 0, y = 0;
  for (; current != null; current = current.offsetParent) {
    x += current.offsetLeft;
    y += current.offsetTop;
  }
 
 return {x: event.pageX - x, y: event.pageY - y };
}

function ball_c(c) {
  var cx = c.x;
  var cy = c.y;
  var x = 160 + Math.round((cx - cy) * 0.5 * 60 / 60 - 20) + 16;
  var y = 280 - Math.round((cx + cy) * 0.5 * 29 / 60 + 25) + 16;

  return v_(x, y);
}

function draw_line(canvas, s, delta, distance, thickness, decrease, color, skip_offset) {
  canvas.strokeStyle = color;

  var t = thickness;
  var td = decrease;
  var d = distance;

  var lx = s.x;
  var ly = s.y;

  if (!skip_offset) {
    lx += delta.x * 10;
    ly += delta.y * 10;
    d -= 10;
  }

  for (; d > 0; d -= 10) {
    var path = d > 10 ? 10.5 : (d + 0.5);

    var nx = lx + delta.x * path;
    var ny = ly + delta.y * path;

    canvas.beginPath();
    canvas.moveTo(lx, ly);
    canvas.lineTo(nx, ny);

    canvas.lineWidth = t;
    canvas.stroke();

    t -= td;
    td -= 0.06;

    if (t < 0)
      t = 0;
    if (td < 0.17)
      td = 0.17;

    lx = lx + delta.x * 10;
    ly = ly + delta.y * 10;
  }

  return {thick: t, decrease: td};
}

function setup_click_handlers() {
  $("#btn-easy").click(function() {
    game_start(0);

    return false;
  });

  $("#btn-tap").click(function() {
    if (_current_level[_game_mode] >= _total_levels)
      return false;

    window.scrollTo(0, 1);

    start_simulator();

    return false;
  });

  $("#btn-prev").click(function() {
    if (_current_level[_game_mode] > 0) {
      stop_simulator();
    
      --_current_level[_game_mode];

      level_begin();
    }
  });

  $("#btn-next").click(function() {
    if (_current_level[_game_mode] < _max_level[_game_mode]) {
      stop_simulator();

      ++_current_level[_game_mode];

      level_begin();
    }
  });

  $("#btn-menu").click(function() {
    stop_simulator();

    $("#logo").css("opacity", "0").css("display", "block");
    $("#game-container").animate({opacity: 0}, 400, function() {
      $("#game-container").css("display", "none");

      $("#logo").animate({opacity: 1}, 400, function() { $("#digger").css("display", "block"); });
    });
  });

  $("#btn-reset").click(function() {
    stop_simulator();

    level_begin();
  });

  $("#btn-help").click(function() {
    $("#digger").css("display", "none");

    $("#help-container").css("opacity", "0").css("display", "block").animate(
      {opacity: 1}, 400);

    return false;
  });

  $("#help-container").click(function() {
    createCookie("rulesShown", "1", 365);    

    $("#help-container").animate({opacity: 0}, 400, function() {
      $("#help-container").css("display", "none");

      $("#digger").css("display", "block");
    });
  });

  $("#btn-go").click(function() {
    $("#grats-container").animate({opacity: 0}, 400, function() {
      $.post("score.php", 
        { seed: ++_ajax_seed, 
          level: _current_level[_game_mode] - 1, 
          mode: _game_mode,
          name: $("#grats-name").val(),
          score: _score }, function(xml) {});
  
      $("#grats-container").css("display", "none");

      level_begin();
    });
  });

  $("#game-canvas-clicker").click(function(event) {
    var c = mouse_position(this, event);

    // Check for penguin selection.
    for (var i = 0; i < _balls.length; ++i) {        
      var b = _balls[i];
      if (!b.penguin)
        continue;

      var cb = ball_c(b.c);
    
      if (v_dist(cb, c) < 18) {
        _selected = b;
        break;
      }
    }

    if (!_selected) {
      var canvas = $("#game-canvas").get(0).getContext("2d");
      canvas.clearRect(0, 0, 320, 320);

      canvas.drawImage(_img_combined_obj,
        _ui.sprites.your_turn.x, _ui.sprites.your_turn.y, _ui.sprites.your_turn.width, _ui.sprites.your_turn.height, Math.round((320 - _ui.sprites.your_turn.width) / 2), Math.round((320 - _ui.sprites.your_turn.height) / 2), _ui.sprites.your_turn.width, _ui.sprites.your_turn.height);  
      return;
    }
    
    var l_c = ball_c(_selected.c);

    var lx = l_c.x;
    var ly = l_c.y;

    var l = v_(lx, ly);

    var delta = v_nor(v_(c.x - lx, c.y - ly));
    var dist = v_dist(l_c, c);

    // Check if we need to kick the ball.
    var kick = null;

    if (_click_position && _click_direction) {
      var bx = Math.round((320 - _ui.sprites.launch.width) / 2);

      if (c.x > bx && c.x < bx + _ui.sprites.launch.width && c.y > 10 && c.y < 10 + _ui.sprites.launch.height)
	      kick = _click_dist * 100;

      if (kick) {
        var a = -0.785398;
        var rx = _click_direction.x * Math.cos(a) + _click_direction.y * 2 * Math.sin(a);
        var ry = _click_direction.x * Math.sin(a) - _click_direction.y * 2 * Math.cos(a);

        _kicks++;

        _selected.f = v_mul(v_nor(v_(rx, ry)), kick);

        _score_last_message = "";

        update_score();

        start_simulator();

        $("#game-canvas").css("display", "none");
        $("#game-canvas-clicker").css("display", "none");

        return;
      } 
    }

    var canvas = $("#game-canvas").get(0).getContext("2d");
    canvas.clearRect(0, 0, 320, 320);

    if (dist < 25)
      dist = 25;
    else if (dist > 150)
      dist = 150;

    var a = -2.356194;
    var rx1 = delta.x * Math.cos(a) - delta.y * Math.sin(a);
    var ry1 = delta.x * Math.sin(a) + delta.y * Math.cos(a);
    var rx2 = delta.x * Math.cos(-a) - delta.y * Math.sin(-a);
    var ry2 = delta.x * Math.sin(-a) + delta.y * Math.cos(-a);

    draw_line(canvas, v_add(l_c, v_(1, 0)), delta, dist, 5, 0.5, "rgb(0, 0, 0)");
    draw_line(canvas, v_add(v_add(l_c, v_mul(delta, dist)), v_(1, 0)), v_(rx1, ry1), 20, 3, 0.6, "rgb(0, 0, 0)", true);
    draw_line(canvas, v_add(v_add(l_c, v_mul(delta, dist)), v_(1, 0)), v_(rx2, ry2), 20, 3, 0.6, "rgb(0, 0, 0)", true);
        
    draw_line(canvas, l_c, delta, dist, 5, 0.5, "rgb(255, 180, 0)");
    draw_line(canvas, v_add(l_c, v_mul(delta, dist)), v_(rx1, ry1), 20, 3, 0.6, "rgb(255, 180, 0)", true);
    draw_line(canvas, v_add(l_c, v_mul(delta, dist)), v_(rx2, ry2), 20, 3, 0.6, "rgb(255, 180, 0)", true);

    canvas.drawImage(_img_combined_obj,
      _ui.sprites.launch.x, _ui.sprites.launch.y, _ui.sprites.launch.width, _ui.sprites.launch.height, Math.round((320 - _ui.sprites.launch.width) / 2), 10, _ui.sprites.launch.width, _ui.sprites.launch.height);  

    _click_dist = dist;
    
    _click_position = c;
    _click_direction = delta; 
  });
}

function make_img(v, force) {
  return $.browser.msie || force ? ("imgs/1/" + v) : ("imgs/" + v);
}

var _img_combined = make_img("ui.atlas.optimized.png");
var _img_combined_obj;

var _preload_init = [ "imgs/underclouds.png", "imgs/1/back.png", "imgs/1/logo.png" ];
var _preload_continue = [ _img_combined, "imgs/1/help.png", "imgs/1/sea.png", "imgs/1/puff.gif" ];
var _preload_continue_count = _preload_continue.length;

function fixup_logo() {
  $("#logo-inner").css("background", "transparent url(imgs/1/back.png) no-repeat center");
  $("#game-inner").css("background", "transparent url(imgs/1/sea.png) repeat");
  $("#logo-img").attr("src", "imgs/1/logo.png");
}

function set_image(id, style) {
  $(id).attr("width", style.width).attr("height", style.height).css("background",
    "transparent url(" + _img_combined + ") no-repeat " + style.style);
}

function fixup_preload() {
  set_image("#btn-easy", _ui.sprites.start);
  set_image("#btn-help", _ui.sprites.help);
  set_image("#btn-other", _ui.sprites.other);

  set_image("#btn-prev", _ui.sprites.prev);
  set_image("#btn-reset", _ui.sprites.reset);
  set_image("#btn-menu", _ui.sprites.menu);
  set_image("#btn-next", _ui.sprites.next);

  set_image("#btn-go", _ui.sprites.go);

  $("#grats").css("background", "transparent url(" + _img_combined + ") no-repeat 0px -149px");

  $("#help-outer").css("background", "transparent url(imgs/1/help.png) no-repeat 0px 0px");

  _img_combined_obj = new Image();
  _img_combined_obj.src = _img_combined;

  var sb = new StringBuilder();
  sb.appendList('<style rel="alternate stylesheet" type="text/css">',
    '.dyn-css-land { background: transparent url(', _img_combined, ') no-repeat ', _ui.sprites.land.style, '; } ',
    '.dyn-css-blocker { background: transparent url(', _img_combined, ') no-repeat ', _ui.sprites.blocker.style, '; } ',
    '.dyn-css-penguin { background: transparent url(', _img_combined, ') no-repeat ', _ui.sprites.penguin.style, '; } ',
    '.dyn-css-bad { background: transparent url(', _img_combined, ') no-repeat ', _ui.sprites.bad.style, '; } ',
    '.dyn-css-bad-big { margin-left: -16px; margin-top: -30px; background: transparent url(', _img_combined, ') no-repeat ', _ui.sprites.bad_big.style, '; } ',
    '.dyn-css-very-bad-big { margin-left: -16px; margin-top: -30px; background: transparent url(', _img_combined, ') no-repeat ', _ui.sprites.very_bad.style, '; } ',
    '.dyn-css-striker { background: transparent url(', _img_combined, ') no-repeat ', _ui.sprites.bad_pest.style, '; }',
    '.dyn-css-flake { margin-left: -4px; margin-top: -3px; background: transparent url(', _img_combined, ') no-repeat ', _ui.sprites.snowflake.style, '; }',
    '</style>');

  $(sb.toString()).appendTo('head');
}

$(function() {
  // Begin images preloading.
  $(document.createElement('img')).bind('load', function() {
    if(_preload_init[0]) {
      this.src = _preload_init.shift();
    } else {
      $("#preloading").css("display", "none");

      fixup_logo();

      $("#brand").animate({opacity: 1}, 1500, function() {
        setTimeout(function() {
          $("#brand").animate({opacity: 0}, 1500, function() {
            $("#logo").animate({opacity: 1}, 1000, function() {
              $("#brand").css("display", "none");
            });
          });
        }, 2000);
      });

      $(document.createElement('img')).bind('load', function() {
        if(_preload_continue[0]) {
          this.src = _preload_continue.shift();
        } else {
          fixup_preload();          

          $("#logo-loading").css("display", "none");
          $("#logo-loaded").css("display", "inline");

          setTimeout(function() {
           updateLayout();   
   
           window.scrollTo(0, 1);

           setInterval(updateLayout, 100); 
          }, 300);
        }
      }).trigger('load');
    }
  }).trigger('load');

  setup_click_handlers();

  _max_level[0] = readCookie("max_level");
  _current_level[0] = readCookie("current_level");
  _max_level[1] = readCookie("max_level_adv");
  _current_level[1] = readCookie("current_level_adv");
 
  _total_levels = 0;
  for (var i = 0; i < _levels_normal.length; ++i)
    if (_levels_normal[i])
      ++_total_levels;
  
  for (var i = 0; i < 2; ++i) {
    _max_level[i] *= 1;
    _current_level[i] *= 1;
    
    if (isNaN(_max_level[i]) || !_max_level[i]) _max_level[i] = 0;
    if (isNaN(_current_level[i]) || !_current_level[i]) _current_level[i] = 0;
    if (_max_level[i] >= _total_levels) _max_level[i] = _total_levels;
    if (_current_level[i] > _max_level[i]) _current_level[i] = _max_level[i];
  }

  var agent = navigator && navigator.userAgent ? navigator.userAgent.toLowerCase() : "";
  var is_iphone = agent && (agent.indexOf('iphone') != -1 || agent.indexOf('ipod') != -1);

  if (!is_iphone) {
    $("#pc-padding").css("display", "block");
  }

  var name = readCookie("name");

  if (name && name.length > 0)
    $("#grats-name").val(name);  
  else
    $("#grats-name").val("nickname");

  document.body.setAttribute("orient", "profile");
});
