var secs
var timerID = null
var timerRunning = false
var delay
var NumPics
var PicDirect = ""
var PicID

function nextrandom() {
var hi = this.seed/this.Q;
var lo = this.seed % this.Q;
var test= this.A * lo - this.R * hi;
if (test>0)
  this.seed=test;
else
  this.seed = test+this.M;
return (this.seed*this.oneOverM);
}
function randomgenerator() {
var d =new Date();
this.seed = 2345678901 + (d.getSeconds() *
0xFFFFFF)+(d.getMinutes()+0xffff);
this.A = 48271;
this.M = 2147483647;
this.Q = this.M / this.A;
this.R  = this.M % this.A;
this.oneOverM = 1.0/this.M;
this.next = nextrandom;
return this;
}
function random(n) {
var rand= new randomgenerator();
return Math.round(n*rand.next()) ;
}
//the next function calls a random feature and link
function getpic() {
var index=random(NumPics)+1;
var picurl="";
picurl=PicDirect+index+".jpg";
return picurl;
}
//end of random stuff

function InitializeTimer(p,d,dir,num)
{
    // Set the length of the timer, in seconds
    secs = 1
    delay = d
    PicID = p
    NumPics = num - 1
    PicDirect = dir
    StopTheClock()
    StartTheTimer()
    timerID = self.setTimeout("StartTheTimer()", this.delay)
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{
	PicID.src = getpic()	
        timerRunning = true
        clearTimeout(timerID)
        timerID = self.setTimeout("StartTheTimer()", this.delay)
}
