var who;
var ntgameYear;
var byeweek_flag;

function wr_hdr_year (yr, conf) {
	document.write("<div id=\"yr" + yr + "\">\n");
	document.write("	<div style=\"width: 360px; height: 40px; color: #000; background: #fff; border-left: 1px solid #000; border-top: 1px solid #000; border-right: 1px solid #000; text-align: center;\">\n");
	switch (conf) {
		case 'Sun Belt':
			document.write("		<img src=\"images/sunbelt.gif\" width=\"100\" height=\"40\" alt=\"\" align=\"top\" />\n");
			break;
		case 'Big West':
			document.write("		<img src=\"images/bigwest.gif\" width=\"100\" height=\"40\" alt=\"\" align=\"top\" />\n");
			break;
		case 'Independent':
			document.write("		<img src=\"images/indep.gif\" width=\"100\" height=\"40\" alt=\"\" align=\"top\" />\n");
			break;
		case 'Southland':
			document.write("		<img src=\"images/southland.gif\" width=\"100\" height=\"40\" alt=\"\" align=\"top\" />\n");
			break;
	}
	document.write("	</div>\n");
	document.write("	<div style=\"width: 362px; height: 15px; color: #fff; background: #000; text-align: center;\">" + yr + " " + conf + " Conference Schedule</div>\n");
	document.write("	<div style=\"width: 362px; height: 15px; background: #ccc; border-bottom: 1px solid #656565;\">\n");
	document.write("		<div style=\"float: right; width: 362px; height: 15px; line-height: 1.1em; color: #000;\">\n");
	document.write("			<span style=\"float: left; width: 187px; text-align: left; padding-left: 45px;\">Team</span>\n");
	document.write("			<span style=\"float: left; width: 40px; text-align: center;\">Conf.</span>\n");
	document.write("			<span style=\"float: left; width: 40px; text-align: center;\">Overall</span>\n");
	document.write("		</div>\n");
	document.write("	</div>\n");
}

function wr_ftr_year () {
	document.write("</div>\n");
}

function wr_hdr_team (teamname, yr, games, cW, cL, aW, aL) {
	findvariables (yr, teamname);
	who = teamname;
	byeweek_flag = 'N';
	document.write("<div id=\"" + yr + teamcode + "_set\" style=\"width: 362px; height: 15px; background: url(\'images/teams/bkgnds/" + teamcode + "_bg.png\') repeat-x;\">\n");
	document.write("	<div>\n");
	document.write("		<div style=\"float: right; width: 322px; height: 15px; line-height: 1.1em; color: #fff;\">\n");
	document.write("			<span style=\"float: left; width: 187px; text-align: left; padding-left: 5px;\">" + teamname + " " + teamnamefull + "</span>\n");
	if ((cW == 0) && (cL == 0)) {
		if (yearToShow == yr) {
			document.write("			<span style=\"float: left; width: 40px; text-align: center;\">0-0</span>\n");
		}
		else {
			document.write("			<span style=\"float: left; width: 40px; text-align: center;\">&nbsp;</span>\n");
		}
	}
	else {
		document.write("			<span style=\"float: left; width: 40px; text-align: center;\">" + cW + "-" + cL + "</span>\n");
	}
	if ((aW == 0) && (aL == 0)) {
		if (yearToShow == yr) {
			document.write("			<span style=\"float: left; width: 40px; text-align: center;\">0-0</span>\n");
		}
		else {
			document.write("			<span style=\"float: left; width: 40px; text-align: center;\">&nbsp;</span>\n");
		}
	}
	else {
		document.write("			<span style=\"float: left; width: 40px; text-align: center;\">" + aW + "-" + aL + "</span>\n");
	}	
	document.write("			<span style=\"float: left; width: 24px; text-align: center;\">\n");
	document.write("				<div id=\"" + yr + teamcode + "_img\" style=\"width: 39px; height: 15px; cursor: pointer; background: url(images/w_show.gif) no-repeat center;\" onclick=\"team_viewer(\'" + yr + teamcode + "\', " + games + ");\">\n");
	document.write("					<img src=\"images/1.gif\" width=\"28\" height=\"5\" alt=\"\" align=\"top\" />\n");
	document.write("				</div>\n");
	document.write("			</span>\n");
	document.write("		</div>\n");
	document.write("		<div style=\"width: 40px; height: 15px; background: url(\'images/teams/" + teamcode + "_sm.gif\') no-repeat 0px -9px;\"></div>\n");
	document.write("	</div>\n");
	document.write("	<div id=\"" + yr + teamcode + "_row\" style=\"display: none;\">\n");
	document.write("		<div style=\"width: 362px; height: 15px; background: #ccc; border-bottom: 1px solid #656565;\">\n");
	document.write("			<div style=\"float: right; width: 362px; line-height: 1.1em; height: 15px; color: #000;\">\n");
	document.write("				<span style=\"float: left; width: 40px; text-align: center;\">Date</span>\n");
	document.write("				<span style=\"float: left; width: 107px; text-align: left; padding-left: 85px;\">Opponent</span>\n");
	document.write("				<span style=\"float: left; width: 40px; text-align: center;\">W/L</span>\n");
	document.write("				<span style=\"float: left; width: 40px; text-align: center;\">W/L</span>\n");
	document.write("				<span style=\"float: left; width: 40px; text-align: center;\">Score</span>\n");
	document.write("			</div>\n");
	document.write("		</div>\n");
}

function wr_ftr_team () { 
	document.write("	</div>\n");
	document.write("</div>\n");
}

