// Date variables
var nextGameDate = ''
var recentPlayedDate = 'August 27, 2011'


// ------------------- REGULAR SEASON -------------------------

// DATE, AWAY_TEAM, HOME_TEAM, LOCATION, WINNER, AWAY_SCORE, HOME_SCORE, COMMENTS
//   note: WINNER: A=Away, H=Home, T=Tie, C=Cancelled, S=Scheduled
scheduleArray = [
['May 6, 2011','Arlington Woods','Bethel Hawks','Craig Henry','H',5,25,'Game completed Saturday August 6th'],
['May 6, 2011','Nepean Baptist Church','Ottawa Chinese Bible Church','Manordale','H',16,18,'Game made up June 1'],
['May 6, 2011','The Bridge','Metropolitan Bible Church','Medhurst East','C',,,'Make up game to be played Sat. Aug. 6th @ 10am'],
['May 6, 2011','Sunnyside Stingers','Woodvale Pentecostal','Medhurst West','C',,,'Make up game to be played Sat. Aug. 6th @ 10am'],
['May 6, 2011','Church of the Resurrection','Bethel Rock','Tanglewood','C',,,'Game Not Completed.'],

['May 13, 2011','Bethel Rock','Arlington Woods','Craig Henry','A',10,7,''],
['May 13, 2011','Bethel Hawks','Woodvale Pentecostal','Manordale','A',20,16,''],
['May 13, 2011','Ottawa Chinese Bible Church','The Bridge','Medhurst East','H',13,22,''],
['May 13, 2011','Nepean Baptist Church','Church of the Resurrection','Medhurst West','H',15,20,''],
['May 13, 2011','Metropolitan Bible Church','Sunnyside Stingers','Tanglewood','A',11,10,''],

['May 20, 2011','Bethel Hawks','Bethel Rock','Craig Henry','A',12,9,'Game played Friday August 5 as part of a double header'],
['May 20, 2011','Arlington Woods','Church of the Resurrection','Manordale','C',,,'Make up game to be played Sat. Aug. 13th @ 10am'],
['May 20, 2011','Sunnyside Stingers','Ottawa Chinese Bible Church','Medhurst East','C',,,'Make up game to be played Sat. Aug. 13th @ 10am'],
['May 20, 2011','The Bridge','Nepean Baptist Church','Medhurst West','A',28,13,'Make up game played'],
['May 20, 2011','Woodvale Pentecostal','Metropolitan Bible Church','Tanglewood','A',1,0,'Game awarded due to Forfeiture (league approval pending)'],

['May 27, 2011','Woodvale Pentecostal','Nepean Baptist Church','Craig Henry','C',,,'Make up game to be played Fri. Aug. 19th @ 6:30pm'],
['May 27, 2011','The Bridge','Arlington Woods','Manordale','A',24,17,'Game made up June 30'],
['May 27, 2011','Bethel Hawks','Church of the Resurrection','Medhurst East','C',,,'Make up game to be played Fri. Aug. 19th @ 6:30pm'],
['May 27, 2011','Metropolitan Bible Church','Ottawa Chinese Bible Church','Medhurst West','C',,,'Make up game to be played Fri. Aug. 19th @ 6:30pm'],
['May 27, 2011','Bethel Rock','Sunnyside Stingers','Tanglewood','C',,,'Make up game to be played Fri. Aug. 19th @ 6:30pm'],

['June 3, 2011','The Bridge','Bethel Hawks','Craig Henry','H',11,31,''],
['June 3, 2011','Sunnyside Stingers','Nepean Baptist Church','Manordale','A',30,24,''],
['June 3, 2011','Metropolitan Bible Church','Arlington Woods','Medhurst East','H',12,20,''],
['June 3, 2011','Woodvale Pentecostal','Bethel Rock','Medhurst West','A',23,13,''],
['June 3, 2011','Ottawa Chinese Bible Church','Church of the Resurrection','Tanglewood','H',11,16,''],

['June 10, 2011','Ottawa Chinese Bible Church','Woodvale Pentecostal','Craig Henry','H',11,15,''],
['June 10, 2011','Church of the Resurrection','Sunnyside Stingers','Manordale','A',32,23,''],
['June 10, 2011','Arlington Woods','Nepean Baptist Church','Medhurst East','A',16,15,''],
['June 10, 2011','Bethel Hawks','Metropolitan Bible Church','Medhurst West','A',20,10,''],
['June 10, 2011','The Bridge','Bethel Rock','Tanglewood','H',5,25,''],

['June 17, 2011','Sunnyside Stingers','The Bridge','Craig Henry','A',15,13,''],
['June 17, 2011','Bethel Rock','Metropolitan Bible Church','Manordale','A',26,13,''],
['June 17, 2011','Church of the Resurrection','Woodvale Pentecostal','Medhurst East','H',4,15,''],
['June 17, 2011','Ottawa Chinese Bible Church','Arlington Woods','Medhurst West','H',13,20,''],
['June 17, 2011','Nepean Baptist Church','Bethel Hawks','Tanglewood','H',5,25,''],

['June 24, 2011','Metropolitan Bible Church','Church of the Resurrection','Craig Henry','C',,,'Game Rained Out'],
['June 24, 2011','Woodvale Pentecostal','The Bridge','Manordale','C',,,'Game Rained Out'],
['June 24, 2011','Nepean Baptist Church','Bethel Rock','Medhurst East','C',,,'Game Rained Out'],
['June 24, 2011','Arlington Woods','Sunnyside Stingers','Medhurst West','C',,,'Game Rained Out'],
['June 24, 2011','Bethel Hawks','Ottawa Chinese Bible Church','Tanglewood','C',,,'Game Rained Out'],

['July 8, 2011','Nepean Baptist Church','Metropolitan Bible Church','Craig Henry','A',25,12,''],
['July 8, 2011','Sunnyside Stingers','Bethel Hawks','Manordale','H',7,27,''],
['July 8, 2011','Bethel Rock','Ottawa Chinese Bible Church','Medhurst East','A',26,10,''],
['July 8, 2011','Church of the Resurrection','The Bridge','Medhurst West','H',11,15,''],
['July 8, 2011','Arlington Woods','Woodvale Pentecostal','Tanglewood','H',6,17,''],

['July 15, 2011','Metropolitan Bible Church','The Bridge','Craig Henry','H',11,15,''],
['July 15, 2011','Ottawa Chinese Bible Church','Nepean Baptist Church','Manordale','H',13,16,''],
['July 15, 2011','Woodvale Pentecostal','Sunnyside Stingers','Medhurst East','A',24,5,''],
['July 15, 2011','Bethel Rock','Church of the Resurrection','Medhurst West','H',10,13,''],
['July 15, 2011','Bethel Hawks','Arlington Woods','Tanglewood','A',25,5,''],

['July 22, 2011','Church of the Resurrection','Nepean Baptist Church','Craig Henry','H',3,4,''],
['July 22, 2011','Arlington Woods','Bethel Rock','Manordale','H',6,25,''],
['July 22, 2011','Woodvale Pentecostal','Bethel Hawks','Medhurst East','H',2,5,''],
['July 22, 2011','Sunnyside Stingers','Metropolitan Bible Church','Medhurst West','S',,,''],
['July 22, 2011','The Bridge','Ottawa Chinese Bible Church','Tanglewood','A',9,5,''],

['August 5, 2011','Ottawa Chinese Bible Church','Sunnyside Stingers','Craig Henry','H',25,28,''],
['August 5, 2011','Metropolitan Bible Church','Woodvale Pentecostal','Manordale','H',5,11,''],
['August 5, 2011','Church of the Resurrection','Arlington Woods','Medhurst East','A',21,9,''],
['August 5, 2011','Bethel Rock','Bethel Hawks','Medhurst West','H',12,14,''],
['August 5, 2011','Nepean Baptist Church','The Bridge','Tanglewood','H',11,17,''],

['August 12, 2011','Sunnyside Stingers','Bethel Rock','Craig Henry','H',14,17,''],
['August 12, 2011','Church of the Resurrection','Bethel Hawks','Manordale','H',5,19,''],
['August 12, 2011','Ottawa Chinese Bible Church','Metropolitan Bible Church','Medhurst East','S',,,''],
['August 12, 2011','Arlington Woods','The Bridge','Medhurst West','H',13,14,''],
['August 12, 2011','Nepean Baptist Church','Woodvale Pentecostal','Tanglewood','H',10,24,'']
];

