//
// Structure Prototypes
//

function PicSrc (i, size)
{
   var a, b = 0, s = '', t = '', u = '';

   for (a=0; a<pics[i].src.length; a++)
      if (pics[i].src.charAt (a) == '/')
         b = a;
   if (b > 0)
   {
      s = pics[i].src.slice (0, b + 1);
      u = pics[i].src.slice (b + 1);
   }
   else u = pics[i].src;

   if (size == 'tiny')
      t = 'tiny/';

   if (size == null)
      size = '';
   if (size != '')
      size = '-' + size;

   a = u.indexOf ('.');

   return '/images/portfolio/' + s + t + u.slice (0, a) + size + u.slice (a);
}

function PIC (r, c, s, volume, bordercolor, background, src)
{
   this.r            = r;
   this.c            = c;
   this.s            = s;
   this.volume       = volume;
   this.bordercolor  = bordercolor;
   this.background   = background;
   this.src          = src;

   this.start        = 0;
   this.milliseconds = 0;
   this.from         = 50;
   this.to           = 50;

   this.current      = 50;
}

//
// Globals
//

/*
   Jennifer_Reece-A206        ???
   Jenyne_Wilson-B261         ???
   Rosetta_Mortati-A185       ??? other ???
   Kaycie_Davis-A232          ??? other ???
   nicole_derseweh-B345       ??? other ???
   Jennifer_Chamberlin-A125   ???

   portraits-000
*/

// new PIC ( 1,  0, 0, 1, 128, 191, 'Autumn_Robertson-A361.jpg'),

