function Roster(teamName, r) {

	this.teamName = teamName;

	this.players = new Array();

	this.count=0;

	if(r.length>0) {

		arrPlayers = r.split("\n");

		for(var i=0;i<arrPlayers.length;i++) {

			arrPlayer = arrPlayers[i].split(",");

			for(var x=arrPlayer.length;x<17;x++) {

				arrPlayer[x] = "";

			}

			this.addPlayer(new Player(arrPlayer[0],arrPlayer[1],arrPlayer[2],arrPlayer[3],arrPlayer[4],arrPlayer[5],arrPlayer[6],arrPlayer[7],arrPlayer[8],

							arrPlayer[9],arrPlayer[10],arrPlayer[11],arrPlayer[12],arrPlayer[13],arrPlayer[14],arrPlayer[15],arrPlayer[16],arrPlayer[17]));

		}

	}

}

Roster.prototype.addPlayer = function(player) {

	this.players[this.count] = player;

	player.index = this.count;

	this.count = this.count + 1;

}

Roster.prototype.getPlayer = function(index) {

	return this.players[index];

}



Roster.prototype.getRosterTable = function(detailed) {

	this.detailed = detailed;

	var sTable = "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"580\" class=\"text\" background=\"../images/bg_caption.gif\">";

	sTable = sTable + "<tr bgcolor=000000>";

	sTable = sTable + "<td width=25><b><font color=ffffff>&nbsp;#</font></b></td>";

	sTable = sTable + "<td width=140><b><font color=ffffff>Name</font></b></td>";

	sTable = sTable + "<td align=\"center\" width=40><b><font color=ffffff>Pos</font></b></td>";

	if(this.detailed) {

		sTable = sTable + "<td width=55><b><font color=ffffff>Height</font></b></td>";

		sTable = sTable + "<td width=55><b><font color=ffffff>Weight</font></b></td>";

		sTable = sTable + "<td align=\"center\" width=0></td>";

		sTable = sTable + "<td width=80><b><font color=ffffff>DOB</font></b></td>";

		sTable = sTable + "<td width=225><b><font color=ffffff>Previous Team</font></b></td>";

	} else {

		sTable = sTable + "<td colspan=\"5\" align=\"left\">&nbsp;</td>";

	}

	sTable = sTable + "<td align=\"left\">&nbsp;</td>";

	sTable = sTable + "</tr>";

       sTable = sTable + "<tr><td colspan=\"9\" bgcolor=ffffff></td></tr>";
       sTable = sTable + "<tr><td colspan=\"9\" height=4></td></tr>";

	for(i=0;i<this.count;i++) {

		sTable = sTable + this.players[i].getTableRow(this.detailed);

	}

       sTable = sTable + "<tr><td colspan=\"9\" height=4></td></tr>";
       sTable = sTable + "<tr><td colspan=\"9\" height=2 bgcolor=ffffff></td></tr>";

	sTable = sTable + "</table>";

	return sTable;

}



function Player(number, name, position, dob, hometown, image, emailaddr, height, weight, games, goals, assists, points, penaltyMins, goalsAgainst, goalsAgainstAvg, minutes, savePct) {

	this.number = number;

	this.name = name;

	this.position = position;

	this.dob = dob;

	this.hometown = hometown;

	this.image = image;

	this.emailaddr = emailaddr;

	this.height = height;

	this.weight = weight;

	this.games = games;

	this.goals = goals;

	this.assists = assists;

	this.points = points;

	this.penaltyMins = penaltyMins;

	this.goalsAgainst = goalsAgainst;

	this.goalsAgainstAvg = goalsAgainstAvg;

	this.minutes = minutes;

	this.savePct = savePct;

}



