var fontTag		= "<font face='Verdana,Sans-Serif'>";
var clFT		= "</font>";
var normalFT		= fontTag + "<font size=2 color=#000000>";
var clNormalFT		= "</font>" + clFT;
var linkFT		= fontTag + "<font size=2 color=#0033cc>";
var clLinkFT		= "</font>" + clFT;
var titleFT 		= fontTag + "<font size=2 color=FFFFFF><b>";
var clTitleFT		= "</b></font>" + clFT;
var smtitleFT 		= fontTag + "<font size=2 color=FFFFFF><b>";
var clSmTitleFT		= "</b></font>" + clFT;
var bonesFT		= "<font face='Verdana,Sans-Serif' color=#666666 size=1>";
var clBonesFT		= "</font>";
var scoresFT		= fontTag + "<font size=5><b>";
var clScoresFT		= "</b></font>" + clFT;
var arrowURL			= "&nbsp;<img src=http://ak.imgfarm.com/images/sports/winners_arrow.gif border=0 height=9 width=9 alt=''>";
var noBoxLink		= false;
var noTeamLink		= false;
var periodName = "";
function siteText(text) {
	return text;
}
function getPeriodName(period, max_period) {
	var ret_val;
	if (max_period == "") max_period = 10000;
	if (isNaN(period)) { return period; }
	return period;
}
function setIndices() {
	SB_GAMECODE	= 0; SB_DAY	= 1;
	SB_DATESTRING	= 2; SB_DATE	= 2;
	SB_H1		= 4; SB_MIN1	= 5;
	SB_MINUTE	= 8; SB_PERIOD	= 9;
	SB_SECOND	= 10;SB_STATUS	= 11;
	SB_HALIAS	= 12;SB_HCITY	= 13;
	SB_HNAME	= 14;SB_HID	= 15;
	SB_VALIAS	= 16;SB_VCITY	= 17;
	SB_VNAME	= 18;SB_VID	= 19;
	SB_VDIVISION	= 0; SB_HDIVISION	= 0;
	SB_VRANK	= 0; SB_HRANK	= 0;
	SB_SCORE_DATE1  = 20;SB_SCORES  = 33;
	SB_SKIP		= 3; EXTRA_COLS = 2;
	periodName = "Period";
		SB_DATE		= 2;
		SB_PERIOD	= 8; SB_STATUS  = 9;
		SB_HALIAS	= 10;SB_HCITY	= 11;
		SB_HNAME	= 12;SB_HID	= 13;
		SB_VALIAS	= 15;SB_VCITY	= 16;
		SB_VNAME	= 17;SB_VID	= 18;
		SB_SCORE_DATE1  = 21;SB_RHE	= 26;
		SB_TIME_OF_GAME_HOURS	= 19;
		SB_TIME_OF_GAME_MINUTES	= 20;
		SB_ATTENDANCE		= 22;
		EXTRA_COLS = 3; MAX_PERIODS = 9;
		periodName = "Inning";
}
function fixTeamNames(alias, city, name) {
	if (alias == 'NYY') return "NY Yankees";
	if (alias == 'NYM') return "NY Mets";
	if (alias == 'CWS') return "Chicago WS";
	if (alias == 'ChC') return "Chicago Cubs";
	if (alias == 'LAD') return "LA Dodgers";
	if (alias == 'LAA') return "LA Angels";
	if (alias == 'ALS') { noTeamLink = true; return "AL All-Stars"; }
	if (alias == 'NLS') { noTeamLink = true; return "NL All-Stars"; }
	return city + " " + name;
  }
