// JavaScript Document
//thumbnail script
current_image=0;
max=22;
count=0;

var delay = 3000;
var lock = false;
var run;

images= new Array()
images[0] =  "../images/big4/americanpie.jpg"
images[1] =  "../images/big4/amoebic.jpg"
images[2] =  "../images/big4/bajaja.jpg"
images[3] =  "../images/big4/birdland.jpg"
images[4] =  "../images/big4/eastyellowstone.jpg"
images[5] =  "../images/big4/fishinnospace.jpg"
images[6] =  "../images/big4/ghosthouse.jpg"
images[7] =  "../images/big4/godisgreat.jpg"
images[8] =  "../images/big4/house.jpg"
images[9] =  "../images/big4/kachina.jpg"
images[10] = "../images/big4/moonie.jpg"
images[11] = "../images/big4/needlesandpinzuh.jpg"
images[12] = "../images/big4/playwintermisty.jpg"
images[13] = "../images/big4/quack.jpg"
images[14] = "../images/big4/reddawn.jpg"
images[15] = "../images/big4/revolution.jpg"
images[16] = "../images/big4/saguarosunset.jpg"
images[17] = "../images/big4/sanjuanfoothills.jpg"
images[18] = "../images/big4/sasquachgodzilla.jpg"
images[19] = "../images/big4/souprice.jpg"
images[20] = "../images/big4/thatoldgangofmine.jpg"
images[21] = "../images/big4/thebigfire.jpg"
images[22] = "../images/big4/whynot.jpg"

imageName = new Array()
imageName[0] = "american pie"
imageName[1] = "amoebic"
imageName[2] = "Baja-Ha"
imageName[3] = "birdland"
imageName[4] = "east of yellowstone"
imageName[5] = "fish in no space"
imageName[6] = "ghost house"
imageName[7] = "god is great"
imageName[8] = "house"
imageName[9] = "kachina"
imageName[10] = "moonie"
imageName[11] = "needlesandpinzuh"
imageName[12] = "play winter misty"
imageName[13] = "quack"
imageName[14] = "red dawn"
imageName[15] = "(R)evolution"
imageName[16] = "saguaro sunset"
imageName[17] = "san juan foothills"
imageName[18] = "sasquach vs godzilla"
imageName[19] = "soup, rice"
imageName[20] = "that ol' gang of mine"
imageName[21] = "the big fire"
imageName[22] = "Why Not?"

// not using this array or the mymenu function which is just a simple test
// intended for multiple gallery pulldown menu
menuitems = new Array()
menuitems[0] = "2006 pics"
menuitems[1] = "butterflys and mosquitos"
menuitems[2] = "2005 pics"
menuitems[3] = "turtles and frogs"

function mymenu() {
  alert("ToDo you selected " + menuitems[document.mytoolbar.picgroups.selectedIndex]);
}

function auto() {
  if (lock == true) {
    lock = false;
    clearInterval(run);
    document.mytoolbar.automatic.value="Auto";
  }
  else if (lock == false) {
    lock = true;
    run = setInterval("nextimage()", delay);
    document.mytoolbar.automatic.value="Stop";
  }
}

function select_image(picnum)
{
  if (!document.mytoolbar.picnum.value.match(/^\d+$/)) {
    document.mytoolbar.picnum.value="";
    alert("invalid value - enter an number from 1 to 23");
    return; 
  }
  if ((document.mytoolbar.picnum.value<1) || (document.mytoolbar.picnum.value>(max+1))){
    document.mytoolbar.picnum.value="";
    alert("invalid value - enter an number from 1 to 23");
    return;
  }
  current_image=parseFloat(picnum.value)-1;
  selected_image= current_image + 1;
  document.images['large'].src=images[current_image];
  document.getElementById('bozo').innerHTML = imageName[current_image];
  document.getElementById('bozo2').innerHTML = (selected_image) + " of " + (max + 1);
  document.mytoolbar.picnum.value="";
}


function nextimage()
{
  if (current_image<max) {
    current_image=current_image+1
  } 
  else {
    current_image=0
  }
  document.images['large'].src=images[current_image];
  document.getElementById('bozo').innerHTML = imageName[current_image];
  document.getElementById('bozo2').innerHTML = (current_image+1) + " of " + (max + 1);
}

function previousimage()
{
  if (current_image>0) {
    current_image=current_image-1
  } 
  else {
    current_image=max
  }
  document.images['large'].src=images[current_image];
  document.getElementById('bozo').innerHTML = imageName[current_image];
  document.getElementById('bozo2').innerHTML = (current_image+1) + " of " + (max + 1);
}

// This is intended for a page with thumbnails - not using in slideshow so may be busted - remove parens
// This defines what to do when an image is clicked on
function image_click(clicks)
{
  current_image=clicks
  document.images['large'].src=images[clicks];
  document.getElementById('bozo').innerHTML = imageName[clicks] + " (" + (clicks +1) + " of " + (max + 1) +")";
}