//SIMPLE IMAGE RANDOMIZER SCRIPT v1.1
//Created by Matt Bower

/*
FOR IMAGES

Link this fie in the <head> area.
Give the <img /> tag an id.
Insert the following code in in a <script> tag AFTER the <img /> tag:

	var rotator = 'file/path/without/filename/'+randomimg('filename',# of pics,'ext');
	document.img_id.src = rotator;

FOR BACKGROUNDS

Link this fie in the <head> area.
Give the container element tag an id.
Insert the following code in in a <script> tag INSIDE the container element tag:

	var rotator = 'file/path/without/filename/'+randomimg('filename',# of pics,'ext');
	document.element_id.style.backgroundImage = rotator;


*/

function randomimg(picname, picnum, ext) {
	var filenum = Math.floor(Math.random() * picnum) + 1;
	if(filenum <= 9) {
		var filename = picname+'0'+filenum+'.'+ext;
	} else {
		var filename = picname+filenum+'.'+ext;
	}
	return filename;
}