//	IE・IE互換かを識別する
var	fIsIE=false;
var	fIsScriptUnsuport=false;
var	fIsScriptChecked=false;
function	ScriptCheck()
{
	StationJSDLCheck();
	if	(fIsScriptChecked)	return;
	fIsScriptChecked	=	true;
	if(IsOpera())
	{	//	Opera	IE互換としてIEとする
		fIsIE	=	true;
	}
	else
	if	(IsIE())
	{	//	IE4以降
		fIsIE	=	true;
	}
	else
	{	//	NSかそれスクリプトサポート外かをチェックする
		try
		{
			//	NS4かチェックする
			if	((navigator.appName=="Netscape")&&(navigator.appVersion.indexOf("4.")==0))
			{	//	NS4	サポート外
				fIsScriptUnsuport	=	true;
			}
			if	(document.addEventListener)
			{	//	NS6以降または、FireFox等Mozili系
				
			}
			else
			{	//	不明なブラウザなのでScriptサポート外
				fIsScriptUnsuport	=	true;
			}
		}
		catch	(e)
		{
			fIsScriptUnsuport	=	true;
		}
	}
}

function	IsOpera()
{
	try
	{
		if(window.opera)
		{	//	Opera	IE互換としてIEとする
			if	(document.getElementById)
			{
				return	true;
			}
		}
	}
	catch	(e)
	{
	}
	return	false;
}
function	IsIE()
{
	try
	{
		if	(document.all)	return	true;
	}
	catch	(e)
	{
	}
	return	false;
}
function	InitPage()
{
	ScriptCheck();
	var	dd = new Date();
	dd.setTime(dd.getTime()+600000);	//	10分後
	document.vac.month.selectedIndex=dd.getMonth();
	DaySetupByMonth();
	document.vac.day.selectedIndex=dd.getDate()-1;
	document.vac.hour.selectedIndex=dd.getHours();
	document.vac.minute.selectedIndex=dd.getMinutes()/10;
	document.vac.train.selectedIndex	=	0;
}
function	DaySetupByMonth()
{
	var	max=0;
	var	tag;
	switch	(document.vac.month.selectedIndex+1)
	{
		case	1:	max	=	31;	break;
		case	2:
			if	(IsLeapYear())
				max	=	29;
			else
				max	=	28;
			break;
		case	3:	max	=	31;	break;
		case	4:	max	=	30;	break;
		case	5:	max	=	31;	break;
		case	6:	max	=	30;	break;
		case	7:	max	=	31;	break;
		case	8:	max	=	31;	break;
		case	9:	max	=	30;	break;
		case	10:	max	=	31;	break;
		case	11:	max	=	30;	break;
		case	12:	max	=	31;	break;
		default:
			max=0;break;
	}
	var	saveSel	=	document.vac.day.selectedIndex;
	var	delm	=	document.getElementById("day");
	var	celm	=	delm.childNodes;
	var	i=0;
	for	(;celm.length!=0;)
	{
		delm.removeChild(celm[0]);
	}
	for	(i=1;i<=max;i++)
	{
		tag	=	document.createElement("OPTION");
		var	wk	=	"0"+i;
		wk	=	wk.substr(wk.length-2,2);
		if	(fIsIE)
		{
			tag.setAttribute("value",i);
			tag.innerText	=	wk;
			document.getElementById("day").appendChild(tag);
		}
		else
		{
			tag.value	=	i;
			tag.text	=	wk;
			document.vac.day.appendChild(tag);
		}
	}
	if	((saveSel+1)>max)
	{
		document.vac.day.selectedIndex	=	max-1;
	}
	else
	{
		document.vac.day.selectedIndex	=	saveSel;
	}
}
function	IsLeapYear()
{
	var	dd		=	new	Date();
	var	y	=	dd.getYear();
	if	(dd.getMonth()>2)
	{	//	二月を過ぎているので来年の2月
		y++;
	}
	if (((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0))
		return	true;
	return	false;
}
function	StationJSDLCheck()
{
	var	temp;
	temp	=	stn_Name_Toukai;
	temp	=	stn_PB_Toukai;
	temp	=	stn_Name_East;
	temp	=	stn_PB_East;
	temp	=	stn_Name_Nagano;
	temp	=	stn_PB_Nagano;
/*	--	直通運転に伴い削除	2010/08/05 H.Kitsukawa
	temp	=	stn_Name_Kyushu;
	temp	=	stn_PB_Kyushu;
*/
	temp	=	stn_Name_Group2;
	temp	=	stn_PB_Group2;
}
function	SelToukai()
{
}
function	SelTouhoku()
{
}
function	SelJyouetu()
{
}
function	SelKyuusyuu()
{
}
var	stations;
var	stationpbs;
function	StnAssistChange()
{
	var	dest	=	document.getElementById("stn_sel");
	var	src		=	document.getElementById("stn_sel_src");
	dest.innerHTML	=	src.innerHTML;
	try
	{
		if	(fIsIE)
		{
			document.getElementById("arr_stnlist").removeChild(document.getElementById("arr_stnlist").firstChild);
			document.getElementById("dep_stnlist").removeChild(document.getElementById("dep_stnlist").firstChild);
		}
		else
		{
			document.vac.arr_stnlist.removeChild(document.vac.arr_stnlist.firstChild);
			document.vac.dep_stnlist.removeChild(document.vac.dep_stnlist.firstChild);
		}
	}
	catch	(e)
	{}
	var	tag;
	var	line_stn="";
	var	line_stn_pb="";
	switch	(document.vac.train.selectedIndex)
	{
		case	1:
			line_stn	=	stn_Name_Toukai;
			line_stn_pb	=	stn_PB_Toukai;
			break;
		case	2:
			line_stn	=	stn_Name_Group2;
			line_stn_pb	=	stn_PB_Group2;
			break;
		case	3:
			line_stn	=	stn_Name_East;
			line_stn_pb	=	stn_PB_East;
			break;
		case	4:
			line_stn	=	stn_Name_Nagano;
			line_stn_pb	=	stn_PB_Nagano;
			break;
/*	--	直通運転に伴い削除	2010/07/13 H.Kitsukawa
		case	5:
			line_stn	=	stn_Name_Kyushu;
			line_stn_pb	=	stn_PB_Kyushu;
			break;
*/
		default:
			dest.innerHTML	=	"";
			return;
	}
	stations	=	line_stn.split("|");
	stationpbs	=	line_stn_pb.split("|");
	for	(stn_no in stations)
	{
		tag	=	document.createElement("OPTION");
		if	(fIsIE)
		{
			tag.setAttribute("value",stationpbs[stn_no]);
			tag.innerText	=	stations[stn_no];
			document.getElementById("dep_stnlist").appendChild(tag);
		}
		else
		{
			tag.value	=	stationpbs[stn_no];
			tag.text	=	stations[stn_no];
			document.vac.dep_stnlist.appendChild(tag);
		}
		tag	=	document.createElement("OPTION");
		if	(fIsIE)
		{
			tag.setAttribute("value",stationpbs[stn_no]);
			tag.innerText	=	stations[stn_no];
			document.getElementById("arr_stnlist").appendChild(tag);
		}
		else
		{
			tag.value	=	stationpbs[stn_no];
			tag.text	=	stations[stn_no];
			document.vac.arr_stnlist.appendChild(tag);
		}
	}
}
function SelectDepartureStation()
{
	document.vac.dep_stn.value	=	stations[document.vac.dep_stnlist.selectedIndex];
	document.vac.dep_stnpb.value	=	stationpbs[document.vac.dep_stnlist.selectedIndex];
}
function SelectArrivalStation()
{
	document.vac.arr_stn.value	=	stations[document.vac.arr_stnlist.selectedIndex];
	document.vac.arr_stnpb.value	=	stationpbs[document.vac.arr_stnlist.selectedIndex];
}
function	SwapDepartureArrival()
{
	var	tmp	=	document.vac.dep_stn.value;
	document.vac.dep_stn.value=document.vac.arr_stn.value;
	document.vac.arr_stn.value	=	tmp;
	var	pb	=	document.vac.dep_stnpb.value;
	document.vac.dep_stnpb.value=document.vac.arr_stnpb.value;
	document.vac.arr_stnpb.value	=	pb;
}

function	StationPBReset()
{
	document.vac.dep_stnpb.value	=	"";
	document.vac.arr_stnpb.value	=	"";
}
function	SubmitForm()
{
	if	(document.vac.train.selectedIndex==0)
	{	//	列車グループが選択されていない
		alert("お乗りになる列車を選択してください");
		document.vac.train.focus();
		return;
	}
	if	(document.vac.dep_stn.value.length==0)
	{	//	乗車駅が入力されていない
		alert("乗車駅を入力してください");
		document.vac.dep_stn.focus();
		return;
	}
	if	(document.vac.dep_stn.value.length>30)
	{	//	乗車駅が長い
		alert("乗車駅は30文字まで入力可能です");
		document.vac.dep_stn.focus();
		return;
	}
	if	(document.vac.arr_stn.value.length==0)
	{	//	降車駅が入力されていない
		alert("降車駅を入力してください");
		document.vac.arr_stn.focus();
		return;
	}
	if	(document.vac.arr_stn.value.length>30)
	{	//	乗車駅が長い
		alert("降車駅は30文字まで入力可能です");
		document.vac.arr_stn.focus();
		return;
	}
	//	全角ハイフォンとマイナスを長音に変換する
	document.vac.dep_stn.value	=	document.vac.dep_stn.value.replace("−","ー");
	document.vac.dep_stn.value	=	document.vac.dep_stn.value.replace("‐","ー");
	document.vac.dep_stn.value	=	document.vac.dep_stn.value.replace("―","ー");
	document.vac.arr_stn.value	=	document.vac.arr_stn.value.replace("−","ー");
	document.vac.arr_stn.value	=	document.vac.arr_stn.value.replace("‐","ー");
	document.vac.arr_stn.value	=	document.vac.arr_stn.value.replace("―","ー");
	return	document.vac.submit();
}

