function MM_jumpMenu(targ,selObj,restore){ //v3.0  var srch = "?od=" + document.theMenu.offDef.options.selectedIndex;  srch = srch + "&st=" + document.theMenu.statType.options.selectedIndex;  srch = srch + "&ca=" + document.theMenu.conAll.options.selectedIndex;  srch = srch + "&cs=" + document.theMenu.cumSing.options.selectedIndex;  srch = srch + "&wk=" + document.theMenu.weekNum.options.selectedIndex;  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+srch+"'");  if (restore) selObj.selectedIndex=0;}var theFields = new Array();  // Required for splitFields function.var doneSplit = 0;var tCount = 0;function splitFields(theString) {  theFields["od"] = 0;  theFields["st"] = 0;  theFields["ca"] = 0;  theFields["cs"] = 0;  theFields["wk"] = 0;  // New for WBW pages  theFields["at"] = 0;  theFields["ht"] = 0;  if (theString.length > 0) {    theString = theString.substring(1,theString.length);    theArray = theString.split("&");    for (i=0;i<theArray.length;i++){      subArray = theArray[i].split("=");      theFields[subArray[0]] = subArray[1];    }  }  doneSplit = 1;}var fname="stat_do.html";function retFileName(theType,offDef) {  var f = "stat" + thisSeason + "_";  f = f + TstatDesc[theType].fid;  if (offDef==0) f = f + "o"  else f = f + "d";  f = f + ".html";  return f}function getFileName() {  fname = retFileName(theFields["st"],theFields["od"]);}TstatDesc = new statDescription();function statDescription(){	this[0] = new Tdesc("First Downs","First Downs","d");  this[1] = new Tdesc("Yards Rushing","Yards Rushing","r");  this[2] = new Tdesc("Yards Passing","Yards Passing","p");  this[3] = new Tdesc("Total Yards","Total Yards","t");	this[4] = new Tdesc("Points For","Points Against","o");	this[5] = new Tdesc("No. Intercepted","Interceptions","i");	this[6] = new Tdesc("No. Sacked","Sacks","s");}function Tdesc(ToDesc, TdDesc, tfID){	this.offDesc = ToDesc;	this.defDesc = TdDesc;	this.fid = tfID;}Tcon = new ConInfo();function ConInfo(){	this[0] = "NFLAB"; 	this[1] = "AFC Only"; 	this[2] = "NFC Only";}Tod = new odInfo();function odInfo(){	this[0] = "Offense"; 	this[1] = "Defense";}Tcs = new csInfo();function csInfo(){	this[0] = "Cumulative"; 	this[1] = "Single Week";}Tc = new ColInfo();function ColInfo(){	this[0] = "#99CCCC"; 	this[1] = "#CCCC99";}function statDet(dataStr) {  var pointer=0;  this.amount = new Array();  this.hasPlayed = new Array();  for (var i=0;i<16;i++) {    pointer = i*4;    this.amount[i] = b362int(dataStr.substring(pointer,pointer+3),1);    if (this.amount[i] > 1926) this.amount[i] = (this.amount[i]-1926)*-1;    this.hasPlayed[i] = b362int(dataStr.substring(pointer+3,pointer+4),1);  }}function b362int(theValue, offSet){  var retVal=0;  if (theValue.length > 1) retVal = b362int(theValue.substring(0,theValue.length-1),offSet * 36);  retVal += ("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(theValue.substring(theValue.length-1,theValue.length)) * offSet);  return retVal;}function buildMenu() {  splitFields(document.location.search);  getFileName();  with (document) {    write('<FORM NAME="theMenu">');    write('<TABLE WIDTH="90%" BORDER="0" CELLSPACING="0" CELLPADDING="0" ALIGN="CENTER">');    write('<TR ALIGN="CENTER">');    write('<TD><SELECT NAME="statType" onChange="MM_jumpMenu(\'self\',this,0)">\n');    for (i=0;i<7;i++) {      write('<OPTION VALUE="' + retFileName(i,theFields["od"]) + '" ');      if (theFields["st"]==i) write('SELECTED');      write('>');      if (theFields["od"]==0) write(TstatDesc[i].offDesc)      else write(TstatDesc[i].defDesc);      write('</OPTION>');    }    write('</SELECT></TD>');    write('<TD><SELECT NAME="conAll" onChange="MM_jumpMenu(\'self\',this,0)">');	for (i=0;i<3;i++) {	  write('<OPTION value="' + fname + '" ');      if (theFields["ca"]==i) write('SELECTED');      write('>');	  write(Tcon[i] + '</OPTION>');	}    write('</SELECT></TD>');    write('<TD><SELECT NAME="offDef" onChange="MM_jumpMenu(\'self\',this,0)">');	for (i=0;i<2;i++) {	  write('<OPTION value="' + retFileName(theFields["st"],i) + '" ');      if (theFields["od"]==i) write('SELECTED');      write('>');	  write(Tod[i] + '</OPTION>');	}    write('</SELECT></TD>');    write('<TD><SELECT NAME="cumSing" onChange="MM_jumpMenu(\'self\',this,0)">');	for (i=0;i<2;i++) {	  write('<OPTION value="' + fname + '" ');      if (theFields["cs"]==i) write('SELECTED');      write('>');	  write(Tcs[i] + '</OPTION>');	}    write('</SELECT></TD>');		write('<TD><SELECT NAME="weekNum" onChange="MM_jumpMenu(\'self\',this,0)">');	for (i=0;i<16;i++) {	  write('<OPTION value="' + fname + '" ');      if (theFields["wk"]==i) write('SELECTED');      write('>');	  write('Week ' + (i+1) + '</OPTION>');    }    write('</SELECT></TD>');    write('</TR></TABLE></FORM>');  }}function format(dispTxt, dispVal) {  // BaH's number format function.  // Now add commas to your digits !!!!  //  var toAdd = '';  var retString = '';  var ftOffset = dispTxt.length;  var theValue = dispVal.toString();  for (var i=theValue.length;i>0;i--) {    var aChar = theValue.substring(i-1,i);    var aForm = dispTxt.substring(ftOffset-1,ftOffset);    if (aForm == ',') {      toAdd = ',';      ftOffset--;      aForm = dispTxt.substring(ftOffset-1,ftOffset);    }    retString = aChar + toAdd + retString;    toAdd = '';    ftOffset--;     }  while (ftOffset > 0) {    var aForm = dispTxt.substring(ftOffset-1,ftOffset);    if (aForm==',') {      toAdd = ',';      ftOffset--;      aForm = dispTxt.substring(ftOffset-1,ftOffset);    }    if (aForm=='#') break;    if (ftOffset > 0) {      retString = aForm + toAdd + retString;    }    toAdd='';    ftOffset--;  }  return retString;}function dplc(aValue,places) {	// 1 decimal place only	var ind = aValue.toString().indexOf('.');	if (!(ind < 0))	return aValue.toString().substr(0,ind+1+places)  else return aValue + '.0';};function buildStats(sortOrder) {  // sortOrder -> 1=descending, 2=ascending  var col = 0;  var orderList = new Array();  var teamTots = new Array();  var gameCount = new Array();    for (var i=0;i<24;i++) {    orderList[i]=i;    teamTots[i]=0;    gameCount[i]=0;    if (theFields["cs"] == 0) {      for (var w=0;w<=theFields["wk"];w++) {        teamTots[i] += Tstats[i].amount[w];        if (Tstats[i].hasPlayed[w]==1) gameCount[i]++;       }    }    else {      teamTots[i] = Tstats[i].amount[theFields["wk"]];    }  }  for (var i=0; i<23; i++) {    for (var n=i+1; n<24; n++) {      if (sortOrder == 1) {        if (teamTots[orderList[i]] < teamTots[orderList[n]]) {          tmp = orderList[i];          orderList[i] = orderList[n];          orderList[n] = tmp;        }      }      else {        if (teamTots[orderList[i]] > teamTots[orderList[n]]) {          tmp = orderList[i];          orderList[i] = orderList[n];          orderList[n] = tmp;        }      }    }  }    with (document) {    write('<TABLE WIDTH="90%" BORDER="0" CELLSPACING="0" CELLPADDING="0" ALIGN="CENTER" CLASS="tabletext_b">');    write('<TR CLASS="standard"><TD ALIGN="CENTER"><B>Pos.</B></TD><TD><B>Team</B></TD>');    write('<TD ALIGN="RIGHT">');    if (theFields["cs"]==0) {      write('<B>Avg.</B>');    }    else {      write('&nbsp;');    }    write('</TD><TD ALIGN="RIGHT"><B>No.</B></TD></TR>');    var counter=0;    var lasti=0;    for (var i=0;i<24;i++){          if ((theFields["ca"]==0) || ((theFields["ca"]==1) && (orderList[i]<12)) || ((theFields["ca"]==2) && (orderList[i]>11))) {  			col = 1 - col;        write('<TR BGCOLOR="' + Tc[col] + '">');        write('<TD ALIGN="CENTER">');        if (counter==0) {          write(counter+1);        }        else {          if (teamTots[orderList[i]] != teamTots[orderList[lasti]]) {            write(counter+1);          }          else {            write('&nbsp;');           }        }        write('</TD><TD NOWRAP>' + TName[orderList[i]].Name + '</TD>');        write('<TD ALIGN="RIGHT">');        if (theFields["cs"]==1) {          write('&nbsp;');        }        else {          if (gameCount[orderList[i]] > 0) {            write(dplc(teamTots[orderList[i]] / gameCount[orderList[i]],1));          }          else {            write('0.0');          }        }        write('</TD>');        write('<TD ALIGN="RIGHT">' + format('##,##0',teamTots[orderList[i]]) + '</TD>');        write('</TR>');        counter++;        lasti = i;      }    }        write('</TABLE>');  }}var wbwLayout = new Array(1,1,1,1,1,1,1,1,1,1,1,2,2,2,3,3,1,1,1,1,2,3,3,1,1,1,2,2,2,2,1,1,1);//var wbwPass = new Array(13,12,14,15,33,35,34,16,36,17,37,38);var wbwRush = new Array(20,21,22,39,23,44,24,43);var wbwTables = new TwbwTables();function TwbwTables() {	this[0] = new TwbwTable("Passing",90,"13,12,14,15,33,35,34,16,36,17,37,38");	this[1] = new TwbwTable("Rushing",65,"20,21,22,39,23,44,24,43");	this[2] = new TwbwTable("Combined",65,"45,40,46,47,48,53,54");	this[3] = new TwbwTable("Scoring",70,"0,1,49,2,3,50,4,5,51");	this[4] = new TwbwTable("Efficiency",65,"11,52,8,7,41,10,9,42");	this[5] = new TwbwTable("Pressure",55,"18,19,24,17,25");	this.length = 6;}function TwbwTable(wDesc,wWidth,wData) {	this.Desc = wDesc;	this.Width = wWidth;	this.List = wData.split(",");}TwbwDesc = new wbwDescription();function wbwDescription(){	var wbwdescs = "FGa,0|FGg,0|EPa,0|EPg,0|2ptA,0|2ptG,0|Punts,0|3rdG,0|3rdA,0|4thG,0|4thA,0|1st,0|Comp,0|Att,0|Yds,0|Long,0|TD,0|Int,0|Hrd,0|Skd,0|Att,0|Yds,0|Long,0|TD,0|Fum,0|Sfty,0|Qtr1,0|Qtr2,0|Qtr3,0|Qtr4,0|OT,0|";	wbwdescs += "Pld,0|Otime,0|Pct,1|AvgC,1|AvgA,1|TD%,1|Int%,1|Rating,1|AvgA,1|Yds,0|3rd%,1|4th%,1|Fum%,1|TD%,1|Att,0|AvgA,1|TD,0|TD%,1|FG%,1|EP%,1|2pt%,1|1st/Att,2|Trn,0|Trn%,1";	wbwSplit = wbwdescs.split("|");	for (i=0;i<wbwSplit.length;i++) {		var wbwS = wbwSplit[i].split(",");		this[i] = new Twbwdsc(wbwS[0],parseInt(wbwS[1]));	}}function Twbwdsc(wDesc,wCalc){	this.Desc = wDesc;	// number of decimal places...	this.Calc = wCalc;}function wbwDet(dataStr) {	if (!doneSplit) splitFields(document.location.search);	tCount++;  if ((theFields["at"]==tCount) || (theFields["ht"]==tCount)) {	  var pointer=0;	  this.amount = new Array();	  this.hasPlayed = new Array();		for (var i=0;i<60;i++) this.amount[i]=0;	  for (i=0;i<33;i++) {	    this.amount[i] = b362int(dataStr.substring(pointer,pointer+wbwLayout[i]),1);	    if (this.amount[i] > 1296) this.amount[i] = (this.amount[i]-1296)*-1;	    pointer += wbwLayout[i];	  }	  if (this.amount[13] > 0) {		  this.amount[33] = this.amount[12] / this.amount[13] * 100;		  this.amount[34] = this.amount[14] / this.amount[12];		  this.amount[35] = this.amount[14] / this.amount[13];		  this.amount[36] = this.amount[16] / this.amount[13] * 100;		  this.amount[37] = this.amount[17] / this.amount[13] * 100;		  var tmp = (this.amount[33] - 30) * 0.05;		  if (tmp < 0) tmp = 0		  else if (tmp > 2.375) tmp = 2.375;		  this.amount[38] = tmp;		  tmp = (this.amount[35] - 3) * 0.25;		  if (tmp < 0) tmp = 0		  else if (tmp > 2.375) tmp = 2.375;			this.amount[38] += tmp;		  tmp = (this.amount[36]) * 0.2;			if (tmp > 2.375) tmp = 2.375;		  this.amount[38] += tmp;		  tmp = 2.375 - (this.amount[37] * 0.25);			if (tmp < 0) tmp = 0;		  this.amount[38] = ((this.amount[38] + tmp) / 6) * 100;	  }	  	  if (this.amount[20] > 0) {	  	this.amount[39] = this.amount[21] / this.amount[20];	  	this.amount[43] = this.amount[24] / this.amount[20] * 100;	  	this.amount[44] = this.amount[23] / this.amount[20] * 100;	  }	  this.amount[40] = this.amount[14] + this.amount[21];	  if (this.amount[8] > 0) this.amount[41] = this.amount[7] / this.amount[8] * 100;	  if (this.amount[10] > 0) this.amount[42] = this.amount[9] / this.amount[10] * 100;	  this.amount[45] = this.amount[13] + this.amount[20];	 	this.amount[47] = this.amount[16] + this.amount[23];	  if (this.amount[45] > 0) {	  	this.amount[46] = this.amount[40] / this.amount[45];	  	this.amount[48] = this.amount[47] / this.amount[45] * 100;	  	this.amount[52] = this.amount[11] / this.amount[45];	  }	  if (this.amount[0] > 0) this.amount[49] = this.amount[1] / this.amount[0] * 100;	  if (this.amount[2] > 0) this.amount[50] = this.amount[3] / this.amount[2] * 100;	  if (this.amount[4] > 0) this.amount[51] = this.amount[5] / this.amount[4] * 100;	  this.amount[53] = this.amount[17] + this.amount[24];		if (this.amount[53] > 0) this.amount[54] = this.amount[53] / this.amount[45] * 100;  }}function buildWBWStats() {  splitFields(document.location.search);  if ((theFields["at"]!=0) && (theFields["ht"]!=0)) {    var theTeams = new Array(theFields["at"]-1,theFields["ht"]-1);    if ((Twbw[theTeams[0]].amount[31]!=0)&&(Twbw[theTeams[1]].amount[31]!=0)) {    	var col = 1;      with (document) {        write('<P ALIGN="CENTER"><B>' + TName[theTeams[0]].Name + ' at ' +TName[theTeams[1]].Name + '</B></P>');        write('<TABLE WIDTH="55%" ALIGN="CENTER" CLASS="tabletext_b"><TR CLASS="standard">');        write('<TD>&nbsp;</TD>');        for(var i=0;i<4;i++) {					write('<TH>' + TwbwDesc[26+i].Desc + '</TH>');        }        if(Twbw[theTeams[0]].amount[32]==1) {          write('<TH>OT</TH>');        }        write('<TD WIDTH="15">&nbsp;</TD><TH>Final</TH></TR>');        for (i=0;i<2;i++) {        	col=1-col;          write('<TR BGCOLOR="' + Tc[col] + '"><TD NOWRAP>' + TName[theTeams[i]].City + '</TD>');          var tot=0;          for (n=0;n<4;n++) {            write('<TD ALIGN="CENTER">' + Twbw[theTeams[i]].amount[26+n] + '</TD>');            tot+=Twbw[theTeams[i]].amount[26+n];          }           if(Twbw[theTeams[i]].amount[32]==1) {            write('<TD ALIGN="CENTER">' + Twbw[theTeams[i]].amount[30] + '</TD>');            tot+=Twbw[theTeams[i]].amount[30];          }          write('<TD>&nbsp;</TD><TD ALIGN="CENTER">' + tot + '</TD></TR>');        }        write('</TABLE><BR>');        				for (var m=0; m<wbwTables.length; m++) {					write('<TABLE CLASS="tabletext_b" ALIGN="CENTER" WIDTH="' + wbwTables[m].Width + '%"><TR CLASS="standard"><TH>');					write(wbwTables[m].Desc + '</TH>');     	  	for (i=0; i<wbwTables[m].List.length; i++) write('<TH>' + TwbwDesc[wbwTables[m].List[i]].Desc + '</TH>');        	for (i=0;i<2;i++) {        		col=1-col;						write('<TR BGCOLOR="' + Tc[col] + '" ALIGN="CENTER"><TD NOWRAP ALIGN="LEFT">' + TName[theTeams[i]].City + '</TD>');						for (n=0;n<wbwTables[m].List.length;n++) {							write('<TD>');							if (TwbwDesc[wbwTables[m].List[n]].Calc) write (dplc(Twbw[theTeams[i]].amount[wbwTables[m].List[n]],TwbwDesc[wbwTables[m].List[n]].Calc))							else write(Twbw[theTeams[i]].amount[wbwTables[m].List[n]]);							write('</TD>');						}						write('</TR>');        	}        	write('</TABLE><BR>');        }      }     }  }}function buildLive(offDef) {	var sortbyDef = '';	if (offDef==2) sortbyDef = ',0,1';	with (document) {		write('<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" CLASS="tabletext_b_link" ALIGN="CENTER">');		write('<TR><TD><PRE CLASS="tabletext_b_link">');		write(' Team            ');		for (var i=0; i<statHead.length; i++) {			write('<A HREF="#" onClick="orderBy('+i+sortbyDef+');" onMouseOver="MM_displayStatusMsg(\'' + statHead[i] + '\');return document.MM_returnValue">');			write(lpad(statHead[i],6));			write('</A>');		}		write('</TD></TR><TD>');		write('<FORM NAME="statForm"><TEXTAREA NAME="statDisplay" ROWS="24" COLS="'+((statHead.length+1)*6+12)+'" CLASS="tabletext_b" WRAP="VIRTUAL">');		write(orderBy(0,1,offDef-1));		write('</TEXTAREA></FORM>');		write('</TD></TR></TABLE>');	}}function orderBy(colNum, retDisplay, sortOrder) {	if (!retDisplay) document.statForm.statDisplay.value = '';	var sortArray = new Array(24);	for (var i=0; i<24; i++) {		sortArray[i]=i;	}	// Do Sort	for (var i=0;i<23;i++) {		for (var n=i+1; n<24; n++) {			if (!sortOrder) { // true is reverse order				if (Tslive[sortArray[i]][colNum] < Tslive[sortArray[n]][colNum]) {					temp = sortArray[i];					sortArray[i] = sortArray[n];					sortArray[n] = temp;				}			}			else {				if (Tslive[sortArray[i]][colNum] > Tslive[sortArray[n]][colNum]) {					temp = sortArray[i];					sortArray[i] = sortArray[n];					sortArray[n] = temp;				}						}		}	}	// Do Display	var st = '';	for (var i=0; i<24;i++) {		tnum = sortArray[i];		st = st + rpad(TName[tnum].City,17);		for (var n=0; n<statHead.length; n++) {			st = st + lpad(Tslive[tnum][n],6);		}		if (i<23) st = st + '\n';	}	if (!retDisplay) document.statForm.statDisplay.value = st	else return st;}function rpad(text,count){  var size = count + 1;  while (--size) text = text + ' ';  return text.substring(0,count);}function lpad(text,count){  var size = count + 1;  while (--size) text = ' ' + text;  return text.substring(text.length-count,text.length);}