// TeamShort, TeamLong, GP, W, L, T, WinPct, RF, RA, RunsDifferential
standingsArray = [
['AW','Arlington Woods',0,0,0,0,0,0,0,0],
['BETHH','Bethel Hawks',0,0,0,0,0,0,0,0],
['BETHR','Bethel Rock',0,0,0,0,0,0,0,0],
['BRI','The Bridge',0,0,0,0,0,0,0,0],
['COR','Church of the Resurrection',0,0,0,0,0,0,0,0],
['MET','Metropolitan Bible Church',0,0,0,0,0,0,0,0],
['NBC','Nepean Baptist Church',0,0,0,0,0,0,0,0],
['OCBC','Ottawa Chinese Bible Church',0,0,0,0,0,0,0,0],
['SWC','Sunnyside Stingers',0,0,0,0,0,0,0,0],
['WOOD','Woodvale Pentecostal',0,0,0,0,0,0,0,0]
];

//-------------------- Manual Standings Array to sort out head to head tie breaker -------------

// TeamShort, TeamLong, GP, W, L, T, WinPct, RF, RA, RunsDifferential
manualArray = [
['AW','Arlington Woods',6,3,3,0,500,0,0,0],
['BETHH','Bethel Hawks',5,5,0,0,1000,0,0,0],
['BETHR','Bethel Rock',5,4,1,0,800,0,0,0],
['BRI','The Bridge',7,4,3,0,571,0,0,0],
['COR','Church of the Resurrection',5,3,2,0,600,0,0,0],
['MET','Metropolitan Bible Church',5,1,4,0,200,0,0,0],
['NBC','Nepean Baptist Church',7,1,6,0,143,0,0,0],
['OCBC','Ottawa Chinese Bible Church',6,1,5,0,167,0,0,0],
['SWC','Sunnyside Stingers',5,2,3,0,400,0,0,0],
['WOOD','Woodvale Pentecostal',5,4,1,0,800,0,0,0]
];


// ------------------- PLAYOFFS -------------------------

// DATE, AWAY_TEAM, HOME_TEAM, LOCATION, WINNER, AWAY_SCORE, HOME_SCORE, COMMENTS
//   note: WINNER: A=Away, H=Home, T=Tie, C=Cancelled, S=Scheduled

playoffSixArray = [
['August 19, 2011','Ottawa Chinese Bible Church','Church of the Resurrection','Craig Henry','H',9,22,''],
['August 19, 2011','Metropolitan Bible Church','Sunnyside Stingers','Manordale','A',15,11,''],
['August 19, 2011','Arlington Woods','Nepean Baptist Church','Tanglewood','A',24,9,''],

['August 26, 2011','Metropolitan Bible Church','Church of the Resurrection','Manordale','S',,,''],
['August 26, 2011','Nepean Baptist Church','Sunnyside Stingers','Tanglewood','H',12,26,''],
['August 26, 2011','Ottawa Chinese Bible Church','Arlington Woods','Craig Henry','A',24,9,''],

['August 27, 2011 @ 9:00','Arlington Woods','Church of the Resurrection','Tanglewood','H',9,11,''],
['August 27, 2011 @ 9:00','Ottawa Chinese Bible Church','Sunnyside Stingers','Manordale','H',19,21,''],
['August 27, 2011 @ 9:00','Metropolitan Bible Church','Nepean Baptist Church','Craig Henry','H',7,29,''],
['August 27, 2011 @ 10:30','Nepean Baptist Church','Church of the Resurrection','Tanglewood','H',19,20,''],
['August 27, 2011 @ 10:30','Arlington Woods','Sunnyside Stingers','Manordale','H',8,30,''],
['August 27, 2011 @ 10:30','Ottawa Chinese Bible Church','Metropolitan Bible Church','Craig Henry','A',7,0,'']
];

// DATE, AWAY_TEAM, HOME_TEAM, LOCATION, WINNER, AWAY_SCORE, HOME_SCORE, COMMENTS
//   note: WINNER: A=Away, H=Home, T=Tie, C=Cancelled, S=Scheduled

playoffFourArray = [
['August 19, 2011','Woodvale Pentecostal','Bethel Hawks','Medhurst East','H',11,22,''],
['August 19, 2011','Bethel Rock','The Bridge','Medhurst West','A',11,1,''],

['August 26, 2011','The Bridge','Bethel Hawks','Medhurst East','H',6,25,''],
['August 26, 2011','Bethel Rock','Woodvale Pentecostal','Medhurst West','A',17,16,''],

['August 27, 2011 @ 9:00','Bethel Rock','Bethel Hawks','Medhurst East','A',16,15,''],
['August 27, 2011 @ 9:00','The Bridge','Woodvale Pentecostal','Medhurst West','H',7,15,'']
];

