// JavaScript Document

/* This file rotates (randomizes) the circular student images that are present on
 * some pages. If you are creating a page that has these images in the proper locations --
 * div elements with the id's pic1, pic2, and pic3 -- you may import this file to randomize
 * those images so that they do not show the same pictures every time. You should still have
 * an image set in the .css file so that they will have a default should something go wrong.
 */

var NUMBER_OF_IMAGES = 11;
var image_numbers = [];

/* returns true if the array contains the element */
function array_contains(array, element)
{
	returnvalue = false;
	for (i=0; i < array.length && !returnvalue; i++)
	{
		returnvalue = (array[i] == element);
	}
	return returnvalue;
}

function randomize_pics()
{
	for (i = 0; i < 3; i++)
	{
		do
		{
			temp = Math.ceil(Math.random() * NUMBER_OF_IMAGES);
		} while (array_contains(image_numbers, temp));
		image_numbers[i] = temp;
	
		element = document.getElementById("pic" + (i + 1));
		element.style.backgroundImage = "url(/images/circlefaces/CircleFace" + image_numbers[i] + ".jpg)";
	}
}

