1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
<!--<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Amtrak FareFinder</title>
</head>


<body bgcolor="CCCCCC">

<h2>Amtrak FareFinder</h2>
<%@ page import="java.util.Calendar" %>
<%!
	int startYear = Calendar.getInstance().get(Calendar.YEAR);
	int startMonth = Calendar.getInstance().get(Calendar.MONTH);
	int startDay = Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
	String[] months = {	"Jan", "Feb", "Mar", "Apr", "May", "Jun", 
						"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
	String[] timeOptions = {"Anytime", "Morning", "Afternoon", "Evening",
						"Midnight", "1 AM", "2 AM", "3 AM", "4 AM", "5 AM", "6 AM",
						"7 AM", "8 AM", "9 AM", "10 AM", "11 AM", "Noon", "1 PM",
						"2 PM", "3 PM", "4 PM", "5 PM", "6 PM", "7 PM", "8 PM", "9 PM",
						"10 PM", "11 PM"};
%>
<% String error = request.getParameter("error");
	if(error != null && error != "" )
	{
		out.println("<h3><font color=red>" + error + "</font><h3><br>");
	}
%>

<FORM METHOD=POST ACTION="Validate.jsp">

	<!-- The Departure Table -->
	<table border=0 cellspacing=2 cellpadding=5 bgcolor=white>
		<tr bgcolor=gray>
			<td colspan=3>
				<center><b><font color=white>Departure</font></b></center>
			</td>
		</tr>
		<tr>
			<td><b>From:</b>
			</td>
			<td><b>Date:</b>
			</td>
			<td><b>Time:</b>
			</td>
		</tr>
		<tr bgcolor=gray>
			<td>
			<INPUT TYPE=TEXT NAME=_origin SIZE=20>
			</td>
			
			<td>
			<SELECT NAME=_depmonthyear Size=1>
				
				<% 
				for(int i = 0; i < 100; ++i)
				{
					for(int j = 0; j < 12; ++j )
					{
						if((startYear+i)==startYear && startMonth==j)
						{
							out.println(String.format(
									"<option value=\"%d-%d\" SELECTED>%s, %d</option>",
									(startYear+i),j+1,months[j],(startYear+i)));
						}
						else if(startYear+i>=startYear && startMonth<=j)
						{	
							out.println(String.format(
									"<option value=\"%d-%d\">%s, %d</option>",
									(startYear+i),j+1,months[j],(startYear+i)));
						}
					}
				}
				%>
			</SELECT>
			
			<SELECT NAME=_depday Size=1>
				<%
				for(int i = 1; i <= 31; ++i)
				{
					if(startDay == i)
					{
						out.println(
							String.format("<option value=\"%d\" SELECTED>%02d</option>", i, i));
					}
					else
					{
						out.println(
							String.format("<option value=\"%d\">%02d</option>", i, i));
					}
				}
				%>
			</SELECT>
			</td>
			
			<td>
			<SELECT NAME=_dephourmin Size=1>
				<%
				for(int i = 0; i < timeOptions.length; ++i)
				{
					out.println(String.format(
							"<option value=\"%s\">%s</option>", 
							timeOptions[i], timeOptions[i]));
				}
				%>
			</SELECT>
			</td>
		</tr>
	</table>
	
	<br>
	
	<!-- The Destination Table -->
	<table border=0 cellspacing=2 cellpadding=5 bgcolor=white>
		<tr bgcolor=gray>
			<td colspan=3>
				<center><b><font color=white>Destination</font></b></center>
			</td>
		</tr>
		<tr>
			<td><b>To:</b>
			</td>
			<td><b>Date:</b>
			</td>
			<td><b>Time:</b>
			</td>
		</tr>
		<tr bgcolor=gray>
			<td>
			<INPUT TYPE=TEXT NAME=_destination SIZE=20>
			</td>
			
			<td>
			<SELECT NAME=_retmonthyear Size=1>
				<% 
				for(int i = 0; i < 100; ++i)
				{
					for(int j = 0; j < 12; ++j )
					{
						if(startYear+i==startYear && startMonth==j)
						{
							out.println(String.format(
									"<option value=\"%d-%d\" SELECTED>%s, %d</option>",
									(startYear+i),j+1,months[j],(startYear+i)));
						}
						else if(startYear+i>=startYear && startMonth<=j)
						{	
							out.println(String.format(
									"<option value=\"%d-%d\">%s, %d</option>",
									(startYear+i),j+1,months[j],(startYear+i)));
						}
					}
				}
				%>
			</SELECT>
			
			<SELECT NAME=_retday Size=1>
				<%
				for(int i = 1; i <= 31; ++i)
				{
					if( startDay == i)
					{
						out.println(
							String.format("<option value=\"%d\" SELECTED>%02d</option>", i, i));
					}
					else
					{
						out.println(
							String.format("<option value=\"%d\">%02d</option>", i, i));
					}
				}
				%>
			</SELECT>
			</td>
			
			<td>
			<SELECT NAME=_rethourmin Size=1>
				<%
				for(int i = 0; i < timeOptions.length; ++i)
				{
					out.println(String.format(
							"<option value=\"%s\">%s</option>", 
							timeOptions[i], timeOptions[i]));
				}
				%>
			</SELECT>
			</td>
		</tr>
	</table>
	
	<br>
	
	<!-- The Passenger Info Table -->
	<table border=0 cellspacing=2 cellpadding=5 bgcolor=white>
		<tr bgcolor=gray>
			<td colspan=3>
				<center><font color=white><b>Passengers</b> (Max of 8)</font></center>
			</td>
		</tr>
		<tr>
			<td><b>Adults:</b> <br>(16+)
			</td>
			<td><b>Children:</b> <br>(Ages 2-15)
			</td>
			<td><b>Infants:</b> <br>(Under age 2)
			</td>
		</tr>
		<tr bgcolor=gray>
			<td>
				<SELECT NAME=_adults>
				<%
					for(int i = 1; i <= 8; ++i)
					{
						out.println(String.format(
									"<option value=\"%d\">%d</option>", i, i));
					}
				%>
				</SELECT>
			</td>
			<td>
				<SELECT NAME=_children>
				<%
					for(int i = 0; i < 6; ++i)
					{
						out.println(String.format(
									"<option value=\"%d\">%d</option>", i, i));
					}
				%>
				</SELECT>
			</td>
			<td>
				<SELECT NAME=_infants>
				<%
					for(int i = 0; i < 5; ++i)
					{
						out.println(String.format(
									"<option value=\"%d\">%d</option>", i, i));
					}
				%>
				</SELECT>
			</td>
		</tr>
		<tr>
			<td colspan=3>
			<b>Sort By: </b>
			<input type="radio" name="_searchBy" value="schedule" CHECKED /> Schedule
			<input type="radio" name="_searchBy" value="fare" /> Fare
			</td>
		</tr>
	</table>
	<P><INPUT TYPE=SUBMIT></P>
	
	
</FORM>
</body>
</html>