			// ----- Information ----- //			var AppName = "Association";			var VersionNum = "1.1";			var LastUpdated = "August 3, 2002";			var Author = "Greg Paskal";			var Copyright = "© 2002 ThouArt Software";			// ----- Global Variables ----- //			var DisplayedImages = Associations * 2;			var PreLoadedImage1 = new Array();			var PreLoadedImage2 = new Array();			var Location = new Array();			var LocationType = new Array();			var Found = new Array();			var RandNum = 0;			var iFileName = "";			var ClickNumber = 0;			var Click1Loc = -1;			var Click2Loc = -1;			var Correct = 0;			var Incorrect = 0;			var StartTime = new Date();						// ----- Preload Images ----- //			for (i=1 ; i<Associations+1 ; i++){				PreLoadedImage1[i] = new Image; PreLoadedImage1[i].src = "img_"+i+"_1"+ImageExt;				PreLoadedImage2[i] = new Image; PreLoadedImage2[i].src = "img_"+i+"_2"+ImageExt;			}			PreLoadedImageBlank = new Image; PreLoadedImageBlank.src = "img_blank"+ImageExt;			PreLoadedImageDefault = new Image; PreLoadedImageDefault.src = "img_default"+ImageExt;			PreLoadedImageWrong = new Image; PreLoadedImageWrong.src = "img_wrong"+ImageExt;			PreLoadedSpacer = new Image; PreLoadedSpacer.src = "../../univ_art/spacer.gif";			if (UseBorder == 1){				PreLoadedBorderTL = new Image; PreLoadedBorderTL.src = "border_tl"+ImageExt;				PreLoadedBorderTM = new Image; PreLoadedBorderTM.src = "border_tm"+ImageExt;				PreLoadedBorderTR = new Image; PreLoadedBorderTR.src = "border_tr"+ImageExt;				PreLoadedBorderRM = new Image; PreLoadedBorderRM.src = "border_rm"+ImageExt;				PreLoadedBorderBR = new Image; PreLoadedBorderBR.src = "border_br"+ImageExt;				PreLoadedBorderBM = new Image; PreLoadedBorderBM.src = "border_bm"+ImageExt;				PreLoadedBorderBL = new Image; PreLoadedBorderBL.src = "border_bl"+ImageExt;				PreLoadedBorderLM = new Image; PreLoadedBorderLM.src = "border_lm"+ImageExt;			}			// ----- Random Number Generator ----- //			function RandomNumber(DisplayedImages){				RandNum = Math.floor(Math.random() * (DisplayedImages));				return RandNum;			}						// ----- Randomly Shuffle Cards ----- //			for (i=1 ; i<Associations+1 ; i++){							// ----- Determine location for first card ----- //				RandNum = RandomNumber(DisplayedImages);				while (Location[RandNum] != null){					RandNum = RandomNumber(DisplayedImages);				}				Location[RandNum] = i;				LocationType[RandNum] = 1;								// ----- Determine location for second card ----- //				RandNum = RandomNumber(DisplayedImages);				while (Location[RandNum] != null){					RandNum = RandomNumber(DisplayedImages);				}				Location[RandNum] = i;				LocationType[RandNum] = 2;			}						// -----  Set up the initial screen view ----- //			function ScreenSetup (){				var CreatedImages = 0;				var CountInRow = 0;				var DynamicLine = "";								window.document.title = Title;				document.bgColor = StartingBGColor;				document.write("<center>");				if (DisplayTitle == 1) document.write("<font face='Verdana, Arial, Helvetica, sans-serif' size='6' color='333333'>" + Title + "</font>");				document.write("<table width='10' cellpadding='0' border='0' cellspacing='"+WidthBetweenImages+"'>");				document.write("	<tr>");				while (CreatedImages < DisplayedImages){					document.write("		<td>");					document.write("			<table width='10' cellpadding='0' border='0' cellspacing='0'>");					if (UseBorder == 1){document.write("				<tr>")};					if (UseBorder == 1){document.write("					<td><img src='../../univ_art/spacer.gif' name='border_tl_"+CreatedImages+"' width='"+BorderCornerWidth+"' height='"+BorderCornerHeight+"' border='0'></td>")};					if (UseBorder == 1){document.write("					<td><img src='../../univ_art/spacer.gif' name='border_tm_"+CreatedImages+"' width='"+BorderHorizontalWidth+"' height='"+BorderCornerHeight+"' border='0'></td>")};					if (UseBorder == 1){document.write("					<td><img src='../../univ_art/spacer.gif' name='border_tr_"+CreatedImages+"' width='"+BorderCornerWidth+"' height='"+BorderCornerHeight+"' border='0'></td>")};					if (UseBorder == 1){document.write("				</tr>")};					document.write("				<tr>");					if (UseBorder == 1){document.write("					<td><img src='../../univ_art/spacer.gif' name='border_lm_"+CreatedImages+"' width='"+BorderCornerWidth+"' height='"+BorderVerticalHeight+"' border='0'></td>")};					if (ImagesBeginAs == 1){document.write("					<td><a href='JavaScript:ImageClicked("+CreatedImages+")'><img src='img_default"+ImageExt+"' name='loc_"+CreatedImages+"' width='"+ImageWidth+"' height='"+ImageHeight+"' border='0'></a></td>")};					if (ImagesBeginAs == 2){document.write("					<td><a href='JavaScript:ImageClicked("+CreatedImages+")'><img src='img_"+Location[CreatedImages]+"_"+LocationType[CreatedImages]+ImageExt+"' name='loc_"+CreatedImages+"' width='"+ImageWidth+"' height='"+ImageHeight+"' border='0'></a></td>")};					if (UseBorder == 1){document.write("					<td><img src='../../univ_art/spacer.gif' name='border_rm_"+CreatedImages+"' width='"+BorderCornerWidth+"' height='"+BorderVerticalHeight+"' border='0'></td>")};					document.write("				</tr>");					if (UseBorder == 1){document.write("				<tr>")};					if (UseBorder == 1){document.write("					<td><img src='../../univ_art/spacer.gif' name='border_bl_"+CreatedImages+"' width='"+BorderCornerWidth+"' height='"+BorderCornerHeight+"' border='0'></td>")};					if (UseBorder == 1){document.write("					<td><img src='../../univ_art/spacer.gif' name='border_bm_"+CreatedImages+"' width='"+BorderHorizontalWidth+"' height='"+BorderCornerHeight+"' border='0'></td>")};					if (UseBorder == 1){document.write("					<td><img src='../../univ_art/spacer.gif' name='border_br_"+CreatedImages+"' width='"+BorderCornerWidth+"' height='"+BorderCornerHeight+"' border='0'></td>")};					if (UseBorder == 1){document.write("				</tr>")};					document.write("			</table>");					document.write("		</td>");										CreatedImages = CreatedImages + 1;					CountInRow = CountInRow + 1;										if (CountInRow == ImagesPerRow){						document.write("	</tr>");						document.write("	<tr>");						CountInRow = 0;					}				}								document.write("	</tr>");				document.write("</table>");				document.write("<form name='ScoreForm'>");				document.write("	Correct = <input type='text' name='Correct' size='10' onFocus='JavaScript:this.blur()'>"); document.ScoreForm.Correct.value = "0";				document.write("	Incorrect = <input type='text' name='Incorrect' size='10' onFocus='JavaScript:this.blur()'>"); document.ScoreForm.Incorrect.value = "0";				document.write("	Score = <input type='text' name='Score' size='10' onFocus='JavaScript:this.blur()'>"); document.ScoreForm.Score.value = "0%";				document.write("	Time Elapsed = <input type='text' name='TimeElapsed' size='10' onFocus='JavaScript:this.blur()'>"); document.ScoreForm.TimeElapsed.value = "0";				document.write("	<input type='button' value='Games' onClick='JavaScript:GamesHome()'>");				document.write("	<input type='button' value='New Game' onClick='JavaScript:NewGame()'>");				if (OptionRevealImages == 1) document.write("	<input type='button' value='Reveal Images' onClick='JavaScript:RevealImages()'>");				document.write("</form>");				if (DisplayCredits == 1) document.write("<font face='Verdana, Arial, Helvetica, sans-serif' size='2' color='333333'>" + AppName + " version " + VersionNum + " - written by " + Author + " - " + Copyright + "</font>");				document.write("</center>");				TimeClock(0,1);			}						// ----- Activated when an image is clicked ----- //			function ImageClicked(ImageNum){				if (ClickNumber != 2) {					if (Found[ImageNum] != "Found"){						if (LocationType[ImageNum] == 1){var LocName = "loc_"+ImageNum; document[LocName].src = PreLoadedImage1[Location[ImageNum]].src};						if (LocationType[ImageNum] == 2){var LocName = "loc_"+ImageNum; document[LocName].src = PreLoadedImage2[Location[ImageNum]].src};						if (UseBorder == 1){Border (ImageNum, "On")};						if (ClickNumber == 0){							Click1Loc = ImageNum;							ClickNumber = 1;						}						else if (ClickNumber == 1){							if (Click1Loc != ImageNum){								Click2Loc = ImageNum;								ClickNumber = 2;								if (Location[Click1Loc] != Location[Click2Loc]){									setTimeout("ImageClickedWrong(Click1Loc, Click2Loc)", (1000 * BeforeWrongTimer));									Score("0","1");								}								else{									Found[Click1Loc] = "Found";									Found[Click2Loc] = "Found";									ClickNumber = 0;									ImageClickedCorrect(Click1Loc, Click2Loc);									Score("1","0");									IsGameOver();								}							}						}					}				}			}						// ----- Activated when a match ----- //			function ImageClickedCorrect(Click1Loc, Click2Loc){				if (ImagesBeginAs == 2){					var LocName = "loc_"+Click1Loc; document[LocName].src = PreLoadedImageDefault.src;					var LocName = "loc_"+Click2Loc; document[LocName].src = PreLoadedImageDefault.src;				}				if (UseBorder == 1){					Border (Click1Loc, "Off");					Border (Click2Loc, "Off");				}			}									// ----- Activated when not a match ----- //			function ImageClickedWrong(Click1Loc, Click2Loc){				var LocName = "loc_"+Click1Loc; document[LocName].src = PreLoadedImageWrong.src;				var LocName = "loc_"+Click2Loc; document[LocName].src = PreLoadedImageWrong.src;				setTimeout("ImageClickedReset(Click1Loc, Click2Loc)", (1000 * WrongTimer));			}						// ----- Activated to reset incorrect cards ----- //			function ImageClickedReset(Click1Loc, Click2Loc){				if (ImagesBeginAs == 1){					var LocName = "loc_"+Click1Loc; document[LocName].src = PreLoadedImageDefault.src;					var LocName = "loc_"+Click2Loc; document[LocName].src = PreLoadedImageDefault.src;					ClickNumber = 0;				}				if (ImagesBeginAs == 2){					if (LocationType[Click1Loc] == 1){var LocName = "loc_"+Click1Loc; document[LocName].src = PreLoadedImage1[Location[Click1Loc]].src};					if (LocationType[Click1Loc] == 2){var LocName = "loc_"+Click1Loc; document[LocName].src = PreLoadedImage2[Location[Click1Loc]].src};					if (LocationType[Click2Loc] == 1){var LocName = "loc_"+Click2Loc; document[LocName].src = PreLoadedImage1[Location[Click2Loc]].src};					if (LocationType[Click2Loc] == 2){var LocName = "loc_"+Click2Loc; document[LocName].src = PreLoadedImage2[Location[Click2Loc]].src};					ClickNumber = 0;				}				if (UseBorder == 1){					Border (Click1Loc, "Off");					Border (Click2Loc, "Off");				}			}			// ----- Turn on and off borders ----- //			function Border(ImageNum, DispOpt){					if (DispOpt == "On"){					var LocName = "border_tl_"+ImageNum; document[LocName].src = PreLoadedBorderTL.src;					var LocName = "border_tm_"+ImageNum; document[LocName].src = PreLoadedBorderTM.src;					var LocName = "border_tr_"+ImageNum; document[LocName].src = PreLoadedBorderTR.src;					var LocName = "border_lm_"+ImageNum; document[LocName].src = PreLoadedBorderLM.src;					var LocName = "border_rm_"+ImageNum; document[LocName].src = PreLoadedBorderRM.src;					var LocName = "border_bl_"+ImageNum; document[LocName].src = PreLoadedBorderBL.src;					var LocName = "border_bm_"+ImageNum; document[LocName].src = PreLoadedBorderBM.src;					var LocName = "border_br_"+ImageNum; document[LocName].src = PreLoadedBorderBR.src;				}				else if (DispOpt == "Off"){					var LocName = "border_tl_"+ImageNum; document[LocName].src = PreLoadedSpacer.src;					var LocName = "border_tm_"+ImageNum; document[LocName].src = PreLoadedSpacer.src;					var LocName = "border_tr_"+ImageNum; document[LocName].src = PreLoadedSpacer.src;					var LocName = "border_lm_"+ImageNum; document[LocName].src = PreLoadedSpacer.src;					var LocName = "border_rm_"+ImageNum; document[LocName].src = PreLoadedSpacer.src;					var LocName = "border_bl_"+ImageNum; document[LocName].src = PreLoadedSpacer.src;					var LocName = "border_bm_"+ImageNum; document[LocName].src = PreLoadedSpacer.src;					var LocName = "border_br_"+ImageNum; document[LocName].src = PreLoadedSpacer.src;								}			}			// ----- Score ----- //			function Score(Correct,Incorrect){				document.ScoreForm.Correct.value = parseFloat(document.ScoreForm.Correct.value) + parseFloat(Correct);				document.ScoreForm.Incorrect.value = parseFloat(document.ScoreForm.Incorrect.value) + parseFloat(Incorrect);				Correct = parseFloat(document.ScoreForm.Correct.value);				Incorrect = parseFloat(document.ScoreForm.Incorrect.value);				document.ScoreForm.Score.value = (parseInt((100/ (Correct + Incorrect)) * Correct))+"%";			}						// ----- Reveal all the images ----- //			function RevealImages(){				for (i=0 ; i < DisplayedImages ; i++){					var LocName = "loc_"+i;					if (LocationType[i] == 1){var LocName = "loc_"+i; document[LocName].src = PreLoadedImage1[Location[i]].src};					if (LocationType[i] == 2){var LocName = "loc_"+i; document[LocName].src = PreLoadedImage2[Location[i]].src};				}			}						// ----- Check if game is over ----- //			function IsGameOver(){				if (parseFloat(document.ScoreForm.Correct.value) == Associations){					document.bgColor = CompletedBGColor;					TimeClock(StartTime,3)				}			}						// ----- Start New Game ----- //			function NewGame(){				window.location.reload();			}						// ----- Go to Games Home Page ----- //			function GamesHome(){				var TheURL = "../../index.html";				window.location = TheURL;			}						// ----- Time Clock ----- //			function TimeClock(StartTime,Option){				// Option 1 = Start Timeclock				// Option 2 = Continue Timeclock				// Option 3 = Stop Timeclock								if (Option == 1){					var StartTime = new Date();					TimerID = setTimeout("TimeClock(StartTime,2)", 500);				} 				else if (Option == 2){					var CurrentTime = new Date();					var ElapsedTime = parseInt(((CurrentTime.getTime()) - (StartTime.getTime()))/1000);					var ElapsedHours = parseInt(ElapsedTime / 3600);					var ElapsedMinutes = parseInt((ElapsedTime-(ElapsedHours * 3600)) / 60);					var ElapsedSeconds = parseInt(ElapsedTime-((ElapsedHours*3600)+(ElapsedMinutes*60)));					document.ScoreForm.TimeElapsed.value = ElapsedHours + ":" + ElapsedMinutes + ":" + ElapsedSeconds;					TimerID = setTimeout("TimeClock(StartTime,2)", 1000);				}				else if (Option == 3){					clearTimeout(TimerID);				}			}