
document.onkeydown = keyHit;

var whichphotos;

function keyHit()
{

  if (window.event.keyCode==73){
    zoomInImage();
  }
  if (window.event.keyCode==79){
    zoomOutImage();
  }

  if (window.event.keyCode==66){
    history.go(-1);
  }

  if (window.event.keyCode==80){
    prevImage();
  }

  if (window.event.keyCode==78){
    nextImage();
  }
}


function imageName(num)
{
  istr = new String(iname[num] [1]);
  return istr;

}

function imageTitle(num)
{
  istr = new String(iname[num] [2]);
  return istr;
}

function cakeTitle(num)
{
  istr = imageTitle(num);
  return istr;
}

function changeOption(selectform)
{
  imagenum = firstImage(selectform.options[selectform.selectedIndex].value);
  whichphotos = selectform.options[selectform.selectedIndex].value;
  document.images.bigname.src="WDimages\/"+imageName(imagenum);
  document.cakeform.caketitle.value = cakeTitle(imagenum);
}

function firstImage (whichph)
{
  var rtnnum = -1;
  if (whichph=="al")
  {
    rtnnum = 0;
  }
  else
  {
    for (i=0; i<iname.length; i++)
    {
      if (iname[i][0] == whichph && rtnnum == -1)
         rtnnum = i;
    }
  }
  return rtnnum;
}

function prevImage()
{
  var currimage = imagenum;
  var nextimgfound = 0;

  while (nextimgfound == 0)
  {

    if (imagenum==0)
    {
      imagenum=iname.length-1;
    }
    else 
    {
      imagenum--;
    }
    if (whichphotos == "al")
      nextimgfound = 1;

    if (iname[imagenum] [0] == whichphotos)
      nextimgfound = 1;
  }
  document.images.bigname.src="WDimages\/"+imageName(imagenum);
  document.cakeform.caketitle.value = cakeTitle(imagenum);
}


function nextImage()
{
  var currimage = imagenum;
  var nextimgfound = 0;

  while (nextimgfound == 0)
  {
    if (imagenum==iname.length-1)
    {
      imagenum=0;
    }
    else
    {
      imagenum++;
    }
    if (whichphotos == "al")
      nextimgfound = 1;

    if (iname[imagenum] [0] == whichphotos)
      nextimgfound = 1;
  } 
  document.images.bigname.src="WDimages\/"+imageName(imagenum);
  document.cakeform.caketitle.value = cakeTitle(imagenum);
}

function zoomInImage(){
    document.images.bigname.width=document.images.bigname.width*1.2;
    document.images.bigname.height=document.images.bigname.height*1.2;
}

function zoomOutImage(){
    document.images.bigname.width=document.images.bigname.width*0.8;
    document.images.bigname.height=document.images.bigname.height*0.8;
}