function teamRow(city, name, t1a3, gameOver, periods, scores,  winning, total, runs, hits, errors, division, rank  ) {
	var retHTML = "<tr bgcolor=#e2e2e2><td width=50%>" + normalFT;
	if (!noTeamLink)
	retHTML += '' + "<a href='/mlb/teams/"+ t1a3.toLowerCase() + "/index.html'><font color=#0033cc>";
	retHTML += "<b>" + city + " " + name + "</b>";
	if (!noTeamLink)
	retHTML += "</font></a>";
	 if ((gameOver == 1) && (winning))
		retHTML += arrowURL;
	retHTML += "</td>";
	for (i=1;i<=periods;i++) {
		retHTML += "<td align=" + align + ">" + normalFT + scores[i] + "</td>";
	}
		retHTML += "<td align=" + align + ">" + normalFT + "<b>" + runs + "</b></font></td>";
		retHTML += "<td align=" + align + ">" + normalFT + "<b>" + hits + "</b></font></td>";
		retHTML += "<td align=" + align + ">" + normalFT + "<b>" + errors + "</b></font></td>";
	retHTML += "</tr>";
	return retHTML;
}
var h_team_id;
var v_team_id;
var attendance;
var whichTeam = new Array(2);
var align="center"; 
function drawBreakdownScoreboard(showHeader, where) {
	var output = "";
	// First check for the existence of sport_scoreboard
	vartype = typeof mlb_scoreboard;
	// If the variable doesn't exist then do nothing
	if (vartype == "undefined") { return;}
	sb = mlb_scoreboard;
	sb = sb[0];
	sb = sb.split("|");
	nav_str = "";
	setIndices();
	//Figure out which is the home team and which is the visiting team
	h_team_id = sb[SB_HID]; 
	v_team_id = sb[SB_VID]; 
	whichTeam[0] = fixTeamNames(sb[SB_HALIAS],  sb[SB_HCITY], sb[SB_HNAME]);
	whichTeam[1] = fixTeamNames(sb[SB_VALIAS],  sb[SB_VCITY], sb[SB_VNAME]);
	periods = 0; maxPeriod = 0;
	HTotal = 0; VTotal = 0;
	HShots = 0; VShots = 0;
	homescores = new Array(); awayscores = new Array();
	homeshots = new Array(); awayshots = new Array();
	awayruns = ""; awayhits = ""; awayerrors = "";
	homeruns = ""; homehits = ""; homeerrors = "";
	var ranked_game;
	if ((sb[SB_HRANK] != "") || (sb[SB_VRANK] != "")) {
	   ranked_game = true;
	}
	for (j=0;j<=MAX_PERIODS;j++) {
		homescores[j] = "&nbsp;"; awayscores[j] = "&nbsp;";
		 homeshots[j] = "&nbsp;"; awayshots[j] = "&nbsp;";
	}
		j=SB_RHE + 1;
		while ((sb[j] != '*') && (j < sb.length)){
			if ((sb[j] == 'runs') || (sb[j] == 'hits') || (sb[j] == 'errors')){
				if (sb[j+1] == sb[SB_HID])
					eval("home" + sb[j] + " = (isNaN(sb[j+2])) ? 0 : sb[j+2];");
				else
					eval("away" + sb[j] + " = (isNaN(sb[j+2])) ? 0 : sb[j+2];");
				j += 2;
			}
			j++;
		}
		j++;
	while (j < sb.length) {
		if (sb[j] == sb[SB_HID])
			homescores[sb[j+1]] = (sb[j+2] == "") ? 0 : sb[j+2];
		else
			awayscores[sb[j+1]] = (sb[j+2] == "") ? 0 : sb[j+2];
		periods = (sb[j+1] > maxPeriod)? sb[j+1] : periods; 
		j += SB_SKIP;
	}
	for(j=0;j<homescores.length;j++)
		HTotal += (isNaN(homescores[j]))? 0 : (homescores[j] - 0);
	for(j=0;j<awayscores.length;j++)
		VTotal += (isNaN(awayscores[j]))? 0 : (awayscores[j] - 0);
	actual_periods = periods;
	if (periods < MAX_PERIODS) periods = MAX_PERIODS;
	lcStatus = sb[SB_STATUS].toLowerCase();
	if ((lcStatus != 'in-progress') && (lcStatus != 'final')) {
		HTotal = "&nbsp;";
		VTotal = "&nbsp;";
	}
	var scorecellwidth = Math.round(60 / ((periods-0) + 3));
	document.write("<table border=0 bgcolor=#ffffff cellpadding=2 cellspacing=1 width=100%>");
	if (showHeader == true) {
		if (HTotal > VTotal) {
			winning_team = sb[SB_HCITY];
			winning_score = HTotal;
			losing_team = sb[SB_VCITY];
			losing_score = VTotal;
		} else {
			winning_team = sb[SB_VCITY];
			winning_score = VTotal;
			losing_team = sb[SB_HCITY];
			losing_score = HTotal;
		}
		winning_score = (winning_score != "&nbsp;") ? " " + winning_score : "";
		losing_score = (losing_score != "&nbsp;") ? " " + losing_score : "";
		document.write("<tr><td colspan=" + (periods+2) +" align=center>" + scoresFT + winning_team + winning_score + ", " + losing_team + losing_score + "</b></font></td></tr>");
		if (lcStatus != 'final')
		document.write("<tr><td colspan=" + (periods+2) +" align=center>" + normalFT + "<font size=+1>" + sb[SB_DAY] + ", " + sb[SB_DATE] + "</font></font></td></tr>");
	}
	if (lcStatus == "pre-game")  {
		slug = getSlug(sb[SB_GAMECODE], 'preview');
		if (slug) {
			nav_str +="<tr><td colspan=" + (periods+2) + ">" + normalFT + '' + "<a href='/news/" + slug + ".html'>" + linkFT + "<b>" + siteText("Preview") + "</b>" + clLinkFT + "</a>" + clNormalFT + "</td></tr>";
		}
	} else {
		nav_str += "<tr><td colspan=" + (periods+2) + ">" + normalFT + '';
		if (where != "box")
			nav_str += "<a href='/mlb/box_scores.html?gid=" + sb[SB_GAMECODE] + "'>" + linkFT + "<b>" + siteText("Box Score") + "</b>" + clLinkFT + "</a>";
		else
			nav_str += "<b>" + siteText("Box Score") + "</b>";
		slug = getSlug(sb[SB_GAMECODE], 'recap');
		if (slug)
			nav_str += " | <a href='/news/" + slug + ".html' target='_top'>" + linkFT + "<b>" + siteText("Recap") + "</b>" + clLinkFT + "</a>";
		if (hasPhotoGal(sb[SB_GAMECODE]) == true) {
			nav_str += " | <a href='/photo_gallery/mlb/" + sb[SB_GAMECODE] + "/images.html'>" + linkFT + "<b>" + siteText("Game Photos") + "</b></b>" + clLinkFT + "</a>";
		}
		  nav_str += " | ";
		  if (where != "log")
			nav_str += "<a href='/mlb/game_logs/" + sb[SB_GAMECODE] + ".html'>" + linkFT + "<b>" + siteText("Game Log") + "</b>" + clLinkFT + "</a>";
		  else
			nav_str += "<b>" + siteText("Game Log") + "</b>";
		nav_str += clNormalFT + "</td></tr>";
	}
	if ((where == "box") || (where == "log")) document.write(nav_str);
	document.write("<tr bgcolor=#002F9C><td>" + smtitleFT + "<b>"); 
	gameOver = 0;
	total_header = "Total";
	if (lcStatus == "final") {
		gameOver = 1;
		document.write(siteText('Final - ' + sb[SB_DATE]));
 		if ((HTotal > VTotal) && (homescores[periods] == "0")) homescores[periods] = "X";
	} else if (lcStatus == "in-progress") {
                 document.write(sb[SB_PERIOD]);
	} else if ((lcStatus == "delayed") || (lcStatus == "postponed")) {
		document.write(siteText(sb[SB_STATUS]));
	} else {
		if ((sb[SB_H1] != "") || (sb[SB_MIN1] != "")) {
			var merid = "AM";
			if (sb[SB_H1] == 12) merid = "PM";
			if ((sb[SB_H1] == 24) || (sb[SB_H1]  == 0)) sb[SB_H1] = 12;
			if (sb[SB_H1] > 12) { sb[SB_H1] -= 12; merid = "PM"; }
			if (sb[SB_MIN1] < 10) sb[SB_MIN1] = "0" + sb[SB_MIN1];
			document.write(sb[SB_H1] + ":" + sb[SB_MIN1] + siteText(merid + " ET"));
		}
	}
	document.write("</b></font></td>");
	for (i=1;i<=periods;i++) {
		document.write("<td align=" + align + ">" + smtitleFT + "<b>" + getPeriodName(i, MAX_PERIODS) + "</b></font></td>");
	}
		document.write("<td align=center width=" + scorecellwidth+ "%>" + smtitleFT + "R" + clTitleFT + "</td>");
		document.write("<td align=center width=" + scorecellwidth+ "%>" + smtitleFT + "H" + clTitleFT + "</td>");
		document.write("<td align=center width=" + scorecellwidth+ "%>" + smtitleFT + "E" + clNormalFT + "</td>");
	var hdiv; var vdiv;
			hdiv = sb[SB_HDIVISION];
			vdiv = sb[SB_VDIVISION];
	var winning = (VTotal > HTotal) ? 1 : 0;
	document.write(teamRow(sb[SB_VCITY], sb[SB_VNAME], sb[SB_VALIAS], gameOver, periods, awayscores,  winning, VTotal, awayruns, awayhits, awayerrors, vdiv, sb[SB_VRANK]));
	winning = (HTotal > VTotal) ? 1 : 0;
	document.write(teamRow(sb[SB_HCITY], sb[SB_HNAME], sb[SB_HALIAS], gameOver, periods, homescores,  winning, HTotal, homeruns, homehits, homeerrors, hdiv, sb[SB_HRANK]));
	if ((where != "box") && (where != "log")) document.write(nav_str);
	document.write("</table>");
}
var TS_WHICH		= 0;
var TS_GAMECODE	= 1;
var TS_TEAMCODE	= 2;
var TS_FIRST_NAME	= 3;
var TS_LAST_NAME	= 4;
var TS_POSITION	= 5;
var TS_ORDER		= 6;
var TS_PLAYER_ID	= 7;
var TS_AT_BATS	 = 8;
var TS_RUNS		= 9;
var TS_HITS		= 10;
var TS_RBIS		= 11;
var TS_TOTAL_BASES	= 12;
var TS_WALKS		= 13;
var TS_STRIKE_OUTS	= 14;
var TS_BATTING_AVG	= 15;
var TS_OBP		= 16;
var TS_SLUG_PCT	= 17;
var TS_LOB		= 18;
function drawBreakdownStats() { 
	var output = normalFT;
	vartype = typeof mlb_stats_team;
	// If the variable doesn't exist then do nothing
	if (vartype == "undefined") { return;}
	var i;
	var team1 = "";
	var team2 = "";
	var tempstr = "";
	var teamStats = mlb_stats_team;
	var teamStatsLength = teamStats.length;
	var at_bats = 0;
	var runs = 0;
	var hits = 0;
	var rbis = 0;
	var lobs = 0;
	var total_bases = 0;
	var walks = 0;
	var strike_outs = 0;
	// Sneak a peek at the first team
	var stat = new Array();
	stat = teamStats[0].split("|");
	var firstTeam = stat[TS_TEAMCODE];
	var currentTeam = "";
	var lastPlayer = "|";
	var team;
	var which = (firstTeam == h_team_id)? 1 : 0;
	var greyRow = false;
	var bgcolor;
	for(i = 0; i < teamStatsLength; i++) {
	 stat = teamStats[i].split("|");
	 if ((lastPlayer.indexOf("|" + stat[TS_PLAYER_ID] + "|") == -1) && (stat[TS_WHICH] == 'b')){
		lastPlayer += stat[TS_PLAYER_ID] + "|";
		bgcolor = greyRow ? "e2e2e2" : "ffffff";
		team = stat[TS_TEAMCODE];
		// Have we gotten to the other team yet?
		if (team != currentTeam) {
			which = 1 - which;
			greyRow = false;
			bgcolor = greyRow ? "e2e2e2" : "ffffff";
			if (team != firstTeam) {
				team = stat[TS_TEAMCODE];
				if (isNaN(at_bats)) at_bats = "";
				if (isNaN(runs)) runs = "";
				if (isNaN(hits)) hits = "";
				if (isNaN(rbis)) rbis = "";
				if (isNaN(total_bases)) total_bases = "";
				if (isNaN(walks)) walks = "";
				if (isNaN(lobs)) lobs = "";
				tempstr += "<tr bgcolor=#9CADDE><td></td><td>" + titleFT + "Totals"+ clTitleFT + "</td><td align=center>" + smtitleFT + at_bats + clSmTitleFT + "</td>";
				tempstr += "<td align=center>" + smtitleFT + runs + clSmTitleFT + "</td><td align=center>" + smtitleFT + hits + clSmTitleFT + "</td>";
				tempstr += "<td align=center>" + smtitleFT + rbis + clSmTitleFT + "</td><td align=center>" + smtitleFT + total_bases + clTitleFT + "</td>";
				tempstr += "<td align=center>" + smtitleFT + walks + clSmTitleFT + "</td><td align=center>" + smtitleFT + strike_outs + clTitleFT + "</td>";
				tempstr += "<td align=center>" + smtitleFT + lobs + clSmTitleFT + "</td>";
				tempstr += "<td align=center>" + smtitleFT + "-" + clSmTitleFT + "</td><td align=center>" + smtitleFT + "-" + clTitleFT + "</td><td align=center>" + smtitleFT + "-" + clTitleFT + "</td>";
				tempstr += "</tr></table><br>";
				tempstr += drawBreakdownBatterStats(currentTeam)
			}
			team1 = tempstr;
			tempstr = "";
			tempstr += "<table width=100% border=0 cellpadding=0 cellspacing=0 bgcolor=#ffffff>";
			tempstr += "<tr bgcolor=#002F9C><td align=center width=100% colspan=13>"+titleFT+"<font color=#ffffff>" + whichTeam[which] + "</font>"+clTitleFT+"</td></tr><tr bgcolor=#9CADDE><td width=5%></td>";
			tempstr += "<td align=left>" + smtitleFT + "NAME" + clSmTitleFT + "</td>";
			tempstr += "<td align=" + align + ">" + smtitleFT + "AB" + clSmTitleFT + "</td>";
			tempstr += "<td align=" + align + ">" + smtitleFT + "R" + clSmTitleFT + "</td>";
			tempstr += "<td align=" + align + ">" + smtitleFT + "H" + clSmTitleFT + "</td>";
			tempstr += "<td align=" + align + ">" + smtitleFT + "RBI" + clSmTitleFT + "</td>";
			tempstr += "<td align=" + align + ">" + smtitleFT + "TB" + clSmTitleFT + "</td>";
			tempstr += "<td align=" + align + ">" + smtitleFT + "BB" + clSmTitleFT + "</td>";
			tempstr += "<td align=" + align + ">" + smtitleFT + "K" + clSmTitleFT + "</td>";
			tempstr += "<td align=" + align + ">" + smtitleFT + "LOB" + clSmTitleFT + "</td>";
			tempstr += "<td align=" + align + ">" + smtitleFT + "AVG" + clSmTitleFT + "</td>";
			tempstr += "<td align=" + align + ">" + smtitleFT + "OBP" + clSmTitleFT + "</td>";
			tempstr += "<td align=" + align + ">" + smtitleFT + "SLG" + clSmTitleFT + "</td></tr>";
			currentTeam = team;
			at_bats = 0;
			runs = 0;
			hits = 0;
			rbis = 0;
			total_bases = 0;
			walks = 0;
			strike_outs = 0;
			lobs = 0;
		}
		at_bats += parseInt(stat[TS_AT_BATS]);
		runs += parseInt(stat[TS_RUNS]);
		hits += parseInt(stat[TS_HITS]);
		rbis += parseInt(stat[TS_RBIS]);
		total_bases += parseInt(stat[TS_TOTAL_BASES]);
		walks += parseInt(stat[TS_WALKS]);
		strike_outs += parseInt(stat[TS_STRIKE_OUTS]);
		lobs += parseInt(stat[TS_LOB]);
		tempstr += "<tr bgcolor=" + bgcolor + "><td width=5%>";
		tempstr += "</td><td>" + normalFT + stat[TS_FIRST_NAME].substr(0,1) + ". " + stat[TS_LAST_NAME];
		if (stat[TS_POSITION] != "") tempstr += ", " + stat[TS_POSITION];
		tempstr += "</font></td>";
		tempstr += "<td align=center>" + normalFT + stat[TS_AT_BATS] + "</font></td>";
		tempstr += "<td align=center>" + normalFT + stat[TS_RUNS] + "</font></td>";
		tempstr += "<td align=center>" + normalFT + stat[TS_HITS] + "</font></td>";
		tempstr += "<td align=center>" + normalFT + stat[TS_RBIS] + "</font></td>";
		tempstr += "<td align=center>" + normalFT + stat[TS_TOTAL_BASES] + "</font></td>";
		tempstr += "<td align=center>" + normalFT + stat[TS_WALKS] + "</font></td>";
		tempstr += "<td align=center>" + normalFT + stat[TS_STRIKE_OUTS] + "</font></td>";
		tempstr += "<td align=center>" + normalFT + stat[TS_LOB] + "</font></td>";
		tempstr += "<td align=center>" + normalFT + formatNum(stat[TS_BATTING_AVG], 3, false) + "</font></td>";
		tempstr += "<td align=center>" + normalFT + formatNum(stat[TS_OBP], 3, false) + "</font></td>";
		tempstr += "<td align=center>" + normalFT + formatNum(stat[TS_SLUG_PCT], 3, false) + "&nbsp;</font></td></tr>";
		greyRow = !greyRow;
	 }
	}
	if (isNaN(at_bats)) at_bats = "";
	if (isNaN(runs)) runs = "";
	if (isNaN(hits)) hits = "";
	if (isNaN(rbis)) rbis = "";
	if (isNaN(total_bases)) total_bases = "";
	if (isNaN(walks)) walks = "";
	tempstr += "<tr bgcolor=#9CADDE><td></td><td>" + titleFT + "Totals"+ clTitleFT + "</td><td align=center>" + smtitleFT + at_bats + clSmTitleFT + "</td>";
	tempstr += "<td align=center>" + smtitleFT + runs + clSmTitleFT + "</td><td align=center>" + smtitleFT + hits + clSmTitleFT + "</td>";
	tempstr += "<td align=center>" + smtitleFT + rbis + clSmTitleFT + "</td><td align=center>" + smtitleFT + total_bases + clTitleFT + "</td>";
	tempstr += "<td align=center>" + smtitleFT + walks + clSmTitleFT + "</td><td align=center>" + smtitleFT + strike_outs + clTitleFT + "</td>";
	tempstr += "<td align=center>" + smtitleFT + lobs + clSmTitleFT + "</td>";
	tempstr += "<td align=center>" + smtitleFT + "-" + clSmTitleFT + "</td><td align=center>" + smtitleFT + "-" + clTitleFT + "</td><td align=center>" + smtitleFT + "-" + clTitleFT + "</td>";
	tempstr += "</tr>";
	tempstr += "</table><br>";
	tempstr += drawBreakdownBatterStats(currentTeam);
	team2 = tempstr;
	output = (firstTeam == h_team_id)? team2 + team1 : team1 + team2;
	output += MLB_drawPitchingStats();
	document.write(output);
}
var PT_WHICH		= 0
var PT_GAMECODE	= 1;
var PT_TEAMCODE	= 2;
var PT_FIRST_NAME	= 3;
var PT_LAST_NAME	= 4;
var PT_PLAYER_ID	= 7;
var PT_INNINGS	 = 8;
var PT_HITS		= 9;
var PT_RUNS		= 10;
var PT_ER		= 11;
var PT_WALKS		= 12;
var PT_STRIKE_OUTS	= 13;
var PT_HR		= 14;
var PT_BATTERS	 = 15;
var PT_PIT		= 16;
var PT_B_S		= 17;
var PT_ERA		= 18;
var PT_WINNING_PITCHER  = 19;
var PT_LOSING_PITCHER	= 20;
var PT_SAVING_PITCHER	= 21;
var PT_WINS		= 22;
var PT_LOSSES	  = 23;
var PT_SAVES		= 24;
function MLB_drawPitchingStats() {
	// First check for the existence of sport_scoreboard
	vartype = typeof mlb_stats_team;
	// If the variable doesn't exist then do nothing
	if (vartype == "undefined") { return "";}
	var output = "";
	var team1 = "";
	var team2 = "";
	var tempstr = "";
	teamStats = mlb_stats_team;
	teamStatsLength = teamStats.length;
	// Sneak a peek at the first team
	stat = teamStats[0].split("|");
	firstTeam = stat[PT_TEAMCODE];
	currentTeam = "";
	var lastPlayer = "";
	which = (firstTeam == h_team_id)? 1 : 0;
	greyRow = false;
	for(i = 0; i < teamStatsLength; i++) {
	 stat = teamStats[i].split("|");
	 if ((lastPlayer.indexOf(stat[PT_PLAYER_ID]) == -1) && (stat[PT_WHICH] == 'p')){
		winlose_str = "";
		bgcolor = greyRow ? "e2e2e2" : "ffffff";
		team = stat[TS_TEAMCODE];
		// Have we gotten to the other team yet?
		if (team != currentTeam) {
			which = 1 - which;
			greyRow = false;
			bgcolor = greyRow ? "e2e2e2" : "ffffff";
			if (team != firstTeam) {
				team = stat[PT_TEAMCODE];
				tempstr += "</table>";
			}
			team1 = tempstr;
			tempstr = "";
			tempstr += "<table width=100% border=0 cellpadding=0 cellspacing=0 bgcolor=#ffffff>";
			tempstr += "<tr bgcolor=#002F9C><td align=center width=100% colspan=13>"+titleFT+"<font color=#ffffff>" + whichTeam[which] + "</font>"+clTitleFT+"</td></tr><tr bgcolor=#9CADDE><td width=5%></td>";
			tempstr += "<td align=left>" + smtitleFT + "NAME" + clSmTitleFT + "</td>";
			tempstr += "<td align=" + align + ">" + smtitleFT + "IP" + clSmTitleFT + "</td>";
			tempstr += "<td align=" + align + ">" + smtitleFT + "H" + clSmTitleFT + "</td>";
			tempstr += "<td align=" + align + ">" + smtitleFT + "R" + clSmTitleFT + "</td>";
			tempstr += "<td align=" + align + ">" + smtitleFT + "ER" + clSmTitleFT + "</td>";
			tempstr += "<td align=" + align + ">" + smtitleFT + "BB" + clSmTitleFT + "</td>";
			tempstr += "<td align=" + align + ">" + smtitleFT + "K" + clSmTitleFT + "</td>";
			tempstr += "<td align=" + align + ">" + smtitleFT + "HR" + clSmTitleFT + "</td>";
			tempstr += "<td align=" + align + ">" + smtitleFT + "BF" + clSmTitleFT + "</td>";
			tempstr += "<td align=" + align + ">" + smtitleFT + "Pit" + clSmTitleFT + "</td>";
			tempstr += "<td align=" + align + ">" + smtitleFT + "B-S" + clSmTitleFT + "</td>";
			tempstr += "<td align=" + align + ">" + smtitleFT + "ERA" + clSmTitleFT + "</td></tr>";
			currentTeam = team;
		}
		tempstr += "<tr bgcolor=" + bgcolor + "><td width=5%>";
		winlose_str = (stat[PT_WINNING_PITCHER] == 'true')? "W" : winlose_str;
		winlose_str = (stat[PT_LOSING_PITCHER]  == 'true')? "L" : winlose_str;
		winlose_str = (stat[PT_SAVING_PITCHER]  == 'true')? "S" : winlose_str;
		if (winlose_str == "S") winlose_str	= " (" + winlose_str + ", " + stat[PT_SAVES] + ")";
		else if (winlose_str != "") winlose_str = " (" + winlose_str + ", " + stat[PT_WINS] + "-" + stat[PT_LOSSES] + ")";
		tempstr += "</td><td>" + normalFT + stat[PT_FIRST_NAME].substr(0,1) + ". " + stat[PT_LAST_NAME] + winlose_str + "</font></td>";
		tempstr += "<td align=center>" + normalFT + stat[PT_INNINGS] + "</font></td>";
		tempstr += "<td align=center>" + normalFT + stat[PT_HITS] + "</font></td>";
		tempstr += "<td align=center>" + normalFT + stat[PT_RUNS] + "</font></td>";
		tempstr += "<td align=center>" + normalFT + stat[PT_ER] + "</font></td>";
		tempstr += "<td align=center>" + normalFT + stat[PT_WALKS] + "</font></td>";
		tempstr += "<td align=center>" + normalFT + stat[PT_STRIKE_OUTS] + "</font></td>";
		tempstr += "<td align=center>" + normalFT + stat[PT_HR] + "</font></td>";
		tempstr += "<td align=center>" + normalFT + stat[PT_BATTERS] + "</font></td>";
		tempstr += "<td align=center>" + normalFT + stat[PT_PIT] + "</font></td>";
		tempstr += "<td align=center>" + normalFT + stat[PT_B_S] + "&nbsp;</font></td>";
		tempstr += "<td align=center>" + normalFT + formatNum(stat[PT_ERA], 2, true) + "</font></td></tr>";
		greyRow = !greyRow;
	 }
	}
	tempstr += "</table><br>";
	team2 = tempstr;
	output = (firstTeam == h_team_id)? team2 + team1 : team1 + team2;
	return output;
}
var PS_TYPE		= 0;
var PS_GAMECODE	= 1;
var PS_TEAMCODE	= 2;
var PS_FIRST_NAME	= 3;
var PS_LAST_NAME	= 4;
var PS_PLAYER_ID	= 5;
var PS_1		= 6;
var PS_2		= 7;
var PS_3		= 8;
var PS_4		= 9;
var PS_5		= 10;
var PS_6		= 11;
var PS_7		= 12;
statType		= new Array();
statType[1]		= "2B";
statType[2]		= "3B";
statType[3]		= "HR";
statType[4]		= "RBI";
statType[5]		= "GIDP";
statType[6]		= "CS";
statType[7]		= "SB";
statType[8]		= "E";
function drawBreakdownBatterStats(team) {
	// First check for the existence of sport_scoreboard
	vartype = typeof mlb_stats_player;
	// If the variable doesn't exist then do nothing
	if (vartype == "undefined") { return "";}
	var output = "";
	var team1 = "";
	var team2 = "";
	var tempstr = "";
	playerStats = mlb_stats_player;
	playerStatsLength = playerStats.length;
	// Sneak a peek at the first team
	stat = playerStats[0].split("|");
	firstTeam = stat[PS_TEAMCODE];
	var lastPlayer = "";
	var type = "";
	var currentType = "";
	// Border Table
	tempstr += normalFT;
	for(i = 0; i < playerStatsLength; i++) {
	  stat = playerStats[i].split("|");
	  if (team == stat[PS_TEAMCODE]) {
		type = stat[PS_TYPE];
		// Are we in a new stat type?  Then print a new headline
		if (type != currentType) {
			lastPlayer = "";
			// Chop off the last comma and space (but not for the first one)
			if (currentType != "") {
				tempstr = tempstr.substring(0, tempstr.length-2);
				tempstr += "<br>";
			}
			currentType = type;
			tempstr += "<b>" + statType[type] + "</b> ";
		}
		if (lastPlayer.indexOf(stat[PS_FIRST_NAME] + " " +stat[PS_LAST_NAME]) == -1) {
		tempstr += stat[PS_FIRST_NAME].charAt(0).toUpperCase() + ". " +stat[PS_LAST_NAME];
		lastPlayer += stat[PS_FIRST_NAME] + " " +stat[PS_LAST_NAME] + " ";
		switch (type) {
			case "3":
				// Home Runs
				tempstr += " (" + stat[PS_1] + ", " + stat[PS_2] + " inning off " + stat[PS_3].charAt(0).toUpperCase() + ". " + stat[PS_4] + " " + stat[PS_6] + " on " + stat[PS_7] + " out); ";
				break;
			case "7":
				// Stolen Base
				tempstr += ", ";
				break;
			case "8":
				// Error
				tempstr += ", ";
				break;
			default:
				if ((stat[PS_2] != "") && ((stat[PS_2]-0) > 1))
					tempstr += " " + stat[PS_2];
				if (stat[PS_1] != "")
					tempstr += " (" + stat[PS_1] + ")"
				tempstr += ", ";
				break;
		}
		}
	 }
	}
	// Chop off the last comma and space
	tempstr = tempstr.substring(0, tempstr.length-2);
	return tempstr + "<br><br>";
}
function drawBreakdownPlayerStats() { 
	MLB_drawPitchingStats();
}
function drawOtherGameInfo() {
	var output = "";
	vartype = typeof sb;
	// If the variable doesn't exist then do nothing
	if (vartype == "undefined") { return "";}
	if (sb[SB_ATTENDANCE] != "" && sb[SB_ATTENDANCE] != 0) {
		output += normalFT + "<b>Attendance</b><br>";
		output += sb[SB_ATTENDANCE] + "</font><br>";
		if ((sb[SB_TIME_OF_GAME_HOURS] != "") && (sb[SB_TIME_OF_GAME_MINUTES] != "")) {
			output += normalFT + "<b>Time</b><br>";
			if (sb[SB_TIME_OF_GAME_MINUTES] < 10) sb[SB_TIME_OF_GAME_MINUTES] = "0" + sb[SB_TIME_OF_GAME_MINUTES];
			output += sb[SB_TIME_OF_GAME_HOURS] + ":" + sb[SB_TIME_OF_GAME_MINUTES] + "</font><br>";
		}
	}
	document.write(output);
}
function MLB_drawTeamHits(team) {
	var lastPlayer = "";
	var type = "";
	var currentType = "";
	// Border Table
	tempstr = normalFT;
	for(i = 0; i < playerStatsLength; i++) {
	  stat = playerStats[i].split("|");
	  if (team == stat[PS_TEAMCODE]) {
		type = stat[PS_TYPE];
		// Are we in a new stat type?  Then print a new headline
		if (type != currentType) {
			lastPlayer = "";
			// Chop off the last comma and space (but not for the first one)
			if (currentType != "") {
				tempstr = tempstr.substring(0, tempstr.length-2);
				tempstr += "<br>";
			}
			currentType = type;
			tempstr += "<b>" + statType[type] + "</b> ";
		}
		if (lastPlayer.indexOf(stat[PS_FIRST_NAME] + " " +stat[PS_LAST_NAME]) == -1) {
		tempstr += stat[PS_FIRST_NAME].charAt(0).toUpperCase() + ". " +stat[PS_LAST_NAME];
		lastPlayer += stat[PS_FIRST_NAME] + " " +stat[PS_LAST_NAME] + " ";
		switch (type) {
			case "3":
				// Home Runs
				tempstr += " (" + stat[PS_1] + ", " + stat[PS_2] + " inning off " + stat[PS_3].charAt(0).toUpperCase() + ". " + stat[PS_4] + " " + stat[PS_6] + " on " + stat[PS_7] + " out); ";
				break;
			case "7":
				// Stolen Base
				tempstr += ", ";
				break;
			case "8":
				// Error
				tempstr += ", ";
				break;
			default:
				if ((stat[PS_2] != "") && ((stat[PS_2]-0) > 1))
					tempstr += " " + stat[PS_2];
				if (stat[PS_1] != "")
					tempstr += " (" + stat[PS_1] + ")"
				tempstr += ", ";
				break;
		}
		}
	 }
	}
	// Chop off the last comma and space
	tempstr = tempstr.substring(0, tempstr.length-2);
	return tempstr + "<br><br>";
}
function drawBreakdownSummary() {
	var outHTML = "";
	vartype = typeof mlb_scoring_summary;
	if (vartype == "undefined") {
		return;
	}
	var summaries = mlb_scoring_summary;
	var summariesLength = summaries.length;
	var i;
	document.write(outHTML);
}
var PV_GAMECODE = 1;
var PV_STYPE	= 2;
var PV_SLUG 	= 3;
var PV_DATE 	= 4; 
function hasPhotoGal(gameCode) {
	vartype = typeof mlb_previews;
	if (vartype == "undefined") {return false;}
	var i;
	for (i=0;i<mlb_previews.length;i++) {
		previews = mlb_previews[i].split("|");
		if ((previews[PV_GAMECODE] == gameCode) && (mlb_previews[i].indexOf("|pg") != -1))
			return true
	}
	return false;
}
function getSlug(gameCode, prev_or_recap) {
	// First check for the existence of sport_scoreboard
	vartype = typeof mlb_previews;
	// If the variable doesn't exist then do nothing
	if (vartype == "undefined") {return false;}
	var i;
        var maybe_match = false;
	for (i=0;i<mlb_previews.length;i++) {
		previews = mlb_previews[i].split("|");
         if (
              (previews[PV_SLUG] != "") &&
              (previews[PV_STYPE] == prev_or_recap)
             ) {
              if (previews[PV_GAMECODE] == gameCode) {
               return previews[PV_DATE] + "/" + previews[PV_SLUG];
              } else if (
	       ('mlb' == 'mlb') &&
               (previews[PV_GAMECODE] == gameCode.substr(0,6) + "1" +  gameCode.substr(7,2))
                ) {
		maybe_match =  previews[PV_DATE] + "/" + previews[PV_SLUG];
	      }
           }
	}
	return maybe_match;
}
