// Based on script created by Computerhope - http://www.computerhope.com & Barry Pranklin - http://www.pranklin.com
// Script is used to generate 3 unique random images out of 9, pair them up with their matching caption, to be placed on the page

// array of instructor images
var images = new Array(7);
images[0] = "<a href='lecturers/gladwell.php'><img src='media/lecturers/GladwellM.gif' alt='Malcolm Gladwell'>";
images[1] = "<a href='lecturers/gordon.php'><img src='media/lecturers/GordonD.gif' alt='DeeDee Gordon'>";
images[2] = "<a href='lecturers/pink.php'><img src='media/lecturers/PinkD.gif' alt='Daniel Pink'>";
images[3] = "<a href='lecturers/lehrer.php'><img src='media/lecturers/LehrerJ.gif' alt='Jonah Lehrer'>";
images[4] = "<a href='lecturers/mccracken.php'><img src='media/lecturers/McCrackenG.gif' alt='Grant McCracken'>";
images[5] = "<a href='lecturers/swanson.php'><img src='media/lecturers/SwansonC.gif' alt='Cheryl Swanson'>";
images[6] = "<a href='lecturers/szeto.php'><img src='media/lecturers/SzetoG.gif' alt='Gong Szeto'>";	

// array of captions, matches the image index
var caption = new Array(7);
caption[0] = "<b>Malcolm Gladwell,</b></a><br />Writer: The New Yorker; Author: The Tipping Point: How Little Things Make a Difference, Blink: The power of Thinking...";
caption[1] = "<b>DeeDee Gordon,</b></a><br />Co-Creator: L Report, Look-Look Magazine, Youth Culture Expert, Trend...";
caption[2] = "<b>Daniel Pink,</b></a><br />Entrepreneur, Speaker, Author of provocative, bestselling books on the changing world of work...";
caption[3] = "<b>Jonah Lehrer,</b></a><br />Editor: Wired; Author: How We Decide, Proust Was a Neuroscientist, The New Yorker, Nature, Seed...";
caption[4] = "<b>Grant McCracken,</b></a><br />PHD, Educator, Author, Consultant, Anthropologist. Clients include: Coca-Cola, Nike, Campbell Soup...";
caption[5] = "<b>Cheryl Swanson,</b></a><br />Founded Toniq, along with Kyla Lange Hart, in 1999 to specialize in strategic imagery, product design and positioning...";
caption[6] = "<b>Gong Szeto,</b></a><br />Entrepreneur; Lecturer; former Director of Design and Product Design, PEAK6 Investments; Designer, OptionsHouse...";
	
			// generates 3 unique numbers out of 9
			var Found=false;
			var Current = new Array();
			var MaxValue=7;   //max number of random numbers that need to be generated, take 0 into account
			var NumUnique=3; //unique numbers required
			var Count=0;
			var Current = new Array(NumUnique);
			
			function get_random(){
				var ranNum= Math.floor(Math.random()*MaxValue);
				return ranNum;
			}
			
			function GetUnique(){
				for (i=0;Count<NumUnique;Count++)
				{
				  Found=false;
				  var rndValue = get_random();
				  var j=0;
				  for (j=0;j<Current.length;j++)
				  {
					if (Current[j] == rndValue)
					{
					  Found=true;
					  break;
					}
				  }
				  if (Found)
				  {
					Count--;
				  } else {
					Current[Count]=rndValue;
				  }
				}
			}
			
			GetUnique();
			//alert("The unique numbers are: " + Current[0] + ", " + Current[1] + ", and " + Current[2]);

// functions that pair up the image and caption, and prepare html
function placeLecturer1(){
	 document.write(images[Current[0]] + caption[Current[0]]);
}

function placeLecturer2(){
	 document.write(images[Current[1]] + caption[Current[1]]);
}

function placeLecturer3(){
	 document.write(images[Current[2]] + caption[Current[2]]);
}