// JavaScript Document

function isEven(value){
	if (value%2 == 0)
		return true;
	else
		return false;
}

function currentWeek(gYear,gMonth,gDay)
{
	var one_day=1000*60*60*24;
	var gmd = new Date(gYear,gMonth-1,gDay);
	var today = new Date();
	var daysLeft;
	
	daysLeft = Math.floor((gmd.getTime()-today.getTime())/(one_day));
	
	if (daysLeft >-4 && daysLeft < 4)
		return true
	else
		return false
}

function loadXMLDoc(url)
{
xmlhttp=null;
if (window.XMLHttpRequest)
  {// code for IE7, Firefox, Mozilla, etc.
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {// code for IE5, IE6
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
if (xmlhttp!=null)
  {
  xmlhttp.onreadystatechange=onResponse;
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
  }
else
  {
  alert("Your browser does not support XMLHTTP.");
  }
}

function loadXMLDoc2(url,resFunc)
{
xmlhttp=null;
if (window.XMLHttpRequest)
  {// code for IE7, Firefox, Mozilla, etc.
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {// code for IE5, IE6
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
if (xmlhttp!=null)
  {
  xmlhttp.onreadystatechange=resFunc;
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
  }
else
  {
  alert("Your browser does not support XMLHTTP.");
  }
}

function addXmlData(tag,strong)
{
	if (typeof(strong) == "undefined")
	  	{strong = 0;}
  xx=x[i].getElementsByTagName(tag);
    {
    try
      {
      txt=txt + "<td align='center'>";
	  if (strong == 1 && xx[0].firstChild.nodeValue != 0) 
	  	{txt=txt + "<strong>";}
	  txt=txt + xx[0].firstChild.nodeValue;
	  if (strong == 1 && xx[0].firstChild.nodeValue != 0) 
	  	{txt=txt + "</strong>";}
	  txt=txt + "</td>";
      }
    catch (er)
      {
      txt=txt + "<td> </td>";
      }
    }
}

//Adds a game matchup to the schedule
function schGameHdr()
{
txt=txt + "<tr class='mixhdrwhtblk' align='center'>";
txt=txt + "<td width='30'>Wk</td>";
txt=txt + "<td width='30'>Gm</td>";
txt=txt + "<td width='70'>Date</td>";
txt=txt + "<td width='70'>Time</td>";
txt=txt + "<td width='110'>Home</td>";
txt=txt + "<td width='25'>H</td>";
txt=txt + "<td width='110'>Away</td>";
txt=txt + "<td width='25'>A</td>";
txt=txt + "</tr>";
}

function tmGoalieHdr()
{
	txt=txt + "<tr class='mixhdrwhtblk' align='center'>";
	txt=txt + "<td width='40'>No.</td>";
	txt=txt + "<td width='125'>Goalie</td>";
	txt=txt + "<td width='40'>GP</td>";
	txt=txt + "<td width='40'>W</td>";
	txt=txt + "<td width='40'>L</td>";
	txt=txt + "<td width='40'>T</td>";
	txt=txt + "<td width='40'>SO</td>";
	txt=txt + "<td width='40'>GA</td>";
	txt=txt + "<td width='40'>GAA</td>";
	txt=txt + "<td width='40'>SV</td>";
	txt=txt + "<td width='70'>SV%</td>";
	txt=txt + "<td width='40'>A</td></tr>";
}

function tmPlayerHdr()
{
	txt=txt + "<tr class='mixhdrwhtblk' align='center'>";
	txt=txt + "<td width='25'>No.</td>";
	txt=txt + "<td width='90'>Player</td>";
	txt=txt + "<td width='25'>GP</td>";
	txt=txt + "<td width='25'>G</td>";
	txt=txt + "<td width='25'>A</td>";
	txt=txt + "<td width='25'>P</td>";
	txt=txt + "<td width='25'>GWG</td>";
	txt=txt + "<td width='25'>PP</td>";
	txt=txt + "<td width='25'>SH</td>";
	txt=txt + "<td width='25'>PIM</td></tr>";
}

function schGame()
{
var gHome = x[i].getElementsByTagName("homeShort")[0].firstChild.nodeValue;
var gAway = x[i].getElementsByTagName("awayShort")[0].firstChild.nodeValue;
var gWinner = x[i].getElementsByTagName("winnerShort")[0].firstChild.nodeValue;

if (currentWeek(x[i].getElementsByTagName("xmlYear")[0].firstChild.nodeValue,x[i].getElementsByTagName("xmlMonth")[0].firstChild.nodeValue,x[i].getElementsByTagName("xmlDay")[0].firstChild.nodeValue))
{
	txt=txt + "<tr class='mixfont' align='center' bgcolor='#99CCFF'>";
}
else if (isEven(x[i].getElementsByTagName("week")[0].firstChild.nodeValue)) 
{
	txt=txt + "<tr class='mixfont' align='center' bgcolor='#CCCCCC'>";
}
else {
	txt=txt + "<tr class='mixfont' align='center'>";
} 
  addXmlData("week");
  addXmlData("gameNum");
  addXmlData("gamedate");
  addXmlData("gametime");
//  addXmlData("home");
//  addXmlData("homeScore");
//  addXmlData("away");
//  addXmlData("awayScore");
{
    try
      {
	  
		if (gHome == gWinner)
		  {
			txt=txt + "<td>";
			txt=txt + "<strong>";
	        txt=txt + x[i].getElementsByTagName("home")[0].firstChild.nodeValue;
			txt=txt + "</strong>";
	        txt=txt + "</td>";
		  }	
		else
	  	{
			txt=txt + "<td>";
	        txt=txt + x[i].getElementsByTagName("home")[0].firstChild.nodeValue;
	        txt=txt + "</td>";
		  }
      }
    catch (er)
      {
      txt=txt + "<td> </td>";
      }
    }

   {
    try
      {
	  
		if (gHome == gWinner)
		  {
			txt=txt + "<td>";
			txt=txt + "<strong>";
	        txt=txt + x[i].getElementsByTagName("homeScore")[0].firstChild.nodeValue;
			if (x[i].getElementsByTagName("result")[0].firstChild.nodeValue == "Overtime"){
			txt=txt + "*";
			}
			txt=txt + "</strong>";
	        txt=txt + "</td>";
		  }	
		else
	  	{
			txt=txt + "<td>";
	        txt=txt + x[i].getElementsByTagName("homeScore")[0].firstChild.nodeValue;
	        txt=txt + "</td>";
		  }
      }
    catch (er)
      {
      txt=txt + "<td> </td>";
      }
    }
   {
    try
      {
		if (gAway == gWinner)
		  {
			txt=txt + "<td>";
			txt=txt + "<strong>";
	        txt=txt + x[i].getElementsByTagName("away")[0].firstChild.nodeValue;
			txt=txt + "</strong>";
	        txt=txt + "</td>";
		  }	
		else
	  	{
			txt=txt + "<td>";
	        txt=txt + x[i].getElementsByTagName("away")[0].firstChild.nodeValue;
	        txt=txt + "</td>";
		  }
      }
    catch (er)
      {
      txt=txt + "<td> </td>";
      }
    }
   {
    try
      {
		if (gAway == gWinner)
		  {
			txt=txt + "<td>";
			txt=txt + "<strong>";
	        txt=txt + x[i].getElementsByTagName("awayScore")[0].firstChild.nodeValue;
			if (x[i].getElementsByTagName("result")[0].firstChild.nodeValue == "Overtime"){
			txt=txt + "*";
			}
	        txt=txt + "</strong>";
	        txt=txt + "</td>";
		  }	
		else
	  	{
			txt=txt + "<td>";
	        txt=txt + x[i].getElementsByTagName("awayScore")[0].firstChild.nodeValue;
	        txt=txt + "</td>";
		  }
      }
    catch (er)
      {
      txt=txt + "<td> </td>";
      }
    }
  
  txt=txt + "</tr>";
}

function schVolunteerHdr()
{
txt=txt + "<tr class='mixhdrwhtblk' align='center'>";
txt=txt + "<td width='30'>Wk</td>";
txt=txt + "<td width='30'>Gm</td>";
txt=txt + "<td width='70'>Date</td>";
txt=txt + "<td width='70'>Time</td>";
txt=txt + "<td width='100'>Teams</td>";
txt=txt + "<td width='100'>Referees</td>";
txt=txt + "<td width='100'>Scorer's Table</td>";
txt=txt + "</tr>";
}

//Adds a volunteer line to the schedule
function schVolunteer()
{
if (currentWeek(x[i].getElementsByTagName("xmlYear")[0].firstChild.nodeValue,x[i].getElementsByTagName("xmlMonth")[0].firstChild.nodeValue,x[i].getElementsByTagName("xmlDay")[0].firstChild.nodeValue))
{
	txt=txt + "<tr class='mixfont' align='center' bgcolor='#99CCFF'>";
}
else if (isEven(x[i].getElementsByTagName("week")[0].firstChild.nodeValue)) 
{
	txt=txt + "<tr class='mixfont' align='center' bgcolor='#CCCCCC'>";
}
else {
	txt=txt + "<tr class='mixfont' align='center'>";
}
  addXmlData("week");
  addXmlData("gameNum");
  addXmlData("gamedate");
  addXmlData("gametime");
   {
    try
      {
      txt=txt + "<td>" + x[i].getElementsByTagName("homeShort")[0].firstChild.nodeValue + " vs. " + x[i].getElementsByTagName("awayShort")[0].firstChild.nodeValue + "</td>";
      }
    catch (er)
      {
      txt=txt + "<td>" + "</td>";
      }
    }
   {
    try
      {
      txt=txt + "<td>" + x[i].getElementsByTagName("ref1")[0].firstChild.nodeValue + ", " + x[i].getElementsByTagName("ref2")[0].firstChild.nodeValue + "</td>";
      }
    catch (er)
      {
      txt=txt + "<td>" + "</td>";
      }
    }
   {
    try
      {
      txt=txt + "<td>" + x[i].getElementsByTagName("announcer")[0].firstChild.nodeValue + ", " + x[i].getElementsByTagName("scorekeeper")[0].firstChild.nodeValue + "</td>";
      }
    catch (er)
      {
      txt=txt + "<td>" + "</td>";
      }
    }
  txt=txt + "</tr>";
}

//Adds a note line to the schedule
function schNote()
{
  txt=txt + "<tr class='mixfont' align='center' bgcolor='#FF0033'>";
  xx=x[i].getElementsByTagName("description");
    {
    try
      {
      txt=txt + "<td colspan = 8>" + xx[0].firstChild.nodeValue + "</td>";
      }
    catch (er)
      {
      txt=txt + "<td> </td>";
      }
    }
  txt=txt + "</tr>";
}

//Adds a note for playoffs line to the schedule
function schNotePlayoffs()
{
if (isEven(x[i].getElementsByTagName("week")[0].firstChild.nodeValue)) 
{
	txt=txt + "<tr class='mixfont' align='center' bgcolor='#CCCCCC'>";
}
else {
	txt=txt + "<tr class='mixfont' align='center'>";
}
  addXmlData("week")
  addXmlData("gameNum")
  addXmlData("gamedate")
  addXmlData("gametime")
  xx=x[i].getElementsByTagName("description");
    {
    try
      {
      txt=txt + "<td colspan = 4>" + xx[0].firstChild.nodeValue + "</td>";
      }
    catch (er)
      {
      txt=txt + "<td> </td>";
      }
    }
  txt=txt + "</tr>";
}

function tmColor(team,text)
{
switch(team)
	{
	case "007":
		text = text + "bgcolor='#E3E3E5' ";
	case "AD":
		text = text + "bgcolor='#FF9999' ";
	case "BP":
		text = text + "bgcolor='#CCFF99' ";
	case "GFK":
		text = text + "bgcolor='#CCFFFF' ";
	case "SA":
		text = text + "bgcolor='#FFCCFF' ";
	case "TB":
		text = text + "bgcolor='#FFCC66' ";
	}
return text
}


function schedule(url,team)
{
xmlhttp=null;
if (window.XMLHttpRequest)
  {// code for IE7, Firefox, Mozilla, etc.
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {// code for IE5, IE6
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
if (xmlhttp!=null)
  {
  xmlhttp.onreadystatechange=onResponse;
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
  }
else
  {
  alert("Your browser does not support XMLHTTP.");
  }

var xmlhttp;

function onResponse()
{
if(xmlhttp.readyState!=4) return;
if(xmlhttp.status!=200)
  {
  alert("Problem retrieving XML data");
  return;
  }
var gametype;
txt="<table width='600' border='0' align='center' cellpadding='2' cellspacing='1' class='schedule_table'>";
x=xmlhttp.responseXML.documentElement.getElementsByTagName("schedule");
schType(team)
txt=txt + "</table>";
document.getElementById('schDisplay').innerHTML=txt;
}
}

function schType(team)
{
switch (team)
{
case "ALL":
	schGameHdr();
	for (i=0;i<x.length;i++)
	{
	
	  if (x[i].getElementsByTagName("type")[0].firstChild.nodeValue == "Note")
	  {
	  schNote();
	  }
	  else if (x[i].getElementsByTagName("type")[0].firstChild.nodeValue == "Note-Playoffs")
	  {
	  schNotePlayoffs();
	  }
	  else
	  {
	  schGame();
	  }
	}
	break;
case "VOL":
	schVolunteerHdr();
	for (i=0;i<x.length;i++)
	{
	
	  if (x[i].getElementsByTagName("type")[0].firstChild.nodeValue == "Note")
	  {
	  schNote();
	  }
	  else if (x[i].getElementsByTagName("type")[0].firstChild.nodeValue == "Note-Playoffs")
	  {
	  schNotePlayoffs();
	  }
	  else
	  {
	  schVolunteer();
	  }
	}
	break;
default:
	schGameHdr();
	for (i=0;i<x.length;i++)
	{
	  if (x[i].getElementsByTagName("type")[0].firstChild.nodeValue == "Note")
	  {
	  schNote();
	  }
	  else if (x[i].getElementsByTagName("type")[0].firstChild.nodeValue == "Note-Playoffs")
	  {
	  schNotePlayoffs();
	  }
	  else if (x[i].getElementsByTagName("homeShort")[0].firstChild.nodeValue == team || x[i].getElementsByTagName("awayShort")[0].firstChild.nodeValue == team )
	  {
	  schGame();
	  }
	}


}

}

function weeklyGames(url)
{
var xmlhttp;
xmlhttp=null;
if (window.XMLHttpRequest)
  {// code for IE7, Firefox, Mozilla, etc.
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {// code for IE5, IE6
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
if (xmlhttp!=null)
  {
  xmlhttp.onreadystatechange=onResponseWg;
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
  }
else
  {
  alert("Your browser does not support XMLHTTP.");
  }

function onResponseWg()
{
if(xmlhttp.readyState!=4) return;
if(xmlhttp.status!=200)
  {
  alert("Problem retrieving XML data");
  return;
  }

	txt="<img src='/season/MIX007/images/ART_thisweeksgames_hdr.jpg' alt='' width='700' height='31' border='0' />"
	txt=txt + "<table width='700' border='0' align='center' cellpadding='0' cellspacing='0' style='margin: 7px 0px 10px 0px;'>"
	x=xmlhttp.responseXML.documentElement.getElementsByTagName("schedule");
	var cWeek=null;
	var cGameDate=null;
for (i=0;i<x.length;i++)
  {
	var cYear = x[i].getElementsByTagName("xmlYear")[0].firstChild.nodeValue;
	var cMonth = x[i].getElementsByTagName("xmlMonth")[0].firstChild.nodeValue;
	var cDay = x[i].getElementsByTagName("xmlDay")[0].firstChild.nodeValue;
//	var hteam = x[i].getElementsByTagName("homeShort")[0].firstChild.nodeValue;
//	var ateam = x[i].getElementsByTagName("awayShort")[0].firstChild.nodeValue;
//	var wteam = x[i].getElementsByTagName("winnerShort")[0].firstChild.nodeValue;
	if (currentWeek(cYear,cMonth,cDay))
	{
	cWeek = x[i].getElementsByTagName("week")[0].firstChild.nodeValue;
	cGameDate = x[i].getElementsByTagName("gamedate")[0].firstChild.nodeValue;

	txt=txt + "<tr><td><h3>";
	txt=txt + "  Week " + cWeek + " - " + cGameDate;
	txt=txt + "</h3></td></tr>";
	txt=txt + "<tr><td>";
	txt=txt + "<table align='center' border='0' cellspacing='4' cellpadding='0'>";
	txt=txt + "<tr>";
		while (cWeek == x[i].getElementsByTagName("week")[0].firstChild.nodeValue && x[i].getElementsByTagName("gameNum")[0].firstChild.nodeValue != 0)
		{
		txt=txt + "<td align='left' valign='top'>";
		txt=txt + "<table width='170' cellspacing='0' border='0'><tr class='mixhdrwhtblk'>";
		{
		try
		  {
		  txt=txt + "<td colspan='3' style='border-bottom: 1px solid #9b9ea3; border-left: 1px solid #9b9ea3; border-right: 1px solid #9b9ea3;'>";
		  txt=txt + x[i].getElementsByTagName("gametime")[0].firstChild.nodeValue;
		  txt=txt + "</td>";
		  }
		catch (er)
		  {
		  txt=txt + "<td> </td>";
		  }
		}
		txt=txt + "</tr>";
		txt=txt + "<tr class='mixfont'";
		if (x[i].getElementsByTagName("homeShort")[0].firstChild.nodeValue == x[i].getElementsByTagName("winnerShort")[0].firstChild.nodeValue){txt=txt + " style='font-weight:bold'";}
		txt=txt + "><td width='60' style='border-bottom: 1px solid #9b9ea3;'>";
		txt=txt + "<a href='/season/MIX007/teams/";
		txt=txt + x[i].getElementsByTagName("homeShort")[0].firstChild.nodeValue;
		txt=txt + ".shtml'>";
		txt=txt + "<img src='/season/MIX007/images/logos/LGO_";
		txt=txt + x[i].getElementsByTagName("homeShort")[0].firstChild.nodeValue;
		txt=txt + "_thb.jpg' alt='";
		txt=txt + x[i].getElementsByTagName("home")[0].firstChild.nodeValue;
		txt=txt + "' style='vertical-align: middle;' />";
		txt=txt + "</a>";
		txt=txt + "</td>";
		txt=txt + "<td align='center' style='border-bottom: 1px solid #9b9ea3;'>";
		txt=txt + x[i].getElementsByTagName("homeShort")[0].firstChild.nodeValue;
		txt=txt + "</td>";
		txt=txt + "<td align='left' valign='middle' style='border-bottom: 1px solid #9b9ea3;'>";
//		if (h_team == w_team){txt=txt + "<strong>"}
		txt=txt + x[i].getElementsByTagName("homeScore")[0].firstChild.nodeValue;
		if (x[i].getElementsByTagName("result")[0].firstChild.nodeValue == "Overtime" && x[i].getElementsByTagName("homeShort")[0].firstChild.nodeValue == x[i].getElementsByTagName("winnerShort")[0].firstChild.nodeValue){
		txt=txt + " OT";
		}
//		if (h_team == w_team){txt=txt + "</strong>";}
		txt=txt + "</td>";
		txt=txt + "<tr class='mixfont' style='border-bottom: 1px solid #9b9ea3;"
		if (x[i].getElementsByTagName("awayShort")[0].firstChild.nodeValue == x[i].getElementsByTagName("winnerShort")[0].firstChild.nodeValue){txt=txt + "font-weight:bold;"}
		txt=txt + "'><td width='60'>";
		txt=txt + "<a href='/season/MIX007/teams/";
		txt=txt + x[i].getElementsByTagName("awayShort")[0].firstChild.nodeValue;
		txt=txt + ".shtml'>"
		txt=txt + "<img src='/season/MIX007/images/logos/LGO_";
		txt=txt + x[i].getElementsByTagName("awayShort")[0].firstChild.nodeValue;
		txt=txt + "_thb.jpg' alt='";
		txt=txt + x[i].getElementsByTagName("away")[0].firstChild.nodeValue;
		txt=txt + "' style='vertical-align: middle;' />";
		txt=txt + "</a>";
		txt=txt + "</td>";
		txt=txt + "<td align='center'>";
//		if (a_team == w_team){txt=txt + "<strong>";}
		txt=txt + x[i].getElementsByTagName("awayShort")[0].firstChild.nodeValue;
//		if (a_team == w_team){txt=txt + "</strong>";}
		txt=txt + "</td>";
		txt=txt + "<td align='left' valign='middle'>";
//		if (a_team == w_team){txt=txt + "<strong>";}
		txt=txt + x[i].getElementsByTagName("awayScore")[0].firstChild.nodeValue;
		if (x[i].getElementsByTagName("result")[0].firstChild.nodeValue == "Overtime" && x[i].getElementsByTagName("awayShort")[0].firstChild.nodeValue == x[i].getElementsByTagName("winnerShort")[0].firstChild.nodeValue){
		txt=txt + " OT";
		}
//		if (a_team == w_team){txt=txt + "</strong>";}
		txt=txt + "</td>";
		txt=txt + "</tr>";
		txt=txt + "</table>";
		txt=txt + "</td>";
		i=i+1;
		}
	txt=txt + "</tr>";
	txt=txt + "</table>";
	txt=txt + "</td></tr>";
	}
  }
txt=txt + "</table>";
document.getElementById('weeks_games').innerHTML=txt;
}

}

function insertCardSwap(ysnPic,dir,filename)
{
if (ysnPic==1)
{
txt=txt + "onMouseOver=\"MM_swapImage('card','','" + dir + filename + ".jpg',1)\" ";
txt=txt + "onClick=\"MM_swapImage('card','','" + dir + filename + "_back.jpg',1)\" ";
txt=txt + "onDblClick=\"MM_swapImage('card','','" + dir + filename + ".jpg',1)\" ";
} 
else
{
txt=txt + "onMouseOver=\"MM_swapImage('card','','" + dir + "nocard.jpg',1)\" ";
txt=txt + "onClick=\"MM_swapImage('card','','" + dir + "nocard_back.jpg',1)\" ";
txt=txt + "onDblClick=\"MM_swapImage('card','','" + dir + "nocard.jpg',1)\" ";
}
}

function cardSwapBack(fileinfo)
{
ysnPic=Number(fileinfo.slice(0,1));
fileId=fileinfo.slice(1);
dir = "/season/MIX007/images/cards/";
filename=dir+fileId+".jpg";
if (ysnPic!=0)
{
MM_swapImage("card","",filename,1);
} 
else
{
MM_swapImage("card","",dir + "nocard.jpg",1);
}

}

function onResponseStatsTm()
{
if(xmlhttp.readyState!=4) return;
if(xmlhttp.status!=200)
  {
  alert("Problem retrieving XML data");
  return;
  }
  	cardImgs = "/season/MIX007/images/cards/";
	j=1
	x=xmlhttp.responseXML.documentElement.getElementsByTagName("StatsPlayers");
	var pos="Goalie"
	txt="<table width='100%' cellspacing='5'>";
/*	txt=txt + "<tr><td colspan='2' height='75'><p><img src='/season/MIX007/images/teams/stats_" + team + "-hdr.gif'></p>";*/
	txt=txt + "<tr><td onMouseOver=\"MM_swapImage('card','','" + cardImgs + "team_" + team + ".jpg',1)\" colspan='2' height='75'><h2><img src='/season/MIX007/images/logos/LGO_" + team + "_thb.jpg' alt='" + teamFull + "' width='60' height='35' style='vertical-align:middle;'>" + teamFull + "</h2>";
	txt=txt + "</td></tr>"; 
	txt=txt + "<tr><td colspan='2'>"
	txt=txt + "<table border='2' cellspacing='0'>";
	tmGoalieHdr();

	for (i=0;i<x.length;i++)
	{
	var type=x[i].getElementsByTagName("type")[0].firstChild.nodeValue;
	var teamid=x[i].getElementsByTagName("Tm")[0].firstChild.nodeValue;
	var fileid=x[i].getElementsByTagName("file")[0].firstChild.nodeValue;
	var photo=x[i].getElementsByTagName("photo")[0].firstChild.nodeValue;
		if (teamid==team && type==pos)
		{
		txt=txt + "<tr class='mixfont' align='center' "; 
			insertCardSwap(photo,cardImgs,fileid);
			if (isEven(j)) 
			{
			txt=txt + "bgcolor='#E3E3E5'>";
			}
			else
			{
			txt=txt + ">";
			}
		addXmlData("No");
/*		{
		try
		  {
		  txt=txt + "<td>";
		  txt=txt + x[i].getElementsByTagName("Name")[0].firstChild.nodeValue + fileid + "test"; 
		  txt=txt + "</td>";
		  }
		catch (er)
		  {
		  txt=txt + "<td> </td>";
		  }
		}*/
		addXmlData("Name");
		addXmlData("GP");
		addXmlData("W");
		addXmlData("L");
		addXmlData("T");
		addXmlData("SO");
		addXmlData("GA");
		addXmlData("GAA");
		addXmlData("Sv");
		addXmlData("Svp");
		addXmlData("A");	
		txt=txt + "</tr>";
		j=j+1
		}
	}
	txt=txt + "</table>";
	txt=txt + "</td></tr>";
	txt=txt + "<tr><td width='375' height='400'>";
	txt=txt + "<table border='2' cellspacing='0'>";
	tmPlayerHdr();

	pos="Player";
	var m=1;
	
	for (i=0;i<x.length;i++)
	{
	var type=x[i].getElementsByTagName("type")[0].firstChild.nodeValue;
	var teamid=x[i].getElementsByTagName("Tm")[0].firstChild.nodeValue;
	var fileid=x[i].getElementsByTagName("file")[0].firstChild.nodeValue;
	var photo=x[i].getElementsByTagName("photo")[0].firstChild.nodeValue;
	if (teamid==team && type==pos)
	{
	txt=txt + "<tr class='mixfont' align='center' "; 
	insertCardSwap(photo,cardImgs,fileid);
		if (isEven(m)) 
		{
		txt=txt + "bgcolor='#E3E3E5'>";
		}
		else
		{
		txt=txt + ">";
		}
	{
	  xx=x[i].getElementsByTagName("No");
		{
		try
		  {
		  txt=txt + "<td height='40'>" + xx[0].firstChild.nodeValue + "</td>";
		  }
		catch (er)
		  {
		  txt=txt + "<td> </td>";
		  }
		}
	}
//	addXmlData("No");	
	addXmlData("Name");
	addXmlData("GP");
	addXmlData("G");
	addXmlData("A");
	addXmlData("P");
	addXmlData("GWG");
	addXmlData("PPG");
	addXmlData("SHG");
	addXmlData("PIM");
	txt=txt + "</tr>";
	m=m+1
	}
	}
	txt=txt + "</table>";
	txt=txt + "</td><td align='center' valign='middle'><img src='" + cardImgs + "team_" + team +".jpg' name='card'></td>";
	txt=txt + "</tr></table>";
	txt=txt + "</td></tr></table>";
	document.getElementById('tmDisplay').innerHTML=txt;
}


function onPlayerStats()
{
if(xmlhttp.readyState!=4) return;
if(xmlhttp.status!=200)
  {
  alert("Problem retrieving XML data");
  return;
  }
 	cardImgs = "/season/MIX007/images/cards/";
	m=1;
	var ldrCount;
	
	x=xmlhttp.responseXML.documentElement.getElementsByTagName("StatsPlayers");
	if(typeof(window.myCount) == "undefined" || window.myCount >=60)
		{ldrCount=x.length;}
	else
		{ldrCount=window.myCount;}
	
	txt="<table width='100%' align='center' border='0' cellspacing='10' cellpadding='0'>";
	txt=txt + "<tr><td><h3>Leaderboard</h3></td></tr>";
	txt=txt + "<tr><td>";
	txt=txt + "<table align='left' border='0' cellspacing='0' cellpadding='0'>";
	txt=txt + "<tr><td colspan='11'><h2>Players</h2></td></tr>";
	txt=txt + "<tr class='mixhdrwhtblk' align='center'>";
	txt=txt + "<td width='25'>Rk</td>";
	txt=txt + "<td width='25'>Tm</td>";
	txt=txt + "<td width='25'>No</td>";
	txt=txt + "<td width='150'>Player</td>";
	txt=txt + "<td width='25'>GP</td>";
	txt=txt + "<td width='25'>P</td>";
	txt=txt + "<td width='25'>G</td>";
	txt=txt + "<td width='25'>A</td>";
	txt=txt + "<td width='25'>GWG</td>";
	txt=txt + "<td width='25'>PP</td>";
	txt=txt + "<td width='25'>SH</td>";
	txt=txt + "<td width='25'>PIM</td></tr>";
	for (i=0;i<ldrCount;i++)
	{
	var type=x[i].getElementsByTagName("type")[0].firstChild.nodeValue;
	var teamid=x[i].getElementsByTagName("Tm")[0].firstChild.nodeValue;
	var fileid=x[i].getElementsByTagName("file")[0].firstChild.nodeValue;
	var photo=x[i].getElementsByTagName("photo")[0].firstChild.nodeValue;
	
	
	txt = txt + "<tr ";
		if (isEven(m)){txt = txt + "bgcolor='#E3E3E5' "};
//		txt = tmColor(teamid,txt);
		insertCardSwap(photo,cardImgs,fileid);
		txt = txt + "class='mixfont'>";
		txt = txt + "<td align='center'>" + m + "</td>";
		addXmlData("Tm");
		addXmlData("No");
		addXmlData("Name");
		addXmlData("GP");
		addXmlData("P",1);
		addXmlData("G");
		addXmlData("A");
		addXmlData("GWG",1);
		addXmlData("PPG",1);
		addXmlData("SHG",1);
		addXmlData("PIM");
		txt = txt + "</tr>"
		m=m+1;
	}
	
	txt = txt + "</table>";
	txt = txt + "</td></tr>";
	txt = txt + "<tr bgcolor='#E3E3E5'><td colspan=2>";
	txt = txt + "<p><a href='/season/MIX007/stats/leaderboard.shtml'>View All</a></p>";
	txt = txt + "</td></tr>";
	txt = txt + "</tr><td>";
		txt=txt + "<table align='left' border='0' cellspacing='0'>";
		txt=txt + "<tr><td colspan='11'><h2>Goalies</h2></td></tr>";
		txt=txt + "<tr class='mixhdrwhtblk' align='center'>";
		txt=txt + "<td width='40'>Tm</td>";
		txt=txt + "<td width='125'>Goalie</td>";
		txt=txt + "<td width='40'>GP</td>";
		txt=txt + "<td width='40'>W</td>";
		txt=txt + "<td width='40'>L</td>";
		txt=txt + "<td width='40'>T</td>";
		txt=txt + "<td width='40'>SO</td>";
		txt=txt + "<td width='40'>GA</td>";
		txt=txt + "<td width='40'>GAA</td>";
		txt=txt + "<td width='40'>SV</td>";
		txt=txt + "<td width='70'>SV%</td>";
		txt=txt + "<td width='40'>A</td></tr>";
		j = 1;
		for (i=0;i<x.length;i++)
		{
		var type=x[i].getElementsByTagName("type")[0].firstChild.nodeValue;
		var teamid=x[i].getElementsByTagName("Tm")[0].firstChild.nodeValue;
		var fileid=x[i].getElementsByTagName("file")[0].firstChild.nodeValue;
		var photo=x[i].getElementsByTagName("photo")[0].firstChild.nodeValue;
		
		
		if (type=="Goalie")
		{
			txt = txt + "<tr ";
			if (isEven(j)){txt = txt + "bgcolor='#E3E3E5' "};
//			txt = tmColor(teamid,txt);
			insertCardSwap(photo,cardImgs,fileid);
			txt = txt + "class='mixfont'>";
			addXmlData("Tm");
			addXmlData("Name");
			addXmlData("GP");
			addXmlData("W");
			addXmlData("L");
			addXmlData("T");
			addXmlData("SO");
			addXmlData("GA");
			addXmlData("GAA");
			addXmlData("Sv");
			addXmlData("Svp");
			addXmlData("A");	
			txt = txt + "</tr>"
			j=j+1;
		}
		}
		
		txt = txt + "</table>";
	txt = txt + "</td></tr></table>";
	document.getElementById('ldrDisplay').innerHTML=txt;
}

function onStandings()
{
if(xmlhttp.readyState!=4) return;
if(xmlhttp.status!=200)
  {
  alert("Problem retrieving XML data");
  return;
  }

	var view;
	x=xmlhttp.responseXML.documentElement.getElementsByTagName("Standings");
	if(typeof(window.standingsView) == "undefined")
		{view = 0;}
	else
		{view = window.standingsView;}
	
	txt="<table width='100%' align='center' border='0' cellspacing='10'>";
//	txt=txt + "<tr><td><h3>Standings</h3></td></tr>";
	txt=txt + "<tr><td>";
	txt=txt + "<table align='center' border='0' cellspacing='0'>";
	txt=txt + "<tr class='mixhdrwhtblk' align='center'>";
	
	if (view==0)
	{
		txt=txt + "<td width='150'>Team</td>";
		txt=txt + "<td width='30'>GP</td>";
		txt=txt + "<td width='30'>Pts</td>";
		txt=txt + "<td width='30'>W</td>";
		txt=txt + "<td width='30'>L</td>";
		txt=txt + "<td width='30'>T</td>";
		txt=txt + "<td width='30'>GF</td>";
		txt=txt + "<td width='30'>GA</td>";
		txt=txt + "<td width='30'>PP</td>";
		txt=txt + "<td width='30'>SHG</td>";
		txt=txt + "<td width='40'>GAA</td>";
		txt=txt + "<td width='40'>Sv%</td>";
		txt=txt + "<td width='30'>SO</td>";
		txt=txt + "<td width='30'>PIM</td>";
		}
	else if (view==1)
	{
		txt=txt + "<td width='150'>Team</td>";
		txt=txt + "<td width='30'>Pts</td>";
		txt=txt + "<td width='30'>W</td>";
		txt=txt + "<td width='30'>L</td>";
		txt=txt + "<td width='30'>T</td>";
		}
	txt=txt + "</tr>";
	
	j=1;
	for (i=0;i<x.length;i++)
	{
		var ppg=x[i].getElementsByTagName("PPG")[0].firstChild.nodeValue;
		var ppo=x[i].getElementsByTagName("PPO")[0].firstChild.nodeValue;
		
		txt = txt + "<tr ";
		if (isEven(j)){txt = txt + "bgcolor='#E3E3E5' "};
		txt = txt + "class='mixfont'>";
//		txt = txt + "<td align='center'>" + j + "</td>";
		
		if (view==0)
		{
		addXmlData("Name");
		addXmlData("GP");
		addXmlData("Pts",1);
		addXmlData("W");
		addXmlData("L");
		addXmlData("T");
		addXmlData("GF");
		addXmlData("GA");
		{
		try
		  {
		  txt=txt + "<td align='center'>";
		  txt=txt + ppg;
		  txt=txt + "/";
		  txt=txt + ppo;
		  txt=txt + "</td>";
		  }
		catch (er)
		  {
		  txt=txt + "<td> </td>";
		  }
		}
		addXmlData("SHG");
		addXmlData("GAA");
		addXmlData("SvP");
		addXmlData("SO");
		addXmlData("PIM");
		}
		else if (view==1)
		{
		addXmlData("ShortName",1);
		addXmlData("Pts");
		addXmlData("W");
		addXmlData("L");
		addXmlData("T");
		}
		
		txt = txt + "</tr>"
		j=j+1;
	}
	
	txt = txt + "</table>";
	txt = txt + "</td></tr></table>";

	document.getElementById('standingsDisplay').innerHTML=txt;
}

function onStandingsSidebar()
{
if(xmlhttp.readyState!=4) return;
if(xmlhttp.status!=200)
  {
  alert("Problem retrieving XML data");
  return;
  }

	x=xmlhttp.responseXML.documentElement.getElementsByTagName("Standings");
	
	txt="<table width='100%' align='center' border='0' cellpadding='0' cellspacing='10'>";
	txt=txt + "<tr><td>";
	txt=txt + "<table align='left' border='0' cellspacing='0' cellpadding='0'>";
	txt=txt + "<tr align='center'>";
	
	txt=txt + "<td width='50' align='left' style='border-bottom: 1px solid #9b9ea3;'><h1>Team</h1></th>";
	txt=txt + "<td width='30' style='border-bottom: 1px solid #9b9ea3;'><h1>P</h1></td>";
	txt=txt + "<td width='30' style='border-bottom: 1px solid #9b9ea3;'><h1>W</h1></td>";
	txt=txt + "<td width='30' style='border-bottom: 1px solid #9b9ea3;'><h1>L</h1></td>";
	txt=txt + "<td width='30' style='border-bottom: 1px solid #9b9ea3;'><h1>T</h1></td>";
	txt=txt + "</tr>";
	
	m=1;
	for (i=0;i<x.length;i++)
	{
		var shortName=x[i].getElementsByTagName("ShortName")[0].firstChild.nodeValue;
		var pts=x[i].getElementsByTagName("Pts")[0].firstChild.nodeValue;
		var wins=x[i].getElementsByTagName("W")[0].firstChild.nodeValue;
		var losses=x[i].getElementsByTagName("L")[0].firstChild.nodeValue;
		var ties=x[i].getElementsByTagName("T")[0].firstChild.nodeValue;
		
		txt = txt + "<tr ";
//		if (isEven(m)){txt = txt + "bgcolor='#E3E3E5' "};
		txt = txt + "class='mixfontbold'>";
		{
		try
		  {
			txt=txt + "<td align='left' style='border-bottom: 1px solid #9b9ea3;'>";
			txt=txt + shortName;
			txt=txt + "</td>";
		  }
		catch (er)
		  {
		  txt=txt + "N/A";
		  }
		}
				{
		try
		  {
			txt=txt + "<td align='center' style='border-bottom: 1px solid #9b9ea3;'>";
			txt=txt + pts;
			txt=txt + "</td>";
		  }
		catch (er)
		  {
		  txt=txt + "N/A";
		  }
		}
		{
		try
		  {
			txt=txt + "<td align='center' style='border-bottom: 1px solid #9b9ea3;'>";
			txt=txt + wins;
			txt=txt + "</td>";
		  }
		catch (er)
		  {
		  txt=txt + "N/A";
		  }
		}
		{
		try
		  {
			txt=txt + "<td align='center' style='border-bottom: 1px solid #9b9ea3;'>";
			txt=txt + losses;
			txt=txt + "</td>";
		  }
		catch (er)
		  {
		  txt=txt + "N/A";
		  }
		}
		{
		try
		  {
			txt=txt + "<td align='center' style='border-bottom: 1px solid #9b9ea3;'>";
			txt=txt + ties;
			txt=txt + "</td>";
		  }
		catch (er)
		  {
		  txt=txt + "N/A";
		  }
		}
		txt = txt + "</tr>"
		m=m+1;
	}
	
	txt = txt + "</table>";
	txt = txt + "</td></tr></table>";

	document.getElementById('standingsSidebar').innerHTML=txt;
}

function onStatsSidebar()
{
if(xmlhttp.readyState!=4) return;
if(xmlhttp.status!=200)
  {
  alert("Problem retrieving XML data");
  return;
  }
	x=xmlhttp.responseXML.documentElement.getElementsByTagName("StatsPlayers");
	
	txt="<table width='100%' align='center' border='0' cellpadding='0' cellspacing='10'>";
	txt=txt + "<tr><td>";
	txt=txt + "<table align='center' border='0' cellspacing='0' cellpadding='0'>";
	txt=txt + "<tr align='center'>";
	
	txt=txt + "<td width='60' align='left' style='border-bottom: 1px solid #9b9ea3;'><h1>Player</h1></th>";
	txt=txt + "<td width='30' style='border-bottom: 1px solid #9b9ea3;'><h1>GP</h1></td>";
	txt=txt + "<td width='30' style='border-bottom: 1px solid #9b9ea3;'><h1>P</h1></td>";
	txt=txt + "<td width='30' style='border-bottom: 1px solid #9b9ea3;'><h1>G</h1></td>";
	txt=txt + "<td width='30' style='border-bottom: 1px solid #9b9ea3;'><h1>A</h1></td>";
	txt=txt + "</tr>";
	
	k=1;
	for (i=0;i<5;i++)
	{
		var first=x[i].getElementsByTagName("FirstName")[0].firstChild.nodeValue;
		var last=x[i].getElementsByTagName("LastName")[0].firstChild.nodeValue;
		var games=x[i].getElementsByTagName("GP")[0].firstChild.nodeValue;
		var pts=x[i].getElementsByTagName("P")[0].firstChild.nodeValue;
		var goals=x[i].getElementsByTagName("G")[0].firstChild.nodeValue;
		var assists=x[i].getElementsByTagName("A")[0].firstChild.nodeValue;
		
		txt = txt + "<tr ";
//		if (isEven(m)){txt = txt + "bgcolor='#E3E3E5' "};
		txt = txt + "class='mixfontbold'>";
		{
		try
		  {
			txt=txt + "<td align='left' style='border-bottom: 1px solid #9b9ea3;'>";
			txt=txt + first + " ";
			txt=txt + last.slice(0,1) + ".";
			txt=txt + "</td>";
		  }
		catch (er)
		  {
		  txt=txt + "N/A";
		  }
		}
				{
		try
		  {
			txt=txt + "<td align='center' style='border-bottom: 1px solid #9b9ea3;'>";
			txt=txt + games;
			txt=txt + "</td>";
		  }
		catch (er)
		  {
		  txt=txt + "N/A";
		  }
		}
		{
		try
		  {
			txt=txt + "<td align='center' style='border-bottom: 1px solid #9b9ea3;'>";
			txt=txt + pts;
			txt=txt + "</td>";
		  }
		catch (er)
		  {
		  txt=txt + "N/A";
		  }
		}
		{
		try
		  {
			txt=txt + "<td align='center' style='border-bottom: 1px solid #9b9ea3;'>";
			txt=txt + goals;
			txt=txt + "</td>";
		  }
		catch (er)
		  {
		  txt=txt + "N/A";
		  }
		}
		{
		try
		  {
			txt=txt + "<td align='center' style='border-bottom: 1px solid #9b9ea3;'>";
			txt=txt + assists;
			txt=txt + "</td>";
		  }
		catch (er)
		  {
		  txt=txt + "N/A";
		  }
		}
		txt = txt + "</tr>"
		k=k+1;
	}
	
	txt = txt + "</table>";
	txt = txt + "</td></tr></table>";
	document.getElementById('statsSidebar').innerHTML=txt;
}