var pixComment = new Array();
var pixIndex = 0;

function picture(image, comment) {
	this.image = image;
	this.comment = comment;
}

//list of pictures with paired with comments they might have
var pix = new Array(new picture("images/pictures/3p.jpg", ""));
pix[pixIndex++] = new picture("images/pictures/bed.jpg", "");
pix[pixIndex++] = new picture("images/pictures/chipmonk.jpg", "");
pix[pixIndex++] = new picture("images/pictures/chrissyDerek.jpg", "");
pix[pixIndex++] = new picture("images/pictures/erinHenderson.jpg", "my beautiful wife");
pix[pixIndex++] = new picture("images/pictures/hippoT.jpg", "");
pix[pixIndex++] = new picture("images/pictures/ladyTramp.jpg", "");
pix[pixIndex++] = new picture("images/pictures/rachelBrad.jpg", "");
pix[pixIndex++] = new picture("images/pictures/seaCow.jpg", "");
pix[pixIndex++] = new picture("images/pictures/trinity.jpg", "");

pics = "<table border = '0' align = 'center'><tr>";
pics += "<td align = 'center'><img width = '250' name = 'leftPix' id = 'leftPix' src = ''><br><div align = 'center' name = 'leftComment'id = 'leftComment'></div></td>";
pics += "<td align = 'center'><img width = '250' name = 'centerPix' id = 'centerPix' src = ''><br><div align = 'center' name = 'centerComment' id = 'centerComment'></div></td>";
pics += "<td align = 'center'><img width = '250' name = 'rightPix' id = 'rightPix' src = ''><br><div align = 'center' name = 'rightComment' id = 'rightComment'></div></td>";
pics += "</tr></table>";

function randomIndex()
{
	var z = Math.floor(Math.random()*pix.length);
	return z;
}

// sets three pictures at random
function setPic()
{
	// start by assuming at least two of the pictures are the same
	var different = false;
	
	// loads three random picture index numbers, may be the same
	var image1 = randomIndex();
	var image2 = image1;
	var image3 = image1;
	
	// compare image1 to image2 and change image2 if they are the same
	while(different == false)
	{
		// sets the different flag to true if the two are not the same
		if(image2 != image1)
		{
		different = true;
		}
		else image2 = randomIndex();
	}
		
	// resets the different flag
	different = false;

	// compares image3 to both image1 and image2
	while(different == false)
	{
		//chooses a new image3 for this iteration
		image3 = randomIndex();
		
		// if image3 is different from image1 the different flag becomes true
		if(image3 != image1)
		{
		different = true;
		}
			
		// if image 3 is the same as image2 the different flag becomes false
		if(image3 == image2)
		{
		different = false;
		}
	}
	
	// puts the images in their places
	document.leftPix.src = pix[image1].image;
	document.centerPix.src = pix[image2].image;
	document.rightPix.src = pix[image3].image;
	
	//puts the comments in their places
	//????	
}
