/**
 *	a simple random integer generator.
 */
function randomInt(n) {
	return Math.round(Math.random()*n - 0.5);
}

/**
 *	a simple script to test random numbers.
 */
function rntest(n) {
	document.writeln("<ol> Testing:");
	for (var i=0;i<1000;i++) {
		var x = randomInt(n);
		if (x<0) {
			alert("too low");
			break;
		} else if (x>=n) {
			alert("too high");
			break;
		}
		document.writeln("<li> num = "+x+"</li>");
	}
	document.writeln("</ol>");
}

/**
 *	creates an image name from an image number.
 */
function imagename(imagenum) {
	var imagebase = "resources/ds/";
	var imgnumstring = "";
	if (imagenum <= 9) {
		imgnumstring = "00"+imagenum;
	} else if (imagenum <=99) {
		imgnumstring = "0"+imagenum;
	} else {
		imgnumstring += imagenum;
	}
	return imagebase+imgnumstring+".jpg";
}

/**
 *	a simple script to load a random image.
 */
function randomImage() {
	var imagenum = randomInt(mImageCount);
//	var s='<img name="photo" src="'+imagename(imagenum)+'" height="355" width="355" alt="" border="0">';
	var s='<img name="photo" src="'+imagename(imagenum)+'" height="80" width="80" alt="" border="0">';
	document.write(s);
}

/**
 *	advances the slide show
 */
function slideShow(start) {
	var delayinseconds = 10;
	
	if (start == mImageCount) {
		start = 0;
	}
	
	if (document.images && document.images['photo']) {
			document.images['photo'].src=imagename(start);
	}
	if (document.all && 
			document.all['photo'] &&
			document.all['photo'].src) {	// to stop omniweb error
			document.all['photo'].src=imagename(start);
	}
	
	var timer = setTimeout("slideShow("+(start+1)+")",delayinseconds*1000);
}