//playoffFourArray = [
//['August 19, 2011','Team42','Team41','Manordale','S',,,''],
//['August 19, 2011','Team44','Team43','Tanglewood','S',,,''],
//['August 26, 2011','Team43','Team41','Manordale','S',,,''],
//['August 26, 2011','Team44','Team42','Tanglewood','S',,,''],
//['August 27, 2011 @ 9:00','Team44','Team41','Medhurst East','S',,,''],
//['August 27, 2011 @ 9:00','Team43','Team42','Medhurst West','S',,,'']
//];

// TeamShort, TeamLong, GP, W, L, T, WinPct, RF, RA, RUNS_DIFFERENTIAL, REGULAR_SEASON_STANDINGS
playoffSixStandingsArray = [
['COR','Church of the Resurrection',1,1,0,0,0,0,0,0,5],
['SWC','Sunnyside Stingers',0,0,0,0,0,0,0,0,6],
['NBC','Nepean Baptist Church',2,1,1,0,0,0,0,0,7],
['AW','Arlington Woods',0,0,0,0,0,0,0,0,8],
['MET','Metropolitan Bible Church',1,0,1,0,0,0,0,0,9],
['OCBC','Ottawa Chinese Bible Church',0,0,0,0,0,0,0,0,10]
];

// TeamShort, TeamLong, GP, W, L, T, WinPct, RF, RA, RUNS_DIFFERENTIAL, REGULAR_SEASON_STANDINGS
playoffFourStandingsArray = [
['BETHH','Bethel Hawks',0,0,0,0,0,0,0,0,1],
['WOOD','Woodvale Pentecostal',0,0,0,0,0,0,0,0,2],
['BRI','The Bridge',0,0,0,0,0,0,0,0,3],
['BETHR','Bethel Rock',0,0,0,0,0,0,0,0,4]
];

function sortCol(Arr,colNum){
 function Sort(a,b) 
 {
   if(a[col] < b[col]) 
      return -1 
   if(a[col] > b[col]) 
      return 1 
   return 0 
 }
 col=colNum
 Arr.sort(Sort) 
}

function sortColDesc(Arr,colNum){
 function Sort(a,b) 
 {
   if(a[col] > b[col]) 
      return -1 
   if(a[col] < b[col]) 
      return 1 
   return 0 
 }
 col=colNum
 Arr.sort(Sort) 
}

function swapRows(tempArray,row1,row2,numCols) {
	var tempRow = [];
	for (iCounter=0;iCounter<numCols;iCounter++)
	{
		tempRow[iCounter] = tempArray[row1][iCounter];
		tempArray[row1][iCounter] = tempArray[row2][iCounter];
		tempArray[row2][iCounter] = tempRow[iCounter];
	}
}


// TEST - new comparator function
function compareFields(a1, a2) {
    return a1[6] > a2[6] ? -1 :
           a1[6] < a2[6] ? 1 :
           a1[9] > a2[9] ? -1 :
           a1[9] < a2[9] ? 1 : 0;
}

// TEST - new comparator function
function comparePlayoffFields(a1, a2) {
    return a1[6] > a2[6] ? -1 :
           a1[6] < a2[6] ? 1 :
           a1[9] > a2[9] ? -1 :
           a1[9] < a2[9] ? 1 : 
           a1[10] < a2[10] ? -1 :
           a1[10] > a2[10] ? 1 : 0;
}

