// JavaScript Document

function switchImage(imgName, imgSrc) {
	if (document.images){
    	if (imgSrc != "none"){
			document.images[imgName].src = imgSrc;
		}
	}
}

function SlideShow(slideList, image, speed, name){
	this.slideList = slideList;
	this.image = image;
	this.speed = speed;
	this.name = name;
	this.current = slideList.length-1;
	this.amount = slideList.length-1;
	this.timer = 0;
}

SlideShow.prototype.play = SlideShow_play;
SlideShow.prototype.playrandom = SlideShow_play_random;  

function SlideShow_play(){
	with(this){
		if(current++ == slideList.length-1) current = 0;
		switchImage(image, slideList[current]);
		
		clearTimeout(timer);

    	timer = setTimeout(name+'.play()', speed);
	}
}

function SlideShow_play_random(){
	with(this){
		current = Math.round(amount*Math.random());
		switchImage(image, slideList[current]);
		clearTimeout(timer);
	
		timer = setTimeout(name+'.playrandom()', speed);
	}
}

function simplePreload(args){ 
	document.imageArray = new Array(args.length);

	for(var i=0; i<args.length; i++){
		document.imageArray[i] = new Image;
		document.imageArray[i].src = args[i];
	}
	return true;
}

function roll(img_name, img_src){
	document[img_name].src = img_src;
	div = document.getElementById(img_name);
	if(div.style.visibility != "visible"){
		div.style.visibility = "visible";
	}else{
		div.style.visibility = "hidden";
	}
}


