

<cfset t = 0>
<cfoutput>
<input type="hidden" name="leaguesize" value="#leaguesize#">
<input type="hidden" name="gamesplayed" value="0">
</cfoutput>

<cfset leagueteams = 0>

<cfloop index=i from=1 to=2240>

<cfif structKeyExists(form,"team" & i)>
<cfset leagueteams = leagueteams + 1>
</cfif>

</cfloop>

<cfif leagueteams neq leaguesize>

<cfoutput>
<font size="+1" face=arial>You have selected #leagueteams# teams.<br>
Please go back and select #leaguesize# teams.</font>
</cfoutput>


<cfelse>

<CFQUERY NAME="GetSeasonID" DATASOURCE="rapidstatsbaseball">  
	SELECT * FROM seasonid where id = 1 
</CFQUERY>

<cfoutput query=getseasonid>
<CFSET SeasonID = SeasonID>
<CFSET NewSeasonID = SeasonId + 1>
</cfoutput>

<CFQUERY NAME="UpdTestID" DATASOURCE="rapidstatsbaseball">  
	UPDATE seasonid 
		SET SeasonID = #NewSeasonID#
		WHERE id = 1
</CFQUERY> 

<cfoutput><input type="hidden" name="seasonid" value="#seasonid#"></cfoutput>


<cfloop index=i from=1 to=2240>

<cfif structKeyExists(form,"team" & i)>
<cfset team = evaluate("team#i#")>

<hr>
<table border=0>
<tr>
<td colspan=2 align=center>

<cfquery name="getbatters" datasource="rapidstatsbaseball">
Select * from gamebatters
where teamid = #team#
order by namelast, namefirst
</cfquery>

<cfquery name="getteams" datasource="rapidstatsbaseball">
Select * from gameteams
where teamid = #team#
</cfquery>

<cfset t = t + 1>
<cfoutput query="getteams">
<input type="hidden" name="team#t#" value="#team#">
<input type="hidden" name="teamname#t#" value="#yearid# #name#">
<input type="hidden" name="teamrating#t#" value="#teamrating#">
<input type="hidden" name="teamrealwins#t#" value="#teamwins#">
<input type="hidden" name="teamreallosses#t#" value="#teamlosses#">
<input type="hidden" name="teamops#t#" value="#teamops#">
<input type="hidden" name="teamwins#t#" value="0">
<input type="hidden" name="teamlosses#t#" value="0">
</cfoutput>


<cfset b=0>
<cfoutput query="getbatters" group="teamid">
<p><font face=arial size=+0>#yearid# #name#<p>
<input type="hidden" name="selectedteam#i#" value="#i#">

</td>
</tr>
<tr>
<td valign=top width=300>
<cfoutput>
<cfset b=b+1>
<font face=arial size=+0>#pos# #namefirst# #namelast#<br> 

<input type="hidden" name="batter_pos#t##b#" value="#pos#">
<input type="hidden" name="batter_namefirst#t##b#" value="#namefirst#">
<input type="hidden" name="batter_namelast#t##b#" value="#namelast#">
<input type="hidden" name="batter_ab#t##b#" value="0">
<input type="hidden" name="batter_r#t##b#" value="0">
<input type="hidden" name="batter_h#t##b#" value="0">
<input type="hidden" name="batter_dbl#t##b#" value="0">
<input type="hidden" name="batter_tpl#t##b#" value="0">
<input type="hidden" name="batter_hr#t##b#" value="0">
<input type="hidden" name="batter_rbi#t##b#" value="0">
<input type="hidden" name="batter_sb#t##b#" value="0">
<input type="hidden" name="batter_bb#t##b#" value="0">
<input type="hidden" name="batter_so#t##b#" value="0">
</cfoutput>

<input type="hidden" name="teambatters#t#" value="#b#">

</cfoutput>

</td>


<cfquery name="getpitchers" datasource="rapidstatsbaseball">
Select * from gamepitchers
where teamid = #team#
order by gs desc, ip desc
</cfquery>

<td valign=top width=300>

<cfset p=0>
<cfoutput query="getpitchers">
<cfset p=p+1>
<font face=arial size=+0>P #namefirst# #namelast#<br> 

<input type="hidden" name="pitcher_namefirst#t##p#" value="#namefirst#">
<input type="hidden" name="pitcher_namelast#t##p#" value="#namelast#">
<input type="hidden" name="pitcher_realwins#t##p#" value="#w#">
<input type="hidden" name="pitcher_reallosses#t##p#" value="#l#">
<input type="hidden" name="pitcher_ip#t##p#" value="0">
<input type="hidden" name="pitcher_w#t##p#" value="0">
<input type="hidden" name="pitcher_l#t##p#" value="0">
<input type="hidden" name="pitcher_sv#t##p#" value="0">
<input type="hidden" name="pitcher_er#t##p#" value="0">
<input type="hidden" name="pitcher_bb#t##p#" value="0">
<input type="hidden" name="pitcher_so#t##p#" value="0">

</cfoutput>
<cfoutput>
<input type="hidden" name="teampitchers#t#" value="#p#">
</cfoutput>
</td>
</tr>
</table>

</cfif>

</cfloop>

<p><input type="Submit" name="simulate" value="Start Season">

</cfif>