function buildStandings(tempArray, tempStandingsArray) {
	// Go through all games played and build standings
	for (i=0;i<tempArray.length;i++)
	{
		if ((tempArray[i][4] != "C") && (tempArray[i][4] != "S")) // if games not Cancelled or still Scheduled
		{
			var AwayWon = 0;
			var HomeWon = 0;
			var TieGame = 0;
			switch(tempArray[i][4]) {
				case "H":	// home team won
					HomeWon++
					break
				case "A":	// away team won
					AwayWon++
					break
				case "T":	// tie game
					TieGame++
					break
			}

			//Process Away Team
			switch(tempArray[i][1]) {
				case "Arlington Woods":
					tempStandingsArray[0][2]++
					tempStandingsArray[0][3] += AwayWon
					tempStandingsArray[0][4] += HomeWon
					tempStandingsArray[0][5] += TieGame
					tempStandingsArray[0][7] += tempArray[i][5]
					tempStandingsArray[0][8] += tempArray[i][6]
					break
				case "Bethel Hawks":
					tempStandingsArray[1][2]++
					tempStandingsArray[1][3] += AwayWon
					tempStandingsArray[1][4] += HomeWon
					tempStandingsArray[1][5] += TieGame
					tempStandingsArray[1][7] += tempArray[i][5]
					tempStandingsArray[1][8] += tempArray[i][6]
					break
				case "Bethel Rock":
					tempStandingsArray[2][2]++
					tempStandingsArray[2][3] += AwayWon
					tempStandingsArray[2][4] += HomeWon
					tempStandingsArray[2][5] += TieGame
					tempStandingsArray[2][7] += tempArray[i][5]
					tempStandingsArray[2][8] += tempArray[i][6]
					break
				case "The Bridge":
					tempStandingsArray[3][2]++
					tempStandingsArray[3][3] += AwayWon
					tempStandingsArray[3][4] += HomeWon
					tempStandingsArray[3][5] += TieGame
					tempStandingsArray[3][7] += tempArray[i][5]
					tempStandingsArray[3][8] += tempArray[i][6]
					break
				case "Church of the Resurrection":
					tempStandingsArray[4][2]++
					tempStandingsArray[4][3] += AwayWon
					tempStandingsArray[4][4] += HomeWon
					tempStandingsArray[4][5] += TieGame
					tempStandingsArray[4][7] += tempArray[i][5]
					tempStandingsArray[4][8] += tempArray[i][6]
					break
				case "Metropolitan Bible Church":
					tempStandingsArray[5][2]++
					tempStandingsArray[5][3] += AwayWon
					tempStandingsArray[5][4] += HomeWon
					tempStandingsArray[5][5] += TieGame
					tempStandingsArray[5][7] += tempArray[i][5]
					tempStandingsArray[5][8] += tempArray[i][6]
					break
				case "Nepean Baptist Church":
					tempStandingsArray[6][2]++
					tempStandingsArray[6][3] += AwayWon
					tempStandingsArray[6][4] += HomeWon
					tempStandingsArray[6][5] += TieGame
					tempStandingsArray[6][7] += tempArray[i][5]
					tempStandingsArray[6][8] += tempArray[i][6]
					break
				case "Ottawa Chinese Bible Church":
					tempStandingsArray[7][2]++
					tempStandingsArray[7][3] += AwayWon
					tempStandingsArray[7][4] += HomeWon
					tempStandingsArray[7][5] += TieGame
					tempStandingsArray[7][7] += tempArray[i][5]
					tempStandingsArray[7][8] += tempArray[i][6]
					break
				case "Sunnyside Stingers":
					tempStandingsArray[8][2]++
					tempStandingsArray[8][3] += AwayWon
					tempStandingsArray[8][4] += HomeWon
					tempStandingsArray[8][5] += TieGame
					tempStandingsArray[8][7] += tempArray[i][5]
					tempStandingsArray[8][8] += tempArray[i][6]
					break
				case "Woodvale Pentecostal":
					tempStandingsArray[9][2]++
					tempStandingsArray[9][3] += AwayWon
					tempStandingsArray[9][4] += HomeWon
					tempStandingsArray[9][5] += TieGame
					tempStandingsArray[9][7] += tempArray[i][5]
					tempStandingsArray[9][8] += tempArray[i][6]
					break
			}

			// Process Home Team
			switch(tempArray[i][2]) {
				case "Arlington Woods":
					tempStandingsArray[0][2]++
					tempStandingsArray[0][3] += HomeWon
					tempStandingsArray[0][4] += AwayWon
					tempStandingsArray[0][5] += TieGame
					tempStandingsArray[0][7] += tempArray[i][6]
					tempStandingsArray[0][8] += tempArray[i][5]
					break
				case "Bethel Hawks":
					tempStandingsArray[1][2]++
					tempStandingsArray[1][3] += HomeWon
					tempStandingsArray[1][4] += AwayWon
					tempStandingsArray[1][5] += TieGame
					tempStandingsArray[1][7] += tempArray[i][6]
					tempStandingsArray[1][8] += tempArray[i][5]
					break
				case "Bethel Rock":
					tempStandingsArray[2][2]++
					tempStandingsArray[2][3] += HomeWon
					tempStandingsArray[2][4] += AwayWon
					tempStandingsArray[2][5] += TieGame
					tempStandingsArray[2][7] += tempArray[i][6]
					tempStandingsArray[2][8] += tempArray[i][5]
					break
				case "The Bridge":
					tempStandingsArray[3][2]++
					tempStandingsArray[3][3] += HomeWon
					tempStandingsArray[3][4] += AwayWon
					tempStandingsArray[3][5] += TieGame
					tempStandingsArray[3][7] += tempArray[i][6]
					tempStandingsArray[3][8] += tempArray[i][5]
					break
				case "Church of the Resurrection":
					tempStandingsArray[4][2]++
					tempStandingsArray[4][3] += HomeWon
					tempStandingsArray[4][4] += AwayWon
					tempStandingsArray[4][5] += TieGame
					tempStandingsArray[4][7] += tempArray[i][6]
					tempStandingsArray[4][8] += tempArray[i][5]
					break
				case "Metropolitan Bible Church":
					tempStandingsArray[5][2]++
					tempStandingsArray[5][3] += HomeWon
					tempStandingsArray[5][4] += AwayWon
					tempStandingsArray[5][5] += TieGame
					tempStandingsArray[5][7] += tempArray[i][6]
					tempStandingsArray[5][8] += tempArray[i][5]
					break
				case "Nepean Baptist Church":
					tempStandingsArray[6][2]++
					tempStandingsArray[6][3] += HomeWon
					tempStandingsArray[6][4] += AwayWon
					tempStandingsArray[6][5] += TieGame
					tempStandingsArray[6][7] += tempArray[i][6]
					tempStandingsArray[6][8] += tempArray[i][5]
					break
				case "Ottawa Chinese Bible Church":
					tempStandingsArray[7][2]++
					tempStandingsArray[7][3] += HomeWon
					tempStandingsArray[7][4] += AwayWon
					tempStandingsArray[7][5] += TieGame
					tempStandingsArray[7][7] += tempArray[i][6]
					tempStandingsArray[7][8] += tempArray[i][5]
					break
				case "Sunnyside Stingers":
					tempStandingsArray[8][2]++
					tempStandingsArray[8][3] += HomeWon
					tempStandingsArray[8][4] += AwayWon
					tempStandingsArray[8][5] += TieGame
					tempStandingsArray[8][7] += tempArray[i][6]
					tempStandingsArray[8][8] += tempArray[i][5]
					break
				case "Woodvale Pentecostal":
					tempStandingsArray[9][2]++
					tempStandingsArray[9][3] += HomeWon
					tempStandingsArray[9][4] += AwayWon
					tempStandingsArray[9][5] += TieGame
					tempStandingsArray[9][7] += tempArray[i][6]
					tempStandingsArray[9][8] += tempArray[i][5]
					break
			}

			//Calculate "Win %"
			//var WinPct = standingsArray[i][3] / standingsArray[i][2]
			//standingsArray[i][6] = WinPct.toFixed(3)
		}
	}

	// Calculate "Win Pct" & "Runs Differential"
	for (i=0;i<tempStandingsArray.length;i++)
	{
		if (tempStandingsArray[i][2] > 0)
		{
			var WinPct = (tempStandingsArray[i][3] + (tempStandingsArray[i][5]/2)) / tempStandingsArray[i][2];
			tempStandingsArray[i][6] = WinPct.toFixed(3);
		}
		else {
			var WinPct = 0.000;
			tempStandingsArray[i][6] = WinPct.toFixed(3);
		}
		tempStandingsArray[i][9] = tempStandingsArray[i][7] - tempStandingsArray[i][8];
	}

	// Calculate standings order
	// --Sort by Runs Differential, descending order
	//sortColDesc(tempStandingsArray,9);
	// --Sort by WinPct, descending order
	//sortColDesc(tempStandingsArray,6);
	// --Sort by Run Differential, if needed
//	for (i=0;i<(tempStandingsArray.length - 1);i++)
//	{
//		for (j=i+1;j<tempStandingsArray.length;j++)
//		{
//			// if i & j have equal WinPct and # of wins
//			if (tempStandingsArray[i][3]==tempStandingsArray[j][3] && tempStandingsArray[i][6]==tempStandingsArray[j][6])
//			{
//				var diffI = tempStandingsArray[i][9];
//				var diffJ = tempStandingsArray[j][9];
//				// compare RunsFor - RunsAgainst differential; higher moves up standings
//				if ((diffI < diffJ && diffI > 0) || (Math.abs(diffI) >= Math.abs(diffJ) && diffI < 0 && diffJ < 0))
//				{
//					swapRows(tempStandingsArray,i,j,tempStandingsArray.length);
//				}
//				//else if (diffI < 0 && diffJ < 0 && (Math.abs(diffI) >= Math.abs(diffJ)))
//				//{
//				//}
//			}
//		}
//	}

	// sort with comparator: WinPct then RunsDifferential
	tempStandingsArray.sort(compareFields)

}