function wr_dtl_game (gameYear, week, homeaway, ranking, opponent, gameMonth, gameDay, win_loss, score) {
	findvariables (gameYear, opponent);
	var conf_game = det_if_conf_game (gameYear, opponent);
	var next_game = det_if_next_game (gameYear, gameMonth, gameDay);
	if (next_game == true) {
		if (byeweek_flag != 'N') {
			var matchFound = false;
			for (idx = 0; idx <= nextgames_idx - 1; idx++) {
				if (nextgames[idx].opponent == who) {
					matchFound = true;
					break;
				}
			}
			if (matchFound == false) {
				nextgames[nextgames_idx] = new nextgame(who, homeaway, opponent, score);
				nextgames_idx = nextgames_idx + 1;
			}
		}
	}

	if (who == 'North Texas') {
		if (next_game == true) { 
			//alert('(' + ntgames_idx + ') ' + who + ' vs ' + opponent + ' found.');
			ntgames[ntgames_idx] = new ntgame (gameYear, week, homeaway, ranking, opponent, gameMonth, gameDay, win_loss, score, teamcode, teamnamefull, pricolor, seccolor);
			ntgames_idx = ntgames_idx + 1;
			ntgameYear = gameYear;
		}
		else {
			if (gameYear == ntgameYear) {
				if ((ntgames_idx > 0) && (ntgames_idx < 3)) {
					switch (ntgames_idx) {
						case 1:
							//alert('(' + ntgames_idx + ') ' + who + ' vs ' + opponent + ' found.');
							ntgames[ntgames_idx] = new ntgame (gameYear, week, homeaway, ranking, opponent, gameMonth, gameDay, win_loss, score, teamcode, teamnamefull, pricolor, seccolor);
							break;
						case 2:
							//alert('(' + ntgames_idx + ') ' + who + ' vs ' + opponent + ' found.');
							ntgames[ntgames_idx] = new ntgame (gameYear, week, homeaway, ranking, opponent, gameMonth, gameDay, win_loss, score, teamcode, teamnamefull, pricolor, seccolor);
							break;
					}
					ntgames_idx = ntgames_idx + 1;
				}
			}
		}
	}
	
	document.write("<div style=\"width: 362px; height: 15px; background: url(\'images/teams/bkgnds/" + teamcode + "_bg.png\') repeat-x;\">\n");
	document.write("	<div style=\"float: right; width: 362px; color: #fff; line-height: 1.1em;\">\n");
	if ((gameMonth == 0) || (gameDay == 0)) {
		document.write("		<span style=\"float: left; width: 40px; text-align: center;\">&nbsp;</span>\n");
	}
	else {
		document.write("		<span style=\"float: left; width: 40px; text-align: center;\">" + gameMonth + "/" + gameDay + "</span>\n");
	}
	switch (homeaway) {
		case 'H':
			document.write("		<span style=\"float: left; width: 10px; text-align: left; padding-right: 5px;\">&nbsp;</span>\n");
			break;
		case '@':
			document.write("		<span style=\"float: left; width: 10px; text-align: left; padding-right: 5px;\">@</span>\n");
			break;
		default:
			document.write("		<span style=\"float: left; width: 10px; text-align: left; padding-right: 5px;\">&nbsp;?</span>\n");
			break;
	}
	if (ranking == 0) {
		document.write("		<span style=\"float: left; width: 20px; text-align: left; padding-right: 5px;\">&nbsp;</span>\n");
	}
	else {
		document.write("		<span style=\"float: left; width: 20px; text-align: left; padding-right: 5px;\">#" + ranking + "</span>\n");
	}
	document.write("		<span style=\"float: left; width: 40px;\">\n");
	document.write("			<div style=\"width: 40px; height: 15px; background: url('images/teams/" + teamcode + "_sm.gif') no-repeat 0px -9px;\"></div>\n");
	document.write("		</span>\n");
	document.write("		<span style=\"float: left; width: 107px; text-align: left; padding-left: 5px;\">" + opponent + "</span>\n");
	switch (win_loss) {	
		case 'W':
			if (conf_game == true) {
				document.write("		<span style=\"float: left; width: 40px; text-align: center;\">" + win_loss + "</span>\n");
			}
			else {
				document.write("		<span style=\"float: left; width: 40px; text-align: center;\">&nbsp;</span>\n");
			}
			document.write("		<span style=\"float: left; width: 40px; text-align: center;\">" + win_loss + "</span>\n");
			break;		
		case 'L':
			if (conf_game == true) {
				document.write("		<span style=\"float: left; width: 40px; text-align: center;\">" + win_loss + "</span>\n");
			}
			else {
				document.write("		<span style=\"float: left; width: 40px; text-align: center;\">&nbsp;</span>\n");
			}
			document.write("		<span style=\"float: left; width: 40px; text-align: center;\">" + win_loss + "</span>\n");
			break;		
		case 'T':
			if (conf_game == true) {
				document.write("		<span style=\"float: left; width: 40px; text-align: center;\">" + win_loss + "</span>\n");
			}
			else {
				document.write("		<span style=\"float: left; width: 40px; text-align: center;\">&nbsp;</span>\n");
			}
			document.write("		<span style=\"float: left; width: 40px; text-align: center;\">" + win_loss + "</span>\n");
			break;		
		case '1st':
			if (conf_game == true) {
				document.write("		<span style=\"float: left; width: 40px; text-align: center;\">&bull;</span>\n");
			}
			else {
				document.write("		<span style=\"float: left; width: 40px; text-align: center;\">&nbsp;</span>\n");
			}
			document.write("		<span style=\"float: left; width: 40px; text-align: center;\">1st</span>\n");
			break;		
		case '2nd':
			if (conf_game == true) {
				document.write("		<span style=\"float: left; width: 40px; text-align: center;\">&bull;</span>\n");
			}
			else {
				document.write("		<span style=\"float: left; width: 40px; text-align: center;\">&nbsp;</span>\n");
			}
			document.write("		<span style=\"float: left; width: 40px; text-align: center;\">2nd</span>\n");
			break;		
		case 'Half':
			if (conf_game == true) {
				document.write("		<span style=\"float: left; width: 40px; text-align: center;\">&bull;</span>\n");
			}
			else {
				document.write("		<span style=\"float: left; width: 40px; text-align: center;\">&nbsp;</span>\n");
			}
			document.write("		<span style=\"float: left; width: 40px; text-align: center;\">Half</span>\n");
			break;		
		case '3rd':
			if (conf_game == true) {
				document.write("		<span style=\"float: left; width: 40px; text-align: center;\">&bull;</span>\n");
			}
			else {
				document.write("		<span style=\"float: left; width: 40px; text-align: center;\">&nbsp;</span>\n");
			}
			document.write("		<span style=\"float: left; width: 40px; text-align: center;\">3rd</span>\n");
			break;		
		case '4th':
			if (conf_game == true) {
				document.write("		<span style=\"float: left; width: 40px; text-align: center;\">&bull;</span>\n");
			}
			else {
				document.write("		<span style=\"float: left; width: 40px; text-align: center;\">&nbsp;</span>\n");
			}
			document.write("		<span style=\"float: left; width: 40px; text-align: center;\">4th</span>\n");
			break;		
		case '':
			//document.write("		<span style=\"float: left; width: 40px; text-align: center;\">&nbsp;</span>\n");
			if (conf_game == true) {
				document.write("		<span style=\"float: left; width: 40px; text-align: center;\">&bull;</span>\n");
			}
			else {			
				document.write("		<span style=\"float: left; width: 40px; text-align: center;\">&nbsp;</span>\n");
			}
			if (next_game == true) {
				document.write("		<span style=\"float: left; width: 40px; text-align: center;\">Next</span>\n");
			}
			else {
				document.write("		<span style=\"float: left; width: 40px; text-align: center;\">&nbsp;</span>\n");
			}
			break;
		default  :
			document.write("		<span style=\"float: left; width: 40px; text-align: center;\">&nbsp;</span>\n");
			document.write("		<span style=\"float: left; width: 40px; text-align: center;\">&nbsp;</span>\n");
			break;
	}
	if (score == '') {
		document.write("		<span style=\"float: left; width: 40px; text-align: center;\">&nbsp;</span>\n");
	}
	else {
		document.write("		<span style=\"float: left; width: 40px; text-align: center;\">" + score + "</span>\n");
	}
	document.write("	</div>\n");
	document.write("</div>\n");
}

