// JavaScript Document

waimea_canyon_names=new Array(" ",
"Waimea Canyon",
"Kalalau Valley",
"Salt Pond 1",
"Salt Pond 2",
"Salt Pond 3");
waimea_canyon=new Array("South & West Tour",
"pictures/waimeacanyon/waimea_valley.jpg",
"pictures/waimeacanyon/kalalau_valley.jpg",
"pictures/waimeacanyon/salt_pond_1.jpg",
"pictures/waimeacanyon/salt_pond_2.jpg",
"pictures/waimeacanyon/salt_pond_3.jpg",
waimea_canyon_names);

north_shore_names=new Array(" ",
"Hanalei Valley",
"Kilauea Point",
"Kilauea Light House",
"Kilauea Light House",
"Kilauea Light House");
north_shore=new Array("North Shore Tour",
"pictures/northshore/hanalei_valley.jpg",
"pictures/northshore/kilauea_point_sign.jpg",
"pictures/northshore/light_house_1.jpg",
"pictures/northshore/light_house_2.jpg",
"pictures/northshore/light_house_3.jpg",
north_shore_names);

albums=new Array(waimea_canyon, north_shore);

counter_min = 0;
counter_max = albums.length-1;
counter = counter_min;
album_position = 0;
browseAlbums = 1;
browsePictures = 0;


function change(num){
  counter = counter + num;
  if (counter > counter_max){
    counter = counter_min;
  }
  if (counter < counter_min){
    counter = counter_max;
  }
  if (browsePictures == 1){
    changeImage();
    changeLabel(albums[album_position][0],"||",albums[album_position][albums[album_position].length-1][counter],"<a href=\"#\" onClick=\"browseAlbums=1, browsePictures=0, counter_max=albums.length-1, counter_min=0, change(0)\"><small> ALBUMS </small></a>");
  }
  if (browseAlbums == 1){
    changeAlbum();
    changeLabel( "<a href=..//%22#/%22 onClick=\"browsePictures=1, browseAlbums=0, counter_max=albums[counter].length-2, counter_min=1, album_position=counter, loadImages(), counter=0, change(1)\" >" + albums[counter][0] + "</a>"," "," ","<a href=\"#\" onClick=\"browsePictures=1, browseAlbums=0, counter_max=albums[counter].length-2, counter_min=1, album_position=counter, loadImages(), counter=0, change(1)\"><small> SELECT </small></a>");
  }
}

function changeAlbum(){
  document.getElementById("album").innerHTML=albums[counter][0];
  document.getElementById("test").innerHTML= "Album " + (counter+1) + " of " + (counter_max+1) + ".  " + (albums[counter].length-2) + " Picture(s).";
  document.getElementById("image").src=albums[counter][1];
}

function changeImage(){
  document.getElementById("image").src=albums[album_position][counter];
  document.getElementById("test").innerHTML="Picture " + (counter) + " of " + (counter_max) +".";
}

function changeLabel(album, separator, picture, midbut){
  document.getElementById("album").innerHTML=album;
  document.getElementById("separator").innerHTML=separator;
  document.getElementById("picture").innerHTML=picture;
  document.getElementById("middleButton").innerHTML=midbut;
}

function loadImages(){
    for (i=1; i < albums[counter].length-1; i++){
        MM_preloadImages(albums[counter][i]);
        document.getElementById("test").innerHTML="Preloading Images in Albums..."+i;
    }
    document.getElementById("test").innerHTML=" ";
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