var pics = new Array
(
   new PIC ( 0,  0, 0, 1, 128, 255, 'Natalie_Brabner-A509.jpg'),
   new PIC ( 1,  0, 0, 1, 128, 253, 'Jamie_Eason-A387.jpg'),                   // 254
   new PIC ( 0,  1, 0, 1, 128, 252, 'Tina_Jo_Orban-B073.jpg'),                 // 25?
   new PIC ( 2,  0, 0, 0, 128, 250, 'Emery_Miller-A645.jpg'),
   new PIC ( 1,  1, 0, 1, 171, 248, 'Lisa_Aukland-A154.jpg'),
   new PIC ( 0,  2, 0, 0, 171, 247, 'Nicole_Derseweh-A159.jpg'),
   new PIC ( 3,  0, 0, 1, 171, 245, 'Shana_Martin-A111.jpg'),
   new PIC ( 2,  1, 0, 0, 171, 243, 'Laura_Cavender-A602.jpg'),
   new PIC ( 1,  2, 0, 0, 171, 242, 'Meriza_De_Guzman-A611.jpg'),
   new PIC ( 0,  3, 0, 0, 171, 240, 'Gina_Aliotti-B671.jpg'),                  // ***
   new PIC ( 4,  0, 0, 1, 171, 239, 'Melissa_Tucker-A089.jpg'),
   new PIC ( 3,  1, 0, 0, 171, 237, 'Allison_Ethier-A229.jpg'),                // ***
   new PIC ( 2,  2, 0, 1, 171, 235, 'Angela_Stueber-A262.jpg'),                // 236
   new PIC ( 1,  3, 0, 1, 171, 234, 'Margaret_Diubaldo-A058.jpg'),
   new PIC ( 0,  4, 0, 0, 171, 232, 'Diana_Chaloux-A922.jpg'),
   new PIC ( 5,  0, 0, 0, 171, 230, 'John_Stutz_Photo-IA134.jpg'),
   new PIC ( 4,  1, 0, 0, 171, 229, 'Nicole_Marie_Fatigati-A768.jpg'),
   new PIC ( 3,  2, 0, 0, 171, 227, 'John_Webster-A092.jpg'),
   new PIC ( 2,  3, 0, 0, 171, 225, 'Sara_Clow-A336.jpg'),
   new PIC ( 1,  4, 0, 0, 171, 224, 'Michelle_Troll-A118.jpg'),
   new PIC ( 0,  5, 0, 0, 171, 222, 'Myrriah_Wenona_Palomares-A360.jpg'),
   new PIC ( 6,  0, 0, 1, 171, 220, 'Leah_Wynne-A108.jpg'),
   new PIC ( 5,  1, 0, 0, 171, 219, 'Chandra_Coffey-A228.jpg'),
   new PIC ( 4,  2, 0, 0, 171, 217, 'Fawnia_Dietrich-A362.jpg'),
   new PIC ( 2,  4, 0, 0, 171, 216, 'Natalie_Brabner-A751.jpg'),
   new PIC ( 1,  5, 0, 0, 171, 214, 'Heather_Cox-F161.jpg'),
   new PIC ( 0,  6, 0, 1, 128, 212, 'Julie_Marsland-A144.jpg'),
   new PIC ( 7,  0, 0, 1, 171, 211, 'Mari_Kudla-A141.jpg'),
   new PIC ( 6,  1, 0, 1, 128, 209, 'Shana_Martin-A057.jpg'),
   new PIC ( 5,  2, 0, 0, 128, 207, 'Jaclyn_Troup-A309.jpg'),
   new PIC ( 2,  5, 0, 0, 128, 206, 'John_Stutz_Photo-IA174.jpg'),
   new PIC ( 1,  6, 0, 0, 128, 204, 'Leah_Wynne-A671.jpg'),
   new PIC ( 0,  7, 0, 0, 128, 202, 'Nicole_Derseweh-B183.jpg'),
   new PIC ( 8,  0, 0, 1, 128, 201, 'Samantha_Waltz-A026.jpg'),
   new PIC ( 7,  1, 0, 0, 128, 199, 'Natalie_Brabner-A789.jpg'),
   new PIC ( 6,  2, 0, 0, 128, 197, 'Angela_Kirkland-A165.jpg'),
   new PIC ( 2,  6, 0, 0, 128, 196, 'Drew_Broadrick-A031.jpg'),
   new PIC ( 1,  7, 0, 0, 128, 194, 'Chandra_Coffey-A101.jpg'),
   new PIC ( 0,  8, 0, 0, 128, 192, 'Misti_Cerra-A154.jpg'),                   // NIX this one if necessary
   new PIC ( 9,  0, 0, 1, 128, 191, 'Lisa_Aukland-A245.jpg'),
   new PIC ( 8,  1, 0, 0, 128, 189, 'Nicole_Derseweh-C733.jpg'),
   new PIC ( 7,  2, 0, 0, 128, 188, 'Natalie_Lantz-A490.jpg'),
   new PIC ( 2,  7, 0, 1, 128, 186, 'Misti_Cerra-A192.jpg'),                   // 185
   new PIC ( 1,  8, 0, 1, 128, 184, 'Jamie_Shires-A613.jpg'),                  // 185
   new PIC ( 0,  9, 0, 0, 128, 183, 'Jamie_Shires-A121.jpg'),                  // ***
   new PIC (10,  0, 0, 0, 128, 181, 'Natalie_Lantz-A706.jpg'),
   new PIC ( 9,  1, 0, 1, 128, 179, 'Gina_Aliotti-B534.jpg'),
   new PIC ( 8,  2, 0, 1,  85, 178, 'Allison_Ethier-A377.jpg'),                // 177
   new PIC ( 2,  8, 0, 1,  85, 176, 'Nita_Marquez-A927.jpg'),                  // 175
   new PIC ( 1,  9, 0, 1,  85, 174, 'Samantha_Waltz-B222.jpg'),                // 173
   new PIC ( 0, 10, 0, 1,  85, 173, 'Jenyne_Wilson-B201.jpg'),
   new PIC (11,  0, 0, 0,  85, 171, 'Jamie_Reed-A577.jpg'),
   new PIC (10,  1, 0, 1,  85, 169, 'Molly_Goodwin-A313.jpg'),                 // 170
   new PIC ( 9,  2, 0, 0,  85, 168, 'Rosa_Maria_Romero-A052.jpg'),
   new PIC ( 2,  9, 0, 0,  85, 166, 'Nicole_Derseweh-C656.jpg'),
   new PIC ( 1, 10, 0, 1,  85, 165, 'Debbie_Leung-A291.jpg'),                  // 164
   new PIC ( 0, 11, 0, 1,  85, 163, 'Fawnia_Dietrich-B292.jpg'),
   new PIC (12,  0, 0, 1,  85, 161, 'Shari_Yates-A089.jpg'),                   // 162
   new PIC (11,  1, 0, 1,  85, 160, 'Andrea_Spinks-A128.jpg'),                 // 159
   new PIC (10,  2, 0, 1,  85, 158, 'Irina_Kiselev-A500.jpg'),                 // 159
   new PIC ( 2, 10, 0, 0,  85, 156, 'Shana_Martin-B163.jpg'),
   new PIC ( 1, 11, 0, 0,  85, 155, 'John_Webster-A256.jpg'),
   new PIC ( 0, 12, 0, 0,  85, 153, 'Lisa_Morton-B071.jpg'),
   new PIC (13,  0, 0, 0,  85, 151, 'Nicole_Marie_Fatigati-A843.jpg'),
   new PIC (12,  1, 0, 0,  85, 150, 'Julie_Childs-A177.jpg'),
   new PIC (11,  2, 0, 0,  85, 148, 'Leanna_Rizkalla-A650.jpg'),
   new PIC ( 2, 11, 0, 1,  85, 146, 'Sara_Clow-A274.jpg'),
   new PIC ( 1, 12, 0, 1,  85, 145, 'Latisha_Wilder-A127.jpg'),
   new PIC ( 0, 13, 0, 0,  85, 143, 'Julie_Marsland-A286.jpg'),
   new PIC (14,  0, 0, 1,  85, 141, 'Waleska_Valle-A174.jpg'),                 // 142
   new PIC (13,  1, 0, 0,  85, 140, 'Lindsey_Cope-A607.jpg'),
   new PIC (12,  2, 0, 1,  85, 138, 'Nicole_Rollolazo-A113.jpg'),
   new PIC ( 2, 12, 0, 0,  85, 137, 'Natalie_Lantz-A115.jpg'),
   new PIC ( 1, 13, 0, 0, 192, 135, 'Monica_Brant-A230.jpg'),
   new PIC ( 0, 14, 0, 1, 192, 133, 'Marika_Johansson-A201.jpg'),              // 132
   new PIC (15,  0, 0, 1, 192, 132, 'Ali_McKnight-A238.jpg'),
   new PIC (14,  1, 0, 0, 192, 130, 'John_Webster-A225.jpg'),
   new PIC (13,  2, 0, 1, 192, 128, 'Allison_Bookless-A035.jpg'),              // 129
   new PIC ( 2, 13, 0, 0, 171, 127, 'Andi_Campbell-A208.jpg'),
   new PIC ( 1, 14, 0, 1, 171, 125, 'Jennifer_Chamberlin-A325.jpg'),           // 126
   new PIC ( 0, 15, 0, 0, 171, 123, 'Nita_Marquez-A204.jpg'),
   new PIC (15,  1, 0, 1, 171, 122, 'Autumn_Robertson-A300.jpg'),
   new PIC (14,  2, 0, 1, 171, 120, 'Jennifer_Lynn_Cowan-A081.jpg'),           // 121
   new PIC (13,  3, 0, 1, 171, 118, 'Kaycie_Davis-A071.jpg'),                  // 119
   new PIC ( 3, 13, 0, 0, 171, 117, 'Nicole_Derseweh-B425.jpg'),
   new PIC ( 2, 14, 0, 1, 171, 115, 'Mindi_O_Brien-B024.jpg'),
   new PIC ( 1, 15, 0, 0, 171, 114, 'John_Stutz_Photo-IB259.jpg'),
   new PIC (15,  2, 0, 0, 171, 112, 'Annette_Milbers-A214.jpg'),
   new PIC (14,  3, 0, 1, 171, 110, 'Nita_Marquez-A311.jpg'),
   new PIC (13,  4, 0, 0, 171, 109, 'Julie_Childs-A416.jpg'),
   new PIC ( 4, 13, 0, 1, 171, 107, 'Allison_Bookless-A178.jpg'),              // 108
   new PIC ( 3, 14, 0, 0, 171, 105, 'Jennifer_Cowan-A248.jpg'),
   new PIC ( 2, 15, 0, 0, 171, 104, 'Tina_Jo_Orban-A182.jpg'),
   new PIC (15,  3, 0, 0, 171, 102, 'Pam_Anstey-A594.jpg'),
   new PIC (14,  4, 0, 1, 171, 100, 'Kali_Knapp-A056.jpg'),                    // 101
   new PIC (13,  5, 0, 0, 171,  99, 'Fawnia_Dietrich-B361.jpg'),
   new PIC ( 5, 13, 0, 0, 171,  97, 'Cindy_Phillips-A161.jpg'),
   new PIC ( 4, 14, 0, 1, 171,  95, 'Angela_Kirkland-B269.jpg'),               //  94
   new PIC ( 3, 15, 0, 1, 171,  94, 'Zuzana_Majorova-A179.jpg'),               //  93
   new PIC (15,  4, 0, 1, 171,  92, 'Natalie_Barnett-B442.jpg'),               //  93
   new PIC (14,  5, 0, 1, 128,  90, 'Sara_Craven-A342.jpg'),                   //  91
   new PIC (13,  6, 0, 0, 128,  89, 'Sara_Clow-A295.jpg'),
   new PIC ( 6, 13, 0, 1, 128,  87, 'Meriza_DeGuzman-A310.jpg'),
   new PIC ( 5, 14, 0, 1, 128,  86, 'Lisa_Morton-A462.jpg'),                   //  87
   new PIC ( 4, 15, 0, 1, 128,  84, 'Nicole_Marie_Fatigati-A049.jpg'),
   new PIC (15,  5, 0, 0, 128,  82, 'Alexis_Ellis-A334.jpg'),
   new PIC (14,  6, 0, 0, 128,  81, 'Samantha_Waltz-B229.jpg'),
   new PIC (13,  7, 0, 1, 128,  79, 'Keri_Doudna-A279.jpg'),                   //  80
   new PIC ( 7, 13, 0, 0, 128,  77, 'Andrea_Dumon-B327.jpg'),
   new PIC ( 6, 14, 0, 1, 128,  76, 'Angela_Kirkland-A087.jpg'),               //  75
   new PIC ( 5, 15, 0, 1, 128,  74, 'Cindy_Phillips-A254.jpg'),                //  73
   new PIC (15,  6, 0, 1, 128,  72, 'Nicole_Marie_Fatigati-A786.jpg'),         //  71
   new PIC (14,  7, 0, 1, 128,  71, 'Lindsey_Cope-A593.jpg'),
   new PIC (13,  8, 0, 0, 128,  69, 'John_Stutz_Photo-IB080.jpg'),
   new PIC ( 8, 13, 0, 1, 128,  67, 'Lisa_Morton-B090.jpg'),                   //  68
   new PIC ( 7, 14, 0, 1, 128,  66, 'Waleska_Valle-A069.jpg'),
   new PIC ( 6, 15, 0, 1, 128,  64, 'Nita_Marquez-A318.jpg'),
   new PIC (15,  7, 0, 1, 128,  63, 'Andi_Campbell-A355.jpg'),
   new PIC (14,  8, 0, 1, 128,  61, 'Jamie_Shires-A166.jpg'),
   new PIC (13,  9, 0, 0, 128,  59, 'Nicole_Marie_Fatigati-A531.jpg'),
   new PIC ( 9, 13, 0, 1, 128,  58, 'Shiva_Bagheri-A048.jpg'),
   new PIC ( 8, 14, 0, 0, 128,  56, 'Nicole_Derseweh-A407.jpg'),
   new PIC ( 7, 15, 0, 1, 128,  54, 'Margaret_Diubaldo-A245.jpg'),
   new PIC (15,  8, 0, 0, 128,  53, 'Angela_Kirkland-A643.jpg'),
   new PIC (14,  9, 0, 0, 128,  51, 'Lindsey_Cope-A317.jpg'),
   new PIC (13, 10, 0, 0, 128,  49, 'Pam_Anstey-A474.jpg'),
   new PIC (10, 13, 0, 0, 128,  48, 'Mari_Kudla-A200.jpg'),
   new PIC ( 9, 14, 0, 0,  85,  46, 'Samantha_Waltz-A112.jpg'),
   new PIC ( 8, 15, 0, 0,  85,  44, 'Andi_Campbell-A260.jpg'),
   new PIC (15,  9, 0, 0,  85,  43, 'Chandra_Coffey-A465.jpg'),
   new PIC (14, 10, 0, 0,  85,  41, 'Cindy_Phillips-A200.jpg'),
   new PIC (13, 11, 0, 0,  85,  39, 'Ryan_Murakoshi-A317.jpg'),
   new PIC (11, 13, 0, 0,  85,  38, 'Natalie_Davidson-A273.jpg'),
   new PIC (10, 14, 0, 0,  85,  36, 'Nicole_Derseweh-C468.jpg'),
   new PIC ( 9, 15, 0, 0,  85,  35, 'Jenyne_Wilson-B314.jpg'),
   new PIC (15, 10, 0, 0,  85,  33, 'Andrea_Spinks-A304.jpg'),
   new PIC (14, 11, 0, 1,  85,  31, 'Chandra_Coffey-A227.jpg'),
   new PIC (13, 12, 0, 0,  85,  30, 'Shiva_Bagheri-A030.jpg'),
   new PIC (12, 13, 0, 0,  85,  28, 'John_Stutz_Photo-IC203.jpg'),
   new PIC (11, 14, 0, 1,  85,  26, 'Fawnia_Dietrich-B079.jpg'),
   new PIC (10, 15, 0, 0,  85,  25, 'Elissa_Schlichter-B364.jpg'),
   new PIC (15, 11, 0, 1,  85,  23, 'Rosetta_Mortati-A137.jpg'),               //  24
   new PIC (14, 12, 0, 1,  85,  21, 'Kali_Knapp-A213.jpg'),
   new PIC (13, 13, 0, 0,  85,  20, 'Nicole_Derseweh-C051.jpg'),
   new PIC (12, 14, 0, 1,  85,  18, 'Kim_Tilden-A216.jpg'),                    //  19
   new PIC (11, 15, 0, 1,  85,  16, 'Jennifer_Reece-A662.jpg'),                //  17
   new PIC (15, 12, 0, 0,  85,  15, 'John_Stutz_Photo-IC118.jpg'),
   new PIC (14, 13, 0, 0,  85,  13, 'Marika_Johansson-A217.jpg'),
   new PIC (13, 14, 0, 0,  85,  12, 'Monica_Brant-A496.jpg'),
   new PIC (12, 15, 0, 1,  85,  10, 'Lindsey_Cope-A732.jpg'),                  //  13
   new PIC (15, 13, 0, 0,  85,   8, 'Lisa_Morton-B042.jpg'),
   new PIC (14, 14, 0, 1,  85,   7, 'Breean_Robinson-A501.jpg'),               //   8
   new PIC (13, 15, 0, 1,  64,   5, 'Mari_Kudla-A156.jpg'),
   new PIC (15, 14, 0, 0,  64,   3, 'Lindsey_Cope-A055.jpg'),
   new PIC (14, 15, 0, 0,  64,   2, 'Shana_Martin-B081.jpg'),
   new PIC (15, 15, 0, 1, 128,   0, 'Jody_May-A012.jpg'),

   new PIC (16,  0, 0, 0, 192, 255, 'test/John_Stutz_Photo-IA092.jpg'),
   new PIC (16,  1, 0, 0, 128, 204, 'test/John_Stutz_Photo-IA168.jpg'),
   new PIC (16,  2, 0, 0,  85, 153, 'test/John_Stutz_Photo-IA174.jpg'),
   new PIC (16,  3, 0, 0, 171, 102, 'test/John_Stutz_Photo-IA204.jpg'),
   new PIC (16,  4, 0, 0, 128,  51, 'test/John_Stutz_Photo-IA227.jpg'),
   new PIC (16,  5, 0, 0,  64,   0, 'test/John_Stutz_Photo-IA134.jpg'),

   new PIC (17,  0, 0, 0,   0,   0, 'test/John_Stutz_Photo-IB009.jpg'),
   new PIC (17,  1, 0, 0, 192, 255, 'test/John_Stutz_Photo-IB050.jpg'),
   new PIC (17,  2, 0, 0,   0,   0, 'test/John_Stutz_Photo-IB070.jpg'),
   new PIC (17,  3, 0, 0, 171, 223, 'test/John_Stutz_Photo-IB080.jpg'),
   new PIC (17,  4, 0, 0, 128, 191, 'test/John_Stutz_Photo-IB076.jpg'),
   new PIC (17,  5, 0, 0,  85, 159, 'test/John_Stutz_Photo-IB096-x.jpg'),
   new PIC (17,  6, 0, 0,   0,   0, 'test/John_Stutz_Photo-IB098.jpg'),
   new PIC (17,  7, 0, 0, 171, 128, 'test/John_Stutz_Photo-IB102.jpg'),
   new PIC (17,  8, 0, 0, 128,  96, 'test/John_Stutz_Photo-IB108.jpg'),
   new PIC (17,  9, 0, 0,   0,   0, 'test/John_Stutz_Photo-IB116.jpg'),
   new PIC (17, 10, 0, 0, 128,  64, 'test/John_Stutz_Photo-IB118.jpg'),
   new PIC (17, 11, 0, 0,  85,  32, 'test/John_Stutz_Photo-IB259.jpg'),
   new PIC (17, 12, 0, 0,  64,   0, 'test/John_Stutz_Photo-IB282.jpg'),

   new PIC (18,  0, 0, 0, 192, 255, 'test/John_Stutz_Photo-IC107.jpg'),
   new PIC (18,  1, 0, 0, 171, 213, 'test/John_Stutz_Photo-IC118.jpg'),
   new PIC (18,  2, 0, 0,  85, 170, 'test/John_Stutz_Photo-IC164.jpg'),
   new PIC (18,  3, 0, 0, 171, 128, 'test/John_Stutz_Photo-IC203.jpg'),
   new PIC (18,  4, 0, 0, 128,  85, 'test/John_Stutz_Photo-IC287.jpg'),
   new PIC (18,  5, 0, 0,  85,  43, 'test/John_Stutz_Photo-IC576.jpg'),
   new PIC (18,  6, 0, 0,  64,   0, 'test/John_Stutz_Photo-IC586.jpg')
);

