<!-- Original:  Ari Rebach (www.arirebach.com) -->

<!-- Begin

// Sets the Location of the Images
var images_path = "images/";

// Sets Default Image Number
var top_left_picture = 0;
var top_right_picture = 0;
var bottom_left_picture = 0;
var bottom_right_picture = 0;

// Array of Images. Add new professor's images at the bottom of this set of statements.
var images = new Array();

/* The diversity array is used to ensure that a diverse cross section of the department is presented.
   This array is two dimensional; the first dimenstion corresponds to the image while the second dimension 
   is where the diversity flags are keep. Currently there are three flags that can be controlled for: 
   ethnicity, gender, and affliation.
   
   Ethnicity: C (Caucasion), AA (African-American), H (Hispanic), A (Asian), O (Other).
   Gender: M (Male), F (Female).
   Affliation: UG (Undergraduate Student), G (Graduate Student), F (Faculty), O (Office Staff), D (Departmental Officer), 
   			   AD (Adjunct Faculty), AF (Affiliate Faculty), E (Emeritus Faculty). */
var diversity = new Array();

images[0] = new Image();
images[0].src = images_path + "pietroski.jpg";
diversity[0] = new Array("C", "M", "F");

images[1] = new Image();
images[1].src = images_path + "morris.jpg";
diversity[1] = new Array("C", "M", "F");

images[2] = new Image();
images[2].src = images_path + "carruthers.jpg";
diversity[2] = new Array("C", "M", "D");

images[3] = new Image();
images[3].src = images_path + "greenspan.jpg";
diversity[3] = new Array("C", "F", "F");

images[4] = new Image();
images[4].src = images_path + "martin.jpg";
diversity[4] = new Array("C", "M", "D");

images[5] = new Image();
images[5].src = images_path + "brown.jpg";
diversity[5] = new Array("C", "M", "E");

images[6] = new Image();
images[6].src = images_path + "levinson.jpg";
diversity[6] = new Array("C", "M", "F");

images[7] = new Image();
images[7].src = images_path + "runnels.jpg";
diversity[7] = new Array("C", "F", "G");

images[8] = new Image();
images[8].src = images_path + "ribeiro.jpg";
diversity[8] = new Array("C", "F", "G");

images[9] = new Image();
images[9].src = images_path + "tiedke.jpg";
diversity[9] = new Array("C", "F", "G");

images[10] = new Image();
images[10].src = images_path + "ealick.jpg";
diversity[10] = new Array("C", "M", "G");

images[11] = new Image();
images[11].src = images_path + "baltzly.jpg";
diversity[11] = new Array("C", "M", "G");

images[12] = new Image();
images[12].src = images_path + "stairs.jpg";
diversity[12] = new Array("C", "M", "D");

function swapPic() {

	// Number of Images in the images array
	var number_of_images = images.length - 1;
	
	// Choose four random numbers, if any are the same the loop repeats.
	do {

		/* Boolean Variable, which controls the loop.
		   TRUE: At the beginning of the loop or when there are NO duplicate images.
		   FALSE: When there ARE Duplicate Images */
		var good = true;
	
		// Gives each image a random number, which will correspond to the images array above.
		top_left_picture = Math.round(Math.random() * number_of_images);
		top_right_picture = Math.round(Math.random() * number_of_images);
		bottom_left_picture = Math.round(Math.random() * number_of_images);
		bottom_right_picture = Math.round(Math.random() * number_of_images);
		
		// Checks to see if the picture in the top left is the same as any other. If so, the boolean is set to repeat the loop.
		if (top_left_picture == top_right_picture || top_left_picture == bottom_left_picture || top_left_picture == bottom_right_picture) {
			good = false;
			}
			
		// Checks to see if the picture in the top right is the same as any other. If so, the boolean is set to repeat the loop.	
		if (top_right_picture == top_left_picture || top_right_picture == bottom_left_picture || top_right_picture == bottom_right_picture) {
			good = false;
			}

		// Checks to see if the picture in the bottom left is the same as any other. If so, the boolean is set to repeat the loop.		 
		if (bottom_left_picture == top_left_picture || bottom_left_picture == top_right_picture || bottom_left_picture == bottom_right_picture) {
			good = false;
			}
			
		// Checks to see if the picture in the bottom right is the same as any other. If so, the boolean is set to repeat the loop.
		if (bottom_right_picture == top_left_picture || bottom_right_picture == top_right_picture || bottom_right_picture == bottom_left_picture) {
			good = false;
			}
		
		// Checks to see if all the pictures are of males. If so, the boolean is set to repeat the loop.
		if (diversity[top_left_picture][1] == "M" && diversity[top_right_picture][1] == "M" &&  diversity[bottom_left_picture][1] == "M" && diversity[bottom_right_picture][1] == "M") {
			good = false;
			}

	} while (!good);

	// Set the Source file for the Images
	document.topleft.src = images[top_left_picture].src;
	document.topright.src = images[top_right_picture].src;
	document.bottomleft.src = images[bottom_left_picture].src;
	document.bottomright.src = images[bottom_right_picture].src;

}
	
//  End -->