Player.prototype.getTableRow = function(detailed) {

	this.detailed = detailed;

	var sRow = "<tr>";


	sRow = sRow + "<td valign=top>" + this.number + "</td>";

	sRow = sRow + "<td valign=top nowrap>" + "<!-- <a href=\"javascript:openPlayer(" + this.index + ")\"> -->" + this.name + "<!-- </a> --></td>";

	sRow = sRow + "<td valign=top align=\"center\">" + this.position + "</td>";

	if(this.detailed) {

		sRow = sRow + "<td valign=top align=\"left\">" + this.height + "</td>";

		sRow = sRow + "<td valign=top align=\"center\">" + this.weight + "</td>";

		sRow = sRow + "<td valign=top align=\"center\"></td>";

		sRow = sRow + "<td valign=top>" + this.dob + "</td>";

		sRow = sRow + "<td valign=top>" + this.hometown + "</td>";

	} else {

		sRow = sRow + "<td colspan=\"5\" align=\"left\">&nbsp;</td>";

	}

	if(this.emailaddr == null) {

		sRow = sRow + "<td>&nbsp;</td>";

	} else {

		sRow = sRow + "<td>" + "<a href=\"mailto:" + this.emailaddr + "\">" + this.emailaddr + "</a></td>";


	}

	sRow = sRow + "</tr>";

        sRow = sRow + "<tr height=1 ><td bgcolor=eaeaea colspan=8></td></tr>";

	return sRow;

}

Player.prototype.formatStats = function() {

	var s = "<div class=headline><font size=\"+1\"><b><i>" + this.name + " - " + this.number + "</i></b></font></div>";

	if(this.detailed) {

                s = s + "<table class=text width=300>";

		s = s + "<tr><td width=85>Position:</td><td>:</td><td width=215><b> " + this.position +"</td></tr>";

		s = s + "<tr><td>Height</td><td>:</td><td><b> " + this.height +"</td></tr>";

		s = s + "<tr><td>Weight</td><td>:</td><td><b> " + this.weight +"</td></tr>";

		s = s + "<tr><td >Year of Birth</td><td>:</td><td><b> " + this.dob +"</td></tr>";

		s = s + "<tr><td >Previous Team</td><td>:</td><td><b> " + this.hometown +"</td></tr>";

		//s = s + "<hr><b>Player Stats</b>";

		//s = s + "<br>Games Played: " + this.games;

		//s = s + "<br>Goals: " + this.goals;

		//s = s + "<br>Assists: " + this.assists;

		//s = s + "<br>Total Points: " + this.points;

		//s = s + "<br>Penalty Minutes: " + this.penaltyMins;

		//if(this.position.toLowerCase()== "goalie" || this.position.toLowerCase()== "goal" || this.position.toLowerCase()== "g") {

			//s = s + "<hr><b>Goalie Stats</b>";

			//s = s + "<br>Goals Against (Total): " + this.goalsAgainst;

			//s = s + "<br>Goals Against (Avg): " + this.goalsAgainstAvg;

			//s = s + "<br>Minutes Played: " + this.minutes;

			//s = s + "<br>Save Percentage: " + this.savePct;

		//}

	}

	s = s + "</table>";
	s = s + "</span><hr width=280>";



	s = s + "<br>";

	return s;

}

Player.prototype.getStatPage = function() {

	var sHTML = "<html><head>";

	sHTML = sHTML + "<title>Hartford Junior Wolf Pack Player Bio : " + this.name + "</title><LINK href=\"../include/style2006.css\" type=text/css rel=stylesheet></head>";

	sHTML = sHTML + "<body bgcolor=000000>"

	sHTML = sHTML + "<table><tr>"

	sHTML = sHTML + "<td valign=top width=200><img src=\"../headshots/" + this.image + "\"+ border=0 width=200 height=250  onerror=\"this.src='http://www.clippershockey.com/headshots/coming_soon.jpg'\"></td>";

	sHTML = sHTML + "<td valign=top width=300>" + this.formatStats();

	sHTML = sHTML + "<center><img src=\"../images/intro_logo.gif\"></center>";

	sHTML = sHTML + "</td></tr></table>"

	sHTML = sHTML + "<p align=right><a href='javascript:window.close()' class=footer>Close Window</a>&nbsp;&nbsp;&nbsp;</p>";

	sHTML = sHTML + "</body></html>"

	return sHTML;	

}