var SCAN       =    0;
var RISE       =  250;
var FALL       = 5000;

var image      =    0;
var state      =    0;
var pend       =   -1;
var flag       =    1;

//
// Functions
//

function Scan ()
{
   var i, j, element;
   var d = new Date ();
   var t = d.getTime ();

   for (i=j=0; i<pics.length; i++)
      if (pics[i].current != pics[i].to)
      {
         element = document.getElementById ('img_' + pics[i].r + '_' + pics[i].c);

         if (element != null)
         {
            if (t < pics[i].start + pics[i].milliseconds)
               pics[i].current = pics[i].from + (pics[i].to - pics[i].from) * ((t - pics[i].start) / pics[i].milliseconds);
            else pics[i].current = pics[i].to;

            SetOpacity (element, pics[i].current);

            j++;
         }
         else pics[i].current = pics[i].to;
      }

   if (j > 0)
      window.setTimeout ("Scan ()", 10);
   else SCAN = 0;
}

function FadeMain (start, milliseconds, o_from, o_to, bg_from, bg_to)
{
   var element_img  = document.getElementById ('img_main');
   var element_cell = document.getElementById ('cell_main');
   var d = new Date ();
   var t = d.getTime ();

   if (t < start + milliseconds)
   {
      SetOpacity (element_img, o_from + (o_to - o_from) * ((t - start) / milliseconds));
      element_cell.style.background = RGB_Gray (Math.round (bg_from + (bg_to - bg_from) * ((t - start) / milliseconds)));

      window.setTimeout ("FadeMain (" + start + ", " + milliseconds + ", " + o_from + ", " + o_to + ", " + bg_from + ", " + bg_to + ")", 10);
   }
   else
   {
      SetOpacity (element_img, o_to);
      element_cell.style.background = RGB_Gray (bg_to);

      window.setTimeout ("Control ()", 0);
   }
}