function buildplayoffSixStandings(tempArray, tempStandingsArray) {
	// Go through all games played and build standings
	for (i=0;i<tempArray.length;i++)
	{
		if ((tempArray[i][4] != "C") && (tempArray[i][4] != "S")) // if games not Cancelled or still Scheduled
		{
			var AwayWon = 0;
			var HomeWon = 0;
			var TieGame = 0;
			switch(tempArray[i][4]) {
				case "H":	// home team won
					HomeWon++
					break
				case "A":	// away team won
					AwayWon++
					break
				case "T":	// tie game
					TieGame++
					break
			}

			//Process Away Team
			switch(tempArray[i][1]) {
				case "Church of the Resurrection":
					tempStandingsArray[0][2]++
					tempStandingsArray[0][3] += AwayWon
					tempStandingsArray[0][4] += HomeWon
					tempStandingsArray[0][5] += TieGame
					tempStandingsArray[0][7] += tempArray[i][5]
					tempStandingsArray[0][8] += tempArray[i][6]
					break
				case "Sunnyside Stingers":
					tempStandingsArray[1][2]++
					tempStandingsArray[1][3] += AwayWon
					tempStandingsArray[1][4] += HomeWon
					tempStandingsArray[1][5] += TieGame
					tempStandingsArray[1][7] += tempArray[i][5]
					tempStandingsArray[1][8] += tempArray[i][6]
					break
				case "Nepean Baptist Church":
					tempStandingsArray[2][2]++
					tempStandingsArray[2][3] += AwayWon
					tempStandingsArray[2][4] += HomeWon
					tempStandingsArray[2][5] += TieGame
					tempStandingsArray[2][7] += tempArray[i][5]
					tempStandingsArray[2][8] += tempArray[i][6]
					break
				case "Arlington Woods":
					tempStandingsArray[3][2]++
					tempStandingsArray[3][3] += AwayWon
					tempStandingsArray[3][4] += HomeWon
					tempStandingsArray[3][5] += TieGame
					tempStandingsArray[3][7] += tempArray[i][5]
					tempStandingsArray[3][8] += tempArray[i][6]
					break
				case "Metropolitan Bible Church":
					tempStandingsArray[4][2]++
					tempStandingsArray[4][3] += AwayWon
					tempStandingsArray[4][4] += HomeWon
					tempStandingsArray[4][5] += TieGame
					tempStandingsArray[4][7] += tempArray[i][5]
					tempStandingsArray[4][8] += tempArray[i][6]
					break
				case "Ottawa Chinese Bible Church":
					tempStandingsArray[5][2]++
					tempStandingsArray[5][3] += AwayWon
					tempStandingsArray[5][4] += HomeWon
					tempStandingsArray[5][5] += TieGame
					tempStandingsArray[5][7] += tempArray[i][5]
					tempStandingsArray[5][8] += tempArray[i][6]
					break
			}

			// Process Home Team
			switch(tempArray[i][2]) {
				case "Church of the Resurrection":
					tempStandingsArray[0][2]++
					tempStandingsArray[0][3] += HomeWon
					tempStandingsArray[0][4] += AwayWon
					tempStandingsArray[0][5] += TieGame
					tempStandingsArray[0][7] += tempArray[i][6]
					tempStandingsArray[0][8] += tempArray[i][5]
					break
				case "Sunnyside Stingers":
					tempStandingsArray[1][2]++
					tempStandingsArray[1][3] += HomeWon
					tempStandingsArray[1][4] += AwayWon
					tempStandingsArray[1][5] += TieGame
					tempStandingsArray[1][7] += tempArray[i][6]
					tempStandingsArray[1][8] += tempArray[i][5]
					break
				case "Napean Baptist Church":
					tempStandingsArray[2][2]++
					tempStandingsArray[2][3] += HomeWon
					tempStandingsArray[2][4] += AwayWon
					tempStandingsArray[2][5] += TieGame
					tempStandingsArray[2][7] += tempArray[i][6]
					tempStandingsArray[2][8] += tempArray[i][5]
					break
				case "Arlington Woods":
					tempStandingsArray[3][2]++
					tempStandingsArray[3][3] += HomeWon
					tempStandingsArray[3][4] += AwayWon
					tempStandingsArray[3][5] += TieGame
					tempStandingsArray[3][7] += tempArray[i][6]
					tempStandingsArray[3][8] += tempArray[i][5]
					break
				case "Metropolitan Bible Church":
					tempStandingsArray[4][2]++
					tempStandingsArray[4][3] += HomeWon
					tempStandingsArray[4][4] += AwayWon
					tempStandingsArray[4][5] += TieGame
					tempStandingsArray[4][7] += tempArray[i][6]
					tempStandingsArray[4][8] += tempArray[i][5]
					break
				case "Ottawa Chinese Bible Church":
					tempStandingsArray[5][2]++
					tempStandingsArray[5][3] += HomeWon
					tempStandingsArray[5][4] += AwayWon
					tempStandingsArray[5][5] += TieGame
					tempStandingsArray[5][7] += tempArray[i][6]
					tempStandingsArray[5][8] += tempArray[i][5]
					break
			}
		}
	}

	// Calculate "Win Pct" and "Runs Differential"
	for (i=0;i<tempStandingsArray.length;i++)
	{
		if (tempStandingsArray[i][2] > 0)
		{
			var WinPct = (tempStandingsArray[i][3] + (tempStandingsArray[i][5]/2)) / tempStandingsArray[i][2];
			tempStandingsArray[i][6] = WinPct.toFixed(3);
		}
		else {
			var WinPct = 0.000;
			tempStandingsArray[i][6] = WinPct.toFixed(3);
		}
		tempStandingsArray[i][9] = tempStandingsArray[i][7] - tempStandingsArray[i][8];
	}

	// sort with comparator: WinPct then RunsDifferential
	tempStandingsArray.sort(comparePlayoffFields)

//	// Calculate standings order
//	// --Sort by Regular Season Standings, ascending order
//	sortCol(tempStandingsArray,10);
//	// --Sort by Runs Differential, descending order
//	sortColDesc(tempStandingsArray,9);
//	// --Sort by WinPct, descending order
//	sortColDesc(tempStandingsArray,6);

//	// --Sort by Run Differential, if needed
//	for (i=0;i<(tempStandingsArray.length - 1);i++)
//	{
//		for (j=i+1;j<tempStandingsArray.length;j++)
//		{
//			// if i & j have equal WinPct and # of wins
//			if (tempStandingsArray[i][3]==tempStandingsArray[j][3] && tempStandingsArray[i][6]==tempStandingsArray[j][6])
//			{
//				var diffI = tempStandingsArray[i][9];
//				var diffJ = tempStandingsArray[j][9];
//				// compare RunsFor - RunsAgainst differential; higher moves up standings
//				if (i != j && ((diffI < diffJ && diffI > 0) || (Math.abs(diffI) >= Math.abs(diffJ) && diffI < 0 && diffJ < 0)))
//				{
//					swapRows(tempStandingsArray,i,j,tempStandingsArray.length);
//				}
//			}
//		}
//	}
}

