function chkEmptyTxt (theObj, msg)
{
	if ( theObj.value == "" )
	{
		alert( msg + "を入力してください。");
		theObj.focus();
		theObj.select();
		return true;
	}
}

function chkNaNTxt( theObj, msg )
{
	if ( isNaN(theObj.value) )
	{
		alert(msg + "を入力してください。");
		theObj.focus();
		theObj.select();
		return true;
	}
}

function chkEmptySel( theObj, msg )
{
	if( theObj[theObj.selectedIndex].value == "" )
	{
		alert(msg + "を選んでください。");
		theObj.focus();
		return true;
	}
}

function chkEmptySelM( theObj, msg )
{
	var errFlag = false;
	
	if( theObj.selectedIndex == -1 )
		errFlag = true;
	else
		if( theObj[theObj.selectedIndex].value == "" )
			errFlag = true;
		else
		{
			errFlag = true;
			for( i=0; i<theObj.length; i++ )
			{
				if( theObj[i].selected )
				{
					errFlag = false;
					break;
				}
			}
		}

	if( errFlag )
	{
		alert("Please select " + msg + "!");
		theObj.focus();
		return true;
	}
}


function chkEmptyOpt( theObj, msg )
{
	for( i=0; i<theObj.length; i++ )
		if( theObj[i].checked )
			return false;
	
	alert(msg + "を選んでください。");
	theObj[0].focus();
	return true;
}


function chkEmptyRad( theObj, msg )
{
	for( i=0; i<theObj.length; i++ )
		if( theObj[i].checked )
			return false;
	
	alert(msg + "を選んでください。");
	theObj[0].focus();
	return true;
}


function chkDate(year, month, day)
{
	if ( year == "" && month == "" && day == "" )
		return false;

	combineDate = new Date(year + "/" + month + "/" + day)
	if ( eval(combineDate.getMonth()) != eval(month - 1) )
		return false;

	if (eval(year) < 1000)
		return false;

	return true;
}


function setSelVal( theObj, theVal )
{
	for( i=0; i<theObj.length; i++ )
		if( theObj[i].value == theVal )
			theObj.selectedIndex = i;
}


function setRadVal( theObj, theVal )
{
	for( i=0; i<theObj.length; i++ )
		if( theObj[i].value == theVal )
			theObj[i].checked = true;
}