function team_viewer(yearteam, games) {
	teamset=yearteam+'_set';
	teamrow=yearteam+'_row';
	imgid=yearteam+'_img';
	height=((games+2)*15)+2;
	newheight=height+'px';
	thedisplay=document.getElementById(teamrow).style.display;
	if(thedisplay=='none'){
		document.getElementById(teamset).style.height=newheight;
		document.getElementById(teamrow).style.display='block';
		document.getElementById(imgid).style.backgroundImage='url(images/w_hide.gif)';
	}
	else if(thedisplay=='block'){
		document.getElementById(teamset).style.height='15px';
		document.getElementById(teamrow).style.display='none';
		document.getElementById(imgid).style.backgroundImage='url(images/w_show.gif)';
	}
	return false;
}

function det_if_conf_game (gameYear, opponent) {
	switch (opponent) {
		case 'North Texas' :
			return true;
			break;
		case 'Western Kentucky' :
			if (gameYear >= 2009) {		
				return true;
			}
			else {
				return false;
			}
			break;
		case 'Florida Atlantic' :
			if (gameYear >= 2004) {		
				return true;
			}
			else {
				return false;
			}
			break;
		case 'Florida International' :
			if (gameYear >= 2004) {		
				return true;
			}
			else {
				return false;
			}
			break;
		case 'Troy' :
			if (gameYear >= 2005) {		
				return true;
			}
			else {
				return false;
			}
			break;
		case 'Louisiana Lafayette' :
			if (gameYear >= 2001) {		
				return true;
			}
			else {
				return false;
			}
			break;
		case 'Louisiana Monroe' :
			if (gameYear >= 2001) {		
				return true;
			}
			else {
				return false;
			}
			break;
		case 'Middle Tennessee' :
			if (gameYear >= 2001) {		
				return true;
			}
			else {
				return false;
			}
			break;
		case 'Arkansas State' :
			if (gameYear >= 1999) {		
				return true;
			}
			else {
				return false;
			}
			break;
		case 'Idaho' :
			if (gameYear <= 2004 && gameYear >=1996) {		
				return true;
			}
			else {
				return false;
			}
			break;
		case 'New Mexico State' :
			if (gameYear <= 2004 && gameYear >=1996) {		
				return true;
			}
			else {
				return false;
			}
			break;
		case 'Utah State' :
			if ((gameYear <= 2004 && gameYear >=2003) || (gameYear <= 2000 && gameYear >=1996)) {		
				return true;
			}
			else {
				return false;
			}
			break;
		case 'Boise State' :
			if (gameYear <= 2000 && gameYear >=1996) {		
				return true;
			}
			else {
				return false;
			}
			break;
		case 'Nevada' :
			if (gameYear <= 1999 && gameYear >=1996) {		
				return true;
			}
			else {
				return false;
			}
			break;
		case 'McNeese State' :
			if (gameYear <= 1994) {		
				return true;
			}
			else {
				return false;
			}
			break;
		case 'Stephen F. Austin' :
			if (gameYear <= 1994) {		
				return true;
			}
			else {
				return false;
			}
			break;
		case 'Northwestern State' :
			if (gameYear <= 1994) {		
				return true;
			}
			else {
				return false;
			}
			break;
		case 'Sam Houston State' :
			if (gameYear <= 1994) {		
				return true;
			}
			else {
				return false;
			}
			break;
		case 'Nicholls State' :
			if (gameYear <= 1994) {		
				return true;
			}
			else {
				return false;
			}
			break;
		case 'Texas State' :
			if (gameYear <= 1994) {		
				return true;
			}
			else {
				return false;
			}
			break;
		default  :
			return false;
			break;
	}
}


function cnv_date(y, m, d) {
	var yyyy = y + "";
	var mm = m + "";
	var dd = d + "";
	if (mm.length < 2) { mm = "0" + mm; } else { mm = mm + ""; }
	if (dd.length < 2) { dd = "0" + dd; } else { dd = dd + ""; }
	return (yyyy + mm + dd);
}

function det_if_next_game (gameYear, gameMonth, gameDay) {
	if ((gameMonth != 0) && (gameDay != 0)) {
		gameDate = cnv_date (gameYear, gameMonth, gameDay);
		begDate = cnv_date (nowYear, nowMonth, nowDay);
		endDate = cnv_date (thisSatYear, thisSatMonth, thisSatDay);
		endDate2 = cnv_date (nextSat1Year, nextSat1Month, nextSat1Day);
	
		if ((gameDate >= begDate) && (gameDate <= endDate)) {
			byeweek_flag = 'Y';
			return true;
		}
		else {
			if ((gameDate >= begDate) && (gameDate <= endDate2) && (byeweek_flag == 'N')) {
				return true;
			}
			else {
				return false;
			}
		}
	}	
}

