/////////////////////////////////////////////////////////
//
// Pick an Image at Random
//
// config bits...
var nPicsAvbl = 9;            // num pics available
//
// collection of images and alt text...
var Pics = new Array();       // array of pic filenames
var Alts = new Array();       // array of alt text
var Posns = new Array();      // record of which pic is in which posn

Pics[0] = "imgs/indexpic1.jpg";
Alts[0] = "Thread detail by Mary Kelly";
Pics[1] = "imgs/indexpichairy.jpg";
Alts[1] = "A hairy thing by Jane Brown";
Pics[2] = "imgs/indexpic2.jpg";
Alts[2] = "NewFormArts sheep";
Pics[3] = "imgs/indexpicsnake.jpg";
Alts[3] = "Calligraphy by Norman Kelly";
Pics[4] = "imgs/indexpicowl.jpg";
Alts[4] = "Owl by Geoff Rollinson";
Pics[5] = "imgs/indexlighthouse.jpg";
Alts[5] = "Lighthouse by Kathy Reynolds";
Pics[6] = "imgs/indexpicbwriver.jpg";
Alts[6] = "Pendle Hill &amp; River Ribble by Jeanette Whigham";
Pics[7] = "imgs/indexpic3.jpg";
Alts[7] = "Med Day";
Pics[8] = "imgs/indexpicconductor.jpg";
Alts[8] = "Pencil sketch by Pat Ellacott";


function clearPosns()
  {
  for (var i = 0; i < nPicsAvbl; i++)
    Posns[i] = -1;
  }

function fillPosns()
  {
  for (var i = 0; i < nPicsAvbl; i++)
    {
    var bDone = false;
    do
      {
      var nRnd = Math.floor(nPicsAvbl * Math.random());
      if (nRnd > 1 && nRnd == nPicsAvbl)
        nRnd--;
      if (Posns[nRnd] == -1)
        {
        Posns[nRnd] = i;
        bDone = true;
        }
      } while (!bDone);
    }
  }

function refillPosns()
  {
  clearPosns();
  fillPosns();
  }

function randomPic(nPosn)
  {
  var nIndex = Posns[nPosn];
  document.write('<img width="180" height="180" style="margin:0 10px 0 10px" src="' + Pics[nIndex] + '" alt="' + Alts[nIndex] + '">');
  }

//
///// End of File ///////////////////////////////////////
