function Check()	
{
	if(document.form1.nickname.value=="")
	{
		alert("ニックネームを入力してね");
		return false;
	}

	flgError=0;
	if (document.form1.year.options[document.form1.year.selectedIndex].value==9999) flgError=1;
	if (document.form1.month.options[document.form1.month.selectedIndex].value==9999) flgError=1;
	if (document.form1.day.options[document.form1.day.selectedIndex].value==9999) flgError=1;
	if (document.form1.hour.options[document.form1.hour.selectedIndex].value==9999) flgError=1;
	if (document.form1.minute.options[document.form1.minute.selectedIndex].value==9999) flgError=1;
	if (document.form1.locate.options[document.form1.locate.selectedIndex].value==9999) flgError=1;

	if (flgError )
	{
			alert("入力が完全ではありません");
			return false;
	}

	cyear=document.form1.year.options[document.form1.year.selectedIndex].value;
	cmonth=document.form1.month.options[document.form1.month.selectedIndex].value;
	cday=document.form1.day.options[document.form1.day.selectedIndex].value;
	
	if (IsTrueDate( cyear,cmonth,cday)==false )
	{
		alert("日付の入力が違うよ");
		return false;
	}

	if (IsTrueBirthDay( cyear,cmonth,cday)==false )
	{
		alert("この生年月日では占えません");
		return false;
	}

	return true;
}




function CheckMeet()	
{
	if(document.form1.nickname.value=="")
	{
		alert("ニックネームを入力してね");
		return false;
	}

	flgError=0;
	if (document.form1.year.options[document.form1.year.selectedIndex].value==9999) flgError=1;
	if (document.form1.month.options[document.form1.month.selectedIndex].value==9999) flgError=1;
	if (document.form1.day.options[document.form1.day.selectedIndex].value==9999) flgError=1;
	if (document.form1.hour.options[document.form1.hour.selectedIndex].value==9999) flgError=1;
	if (document.form1.minute.options[document.form1.minute.selectedIndex].value==9999) flgError=1;
	if (document.form1.locate.options[document.form1.locate.selectedIndex].value==9999) flgError=1;

	if (document.form1.myear.options[document.form1.myear.selectedIndex].value==9999) flgError=1;
	if (document.form1.mmonth.options[document.form1.mmonth.selectedIndex].value==9999) flgError=1;
	if (document.form1.mday.options[document.form1.mday.selectedIndex].value==9999) flgError=1;

	if (flgError )
	{
			alert("入力が完全ではありません");
			return false;
	}

	cyear=document.form1.year.options[document.form1.year.selectedIndex].value;
	cmonth=document.form1.month.options[document.form1.month.selectedIndex].value;
	cday=document.form1.day.options[document.form1.day.selectedIndex].value;

	
	if (IsTrueDate( cyear,cmonth,cday)==false )
	{
		alert("日付の入力が違うよ");
		return false;
	}

	if (IsTrueBirthDay( cyear,cmonth,cday)==false )
	{
		alert("この生年月日では占えません");
		return false;
	}


	cyear=document.form1.myear.options[document.form1.myear.selectedIndex].value;
	cmonth=document.form1.mmonth.options[document.form1.mmonth.selectedIndex].value;
	cday=document.form1.mday.options[document.form1.mday.selectedIndex].value;
	if(cday==99) cday=1;

	if (IsTrueDate( cyear,cmonth,cday)==false )
	{
		alert("出会った日の入力が違うよ");
		return false;
	}

	if (IsTrueBirthDay( cyear,cmonth,cday)==false )
	{
		alert("出会った日の入力が違うよ");
		return false;
	}

	return true;
}