//---------------------------------------------------------------------------------------------------------------------------
// determine calendar dates for schedule functionality
//---------------------------------------------------------------------------------------------------------------------------

// find today's date
var nowDate = new Date();
var nowYear = nowDate.getYear();
if (nowYear < 2000) { nowYear = nowDate.getYear() + 1900; }
var nowMonth = nowDate.getMonth() + 1;
var nowDay = nowDate.getDate();
var nowDayOfWeek = nowDate.getDay();
//alert('nowDate=' + nowDate + '\nToday is : ' + nowMonth + '/' + nowDay + '/' + nowYear + ' (Day of Week = '+ nowDayOfWeek + ')');

//based on today - find the saturday for this week
var thisSatDate = new Date();
thisSatDate.setDate(thisSatDate.getDate() + (6 - nowDayOfWeek));
var thisSatYear = thisSatDate.getYear();
if (thisSatYear < 2000) { thisSatYear = thisSatDate.getYear() + 1900; }
var thisSatMonth = thisSatDate.getMonth() + 1;
var thisSatDay = thisSatDate.getDate();
var thisSatDayOfWeek = thisSatDate.getDay();
//alert('thisSatDate=' + thisSatDate + '\nThe Saturday for this week is : ' + thisSatMonth + '/' + thisSatDay + '/' + thisSatYear + ' (Day of Week = '+ thisSatDayOfWeek + ')');

//based on today - find the coming wednesday date
var nextWedDate = new Date();
if (nowDayOfWeek <= 3) {
	nextWedDate.setDate(nextWedDate.getDate() + (3 - nowDayOfWeek));
}
else {
	nextWedDate.setDate(nextWedDate.getDate() + (6 - nowDayOfWeek) + 4);
}
var nextWedYear = nextWedDate.getYear();
if (nextWedYear < 2000) { nextWedYear = nextWedDate.getYear() + 1900; }
var nextWedMonth = nextWedDate.getMonth() + 1;
var nextWedDay = nextWedDate.getDate();
var nextWedDayOfWeek = nextWedDate.getDay();
//alert('nextWedDate=' + nextWedDate + '\nThe next Wednesday date is : ' + nextWedMonth + '/' + nextWedDay + '/' + nextWedYear + ' (Day of Week = '+ nextWedDayOfWeek + ')');

//based on today - find the next sunday date (sun 1)
var nextSun1Date = new Date();
nextSun1Date.setDate(nextSun1Date.getDate() + (6 - nowDayOfWeek) + 1);
var nextSun1Year = nextSun1Date.getYear();
if (nextSun1Year < 2000) { nextSun1Year = nextSun1Date.getYear() + 1900; }
var nextSun1Month = nextSun1Date.getMonth() + 1;
var nextSun1Day = nextSun1Date.getDate();
var nextSun1DayOfWeek = nextSun1Date.getDay();
//alert('nextSun1Date=' + nextSun1Date + '\nThe Sunday for next week is : ' + nextSun1Month + '/' + nextSun1Day + '/' + nextSun1Year + ' (Day of Week = '+ nextSun1DayOfWeek + ')');

//based on today - find the saturday for next week (sat 1)
var nextSat1Date = new Date();
nextSat1Date.setDate(nextSat1Date.getDate() + (6 - nowDayOfWeek) + 7);
var nextSat1Year = nextSat1Date.getYear();
if (nextSat1Year < 2000) { nextSat1Year = nextSat1Date.getYear() + 1900; }
var nextSat1Month = nextSat1Date.getMonth() + 1;
var nextSat1Day = nextSat1Date.getDate();
var nextSat1DayOfWeek = nextSat1Date.getDay();
//alert('nextSat1Date=' + nextSat1Date + '\nThe Saturday for next week is : ' + nextSat1Month + '/' + nextSat1Day + '/' + nextSat1Year + ' (Day of Week = '+ nextSat1DayOfWeek + ')');

//based on today - find the sunday for the following week (sun 2)
var nextSun2Date = new Date();
nextSun2Date.setDate(nextSun2Date.getDate() + (6 - nowDayOfWeek) + 8);
var nextSun2Year = nextSun2Date.getYear();
if (nextSun2Year < 2000) { nextSun2Year = nextSun2Date.getYear() + 1900; }
var nextSun2Month = nextSun2Date.getMonth() + 1;
var nextSun2Day = nextSun2Date.getDate();
var nextSun2DayOfWeek = nextSun2Date.getDay();
//alert('nextSun2Date=' + nextSun2Date + '\nSunday for two weeks is : ' + nextSun2Month + '/' + nextSun2Day + '/' + nextSun2Year + ' (Day of Week = '+ nextSun2DayOfWeek + ')');

//based on today - find the saturday for the following week (sat 2)
var nextSat2Date = new Date();
nextSat2Date.setDate(nextSat2Date.getDate() + (6 - nowDayOfWeek) + 14);
var nextSat2Year = nextSat2Date.getYear();
if (nextSat2Year < 2000) { nextSat2Year = nextSat2Date.getYear() + 1900; }
var nextSat2Month = nextSat2Date.getMonth() + 1;
var nextSat2Day = nextSat2Date.getDate();
var nextSat2DayOfWeek = nextSat2Date.getDay();
//alert('nextSat2Date=' + nextSat2Date + '\nThe Saturday for two weeks is : ' + nextSat2Month + '/' + nextSat2Day + '/' + nextSat2Year + ' (Day of Week = '+ nextSat2DayOfWeek + ')');

