
/////////// functions for gallerypic switching & info box /////////

var mouseisover = new Image();

function showpicinfo(which) {
  o = document.getElementById(which)
  mouseisover = o
  for (i=1; i<homeimages.length ; i++ ) {
    if (homeimages[i].src == o.src && infotext[i] > '' ) {
      document.getElementById('itext').innerHTML = infotext[i];
      document.getElementById('idiv').style.visibility = 'visible';
    }
  }
}

function gallchange() {
  var o = document.getElementById('slideshow'+nextgall)
  o.src = homeimages[nextpic].src;   o.alt = altext[nextpic];
  if (o.src==mouseisover.src) {
    if (infotext[nextpic] > '') {
      document.getElementById('itext').innerHTML = infotext[nextpic];
    }
    else {
      hideidiv();
    }
  }
  nextgall = nextgall + 1; if (nextgall == 5) {nextgall = 1}
  nextpic  = nextpic  + 1; if (nextpic >= homeimages.length) {nextpic = 1}
}

// initialise gallerychanger
var nextpic = 5
var nextgall = 1
setInterval('gallchange()', 4000)

function hideidiv() {
  document.getElementById('idiv').style.visibility='hidden';
}

function clrTmr() {
  if (typeof(mytimer) != 'undefined') {
    clearTimeout(mytimer);
  }
}

function setTmr() {
  clrTmr();
  mytimer=setTimeout('hideidiv()',800);
}

addEvent(window, 'load', attachBvrs);
addEvent(document, 'click', hideidiv);

function attachBvrs() {
  o = document.getElementById('idiv');
  o.onmouseover = function() { clrTmr(); }
  o.onmouseout  = function() { setTmr(); }
  for ( i=1; i<=4; i++ ) {
    o = document.getElementById('slideshow'+i);
    o.onmouseover = function() { clrTmr(); showpicinfo(this.id); }
    o.onmouseout  = function() { setTmr(); }
  }
}