function pCheck()	
{
	if(document.form1.pnickname.value=="")
	{
		alert("ニックネームを入力してね");
		return false;
	}

	flgError=0;
	if (document.form1.pyear.options[document.form1.pyear.selectedIndex].value==9999) flgError=1;
	if (document.form1.pmonth.options[document.form1.pmonth.selectedIndex].value==9999) flgError=1;
	if (document.form1.pday.options[document.form1.pday.selectedIndex].value==9999) flgError=1;
	if (document.form1.phour.options[document.form1.phour.selectedIndex].value==9999) flgError=1;
	if (document.form1.pminute.options[document.form1.pminute.selectedIndex].value==9999) flgError=1;
	if (document.form1.plocate.options[document.form1.plocate.selectedIndex].value==9999) flgError=1;

	if (flgError )
	{
			alert("入力が完全ではありません");
			return false;
	}

	cyear=document.form1.pyear.options[document.form1.pyear.selectedIndex].value;
	cmonth=document.form1.pmonth.options[document.form1.pmonth.selectedIndex].value;
	cday=document.form1.pday.options[document.form1.pday.selectedIndex].value;
	
	if (IsTrueDate( cyear,cmonth,cday)==false )
	{
		alert("日付の入力が違うよ");
		return false;
	}
	if (IsTrueBirthDay( cyear,cmonth,cday)==false )
	{
		alert("この生年月日では占えません");
		return false;
	}
	return true;
}

function Checkboth()	
{
	if(document.form1.pnickname.value=="")
	{
		alert("ニックネームを入力してね");
		return false;
	}
	if(document.form1.nickname.value=="")
	{
		alert("あなたのニックネームを入力してね");
		return false;
	}

	flgError=0;
	if (document.form1.pyear.options[document.form1.pyear.selectedIndex].value==9999) flgError=1;
	if (document.form1.pmonth.options[document.form1.pmonth.selectedIndex].value==9999) flgError=1;
	if (document.form1.pday.options[document.form1.pday.selectedIndex].value==9999) flgError=1;
	if (document.form1.phour.options[document.form1.phour.selectedIndex].value==9999) flgError=1;
	if (document.form1.pminute.options[document.form1.pminute.selectedIndex].value==9999) flgError=1;
	if (document.form1.plocate.options[document.form1.plocate.selectedIndex].value==9999) flgError=1;

	if (flgError )
	{
			alert("入力が完全ではありません");
			return false;
	}

	cyear=document.form1.pyear.options[document.form1.pyear.selectedIndex].value;
	cmonth=document.form1.pmonth.options[document.form1.pmonth.selectedIndex].value;
	cday=document.form1.pday.options[document.form1.pday.selectedIndex].value;
	
	if (IsTrueDate( cyear,cmonth,cday)==false )
	{
		alert("日付の入力が違うよ");
		return false;
	}
	if (IsTrueBirthDay( cyear,cmonth,cday)==false )
	{
		alert("この生年月日では占えません");
		return false;
	}
	return true;
}






function dounknown()
{
	if (document.form1.knowtime.checked)
	{
		alert("出生時間は不明にします");
		document.form1.hour.selectedIndex=0; //0時のこと
		document.form1.minute.selectedIndex=0;  //0分
//		document.form1.locate.selectedIndex=48; //不明
	} else {
		document.form1.hour.selectedIndex=13; 
		document.form1.minute.selectedIndex=31; 
//		document.form1.locate.selectedIndex=0; 
	}		
}

function pdounknown()
{
	if (document.form1.pknowtime.checked)
	{
		alert("出生時間は不明にします");
		document.form1.phour.selectedIndex=0; //12時のこと
		document.form1.pminute.selectedIndex=0;  //0分
//		document.form1.plocate.selectedIndex=48; //不明
	} else {
		document.form1.phour.selectedIndex=13; 
		document.form1.pminute.selectedIndex=31; 
//		document.form1.plocate.selectedIndex=0; 
	}		
}

function IsTrueDate(year,month,day)
{
	if (month==2 || month==4 || month==6 || month==9 || month==11 )
		if(day==31)	return false;
	
	if (month !=2 ) return true;

	if ( IsLeap(year) ==false )
	{
		if ( day==29 || day==30 || day==31 )
			return false;
	}
	else
	{
		if (day==30 || day==31 )
			return false;
	}
	return true;
}