/*
alert('nowDate=' + nowDate + '\nToday is : ' + nowMonth + '/' + nowDay + '/' + nowYear + ' (Day of Week = '+ nowDayOfWeek + ')\n\n' +
      'thisSatDate=' + thisSatDate + '\nThe Saturday for this week is : ' + thisSatMonth + '/' + thisSatDay + '/' + thisSatYear + ' (Day of Week = '+ thisSatDayOfWeek + ')\n\n' +
      'nextWedDate=' + nextWedDate + '\nThe next Wednesday date is : ' + nextWedMonth + '/' + nextWedDay + '/' + nextWedYear + ' (Day of Week = '+ nextWedDayOfWeek + ')\n\n' +
      'nextSun1Date=' + nextSun1Date + '\nThe Sunday for next week is : ' + nextSun1Month + '/' + nextSun1Day + '/' + nextSun1Year + ' (Day of Week = '+ nextSun1DayOfWeek + ')\n\n' +
      'nextSat1Date=' + nextSat1Date + '\nThe Saturday for next week is : ' + nextSat1Month + '/' + nextSat1Day + '/' + nextSat1Year + ' (Day of Week = '+ nextSat1DayOfWeek + ')\n\n' +
      'nextSun2Date=' + nextSun2Date + '\nThe Sunday for two weeks is : ' + nextSun2Month + '/' + nextSun2Day + '/' + nextSun2Year + ' (Day of Week = '+ nextSun2DayOfWeek + ')\n\n' +
      'nextSat2Date=' + nextSat2Date + '\nThe Saturday for two weeks is : ' + nextSat2Month + '/' + nextSat2Day + '/' + nextSat2Year + ' (Day of Week = '+ nextSat2DayOfWeek + ')');
*/  
	  
var minYear = 1994;
var maxYear = 2011;
function switchYear(year) {
	for (var chkYear = minYear; chkYear <= maxYear; chkYear++) {
		var el = document.getElementById('yr' + chkYear);
		if (chkYear == year) {
			el.style.display = '';
		}
		else {
			el.style.display = 'none';
		}
	}
}

var nextgames_idx = 0;
var nextgames_tot = 7;
var nextgames = new Array(nextgames_tot);
function nextgame (who, homeaway, opponent, score) {
	this.who = who;
	this.homeaway = homeaway;
	this.opponent = opponent;
	this.score = score;
}

function build_div_thisweek() {
	if (nextgames_idx > 0) {
		document.write("<table cellpadding=\"0\" cellspacing=\"0\" class=\"moduletable\">\n");
		document.write("	<tr>\n");
		document.write("		<td>\n");
		document.write("			<img src=\"images/center_thisweek.gif\" width=\"300\" height=\"20\" alt=\"This Week\" align=\"top\" /> \n");
		divHeight= 20 + (15*(nextgames_idx)) + (2*nextgames_idx) - 2;
		document.write("			<div style=\"background: #fff; height: " + divHeight + "px; background: url(\'images/gmg_bkgnd.gif\') repeat-y;\">\n");
		document.write("				<div style=\"width: 300px; height: 15px; color: #000; background: #ccc; border-bottom: 1px solid #656565;\">\n");
		document.write("					<span style=\"float: left; width: 105px; line-height: 1.1em; text-align: left; padding-left: 45px;\">Away</span>\n");
		document.write("					<span style=\"float: left; width: 105px; line-height: 1.1em; text-align: left; padding-left: 45px;\">Home</span>\n");
		document.write("				</div>\n");
		document.write("				<div style=\"width: 300px; height: 2px; background: transparent;\"></div>\n");
		nextgames_tot = nextgames_idx - 1;
		nextgames_idx = 0;
		for (idx = nextgames_idx; idx <= nextgames_tot; idx++) {
			document.write("				<div style=\"width: 300px; height: 15px; line-height: 1.1em; color: #fff;\">\n");
			if (nextgames[idx].homeaway == 'H') {
				hometeam = nextgames[idx].who;
				awayteam = nextgames[idx].opponent;
			}
			else {
				hometeam = nextgames[idx].opponent;
				awayteam = nextgames[idx].who;
			}
			findvariables (nowYear, hometeam);
			document.write("					<div style=\"float: right; width: 150px; height: 15px; background: url(\'images/teams/bkgnds/" + teamcode + "_bg.png\') repeat-x;\">\n");
			document.write("						<span style=\"float: left; width: 40px;\">\n");
			document.write("							<div style=\"width: 40px; height: 15px; background: url(\'images/teams/" + teamcode + "_sm.gif\') no-repeat 0px -9px;\"></div>\n");
			document.write("						</span>\n");
			document.write("						<span style=\"float: left; width: 100px; text-align: left; padding-left: 5px;\">" + hometeam + "</span>\n");
			document.write("					</div>\n");
			findvariables (nowYear, awayteam);
			document.write("					<div style=\"width: 150px; height: 15px; background: url(\'images/teams/bkgnds/" + teamcode + "_bg.png\') repeat-x;\">\n");
			document.write("						<span style=\"float: left; width: 40px;\">\n");
			document.write("							<div style=\"width: 40px; height: 15px; background: url(\'images/teams/" + teamcode + "_sm.gif\') no-repeat 0px -9px;\"></div>\n");
			document.write("						</span>\n");
			document.write("						<span style=\"float: left; width: 100px; text-align: left; padding-left: 5px;\">" + awayteam + "</span>\n");
			document.write("					</div>\n");
			document.write("				</div>\n");
			document.write("				<div style=\"width: 300px; height: 2px; background: transparent;\">&nbsp;</div>\n");
		}
		document.write("			</div>\n");
		document.write("		</td>\n");
		document.write("	</tr>\n");
		document.write("</table>\n");
	}
}

var ntgames_idx = 0;
var ntgames_tot = 2;
var ntgames = new Array(ntgames_tot);
function ntgame (gameYear, week, homeaway, ranking, opponent, gameMonth, gameDay, win_loss, score, teamcode, teamnamefull, pricolor, seccolor) {
	this.gameYear = gameYear;
	this.week = week;
	this.homeaway = homeaway;
	this.ranking = ranking;
	this.opponent = opponent;
	this.gameMonth = gameMonth;
	this.gameDay = gameDay;
	this.win_loss = win_loss;
	this.score = score;
	this.teamcode = teamcode;
	this.teamnamefull = teamnamefull; 
	this.pricolor = pricolor;
	this.seccolor = seccolor;
}