function buildplayoffFourStandings(tempArray, tempStandingsArray) {
	// Go through all games played and build standings
	for (i=0;i<tempArray.length;i++)
	{
		if ((tempArray[i][4] != "C") && (tempArray[i][4] != "S")) // if games not Cancelled or still Scheduled
		{
			var AwayWon = 0;
			var HomeWon = 0;
			var TieGame = 0;
			switch(tempArray[i][4]) {
				case "H":	// home team won
					HomeWon++
					break
				case "A":	// away team won
					AwayWon++
					break
				case "T":	// tie game
					TieGame++
					break
			}

			//Process Away Team
			switch(tempArray[i][1]) {
				case "Bethel Hawks":
					tempStandingsArray[0][2]++
					tempStandingsArray[0][3] += AwayWon
					tempStandingsArray[0][4] += HomeWon
					tempStandingsArray[0][5] += TieGame
					tempStandingsArray[0][7] += tempArray[i][5]
					tempStandingsArray[0][8] += tempArray[i][6]
					break
				case "Woodvale Pentecostal":
					tempStandingsArray[1][2]++
					tempStandingsArray[1][3] += AwayWon
					tempStandingsArray[1][4] += HomeWon
					tempStandingsArray[1][5] += TieGame
					tempStandingsArray[1][7] += tempArray[i][5]
					tempStandingsArray[1][8] += tempArray[i][6]
					break
				case "The Bridge":
					tempStandingsArray[2][2]++
					tempStandingsArray[2][3] += AwayWon
					tempStandingsArray[2][4] += HomeWon
					tempStandingsArray[2][5] += TieGame
					tempStandingsArray[2][7] += tempArray[i][5]
					tempStandingsArray[2][8] += tempArray[i][6]
					break
				case "Bethel Rock":
					tempStandingsArray[3][2]++
					tempStandingsArray[3][3] += AwayWon
					tempStandingsArray[3][4] += HomeWon
					tempStandingsArray[3][5] += TieGame
					tempStandingsArray[3][7] += tempArray[i][5]
					tempStandingsArray[3][8] += tempArray[i][6]
					break
			}

			// Process Home Team
			switch(tempArray[i][2]) {
				case "Bethel Hawks":
					tempStandingsArray[0][2]++
					tempStandingsArray[0][3] += HomeWon
					tempStandingsArray[0][4] += AwayWon
					tempStandingsArray[0][5] += TieGame
					tempStandingsArray[0][7] += tempArray[i][6]
					tempStandingsArray[0][8] += tempArray[i][5]
					break
				case "Woodvale Pentecostal":
					tempStandingsArray[1][2]++
					tempStandingsArray[1][3] += HomeWon
					tempStandingsArray[1][4] += AwayWon
					tempStandingsArray[1][5] += TieGame
					tempStandingsArray[1][7] += tempArray[i][6]
					tempStandingsArray[1][8] += tempArray[i][5]
					break
				case "The Bridge":
					tempStandingsArray[2][2]++
					tempStandingsArray[2][3] += HomeWon
					tempStandingsArray[2][4] += AwayWon
					tempStandingsArray[2][5] += TieGame
					tempStandingsArray[2][7] += tempArray[i][6]
					tempStandingsArray[2][8] += tempArray[i][5]
					break
				case "Bethel Rock":
					tempStandingsArray[3][2]++
					tempStandingsArray[3][3] += HomeWon
					tempStandingsArray[3][4] += AwayWon
					tempStandingsArray[3][5] += TieGame
					tempStandingsArray[3][7] += tempArray[i][6]
					tempStandingsArray[3][8] += tempArray[i][5]
					break
			}
		}
	}

	// Calculate "Win Pct" and "Runs Differential"
	for (i=0;i<tempStandingsArray.length;i++)
	{
		if (tempStandingsArray[i][2] > 0)
		{
			var WinPct = (tempStandingsArray[i][3] + (tempStandingsArray[i][5]/2)) / tempStandingsArray[i][2];
			tempStandingsArray[i][6] = WinPct.toFixed(3);
		}
		else {
			var WinPct = 0.000;
			tempStandingsArray[i][6] = WinPct.toFixed(3);
		}
		tempStandingsArray[i][9] = tempStandingsArray[i][7] - tempStandingsArray[i][8];
	}

	// sort with comparator: WinPct then RunsDifferential
	tempStandingsArray.sort(comparePlayoffFields)

//	// Calculate standings order
//	// --Sort by Regular Season Standings, ascending order
//	sortCol(tempStandingsArray,10);
//	// --Sort by Runs Differential, descending order
//	sortColDesc(tempStandingsArray,9);
//	// --Sort by WinPct, descending order
//	sortColDesc(tempStandingsArray,6);
//	// --Sort by Run Differential, if needed
//	for (i=0;i<(tempStandingsArray.length - 1);i++)
//	{
//		for (j=i+1;j<tempStandingsArray.length;j++)
//		{
//			// if i & j have equal WinPct and # of wins
//			if (tempStandingsArray[i][3]==tempStandingsArray[j][3] && tempStandingsArray[i][6]==tempStandingsArray[j][6])
//			{
//				var diffI = tempStandingsArray[i][9];
//				var diffJ = tempStandingsArray[j][9];
//				// compare RunsFor - RunsAgainst differential; higher moves up standings
//				if (i != j && ((diffI < diffJ && diffI > 0) || (Math.abs(diffI) >= Math.abs(diffJ) && diffI < 0 && diffJ < 0)))
//				{
//					swapRows(tempStandingsArray,i,j,tempStandingsArray.length);
//				}
//			}
//		}
//	}
}

