var slidetiming = 5000;
var displaycount = 15;    /* thumbs display size */
var imageptr = 1;  	 			/* the current enlargement array element */
var wait;
var running = true;
var browser=navigator.appName;
/* var b_version=navigator.appVersion;
var version=parseFloat(b_version);
if ((browser=="Netscape"||browser=="Microsoft Internet Explorer")*/


function load () {

  if (imgfile.length < displaycount) displaycount = imgfile.length; 
  if (document.getElementById('gallerystats')) {document.getElementById('gallerystats').childNodes[0].nodeValue = gallerystats;}
	showthumbs ();
	showphoto(imageptr); 
	slideshow();
}

function showthumbs () {
var pid;
  
  for (i = 1; i <= imagecount; i++) {
	  pid = 'thumbnail' + i.toString();
	  if (document.getElementById(pid)) {
      document.getElementById(pid).src = imgfile[i];
      document.getElementById(pid).alt = imgname[i]; }
	}
}

function findimage (frameno) {
  if (running==true) {
	  running = false;
    if (document.getElementById('stopstart')) {document.getElementById('stopstart').childNodes[0].nodeValue = 'Start Slideshow'; }
}		
  imageptr = frameno;
	if (imageptr <= imagecount) showphoto(imageptr); 
}

function steponimage (stepOn) {
  if (stepOn == true) {				 						    /* stepping down */
    if(imageptr < imagecount) {
      imageptr++;
      showphoto(imageptr);	}}
  else {							 												/* stepping up */
    if (imageptr > 1) {
      imageptr--;
      showphoto(imageptr);	}}
}

function showphoto(photonum) {

/*	wont work in Opera etc  displayphoto (photonum); 
so used  document.getElementById('photoimage').src = imgfile[photonum]; 
next for merge but try IEn*/
		if (browser=="Microsoft Internet Explorer") {
      displayphoto (photonum);}
	  else {
		  document.images.currentimg.src = imgfile[photonum]; }		
    showphotostats (photonum);
    imageptr = photonum;

  if (document.getElementById('imgleft')) {
    if ((imageptr > 1) && (! running)) {
			document.getElementById('imgleft').src = '../furniture/button_lt.gif';}
    else {
			document.getElementById('imgleft').src = '../furniture/blankbutton.jpg';}
  }
  if (document.getElementById('imgright')) {
    if ((imageptr < imagecount) && (! running)) {
      document.getElementById('imgright').src = '../furniture/button_rt.gif';}
    else {
      document.getElementById('imgright').src = '../furniture/blankbutton.jpg';}  
	}		 
}

function displayphoto (photonum) {

      document.images.currentimg.style.filter="blendTrans(duration=1.0)"; /* CrossFadeDuration */
      document.images.currentimg.filters.blendTrans.Apply();
      document.images.currentimg.src = imgfile[imageptr];
      document.images.currentimg.filters.blendTrans.Play();
}

function showphotostats (photonum) {
/* this condition is dodgy - is it needed? */
  if (document.getElementById) {
    document.getElementById('photoimage').alt = imgname[photonum]; 
    document.getElementById('phototitle').childNodes[0].nodeValue = imgname[photonum]; 
    document.getElementById('photodesc').childNodes[0].nodeValue = imgdesc[photonum]; 
    document.getElementById('photocredit').childNodes[0].nodeValue = imgcred[photonum];
    document.getElementById('catalognum').childNodes[0].nodeValue = 'Photo ' + imgcnum[photonum]; 
	}
}

function slideshow(){

  if (running) {
    if (imageptr > imagecount) imageptr=1;
		if (browser=="Microsoft Internet Explorer") {
      displayphoto (imageptr);}
	  else {
		  document.images.currentimg.src = imgfile[imageptr]; }		
	  showphotostats (imageptr);
    if (document.getElementById('stopstart')) {document.getElementById('stopstart').childNodes[0].nodeValue = 'Stop Slideshow'; }
    imageptr++;
    if (imageptr > imagecount) imageptr=1;
    wait = setTimeout('slideshow()', slidetiming); }
  else	{	
    if (document.getElementById('stopstart')) {document.getElementById('stopstart').childNodes[0].nodeValue = 'Start Slideshow'; }}
} 

function setrunmode () {

  if (running) {
    running = false;
		showphoto(imageptr);
    if (document.getElementById('stopstart')) {document.getElementById('stopstart').childNodes[0].nodeValue = 'Start Slideshow'; }}
  else {
    running = true;
		imageptr++;
    if (document.getElementById('imgleft')) {document.getElementById('imgleft').src = '../furniture/blankbutton.jpg';}
    if (document.getElementById('imgright')) {document.getElementById('imgright').src = '../furniture/blankbutton.jpg'; } 
    wait = setTimeout('slideshow()', 0);}
}

function openhelpwindow(url) {
  mywin = window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=500,height=500,top=200,left=200');
}