function build_div_ntgames () {
	if (ntgames_idx > 0) {
		document.write("<img align=\"top\" width=\"300\" src=\"images/center_upcoming.gif\" alt=\"Upcoming Games\" height=\"20\" />\n"); 
		document.write("<div style=\"width: 300px;\">\n"); 
		document.write("	<div class=\"u_games_area\">\n"); 
		document.write("		<span class=\"u_space_side\">\n"); 
		document.write("			<img src=\"images/1.gif\" width=\"20\" height=\"120\" border=\"0\" alt=\"\" />\n"); 
		document.write("		</span>\n"); 
		for (idx = 0; idx <= ntgames_idx - 1; idx++) {
			wr_ntgame(idx, 'N');
		}
		if (ntgames_idx - 1 < ntgames_tot) {
			for (idx = ntgames_idx; idx <= ntgames_tot; idx++) {
				wr_ntgame(idx, 'Y');
			}
		}
		document.write("		<span class=\"u_space_side\">\n"); 
		document.write("			<img src=\"images/1.gif\" width=\"20\" height=\"120\" border=\"0\" alt=\"\" />\n"); 
		document.write("		</span>\n"); 
		document.write("		<img src=\"images/1.gif\" width=\"300\" height=\"96\" border=\"0\" alt=\"\" />\n"); 
		document.write("	</div>\n"); 
		for (idx = 0; idx <= ntgames_idx - 1; idx++) {
			if (idx == 0) {
				document.write("	<div id=\"" + idx + "_name\" class=\"u_name_area\" style=\"background: " + ntgames[idx].seccolor + "; display: block;\">\n"); 
			}
			else {
				document.write("	<div id=\"" + idx + "_name\" class=\"u_name_area\" style=\"background: " + ntgames[idx].seccolor + "; display: none;\">\n"); 
			}
			document.write("		<div class=\"u_name\" style=\"color: " + ntgames[idx].pricolor + ";\">\n"); 
			document.write("			" + ntgames[idx].opponent + " " + ntgames[idx].teamnamefull + "\n"); 
			document.write("		</div>\n"); 
			document.write("	</div>\n"); 
		}
		document.write("</div>\n");
	}
}

function wr_ntgame(idx, isEmpty) {
	if (isEmpty == 'N') {
		if (idx == 0) {
			document.write("		<span id=\"" + idx + "_game\" class=\"u_game\" style=\"background: " + ntgames[idx].pricolor + ";\" onmouseover=\"game_viewer(" + idx + ");\">\n"); 
		}
		else {
			document.write("		<span id=\"" + idx + "_game\" class=\"u_game\" style=\"background: #dde4d2;\" onmouseover=\"game_viewer(" + idx + ");\">\n"); 
		}
		document.write("			<div class=\"u_game_date\">\n"); 
		if (idx == 0) {
			document.write("				<span id=\"" + idx + "_date\" class=\"u_date\" style=\"color: #fff;\">" + ntgames[idx].gameMonth + "/" + ntgames[idx].gameDay + "</span>\n"); 
		}
		else {
			document.write("				<span id=\"" + idx + "_date\" class=\"u_date\" style=\"color: #000;\">" + ntgames[idx].gameMonth + "/" + ntgames[idx].gameDay + "</span>\n"); 
		}
		document.write("				<img src=\"images/1.gif\" width=\"80\" height=\"15\" border=\"0\" alt=\"\" />\n"); 
		document.write("			</div>\n"); 
		document.write("			<div class=\"u_game_homeaway\">\n"); 
		if (ntgames[idx].homeaway == 'H') {
			if (idx == 0) {
				document.write("				<span id=\"" + idx + "_homeaway\" class=\"u_homeaway\" style=\"color: #fff;\">Home</span>\n"); 
			}
			else {
				document.write("				<span id=\"" + idx + "_homeaway\" class=\"u_homeaway\" style=\"color: #000;\">Home</span>\n"); 
			}
		}
		else {
			if (idx == 0) {
				document.write("				<span id=\"" + idx + "_homeaway\" class=\"u_homeaway\" style=\"color: #fff;\">Away</span>\n"); 
			}
			else {
				document.write("				<span id=\"" + idx + "_homeaway\" class=\"u_homeaway\" style=\"color: #000;\">Away</span>\n"); 
			}
		}
		document.write("				<img src=\"images/1.gif\" width=\"80\" height=\"15\" border=\"0\" alt=\"\" />\n"); 
		document.write("			</div>\n"); 
		document.write("			<div class=\"u_game_team\">\n"); 
		document.write("				<span class=\"u_game_space\">&nbsp;</span>\n"); 
		document.write("				<span class=\"u_game_img\" style=\"background: url(\'images/teams/" + ntgames[idx].teamcode + ".gif\') no-repeat -10px -5px;\">\n"); 
		document.write("					<img src=\"images/1.gif\" width=\"60\" height=\"50\" border=\"0\" alt=\"\" />\n"); 
		document.write("				</span>\n"); 
		document.write("				<span class=\"u_game_space\">&nbsp;</span>\n"); 
		document.write("				<img src=\"images/1.gif\" width=\"80\" height=\"50\" border=\"0\" alt=\"\" />\n"); 
		document.write("			</div>\n"); 
		if (idx == 0) {
			document.write("			<div id=\"" + idx + "_grad\" class=\"u_game_grad\" style=\"background: url(\'images/teams/bkgnds/" + ntgames[idx].teamcode + "_bg.png\') repeat-x; display: block;\">&nbsp;</div>\n"); 
		}
		else {
			document.write("			<div id=\"" + idx + "_grad\" class=\"u_game_grad\" style=\"background: url(\'images/teams/bkgnds/" + ntgames[idx].teamcode + "_bg.png\') repeat-x; display: none;\">&nbsp;</div>\n"); 
		}
		document.write("		</span>\n"); 
		if (idx <= 1) {								
			document.write("		<span class=\"u_space_mid\">\n"); 
			document.write("			<img src=\"images/1.gif\" width=\"7\" height=\"120\" border=\"0\" alt=\"\" />\n"); 
			document.write("		</span>\n"); 
		}
	}
	else {
		document.write("		<span id=\"" + idx + "_game\" class=\"u_game_empty\" style=\"background: #dde4d2;\">\n"); 
		document.write("			<img src=\"images/1.gif\" width=\"80\" height=\"120\" border=\"0\" alt=\"\" />\n"); 
		document.write("		</span>\n"); 
		if (idx <= 1) {								
			document.write("		<span class=\"u_space_mid\">\n"); 
			document.write("			<img src=\"images/1.gif\" width=\"7\" height=\"120\" border=\"0\" alt=\"\" />\n"); 
			document.write("		</span>\n"); 
		}
	}
}