function ImgLoad ()
{
   flag = 0;
}

function Control (i)
{
   var d = new Date ();
   var t = d.getTime ();
   var element;

   state++;

   if (state == 1)
   {
      window.setTimeout ("FadeMain (" + t + ", 1500, 100, 0, " + pics[image].background + ", " + pics[i].background + ")", 0);

      image = i;
   }
   if (state == 2)
   {
      flag = 1;

      element_img = document.getElementById ('img_main');

      element_img.src = PicSrc (image, 'low');
      element_img.style.borderColor = RGB_Gray (pics[image].bordercolor);

      window.setTimeout ("Control ()", 250);
   }
   if (state == 3)
   {
      if (flag != 0)
      {
         state--;
         window.setTimeout ("Control ()", 10);
      }
      else state++;
   }
   if (state == 4)
   {
      window.setTimeout ("FadeMain (" + t + ", 3000, 0, 100, " + pics[image].background + ", " + pics[image].background + ")", 0);
   }
   if (state == 5)
   {
      state = 0;
      if (pend >= 0)
      {
         Control (pend);
         pend = -1;
      }
   }
}

function CellOver (r, c)
{
   var i;
   var d = new Date ();
   var t = d.getTime ();

   for (i=0; pics[i].r!=r || pics[i].c!=c; i++);

   pics[i].from         = pics[i].current;
   pics[i].to           = 100;
   pics[i].start        = t;
   pics[i].milliseconds = Math.round (RISE * ((pics[i].to - pics[i].from) / 50));

   if (SCAN == 0)
   {
      SCAN = 1;
      window.setTimeout ("Scan ()", 0);
   }
}

