if (document.images) {
   img1 = new Image(); img1.src = "page2/gaiyob.gif";
   img2 = new Image(); img2.src = "page2/gyomub.gif";
   img3 = new Image(); img3.src = "page2/jissekib.gif";
   img4 = new Image(); img4.src = "page2/bosyub.gif";
   img5 = new Image(); img5.src = "page2/internb.gif";
   img6 = new Image(); img6.src = "page2/jizaib.gif";
   img7 = new Image(); img7.src = "page2/toiawab.gif";
   img8 = new Image(); img8.src = "page2/newsb.gif";
   img9 = new Image(); img9.src = "page2/topb.gif";
}
function setImage(img, image) {
   if (img) {
      img.src = image;
   }
}

function isNum(passedVal) {
	for(i=0;i<passedVal.length;i++) {
		if(passedVal.charAt(i)<"0")	return false
		if(passedVal.charAt(i)>"9")	return false
	}
	return true
}

function GetDayMax(yearcnt, monthcnt) {
	if(monthcnt==2) {
		if( yearcnt % 4 == 0 )	return 29
		else			return 28
	}
	if((monthcnt==4)||(monthcnt==6)||(monthcnt==9)||(monthcnt==11))	return 30
	else								return 31
}

function Check_Year() {
	if((document.form1.year.value!="")&&(isNum(document.form1.year.value)==false)) {
		alert("年数の西暦入力です。\n半角数字で最大２桁です。")
		document.form1.year.value=""
		return false
	}
	if((document.form1.month.value!="")&&(isNum(document.form1.month.value) == false)) {
		alert("月数の入力です。\n半角数字で最大２桁です。")
		document.form1.month.value=""
		return false
	}
	if((document.form1.month.value!="")&&(( document.form1.month.value < 1 )||( document.form1.month.value > 12 ))) {
		alert("月数の入力です。\n半角で１から12の間の数を入力して下さい。")
		document.form1.month.value=""
		return false
	}
	if((document.form1.day.value!="")&&(isNum(document.form1.day.value)==false)) {
		alert("日数の入力です。\n半角数字で最大２桁です。")
		document.form1.day.value=""
		return false
	}
	maxday = GetDayMax(document.form1.year.value, document.form1.month.value)
	if((document.form1.day.value!="")&&((document.form1.day.value<1)||(document.form1.day.value>maxday))) {
		alert(document.form1.month.value+"月の日数入力です。\n半角数字で１から"+maxday+"までの値を入力して下さい。")
		document.form1.day.value=""
		return false
	}
	return true
}

function Check_Int(code) {
	if((code!="")&&(isNum(code)==false)) {
		alert("数値の入力は半角数字で行って下さい。")
		return false
	}
	return true
}

function AgeChecktoToday(TodayMonth, TodayDate)
{
	monthcnt = TodayMonth - document.form1.month.value
	if( monthcnt != 0 )
	{
		if ( monthcnt < 0 )	return 0
		else			return 1
	}
	else
	{
		daycnt = TodayDate - document.form1.day.value
		if( daycnt < 0 )	return 0
		else			return 1
	}
}

function Age_Count()
{
	if(Check_Year()==true)
	{
		if((document.form1.year.value!="")&&(document.form1.month.value!="")&&(document.form1.day.value!=""))
		{
			dt = new Date
			TodayYear = dt.getYear()
			TodayMonth = dt.getMonth() + 1
			TodayDate = dt.getDate()
			Older = TodayYear - document.form1.year.value + ""
			if( Older.length >= 4 )
				Older = Older.substring(2, 4)
			document.form1.age.value = Older
			if( AgeChecktoToday(TodayMonth, TodayDate) == 0 )
				document.form1.age.value--
		}
	}
}

function Check_Submit()
{
	if(confirm("送信してもよろしいですか？"))
		document.form1.elements.submit()
}

