/*
 * ======================================================================
 * This file contains the JavaScript to get the picture page to work.
 * ----------------------------------------------------------------------
 * Copyright Andrew and Elaine Foakes.
 * ======================================================================
 */

/*
 * ----------------------------------------------------------------------
 * Set up the number of pictures and initialise them.
 * ----------------------------------------------------------------------
 */

/*
 * NPicture is the number of pictures.
 * IPicture is the current picture being shown.  Here it is set up as the
 *          first picture to be shown.
 * fp       is just a string for holding the full caption.
 */
var NPictures = 22;
var IPicture = 0;
fp = new String();

/*
 * Set up the arrays that will hold the pictures (APicture) and their description (FPicture).
 */
APictures=new Array(NPictures);
FPictures=new Array(NPictures);
for (var i=0 ; i < NPictures ; i++)
{
  APictures[i] = new Image();
  FPictures[i] = new String();
}

/*
 * ----------------------------------------------------------------------
 * This is where the pictures are loaded up.  The size is also set up and
 * a caption is stored..
 * ----------------------------------------------------------------------
 */

APictures[0].src = "pictures/16_2009-11-19_Orchestra.jpg";
APictures[0].width = 643;
APictures[0].height = 482;
FPictures[0] = "The orchestra rehearsing in November, 2009.";

APictures[1].src = "pictures/01_2004-03-25_Orchestra.jpg";
APictures[1].width = 678;
APictures[1].height = 482;
FPictures[1] = "The first picture of the orchestra from our first term in March 2004 and the orchestra is relaxing after the dress rehearsal.  It was much smaller then than now!";

APictures[2].src = "pictures/02_2004-07-01_Orchestra.jpg";
APictures[2].width = 680;
APictures[2].height = 482;
FPictures[2] = "Here is Elaine conducting us for only our second term.";

APictures[3].src = "pictures/03_2004-11-25_Orchestra.jpg";
APictures[3].width = 691;
APictures[3].height = 482;
FPictures[3] = "By the autumn of 2004, we had started to grow.  Here is the orchestra, with guest trumpeter Matthew Tickle.";

APictures[4].src = "pictures/04_2005-07-07_Orchestra.jpg";
APictures[4].width = 643;
APictures[4].height = 482;
FPictures[4] = "By the summer of 2005, we had grown to a nice size, with 2 percussionists!";

APictures[5].src = "pictures/05_2007-11-29_Orchestra.jpg";
APictures[5].width = 643;
APictures[5].height = 482;
FPictures[5] = "Here we are in November 2007, being worked hard by Elaine!";

APictures[6].src = "pictures/06_2008-03-27_Orchestra.jpg";
APictures[6].width = 643;
APictures[6].height = 482;
FPictures[6] = "Here is the orchestra, taken in March 2008.";

APictures[7].src = "pictures/07_2008-07-03_Orchestra.jpg";
APictures[7].width = 643;
APictures[7].height = 482;
FPictures[7] = "The orchestra from July 2008.";

APictures[8].src = "pictures/08_2008-03-27_Bob_&_Ethel.jpg";
APictures[8].width = 643;
APictures[8].height = 482;
FPictures[8] = "Each concert features small group and solo performances from members of the orchestra.  Our spring concert featured a duet by Bob and Ethel.";

APictures[9].src = "pictures/09_2008-03-27_Ruth_&_William.jpg";
APictures[9].width = 643;
APictures[9].height = 482;
FPictures[9] = "The orchestra features a number of family groups, such as Ruth and William, who played a duet in our spring concert in 2008.";

APictures[10].src = "pictures/10_2008-07-03_Peter_&_Jessica.jpg";
APictures[10].width = 643;
APictures[10].height = 482;
FPictures[10] = "Here are a number of our younger members, including Peter and Jessica in the flute section.";

APictures[11].src = "pictures/12_2008-11-27_Orchestra.jpg";
APictures[11].width = 643;
APictures[11].height = 482;
FPictures[11] = "The orchestra during its winter rehearsals in November, 2008.";

APictures[12].src = "pictures/11_2009-03-19_Clarinet section.jpg";
APictures[12].width = 643;
APictures[12].height = 482;
FPictures[12] = "The clarinet section working hard practising for our spring concert in 2009.";

APictures[13].src = "pictures/13_2009-03-19_Tracy_and_Frank.jpg";
APictures[13].width = 643;
APictures[13].height = 482;
FPictures[13] = "The spring term of 2009 saw Tracy Tickle stand in as guest pianist as Frank had to miss the concert.  Here is Frank helping Tracy learn the pieces.";

APictures[14].src = "pictures/14_2009-03-19_Brass.jpg";
APictures[14].width = 643;
APictures[14].height = 482;
FPictures[14] = "The front line of our trumpet and saxophone sections giving their full sound during our spring rehearsal, 2009.";

APictures[15].src = "pictures/15_2009-03-19_Orchestra.jpg";
APictures[15].width = 643;
APictures[15].height = 482;
FPictures[15] = "The orchestra rehearsing in March, 2009.";

APictures[16].src = "pictures/17_2009-11-19_Back_row.jpg";
APictures[16].width = 643;
APictures[16].height = 482;
FPictures[16] = "The back row practising their moves in November, 2009.";

APictures[17].src = "pictures/18_2009-11-19_Elaine.jpg";
APictures[17].width = 362;
APictures[17].height = 482;
FPictures[17] = "Elaine conducting energetically in November, 2009.";

APictures[18].src = "pictures/19_2010-06-27_Orchestra.jpg";
APictures[18].width = 643;
APictures[18].height = 482;
FPictures[18] = "The orchestra performing at the Oakley Green and Fifield food festival in June, 2010.";

APictures[19].src = "pictures/20_2010-11-25_Orchestra.jpg";
APictures[19].width = 643;
APictures[19].height = 482;
FPictures[19] = "Elaine giving out clear instructions as the orchestra prepares for its Christmas concert in November 2010.";

APictures[20].src = "pictures/21_2010-11-25_Orchestra.jpg";
APictures[20].width = 643;
APictures[20].height = 482;
FPictures[20] = "The orchestra relaxing after its last rehearsal of the winter term in November, 2010.";

APictures[21].src = "pictures/22_2011-03-24_Saxtet.jpg";
APictures[21].width = 670;
APictures[21].height = 482;
FPictures[21] = "April 2011 saw the first performance by our very own Saxtet.";

/*
 * ----------------------------------------------------------------------
 * Here are the functions that allow the page to work..
 * ----------------------------------------------------------------------
 */

/*
 * This sets the first picture on first loading of the page.
 */
function FirstPicture()
{
  NewPicture(IPicture)
}

/*
 * This grabs the next page when the button is pressed.
 */
function NextPicture()
{
  IPicture = (IPicture + 1)%NPictures;

  NewPicture(IPicture)
}

/*
 * This grabs the previous page when the button is pressed.
 */
function PrevPicture()
{
  if (IPicture == 0 )
  {
    IPicture = NPictures - 1;
  }
  else
  {
    IPicture = IPicture - 1;
  }

  NewPicture(IPicture)
}

/*
 * This actually does the work of changing the picture and caption.
 */
function NewPicture(ip)
{
  document["Picture"].src = APictures[ip].src;
  document["Picture"].width = APictures[ip].width;
  document["Picture"].height = APictures[ip].height;

  fp = "Picture " + (ip+1) + " of " + NPictures + ": " + FPictures[ip];
  document.getElementById("Caption").innerHTML = fp;
}

