var whichArea;
var whichSection;
var picQuantity;
var imgboxObj;
//a random number from 0 to picQuantity occupies each of three positions
var whichImg = new Array (0, 1, 2);
//the position currently being flipped
var whichPosition = 0;

function goSlide(area,section,quantity) {
	whichArea = area;
	whichSection = section;
	picQuantity = quantity;
	imgboxObj = document.getElementById("imgbox");
	//preload pics into cache
	for (var i = 0; i < picQuantity; i++) {
		var picObj = new Image();
		picObj.src = "../pics/pics" + whichSection + "/pic" + i + ".jpg";
	}
	pickPic();
}

function pickPic() {
    //randomly select a pic from the number of available pics
    var randomNum = Math.floor((Math.random() * picQuantity));
    //if pic/random number is in use, rerandomize to prevent duplicates from showing at the same time
    while (randomNum == whichImg[0] || randomNum == whichImg[1] || randomNum == whichImg[2]) {
        randomNum = Math.floor((Math.random() * picQuantity));
    }
    whichImg[whichPosition] = randomNum;
    imgboxObj.childNodes[whichPosition].src = "../pics/pics" + whichSection + "/pic" + randomNum + ".jpg";
    //randomly choose which position will take the next random pic
    whichPosition = Math.floor((Math.random() * whichImg.length));
    setTimeout("pickPic()",2000);
}