function displayStandings(tempArray)
{
	document.write('<table border="0" cellspacing="0" cellpadding="0" width="465">')
	document.write('<tr bgcolor="#000066">')
	document.write('<td width="10"><img height="1" src="images/1by1trans.gif" width="10"></td>')
	document.write('<th width="180" class="table_header_left" align="left"><font color="ffffff">Team&nbsp;</font></th>')
	document.write('<th width="30" class="table_header"> GP </th>')
	document.write('<th width="30" class="table_header"> W </th>')
	document.write('<th width="30" class="table_header"> L </th>')
	document.write('<th width="30" class="table_header"> T </th>')
	document.write('<th width="55" class="table_header"> Win Pct </th>')
	document.write('<th width="30" class="table_header"> RF </th>')
	document.write('<th width="30" class="table_header"> RA </th>')
	document.write('<th width="35" class="table_header"> Diff </th>')
	document.write('<td width="2" nowrap class="table_header">&nbsp;&nbsp;</td>')
	document.write('</tr>')
	for (i=0;i<tempArray.length;i++)
	{
		//// Calculate "Win %"
		//var WinPct = tempArray[i][3] / tempArray[i][2]
		//tempArray[i][6] = WinPct.toFixed(3)

		if (i%2)
		{
			document.write('<tr bgcolor="#CCCCCC">')
		}
		else
		{
			document.write('<tr bgcolor="#FFFFFF">')
		}
		document.write('<td><img height="1" src="images/1by1trans.gif" width="10"></td>')
		document.write('<td>' + tempArray[i][1] + '</td>')
		document.write('<td class="table_cell">' + tempArray[i][2] + '</td>')
		document.write('<td class="table_cell">' + tempArray[i][3] + '</td>')
		document.write('<td class="table_cell">' + tempArray[i][4] + '</td>')
		document.write('<td class="table_cell">' + tempArray[i][5] + '</td>')
		document.write('<td class="table_cell">' + tempArray[i][6] + '</td>')
		document.write('<td class="table_cell">' + tempArray[i][7] + '</td>')
		document.write('<td class="table_cell">' + tempArray[i][8] + '</td>')
		document.write('<td class="table_cell">' + tempArray[i][9] + '</td>')
		document.write('<td nowrap class="table_cell">&nbsp;&nbsp;</td>')
		document.write('</tr>')
		//document.write(tempArray[i])
		//document.write('<br>')
	}
	document.write('<tr valign="top"><td colspan="11" bgcolor="000066" height="2"></td></tr>')
	document.write('</table>')
}

function getShortName(teamName)
{
	var shortName
	switch(teamName) {
		case "Arlington Woods":
			shortName="A. Woods"
			break
		case "Bethel Hawks":
			shortName="B. Hawks"
			break
		case "Bethel Rock":
			shortName="B. Rock"
			break
		case "Church of the Resurrection":
			shortName="COR"
			break
		case "Metropolitan Bible Church":
			shortName="The Met"
			break
		case "Nepean Baptist Church":
			shortName="NBC"
			break
		case "Ottawa Chinese Bible Church":
			shortName="OCBC"
			break
		case "Sunnyside Stingers":
			shortName="Sunnyside"
			break
		case "The Bridge":
			shortName="Bridge"
			break
		case "Woodvale Pentecostal":
			shortName="Woodvale"
			break
	}
	return shortName
}

function displayUpcomingGames()
{
	// Regular Season upcoming games
	var i=0
	while (i < scheduleArray.length)
	{
		if (scheduleArray[i][0] == nextGameDate)
		{
			break
		}
		else
		{
			i++
		}
	}
	if (i < scheduleArray.length)
	{
		document.write('<b>Friday, ' + nextGameDate + '</b><br>')
		while (scheduleArray[i][0] == nextGameDate)
		{
			var AwayShortName = getShortName(scheduleArray[i][1])
			var HomeShortName = getShortName(scheduleArray[i][2])
			document.write(AwayShortName + ' @ ' + HomeShortName + ' (<a href="locations.html#' + scheduleArray[i][3] + '">' + scheduleArray[i][3] + '</a>)<br>')
			i++
		}
		document.write('<br>')
	}

	// Playoff A upcoming games
	var k=0
	while (k < playoffFourArray.length)
	{
		if (playoffFourArray[k][0] == nextGameDate)
		{
			break
		}
		else
		{
			k++
		}
	}
	if (k < playoffFourArray.length)
	{
		document.write('<b><u>DIVISION A Playoff Games</u></b><br><br>')
		document.write('<b>' + nextGameDate + '</b><br>')
		while (playoffFourArray[k][0] == nextGameDate)
		{
			var AwayShortName = getShortName(playoffFourArray[k][1])
			var HomeShortName = getShortName(playoffFourArray[k][2])
			document.write(AwayShortName + ' @ ' + HomeShortName + ' (<a href="locations.html#' + playoffFourArray[k][3] + '">' + playoffFourArray[k][3] + '</a>)<br>')
			k++
		}
		document.write('<br>')
	}

	// Playoff B upcoming games
	var j=0
	while (j < playoffSixArray.length)
	{
		if (playoffSixArray[j][0] == nextGameDate)
		{
			break
		}
		else
		{
			j++
		}
	}
	if (j < playoffSixArray.length)
	{
		document.write('<b><u>DIVISION B Playoff Games</u></b><br><br>')
		document.write('<b>' + nextGameDate + '</b><br>')
		while (playoffSixArray[j][0] == nextGameDate)
		{
			var AwayShortName = getShortName(playoffSixArray[j][1])
			var HomeShortName = getShortName(playoffSixArray[j][2])
			document.write(AwayShortName + ' @ ' + HomeShortName + ' (<a href="locations.html#' + playoffSixArray[j][3] + '">' + playoffSixArray[j][3] + '</a>)<br>')
			j++
		}
		document.write('<br>')
	}

}