function openPlayer(index) {

	var height=490;



	if(r.getPlayer(index).detailed) {

		if(r.getPlayer(index).position.toLowerCase()== "goalie") {

			height = 300;

		} else {

			height=300;

		}

	} else {

		height=300;

	}

	w = window.open("","_blank","height=" + height + ",width=515,left=150,top=150,status=no,toolbar=no,menubar=no,location=no");

	w.document.write(r.getPlayer(index).getStatPage());

}	



function Schedule(teamName, data) {

	this.teamName = teamName;

	this.games = new Array();

	if(data.length>0) {

		arrRows = data.split("\n");

		for(var i=0;i<arrRows.length;i++) {

			arrRow = arrRows[i].split(",");

			for(var x=arrRow.length;x<7;x++) {

				arrRow[x] = "";

			}

			//date, time, location, team, w/l, gf, ga

			this.games[i] = new Array();

			this.games[i].date = arrRow[0];

			this.games[i].time = arrRow[1];

			this.games[i].type = arrRow[2];

			this.games[i].location = arrRow[3];

			this.games[i].team = arrRow[4];

			this.games[i].outcome = arrRow[5];

			this.games[i].goalsFor = arrRow[6];

			this.games[i].goalsAgainst = arrRow[7];

		}

	}

	

}


function getScheduleTable(schedule) {

	var sTable = "<table cellspacing=0 cellpadding=0 border=0 width=585 class=\"text\" background=\"../images/bg_caption.gif\"";

	sTable = sTable + "<tr>";

	sTable = sTable + "<td align=\"left\" bgcolor=000000 width=85><b>Date</b></td>";

	sTable = sTable + "<td align=\"left\" bgcolor=000000 width=60><b>Time</b></td>";

	sTable = sTable + "<td align=\"center\" bgcolor=000000 width=40><b>H/A</b></td>";

	sTable = sTable + "<td align=\"left\" bgcolor=000000><b>Location</b></td>";

	sTable = sTable + "<td align=\"left\" bgcolor=000000><b>Opponent</b></td>";

	sTable = sTable + "<td align=\"center\" bgcolor=000000 width=25><b>W/L</b></td>";

	sTable = sTable + "<td align=\"center\" bgcolor=000000 width=25><b>GF</b></td>";

	sTable = sTable + "<td align=\"center\" bgcolor=000000 width=25><b>GA</b></td>";

	sTable = sTable + "</tr>";

       sTable = sTable + "<tr><td colspan=\"8\" bgcolor=ffffff></td></tr>";
       sTable = sTable + "<tr><td colspan=\"8\" height=4></td></tr>";

	for(i=0;i<schedule.games.length;i++) {

		sTable = sTable + "<tr>";

		sTable = sTable + "<td align=\"left\">" + schedule.games[i].date + "</td>";

		sTable = sTable + "<td align=\"left\">" + schedule.games[i].time + "</td>";

		sTable = sTable + "<td align=\"center\">" + schedule.games[i].type + "</td>";

		sTable = sTable + "<td align=\"left\">" + schedule.games[i].location + "</td>";

		sTable = sTable + "<td align=\"left\">" + schedule.games[i].team + "</td>";

		sTable = sTable + "<td align=\"center\">" + schedule.games[i].outcome + "</td>";

		sTable = sTable + "<td align=\"center\">" + schedule.games[i].goalsFor + "</td>";

		sTable = sTable + "<td align=\"center\">" + schedule.games[i].goalsAgainst + "</td>";


		sTable = sTable + "</tr>";

	}

       sTable = sTable + "<tr><td colspan=\"8\" height=4></td></tr>";
       sTable = sTable + "<tr><td colspan=\"8\" height=2 bgcolor=ffffff></td></tr>";

	sTable = sTable + "</table>";

	return sTable;



}


