#!/usr/bin/perl

######################################################################
# 京成電鉄、乗り継ぎ・運賃検索フォーム
# (c)2010 createch
######################################################################
$now_time = time;
($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime($now_time))[0..6];
$year += 1900;
$mon++;

#年月
$ym0 = sprintf("%04d%02d", $year, $mon);
$fym0 = sprintf("%04d年%02d", $year, $mon);
$next_year = $year;
$next_mon = $mon+1;
if ($next_mon>12) {
	$next_year++;
	$next_mon -= 12;
}
$ym1 = sprintf("%04d%02d", $next_year, $next_mon);
$fym1 = sprintf("%04d年%02d", $next_year, $next_mon);

#日にち
$day1 = int($mday/10);
$day2 = $mday % 10;

$select_day1 = "";
for ($i=0;$i<4;$i++) {
	if ($i==$day1) {
		$select_day1 .= "document.write('<option value=\"$i\" selected>$i</option>');\n";
	} else {
		$select_day1 .= "document.write('<option value=\"$i\">$i</option>');\n";
	}
}
$select_day2 = "";
for ($i=0;$i<10;$i++) {
	if ($i==$day2) {
		$select_day2 .= "document.write('<option value=\"$i\" selected>$i</option>');\n";
	} else {
		$select_day2 .= "document.write('<option value=\"$i\">$i</option>');\n";
	}
}

#時間
$select_hour = "";
for ($i=0;$i<24;$i++) {
	if ($i==$hour) {
		$select_hour .= "document.write('<option value=\"".sprintf("%02d", $i)."\" selected>$i</option>');\n";
	} else {
		$select_hour .= "document.write('<option value=\"".sprintf("%02d", $i)."\">$i</option>');\n";
	}
}

#分
$min1 = int($min/10);
$min2 = $min % 10;

$select_min1 = "";
for ($i=0;$i<6;$i++) {
	if ($i==$min1) {
		$select_min1 .= "document.write('<option value=\"$i\" selected>$i</option>');\n";
	} else {
		$select_min1 .= "document.write('<option value=\"$i\">$i</option>');\n";
	}
}
$select_min2 = "";
for ($i=0;$i<10;$i++) {
	if ($i==$min2) {
		$select_min2 .= "document.write('<option value=\"$i\" selected>$i</option>');\n";
	} else {
		$select_min2 .= "document.write('<option value=\"$i\">$i</option>');\n";
	}
}

print "Content-type: text/javascript\n\n";

print <<"EOM";
document.write('<form name="form1" method="post" action="./cgi-keisei/timesv/conv.php" onsubmit="return kensaku()">');
document.write('<input name="rsf" value="" type="hidden" />');
document.write('<input name="rst" value="" type="hidden" />');

document.write('<input name="rst" value="" type="hidden" />');
document.write('<input type="hidden" name="ep" value="1" id="yes" />');
document.write('<dl>');
document.write('<dt>駅名指定</dt>');
document.write('<dd>出発駅&nbsp;<input name="sf" onfocus="setFocus(0)" type="text" class="box"><br />');
document.write('到着駅&nbsp;<input name="st" onfocus="setFocus(1)" type="text" class="box"></dd>');
document.write('</dl>');

document.write('<dl>');
document.write('<dt>日付指定</dt>');

document.write('<dd>');
document.write('<select name="month">');
document.write('<option value="$ym0" selected>$fym0</option>');
document.write('<option value="$ym1">$fym1</option>');
document.write('</select>');
document.write('月<br />');

document.write('<select name="day1">');
$select_day1
document.write('</select><!--');
document.write('--><select name="day2">');
$select_day2
document.write('</select>');
document.write('日</dd>');
document.write('</dl>');

document.write('<dl>');
document.write('<dt>時間指定</dt>');
document.write('<dd>');
document.write('<select name="hour">');
$select_hour
document.write('</select>');
document.write('時');
document.write('<select name="min1">');
$select_min1
document.write('</select><!--');
document.write('--><select name="min2">');
$select_min2
document.write('</select>');
document.write('分に<br />');
document.write('<input name="sr" value="0" checked="checked" type="radio" class="radiobtn">出発&nbsp;');
document.write('<input name="sr" value="1" type="radio" class="radiobtn">到着</dd>');

document.write('</dl>');

document.write('<dl>');
document.write('<dt>表\示条件</dt>');
document.write('<dd class="btn1"><input name="rp" value="0" checked="checked" type="radio" class="radiobtn">時間順&nbsp;');
document.write('<input name="rp" value="2" type="radio" class="radiobtn">乗り換え回数順</dd>');
document.write('</dl>');

document.write('<div class="btn" align="center"><input name="submit" src="topimg/transit_btn01.gif" value="検索する" type="image"></div>');
document.write('</form>');


EOM

__END__