function displayRecentScores(tempArray)
{
	var i=0
	while (i < tempArray.length)
	{
		if (tempArray[i][0] == recentPlayedDate)
		{
			break
		}
		else
		{
			i++
		}
	}
	if (i < tempArray.length)
	{
		document.write('<b>' + recentPlayedDate + '</b><br>')
		while ((i < tempArray.length) && (tempArray[i][0] == recentPlayedDate))
		{
			var AwayShortName = getShortName(tempArray[i][1])
			var HomeShortName = getShortName(tempArray[i][2])
			if (tempArray[i][4] == "C")
			{
				document.write(AwayShortName + ' @ ' + HomeShortName + ' - CANCELLED<br>')
			}
			else if (tempArray[i][4] == "S")
			{
				document.write(AwayShortName + ' @ ' + HomeShortName + ' - AWAITING SCORE<br>')
			}
			else if (tempArray[i][4] == "H")
			{
				document.write(HomeShortName + ' ' + tempArray[i][6] + ', ' + AwayShortName + ' ' + tempArray[i][5] + '<br>')
			}
			else
			{
				document.write(AwayShortName + ' ' + tempArray[i][5] + ', ' + HomeShortName + ' ' + tempArray[i][6] + '<br>')
			}
			i++
		}
	}
}

function displaySeasonSchedule(tempArray)
{
	document.write('<TABLE CELLSPACING="0" CELLPADDING="2">')
	document.write('<TR BGCOLOR="#AAAAAA">')
	document.write('<TH width="150" align="left">DATE</TH>')
	document.write('<TH width="180" align="left">AWAY TEAM</TH>')
	document.write('<TH width="180" align="left">HOME TEAM</TH>')
	document.write('<TH width="100" align="left">LOCATION</TH>')
	document.write('</TR>')
	var currentPlayDate = tempArray[0][0]
	var sectionCounter = 0
	for (i=0;i<tempArray.length;i++)
	{
		if (currentPlayDate != tempArray[i][0])
		{
			sectionCounter++
			currentPlayDate = tempArray[i][0]
		}

		if (sectionCounter%2)
		{
			document.write('<TR class="tablerow_alt">')
		}
		else
		{
			document.write('<TR>')
		}
		document.write('<TD>' + tempArray[i][0] + '</TD>')
		document.write('<TD>' + tempArray[i][1] + '</TD>')
		document.write('<TD>' + tempArray[i][2] + '</TD>')
		document.write('<TD>' + tempArray[i][3] + '</TD>')
		document.write('</TR>')
	}
	document.write('</TABLE>')
}

function displaySeasonScores(tempArray)
{
	document.write('<TABLE width="100%" CELLSPACING="0" CELLPADDING="2">')
	document.write('<TR BGCOLOR="#AAAAAA">')
	document.write('<TH WIDTH="140">DATE</TH>')
	document.write('<TH WIDTH="150">AWAY TEAM</TH>')
	document.write('<TH WIDTH="150">HOME TEAM</TH>')
	document.write('<TH ALIGN="center"> SCORE </TH>')
//	document.write('<TH>WINNER</TH>')
	document.write('<TD>&nbsp;&nbsp;</TD>')
	document.write('<TD><B>GAME COMMENTS</B></TH>')
	document.write('</TR>')
	var currentPlayDate = tempArray[0][0]
	var sectionCounter = 0
	for (i=0;i<tempArray.length;i++)
	{
		if (currentPlayDate != tempArray[i][0])
		{
			sectionCounter++
			currentPlayDate = tempArray[i][0]
		}

		if (sectionCounter%2)
		{
			document.write('<TR class="tablerow_alt">')
		}
		else
		{
			document.write('<TR>')
		}
		document.write('<TD valign="top">' + tempArray[i][0] + '</TD>')  // Date
		document.write('<TD valign="top">' + tempArray[i][1] + '</TD>')  // name of Away Team
		document.write('<TD valign="top">' + tempArray[i][2] + '</TD>')  // name of Home Team
		if (tempArray[i][4] == "S")  // score
		{
			document.write('<TD></TD>')
		}
		else if (tempArray[i][4] == "C")
		{
			document.write('<TD ALIGN="center" valign="top" nowrap>0 - 0</TD>')
		}
		else
		{
			document.write('<TD ALIGN="center" valign="top" nowrap>' + tempArray[i][5] + ' - ' + tempArray[i][6] + '</TD>')
		}

//		if (tempArray[i][4] == "H")  // winner
//		{
//			document.write('<TD>Home</TD>')
//		}
//		else if (tempArray[i][4] == "A")
//		{
//			document.write('<TD>Away</TD>')
//		}
//		else if (tempArray[i][4] == "T")
//		{
//			document.write('<TD>Tie</TD>')
//		}
//		else
//		{
//			document.write('<TD></TD>')
//		}

		document.write('<TD>&nbsp;&nbsp;</TD>')
		if (tempArray[i][7].length > 0)  // game comments
		{
			document.write('<TD>' + tempArray[i][7] + '</TD>')
		}
		else
		{
			document.write('<TD></TD>')
		}
		document.write('</TR>')
	}
	document.write('</TABLE>')
}


function displayMobileStandings(tempArray)
{
	document.write('<table border="1" cellspacing="0" cellpadding="0">')
	document.write('<tr bgcolor="#000066">')
	document.write('<th class="table_header_left" align="left"><font color="ffffff">Team&nbsp;</font></th>')
	document.write('<th class="table_header"> GP </th>')
	document.write('<th class="table_header"> W </th>')
	document.write('<th class="table_header"> L </th>')
	document.write('<th class="table_header"> T </th>')
	document.write('<th class="table_header"> WinPct </th>')
	document.write('<th class="table_header"> RF </th>')
	document.write('<th class="table_header"> RA </th>')
	document.write('<th class="table_header"> Diff </th>')
	document.write('</tr>')
	for (i=0;i<tempArray.length;i++)
	{
		//// Calculate "Win %"
		//var WinPct = tempArray[i][3] / tempArray[i][2]
		//tempArray[i][6] = WinPct.toFixed(3)

		if (i%2)
		{
			document.write('<tr bgcolor="#CCCCCC">')
		}
		else
		{
			document.write('<tr bgcolor="#FFFFFF">')
		}
		document.write('<td>' + getShortName(tempArray[i][1]) + '</td>')
		document.write('<td class="table_cell">' + tempArray[i][2] + '</td>')
		document.write('<td class="table_cell">' + tempArray[i][3] + '</td>')
		document.write('<td class="table_cell">' + tempArray[i][4] + '</td>')
		document.write('<td class="table_cell">' + tempArray[i][5] + '</td>')
		document.write('<td class="table_cell">' + tempArray[i][6] + '</td>')
		document.write('<td class="table_cell">' + tempArray[i][7] + '</td>')
		document.write('<td class="table_cell">' + tempArray[i][8] + '</td>')
		document.write('<td class="table_cell">' + tempArray[i][9] + '</td>')
		document.write('</tr>')
		//document.write(tempArray[i])
		//document.write('<br>')
	}
	document.write('</table>')
}