function game_viewer(game) {
	for (idx = 0; idx <= ntgames_idx - 1; idx++) {
		gameid=idx+'_game';
		dateid=idx+'_date';
		homeawayid=idx+'_homeaway';
		gradid=idx+'_grad';
		nameid=idx+'_name';
		if (idx == game) {
			document.getElementById(gameid).style.background=ntgames[idx].pricolor;
			document.getElementById(dateid).style.color='#fff';
			document.getElementById(homeawayid).style.color='#fff';
			document.getElementById(gradid).style.display='block';
			document.getElementById(nameid).style.display='block';
		}
		else {
			document.getElementById(gameid).style.background='#dde4d2';
			document.getElementById(dateid).style.color='#000';
			document.getElementById(homeawayid).style.color='#000';
			document.getElementById(gradid).style.display='none';
			document.getElementById(nameid).style.display='none';
			
		}
	}
	return false;
}

function countdown() {
	if (ntgames_idx > 0) {
		if ((ntgames[0].gameYear != nowYear) ||
		    (ntgames[0].gameMonth != nowMonth) ||
			(ntgames[0].gameDay != nowDay)) {
			document.write("<table cellpadding=\"0\" cellspacing=\"0\" class=\"moduletable\">\n"); 
			document.write("	<tr>\n"); 
			document.write("		<td>\n"); 
			document.write("			<div style=\"width: 300px; background: #fff; height: 72px;\">\n"); 
			document.write("				<div style=\"width: 300px; height: 72px;\">\n"); 
			document.write("					<div id=\"countdown\">\n"); 
			document.write("					 	<div id=\"ccad\"><img src=\"scripts/countdown/ccad_nt.gif\"></div>\n"); 
			document.write("						<div class=\"hd\"></div>\n"); 
			document.write("						<div class=\"bd\" id=\"countdownbody\"><div id=\"countdownnumbers\"></div></div>\n"); 
			document.write("						<div class=\"ft\"></div>\n"); 
			document.write("					</div>\n"); 
			document.write("				</div>\n"); 
			document.write("				<script>\n"); 
			document.write("					countdownsetup();\n"); 
			document.write("					var countdowndigits = countdowninit();\n"); 
			document.write("					if (countdowndigits) { var sdcounter = setInterval(function() { countdowndigits = countmedown(countdowndigits); },1000); }\n"); 
			document.write("				</script>\n"); 
			document.write("			</div>\n"); 
			document.write("		</td>\n"); 
			document.write("	</tr>\n"); 
			document.write("</table>\n"); 
		}
	}
/* if no games in the near future, countdown for first game of the season. */
	else {
			document.write("<table cellpadding=\"0\" cellspacing=\"0\" class=\"moduletable\">\n"); 
			document.write("	<tr>\n"); 
			document.write("		<td>\n"); 
			document.write("			<div style=\"width: 300px; background: #fff; height: 72px;\">\n"); 
			document.write("				<div style=\"width: 300px; height: 72px;\">\n"); 
			document.write("					<div id=\"countdown\">\n"); 
			document.write("					 	<div id=\"ccad\"><img src=\"scripts/countdown/ccad_nt.gif\"></div>\n"); 
			document.write("						<div class=\"hd\"></div>\n"); 
			document.write("						<div class=\"bd\" id=\"countdownbody\"><div id=\"countdownnumbers\"></div></div>\n"); 
			document.write("						<div class=\"ft\"></div>\n"); 
			document.write("					</div>\n"); 
			document.write("				</div>\n"); 
			document.write("				<script>\n"); 
			document.write("					countdownsetup();\n"); 
			document.write("					var countdowndigits = countdowninit();\n"); 
			document.write("					if (countdowndigits) { var sdcounter = setInterval(function() { countdowndigits = countmedown(countdowndigits); },1000); }\n"); 
			document.write("				</script>\n"); 
			document.write("			</div>\n"); 
			document.write("		</td>\n"); 
			document.write("	</tr>\n"); 
			document.write("</table>\n"); 
	}
}


function countdown2() {
	if (ntgames_idx > 0) {
		if ((ntgames[0].gameYear != nowYear) ||
		    (ntgames[0].gameMonth != nowMonth) ||
			(ntgames[0].gameDay != nowDay)) {
			document.write("<table cellpadding=\"0\" cellspacing=\"0\" class=\"moduletable\">\n"); 
			document.write("	<tr>\n"); 
			document.write("		<td>\n"); 
			document.write("			<img align=\"top\" width=\"300\" src=\"images/center_countdown.gif\" alt=\"Countdown to Gameday\" height=\"20\" />\n");
			document.write("			<div style=\"width: 300px; background: url(images/photo_bkgnd.gif) repeat-y; height: 30px; padding-top: 3px; padding-left: 25px;\">\n"); 

			document.write("			<object type=\"application/x-shockwave-flash\" data=\"scripts/fl_countdown_v3_3.swf?yr=" + ntgames[0].gameYear + "&amp;mo=" + ntgames[0].gameMonth + "&amp;da=" + ntgames[0].gameDay + "&amp;co=008432&amp;snd=on\" width=\"250\" height=\"30\">\n");
			document.write("				<param name=\"movie\" value=\"scripts/fl_countdown_v3_3.swf?yr=" + ntgames[0].gameYear + "&amp;mo=" + ntgames[0].gameMonth + "&amp;da=" + ntgames[0].gameDay + "&amp;co=OO8432\" />\n");
			document.write("				<param name=\"bgcolor\" value=\"#ffffff\" />\n");
			document.write("				<p><!--alternative content--></p>\n");
			document.write("			</object>\n");
			
			document.write("			</div>\n"); 
			document.write("		</td>\n"); 
			document.write("	</tr>\n"); 
			document.write("</table>\n"); 
		}
	}
/* if no games in the near future, countdown for first game of the season. */
	else {
			document.write("<table cellpadding=\"0\" cellspacing=\"0\" class=\"moduletable\">\n"); 
			document.write("	<tr>\n"); 
			document.write("		<td>\n"); 
			document.write("			<img align=\"top\" width=\"300\" src=\"images/center_countdown.gif\" alt=\"Countdown to Gameday\" height=\"20\" />\n");
			document.write("			<div style=\"width: 300px; background: url(images/photo_bkgnd.gif) repeat-y; height: 30px; padding-top: 3px; padding-left: 25px;\">\n"); 

			document.write("			<object type=\"application/x-shockwave-flash\" data=\"scripts/fl_countdown_v3_3.swf?yr=2009&amp;mo=9&amp;da=3&amp;co=008432&amp;snd=on\" width=\"250\" height=\"30\">\n");
			document.write("				<param name=\"movie\" value=\"scripts/fl_countdown_v3_3.swf?yr=2009&amp;mo=9&amp;da=3&amp;co=OO8432\" />\n");
			document.write("				<param name=\"bgcolor\" value=\"#ffffff\" />\n");
			document.write("				<p><!--alternative content--></p>\n");
			document.write("			</object>\n");

			document.write("			</div>\n"); 
			document.write("		</td>\n"); 
			document.write("	</tr>\n"); 
			document.write("</table>\n"); 
	}
}

