var selected = 0;
var play = 1;
var numx = 0;
function change(num){
  clearTimeout(tid);
  play = 0;
  document.bigpic.src=imgsrcs[num];
  st = 'pic'+selected;
  st2 = 'pic'+num;
  if(num!=selected){
    document.getElementById(st).className = "transON";
    document.getElementById(st2).className = "transOFF";
    selected = num;
  }
  document.pp.src = "images/play.gif";
}
function achange(num){
  document.bigpic.src=imgsrcs[num];
  st = 'pic'+selected;
  st2 = 'pic'+num;
  if(num!=selected){
    document.getElementById(st).className = "transON";
    document.getElementById(st2).className = "transOFF";
    selected = num;
  }
}
function preloadpics(){
  for(x=0; x<imgsrcs.length; x++){
    psrcs = new Image();
    psrcs.src = imgsrcs[x];
  }
  tid=setTimeout('auto(0)', 3000);
}
function mOut(n){
  str = 'pic'+n;
  if(n!=selected){
    document.getElementById(str).className = "transON";
  }
}
function redirect(){
  document.location.href=urls[selected];
}
function auto(x){
  play=1;
  numx = x;
  nn = nextnum(numx);
  achange(nn);
  tid = setTimeout('auto(nn)', 3000);
}
function nextnum(c){
  if(c==urls.length-1){
    return 0;
  }
  else{return c+1;}
}
function mode(){
  s = selected;
  if(play==0){
    document.pp.src = "images/pause.gif";
    clearTimeout(tid);
    tid=setTimeout('auto(s)', 50);
  }
  if(play==1){
    change(s);
  }
}