function IsTrueBirthDay(year,month,day)
// 未来の生年月日を入れてないか？
{
	today=new Date();
	
	inpDate=year+"/"+month+"/"+day;
	chkDate=Date.parse(inpDate);
	curDate=today.getTime();
	if (chkDate>curDate)
		return false;
	return true;
	
	
}

function IsLeap(year)
// 閏年かどうかのﾁｪｯｸをする
// ４で割り切れる年は閏年、但し１００で割れたら違う。ただし４００で割れたら閏年
{
	
	flag=false;
	y=eval(year);
	if (((y%4==0) && (y%100 !=0)) || (y%400==0)) 
		return true;
	else
		return false;
}


//======================================================
//  全角数字->半角数字へ
//======================================================
function toHankakuNum(orgText)
{
	han="0123456789";
	zen="０１２３４５６７８９";
	str="";
	for (i=0; i<orgText.length; i++)
	{
		c=orgText.charAt(i);
		n=zen.indexOf(c,0);
		if ( n>=0 ) c=han.charAt(n);
		str+=c;
	}
	return str;
}

/////////////////////////////////////////////////////////////
//数字の判定
///////////////////////////////////////////////////////////
function IsNum(txtVal)
{
	for( i=0; i<txtVal.length; i++ )
	{
		c=txtVal.charAt(i);
		if ("0123456789".indexOf(c,0)<0 )  return false;
	}
	return true;
}


flgSEND=false;

///////////////////////////////////////////////////////////	
//   数値フィールドのチェック
///////////////////////////////////////////////////////////
function AllNumCheck()
{
	if (flgSEND)	
	{
		alert("送信済みです。お待ち下さい");
		return false;
	}
	
// 全項目入ってる？
	flgError=0;
	if(document.Cinput.tn1.value=="") flgError=1;
	if(document.Cinput.tn2.value=="") flgError=1;
	if(document.Cinput.tn3.value=="") flgError=1;
	if(document.Cinput.cn1.value=="") flgError=1;
	if(document.Cinput.cn2.value=="") flgError=1;
	if(document.Cinput.cn3.value=="") flgError=1;
	if(document.Cinput.cn4.value=="") flgError=1;
	if(document.Cinput.name.value=="") flgError=1;

	if (flgError)	
	{
		alert("すべての項目を入力してね");
		return false;
	}

// まず全角ー＞半角変換
	document.Cinput.tn1.value=toHankakuNum(document.Cinput.tn1.value);
	document.Cinput.tn2.value=toHankakuNum(document.Cinput.tn2.value);
	document.Cinput.tn3.value=toHankakuNum(document.Cinput.tn3.value);

	document.Cinput.cn1.value=toHankakuNum(document.Cinput.cn1.value);
	document.Cinput.cn2.value=toHankakuNum(document.Cinput.cn2.value);
	document.Cinput.cn3.value=toHankakuNum(document.Cinput.cn3.value);
	document.Cinput.cn4.value=toHankakuNum(document.Cinput.cn4.value);
	
// 数字かどうか？
	flgError=0;
	if ( !IsNum(document.Cinput.tn1.value) ) flgError=1;
	if ( !IsNum(document.Cinput.tn2.value) ) flgError=1;
	if ( !IsNum(document.Cinput.tn3.value) ) flgError=1;
	
	if ( !IsNum(document.Cinput.cn1.value) ) flgError=1;
	if ( !IsNum(document.Cinput.cn2.value) ) flgError=1;
	if ( !IsNum(document.Cinput.cn3.value) ) flgError=1;
	if ( !IsNum(document.Cinput.cn4.value) ) flgError=1;
	if (flgError)	
	{
		alert("入力内容が正しくありません");
		return false;
	}
	
	flgSEND=true;
	return true;
}

