
var Ar_Images = new Array(1000);
var DelayTime;
var ImageNum;
var Amount;
var SelRand;
var FileType;
var Directory;
var position=0;
var tm;

function GetRazr(n){var i =0; while(Math.pow(10,i) <= Math.round(n)){i++;} return i;}


function CBG(path,num, t)
{var i = num+1;
while (i > num || i==0) {i = Math.round(Math.random()*Math.pow(10,GetRazr(num)));}
fullpath = path +"/"+ i +"."+t;
document.body.background=fullpath;}


function RandImg(inum,path,num, t)
{var i = num+1;
while (i > num || i==0) {i = Math.round(Math.random()*Math.pow(10,GetRazr(num)));}
fullpath = path +"/"+ i +"."+t;
document.images[inum].src = fullpath;}

/************************************************************************************/

function LoadImg ()
{var n = 0;
while (n <= Amount)
{fullpath = Directory +"/"+ n +"." + FileType; Ar_Images[n] = new Image();Ar_Images[n].src = fullpath;
n++;}}


function OutputImg(pos)
{document.images[ImageNum].src = Ar_Images[pos].src;}

function BG(pos) {document.body.background=Ar_Images[pos].src;}

function PreLoadCBG()
{var i = Amount+1;
while (i > Amount) {i = Math.round(Math.random()*Math.pow(10,GetRazr(Amount)));}
document.body.background=Ar_Images[i].src;}


function PreLoadRandImg()
{var i = Amount+1;
while (i > Amount || i ==0 ){i = Math.round(Math.random()*Math.pow(10,GetRazr(Amount)));}
document.images[ImageNum].src = Ar_Images[i].src;
}


function StartTimer( ) 
{
if (SelRand==true) {PreLoadRandImg();}
if (SelRand==false) {OutputImg(position); position++; 
			  if (position>Amount)position = 1;}
tm = setTimeout( "StartTimer()",DelayTime); 
} 

function StopTimer(){clearTimeout(tm);}