$(document).ready(function() {
	/* INITIAL RUNS */
	$(window).resize(checkWidth);
	checkWidth();
});

function checkWidth() {
	if($("#game-page").size() > 0) {
		if($(window).width() < 875) {
		  $("#playerStats thead th.goals").html("G");
		  $("#playerStats thead th.assists").html("A");
		  $("#playerStats thead th.points").html("P");

		  $("#goalStats thead th.assist1").html("Assist");
		  $("#goalStats thead th.assist2").html("Assist");
		} else {
		  $("#playerStats thead th.goals").html("Goals");
		  $("#playerStats thead th.assists").html("Assists");
		  $("#playerStats thead th.points").html("Points");

		  $("#goalStats thead th.assist1").html("Assist #1");
		  $("#goalStats thead th.assist2").html("Assist #2");
		}
	} else if($("#goalie-stats").size() > 0) {
		if($(window).width() < 875) {
		  $("#goalieStats thead th.wins").html("W");
		  $("#goalieStats thead th.losses").html("L");
		  $("#goalieStats thead th.ties").html("T");
		  $("#goalieStats thead th.points").html("P");
		} else {
		  $("#goalieStats thead th.wins").html("Wins");
		  $("#goalieStats thead th.losses").html("Losses");
		  $("#goalieStats thead th.ties").html("Ties");
		  $("#goalieStats thead th.points").html("Points");
		}
	} else if($("#player-page").size() > 0) {
		if($(window).width() < 750) {
		  $("#playerStats thead th.goals").html("G");
		  $("#playerStats thead th.assists").html("A");
		  $("#playerStats thead th.points").html("P");
		  $("#playerStats thead th.point_streak").html("Streak");

		  $("#gameStats td.date").each(function() {
			var date = $(this).html();
			var index = date.indexOf(',');
			if(index != -1) {
			  date = date.substring(0, (index - 2));
			  $(this).html(date);
			}
		  });

		  $("#careerRSStats thead th.goals").html("G");
		  $("#careerRSStats thead th.assists").html("A");
		  $("#careerRSStats thead th.points").html("P");

		  $("#careerPOStats thead th.goals").html("G");
		  $("#careerPOStats thead th.assists").html("A");
		  $("#careerPOStats thead th.points").html("P");

		  $("#careerTotalStats thead th.goals").html("G");
		  $("#careerTotalStats thead th.assists").html("A");
		  $("#careerTotalStats thead th.points").html("P");
		} else {
		  $("#playerStats thead th.goals").html("Goals");
		  $("#playerStats thead th.assists").html("Assists");
		  $("#playerStats thead th.points").html("Points");
		  $("#playerStats thead th.point_streak").html("Point Streak");

		  $("#gameStats td.date").each(function() {
			var date = $(this).parent('tr').find('.old_date').html();
			$(this).html(date);
		  });

		  $("#careerRSStats thead th.goals").html("Goals");
		  $("#careerRSStats thead th.assists").html("Assists");
		  $("#careerRSStats thead th.points").html("Points");

		  $("#careerPOStats thead th.goals").html("Goals");
		  $("#careerPOStats thead th.assists").html("Assists");
		  $("#careerPOStats thead th.points").html("Points");

		  $("#careerTotalStats thead th.goals").html("Goals");
		  $("#careerTotalStats thead th.assists").html("Assists");
		  $("#careerTotalStats thead th.points").html("Points");
		}
	}  else if($("#goalie-page").size() > 0) {
		if($(window).width() < 750) {
		  $("#gameStats td.date").each(function() {
			var date = $(this).html();
			var index = date.indexOf(',');
			if(index != -1) {
			  date = date.substring(0, (index - 2));
			  $(this).html(date);
			}
		  });
		  $("#careerRSStats thead th.wins").html("W");
		  $("#careerRSStats thead th.losses").html("L");
		  $("#careerRSStats thead th.ties").html("T");
		  $("#careerRSStats thead th.points").html("P");
		  
		  $("#careerPOStats thead th.wins").html("W");
		  $("#careerPOStats thead th.losses").html("L");
		  $("#careerPOStats thead th.ties").html("T");
		  $("#careerPOStats thead th.points").html("P");
		} else {
		  $("#gameStats td.date").each(function() {
			var date = $(this).parent('tr').find('.old_date').html();
			$(this).html(date);
		  });
		  $("#careerRSStats thead th.wins").html("Wins");
		  $("#careerRSStats thead th.losses").html("Losses");
		  $("#careerRSStats thead th.ties").html("Ties");
		  $("#careerRSStats thead th.points").html("Points");
		  
		  $("#careerPOStats thead th.wins").html("Wins");
		  $("#careerPOStats thead th.losses").html("Losses");
		  $("#careerPOStats thead th.ties").html("Ties");
		  $("#careerPOStats thead th.points").html("Points");
		}
	} else if($("#player-stats").size() > 0) {
		if($(window).width() < 750) {
		  $("#playerStats thead th.goals").html("G");
		  $("#playerStats thead th.assists").html("A");
		  $("#playerStats thead th.points").html("P");
		  $("#playerStats thead th.point_streak").html("Streak");
		} else {
		  $("#playerStats thead th.goals").html("Goals");
		  $("#playerStats thead th.assists").html("Assists");
		  $("#playerStats thead th.points").html("Points");
		  $("#playerStats thead th.point_streak").html("Point Streak");
		}
	} else if($("#schedule-page").size() > 0) {
		if($(window).width() < 750) {
		  $("#schedule thead th.game_number").html("#");
			$("#schedule thead th.home_team").html("Home");
			$("#schedule thead th.away_team").html("Away");
			$("#schedule thead th.home_score").html("Score");
			$("#schedule thead th.away_score").html("Score");
			$("#schedule td.date").each(function() {
			  var date = $(this).html();
			  var index = date.indexOf(',');
			  if(index != -1) {
				date = date.substring(0, (index - 2));
				$(this).html(date);
			  }
			});
		} else {
		  $("#schedule thead th.game_number").html("Game #");
			$("#schedule thead th.home_team").html("Home Team");
			$("#schedule thead th.away_team").html("Away Team");
			$("#schedule thead th.home_score").html("Home Score");
			$("#schedule thead th.away_score").html("Away Score");
			$("#schedule td.date").each(function() {
			  var date = $(this).parent('tr').find('.old_date').html();
			  $(this).html(date);
			});
		}
	} else if($("#standings-page").size() > 0) {
		if($(window).width() < 750) {
		  $("#teamStats thead th.wins").html("W");
		  $("#teamStats thead th.losses").html("L");
		  $("#teamStats thead th.ties").html("T");
		  $("#teamStats thead th.points").html("P");
		} else {
		  $("#teamStats thead th.wins").html("Wins");
		  $("#teamStats thead th.losses").html("Losses");
		  $("#teamStats thead th.ties").html("Ties");
		  $("#teamStats thead th.points").html("Points");
		}
	} else if($("#team-page").size() > 0) {
		if($(window).width() < 750) {
		  $("#teamStats thead th.wins").html("W");
		  $("#teamStats thead th.losses").html("L");
		  $("#teamStats thead th.ties").html("T");
		  $("#teamStats thead th.points").html("P");

		  $("#playerStats thead th.rank").html("#");
		  $("#playerStats thead th.goals").html("G");
		  $("#playerStats thead th.assists").html("A");
		  $("#playerStats thead th.ties").html("T");
		  $("#playerStats thead th.points").html("P");
		  $("#playerStats thead th.point_streak").html("Streak");

		  $("#goalieStats thead th.wins").html("W");
		  $("#goalieStats thead th.losses").html("L");
		  $("#goalieStats thead th.ties").html("T");
		  $("#goalieStats thead th.points").html("P");

		  $("#schedule thead th.game_number").html("#");
		  $("#schedule thead th.rtd").html("RTD");
		  $("#schedule td.date").each(function() {
			var date = $(this).html();
			var index = date.indexOf(',');
			if(index != -1) {
			  date = date.substring(0, (index - 2));
			  $(this).html(date);
			}
		  });
		} else {
		  $("#teamStats thead th.wins").html("Wins");
		  $("#teamStats thead th.losses").html("Losses");
		  $("#teamStats thead th.ties").html("Ties");
		  $("#teamStats thead th.points").html("Points");

		  $("#playerStats thead th.rank").html("Rank");
		  $("#playerStats thead th.goals").html("Goals");
		  $("#playerStats thead th.assists").html("Assists");
		  $("#playerStats thead th.ties").html("Ties");
		  $("#playerStats thead th.points").html("Points");
		  $("#playerStats thead th.point_streak").html("Point Streak");

		  $("#goalieStats thead th.wins").html("Wins");
		  $("#goalieStats thead th.losses").html("Losses");
		  $("#goalieStats thead th.ties").html("Ties");
		  $("#goalieStats thead th.points").html("Points");

		  $("#schedule thead th.game_number").html("Game #");
		  $("#schedule thead th.rtd").html("Record To Date");
		  $("#schedule td.date").each(function() {
			var date = $(this).parent('tr').find('.old_date').html();
			$(this).html(date);
		  });
		}
	}
}