function build_div_today () {
	if (ntgames_idx > 0) {
		idx = 0;
		if ((ntgames[idx].gameYear == nowYear) &&
		    (ntgames[idx].gameMonth == nowMonth) &&
			(ntgames[idx].gameDay == nowDay)) {
			document.write("<table cellpadding=\"0\" cellspacing=\"0\" class=\"moduletable\">\n");
			document.write("	<tr>\n");
			document.write("		<td>\n");
			document.write("			<img align=\"top\" width=\"300\" src=\"images/center_today.gif\" alt=\"Today\'s Game\" height=\"20\" />\n"); 
			document.write("			<div style=\"width: 300px;\">\n"); 
			divHeight= 80;
			document.write("				<div style=\"background: #fff; height: " + divHeight + "px; background: transparent;\">\n");
			document.write("					<div style=\"width: 300px; height: 2px; background: transparent;\"></div>\n");
			var dashloc = 0;
			var ntscore = 0;
			var opponentscore = 0;
			var homescore = 0;
			var awayscore = 0;
			if (ntgames[idx].score == '') {
				ntscore = 0;
				opponentscore = 0;
			}
			else {
				if (ntgames[idx].score.indexOf('-') <= 0) {
					ntscore = 0;
					opponentscore = 0;
				}
				else {
					dashloc = ntgames[idx].score.indexOf('-');
					ntscore = ntgames[idx].score.substring(0,dashloc);
					opponentscore = ntgames[idx].score.substring(dashloc+1,ntgames[idx].score.length);
				}
			}
			document.write("					<div style=\"width: 300px; height: 60px; line-height: 1.3em; color: #fff;\">\n");
			if (ntgames[idx].homeaway == 'H') {
				hometeam = 'North Texas'
				awayteam = ntgames[idx].opponent;
				homescore = ntscore;
				awayscore = opponentscore;
			}
			else {
				hometeam = ntgames[idx].opponent;
				awayteam = 'North Texas';
				homescore = opponentscore;
				awayscore = ntscore;
			}
			findvariables (ntgames[idx].gameYear, awayteam);
			document.write("						<div style=\"width: 300px; height: 30px; background: " + seccolor + " url(\'images/teams/bkgnds/" + teamcode + "_bg.png\') repeat-x;\">\n");
			document.write("							<span style=\"float: left; width: 80px;\">\n");
			document.write("								<div style=\"width: 80px; height: 30px; background: url(\'images/teams/" + teamcode + ".gif\') no-repeat 0px -18px;\"></div>\n");
			document.write("							</span>\n");
			document.write("							<span style=\"float: left; width: 215px; text-align: left; padding-left: 5px;\">" + awayteam + "<br />" + teamnamefull + "</span>\n");
			document.write("						</div>\n");
			document.write("						<div style=\"position: relative; top: -36px; width: 285px; height: 0px; line-height: 1.4em; text-align: right; padding-right: 15px; font-size: 28px; color: #fff; background: transparent;\">" + awayscore + "</div>\n");
			findvariables (ntgames[idx].gameYear, hometeam);
			document.write("						<div style=\"width: 300px; height: 30px; background: " + seccolor + " url(\'images/teams/bkgnds/" + teamcode + "_bg.png\') repeat-x;\">\n");
			document.write("							<span style=\"float: left; width: 80px;\">\n");
			document.write("								<div style=\"width: 80px; height: 30px; background: url(\'images/teams/" + teamcode + ".gif\') no-repeat 0px -18px;\"></div>\n");
			document.write("							</span>\n");
			document.write("							<span style=\"float: left; width: 100px; text-align: left; padding-left: 5px;\">" + hometeam + "<br />" + teamnamefull + "</span>\n");
			document.write("						</div>\n");
			document.write("						<div style=\"position: relative; top: -36px; width: 285px; height: 0px; line-height: 1.4em; text-align: right; padding-right: 15px; font-size: 28px; color: #fff; background: transparent;\">" + homescore + "</div>\n");
			document.write("					</div>\n");
			var gamestatus;
			switch (ntgames[idx].win_loss) {	
				case 'W':
					gamestatus = 'Final';
					break;		
				case 'L':
					gamestatus = 'Final';
					break;		
				case '1st':
					gamestatus = 'In Progress (1st Quarter)';
					break;		
				case '2nd':
					gamestatus = 'In Progress (2nd Quarter)';
					break;		
				case 'Half':
					gamestatus = 'Half Time';
					break;		
				case '3rd':
					gamestatus = 'In Progress (3rd Quarter)';
					break;		
				case '4th':
					gamestatus = 'In Progress (4th Quarter)';
					break;		
				case '':
					gamestatus = 'Game has not yet started'	;
					break;
				default  :
					gamestatus = '';
					break;
			}
			document.write("					<div style=\"width: 300px; height: 15px; color: #000; background: transparent;\">\n");
			document.write("						<span style=\"float: left; width: 285px; line-height: 1.1em; color: #fff; text-align: right; padding-right: 15px;\">" + gamestatus + "</span>\n");
			document.write("					</div>\n");
			document.write("					<div style=\"width: 300px; height: 2px; background: transparent;\"></div>\n");
			document.write("				</div>\n");
			document.write("			</div>\n");
			document.write("		</td>\n");
			document.write("	</tr>\n");
			document.write("</table>\n");
		}
	}
}

