var curImg = 0;
var timerId = -1;
var secTimerId = -1;
var interval = 6000;
var secInterval = interval / 1000;
var currSec = secInterval;
var copyType = "";
var isPlaying = 1;

function replaceNum()
{
  var input = SHOWINGSTRING;
  var output = input;
  var idx = output.indexOf("%slideNum");
  if (idx > -1) {
    output = input.substring(0, idx);
    output += eval(curImg+1);
    output += input.substr(idx+9);
  }
  return output;
}



function changeSpeed()
{
  var sidx = document.forms[0].speedMenu.selectedIndex;
  var speed = document.forms[0].speedMenu.options[sidx].value;

  interval = speed;
  secInterval = interval / 1000;

  if (timerId != -1) {
    clearTimers();
  }

  play();
}



function imgLoadNotify()
{
  if (isPlaying == 1)
    setTimers();
}



function changeSlide()


{
  

var width = a_width[curImg];
  
var height = a_height[curImg];
 
var caption = a_cap[curImg]; 

	if (timerId != -1) {
    clearTimers();
    
	dispLoading ();
  }

  


var img = "<img src=" + a_src[curImg] + " width=" + width +
 " height=" + height + " border=1 onload=\"imgLoadNotify();\">";

var html = caption;

var pnumLine = replaceNum();

  

switch(navigator.family) 

	{
    

	case 'gecko':
      

  document.getElementById("imgDiv").innerHTML = img;
    
  document.getElementById("capDiv").innerHTML = html;
    
  document.getElementById("pnumDiv").innerHTML = pnumLine;
      

	break;
    

	case 'nn4':
        

  document.layers[2].document.imgDiv.document.open();
      
  document.layers[2].document.imgDiv.document.write(html);
      
  document.layers[2].document.imgDiv.document.close();

      

  document.layers[0].document.pnumDiv.document.open();
      
  document.layers[0].document.pnumDiv.document.write(pnumLine);
      
  document.layers[0].document.pnumDiv.document.close();

        

	break;
    

	case 'ie4':
      
  document.all.pem.innerHTML = pnumLine;
        
  document.all.imgp.innerHTML = html;
      
  document.all.imgc.innerHTML = img;
      

	break;
  

	}


}




function forward()

{
  curImg++;
  if (curImg == numImgs) 
    curImg = 0;
  changeSlide();


}

function rewind()
{
  curImg--;
  if (curImg < 0) 
      curImg = numImgs - 1;
  
changeSlide();
}

function dispSec()
{
  var dispSec = ( currSec < 0 ) ? 0 : currSec;
  var secText = "<font color=#999999 size=-2>Next slide in " + dispSec + " sec</font>";

  switch(navigator.family) {
    case 'gecko':
      document.getElementById("timerDiv").innerHTML = secText;
      break;
    case 'nn4':
      document.layers[1].document.timerDiv.document.open();
      document.layers[1].document.timerDiv.document.write(secText);
      document.layers[1].document.timerDiv.document.close();
      break;
    case 'ie4':
      document.all.timer.innerHTML = secText;
      break;
  }

  currSec--;
}




function dispLoading()
{
  var text = "<font face=arial color=black size=-2>Loading image...</font>";

  switch(navigator.family) {
    case 'gecko':
      document.getElementById("timerDiv").innerHTML = text;
      break;
    case 'nn4':
      document.layers[1].document.timerDiv.document.open();
      document.layers[1].document.timerDiv.document.write(text);
      document.layers[1].document.timerDiv.document.close();
      break;
    case 'ie4':
      document.all.timer.innerHTML = text;
      break;
  }
}



function stop()
{
  clearTimers();

  isPlaying = 0;

  var secText = "<font face=arial color=black size=-2>Slideshow Stopped</font>";

  switch(navigator.family) {
    case 'gecko':
      document.getElementById("timerDiv").innerHTML = secText;
      break;
    case 'nn4':
      document.layers[1].document.timerDiv.document.open();
      document.layers[1].document.timerDiv.document.write(secText);
      document.layers[1].document.timerDiv.document.close();
      break;
    case 'ie4':
      document.all.timer.innerHTML = secText;
      break;
  }

  document.playbtn.src = buttonImgPfx + buttonOffArray[0];
  document.stopbtn.src = buttonImgPfx + buttonOnArray[1];
}


function toggle() {if (isPlaying == 0)
 { play() } else { stop() } }

function off()
{
  clearTimers();

  isPlaying = 0;

  var secText = "<font face=arial color=black size=-2></font>";

  switch(navigator.family) {
    case 'gecko':
      document.getElementById("timerDiv").innerHTML = secText;
      break;
    case 'nn4':
      document.layers[1].document.timerDiv.document.open();
      document.layers[1].document.timerDiv.document.write(secText);
      document.layers[1].document.timerDiv.document.close();
      break;
    case 'ie4':
      document.all.timer.innerHTML = secText;
      break;
  }

  document.playbtn.src = buttonImgPfx + buttonOffArray[0];
  document.stopbtn.src = buttonImgPfx + buttonOnArray[1];
}

function play()
{
  setTimers();
  startShow();
}


function startShow()
{
  isPlaying = 1;

  document.playbtn.src = buttonImgPfx + buttonOnArray[0];
  document.stopbtn.src = buttonImgPfx + buttonOffArray[1];
}



function setTimers()
{
  currSec = secInterval;
  dispSec();

  if (secTimerId == -1)
    secTimerId = window.setInterval('dispSec();', 1000);
  if (timerId == -1)
    timerId = window.setInterval('forward();', interval);
}

function clearTimers()
{
  window.clearInterval(timerId);
  timerId = -1;
  window.clearInterval(secTimerId);
  secTimerId = -1;
}

function setButton(direction)
{
  if (direction == 0) {
    document.prevbtn.src = buttonImgPfx + buttonOnArray[2];
    window.setTimeout("document.prevbtn.src = buttonImgPfx + buttonOffArray[2];", 300);
  } else {
    document.fowdbtn.src = buttonImgPfx + buttonOnArray[3];
    window.setTimeout("document.fowdbtn.src = buttonImgPfx + buttonOffArray[3];", 300);
  }
}



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_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}



   function boxClicked(){
   var ie=(document.all)
   var nn=(document.layers)
        var checkedState = '';
     if(ie)
{
        if(checkedState == true){
             navigation.style.display = '';
			 play();
        }else{
                  navigation.style.display = "";
        }
        

}
else
if (nn)
{
    if(checkedState == true){
             navigation.style.visibility = "inherit";
        }else{
                  navigation.style.visibility = "hide";
        }
   
}        
   
   }