function CellOut (r, c)
{
   var i;
   var d = new Date ();
   var t = d.getTime ();

   for (i=0; pics[i].r!=r || pics[i].c!=c; i++);

   pics[i].from  = pics[i].current;
   pics[i].to    = 50;
   pics[i].start = t;

   if (pics[i].from >= pics[i].to)
      pics[i].milliseconds = Math.round (FALL * ((pics[i].from - pics[i].to) / 50));
   else pics[i].milliseconds = Math.round (FALL * ((pics[i].to - pics[i].from) / 50));


   if (SCAN == 0)
   {
      SCAN = 1;
      window.setTimeout ("Scan ()", 0);
   }
}

function CellClick (r, c)
{
   var i;

   for (i=0; pics[i].r!=r || pics[i].c!=c; i++);

   if (state == 0)
   {
      if (i != image)
         Control (i);
   }
   else if (i != image)
      pend = i;
   else pend = -1;
}

function FilterOver (volume)
{
   var i;
   var d = new Date ();
   var t = d.getTime ();

   for (i=0; i<pics.length; i++)
   {
      pics[i].from  = pics[i].current;
      pics[i].start = t;

      if (pics[i].volume == volume)
      {
         pics[i].to           = 100;
         pics[i].milliseconds = Math.round (RISE * ((pics[i].to - pics[i].from) / 50) * 5);
      }
      else
      {
         pics[i].to           = 0;
         pics[i].milliseconds = Math.round (RISE * ((pics[i].from - pics[i].to) / 50) * 5);
      }
   }

   if (SCAN == 0)
   {
      SCAN = 1;
      window.setTimeout ("Scan ()", 0);
   }
}

function FilterOut (volume)
{
   var i;
   var d = new Date ();
   var t = d.getTime ();

   for (i=0; i<pics.length; i++)
   {
      pics[i].from  = pics[i].current;
      pics[i].to    = 50;
      pics[i].start = t;

      if (pics[i].from >= pics[i].to)
         pics[i].milliseconds = Math.round (FALL * ((pics[i].from - pics[i].to) / 50));
      else pics[i].milliseconds = Math.round (FALL * ((pics[i].to - pics[i].from) / 50));
   }

   if (SCAN == 0)
   {
      SCAN = 1;
      window.setTimeout ("Scan ()", 0);
   }
}

/*
         r = c = i = 0;

         do
         {
            document.write ('   new PIC (' + r + ', ' + c + ', \'\', 0,   ' + (255 - Math.round (255 * i / 155)) + '),<BR>');

            if (r > 0  &&  c < 15)
            {
               do
               {
                  r--;
                  c++;
               }
               while (r >=3  &&  r <= 12  &&  c >= 3  &&  c <= 12);
            }
            else
            {
               r += c + 1;
               c  = 0;

               if (r > 15)
               {
                  c = r - 15;
                  r = 15;
               }
            }
            i++;
         }
         while (c < 16);
*/
