// Basic Java functions
function runSlideShow(){

var newttle = "skip";

  if (ImageTot > 1) {
    // Get a randon number and construct image name 
     if (autoRun == 1) {
         ImageNumb1 = Math.floor(Math.random()*ImageTot+1) - 1;
         IMAGE1.src = "graphics/splash/"+Imagelist[ImageNumb1];
         autoRun = 0;
     }    
     else {
          ImageNumb1++;
          if (ImageNumb1 >= ImageTot) {ImageNumb1 = 0};
     }
     FadeInImage('IMAGE1','graphics/splash/'+Imagelist[ImageNumb1],'IMAGE1b',newttle);
  }

  if (slidemax > 0) {
      autoRun = 0;
      slideidx++;
      titleidx++;
      if (slideidx >= slidemax) {slideidx = 0};
      if (titleidx >= titlemax) {titleidx = 0};
      document.getElementById("caption").innerHTML="&nbsp;";
      var newsrc = slidelist[slideidx];
      newttl = slidettle[titleidx];

      FadeInImage('SldVue',newsrc,'SldVueb',newttl);
  }

  if (autoRun == 0) t = setTimeout('runSlideShow()', slideShowSpeed);

}

function startShow(slides) {
  if (slidemax == 0) {
    document.getElementById("slidemsg").innerHTML= "Slide show is <b>RUNNING</b> - click on the picture to pause, or a thumbnail to select";
    slidemax = slides;
  }
  else {
    document.getElementById("slidemsg").innerHTML= "Slide show is <b>PAUSED</b> - click on the picture to resume, or a thumbnail to select";
    slidemax = 0;
  }
}

function ShowPic(PicID,Caption){
  document.getElementById("caption").innerHTML=Caption;
  SldVue.src = PicID;
  document.getElementById("slidemsg").innerHTML= "Slide show is <b>STOPPED</b> - click on the picture to restart, or select another thumbnail";
  slidemax = 0;
}

function SetOpacity(object,opacityPct,newtitle)
{
  // IE.
  object.style.filter = 'alpha(opacity=' + opacityPct + ')';
  // Old mozilla and firefox
  object.style.MozOpacity = opacityPct/100;
  // Everything else.
  object.style.opacity = opacityPct/100;

  if (newtitle!="skip")  {  
    var xttle = newtitle;
    var ttlL = xttle.length;
    var xl = Math.round(ttlL * opacityPct / 100)
    var ttlX = xttle.substring(0,xl);
    document.getElementById("caption").innerHTML=ttlX;
  }

}

function ChangeOpacity(id,msDuration,msStart,fromO,toO,newtitle)
{
  var element=document.getElementById(id);

  var opacity = element.style.opacity * 100;
  var msNow = (new Date()).getTime();
  opacity = fromO + (toO - fromO) * (msNow - msStart) / msDuration;
  if (opacity<0) 
    SetOpacity(element,0,newtitle)
  else if (opacity>100)
    SetOpacity(element,100,newtitle)
  else
  {
    SetOpacity(element,opacity,newtitle);
    element.timer = window.setTimeout("ChangeOpacity('" + id + "'," + msDuration + "," + msStart + "," + fromO + "," + toO + ",'" + newtitle + "')",1);
  }
}

function FadeInImage(foregroundID,newImage,backgroundID,newtitle)
{
  var foreground=document.getElementById(foregroundID);
  var background=document.getElementById(backgroundID);

  if (background)
  {
    background.src = foreground.src;
    background.style.backgroundImage = 'url(' + foreground.src + ')';
    background.style.backgroundRepeat = 'no-repeat';
  }

  SetOpacity(foreground,0, newtitle);
  foreground.src = newImage;
  if (foreground.timer) window.clearTimeout(foreground.timer); 
  var startMS = (new Date()).getTime();
  foreground.timer = window.setTimeout("ChangeOpacity('" + foregroundID + "',1000," + startMS + ",0,100,'" + newtitle + "')",10);
}


function clickIE4(){
  if (event.button==2){
    alert(message);
    return false;
  }
}
function clickNS4(e){
  if (document.layers||document.getElementById&&!document.all){
    if (e.which==2||e.which==3){
      alert(message);
      return false;
    }
  }
}

