/**
 *
 * バリデーション
 *
 * @auther yamazaki@re-set.ne.jp(2009.09.13)
 */
function check_input( obj, name ) {

	if ( obj.value == '' ) {
		alert( name + 'を入力してください。' );
		obj.focus();
		return false;
	}
	return true;
}

function check_selected( obj, name ) {

	var val = '';
	if ( obj.selectedIndex >= 0 ) {
		val = obj[ obj.selectedIndex ].value;
	}
	
	if ( val == '' ) {
		alert( name + 'を選択してください。' );
		obj.focus();
		return false;
	}
	return true;
}

function check_numeric( obj, name ) {

	if ( obj.value.match( /[^0-9]/ ) ) {
		alert( name + 'には半角数字を入力してください。' );
		obj.focus();
		return false;
	}
	return true;
}


function check_zero( obj, name ) {

	if ( obj.value == '0' ) {
		alert( name + 'には1以上の数字を入力してください。' );
		obj.focus();
		return false;
	}
	return true;
}

function check_checkbox( fm, obj, name, foc ) {

	var i, found = '';
	if (fm.elements[obj].length) {
		for ( i = 0; i < fm.elements[obj].length; i++ ) {
			if ( fm.elements[obj][i].checked ) {
				found = fm.elements[obj][i].value;
				break;
			}
		}
	}else if(fm.elements[obj].checked){
		found = fm.elements[obj].value;
	}
	
	if ( ! found ) {
		if (fm.elements[obj].length) {
			fm.elements[obj][0].focus();
		}else{
			fm.elements[obj].focus();
		}
		alert( name + 'を選択してください。' );
		return false;
	}
	
	return found;
}

function check_radio( obj, name ) {

	var i, found = '';
	
	for ( i = 0; i < obj.length; i++ ) {
		if ( obj[i].checked ) {
			found = obj[i].value;
			break;
		}
	}
	
	if ( ! found ) {
		alert( name + 'を選択してください。' );
		obj[0].focus();
		return false;
	}
	
	return found;
}

function check_mail( obj, mail1, mail2 ) {

	if ( mail1.value != mail2.value ) {
		alert( 'メールアドレス（確認）を正しく入力してください。' );
		obj.focus();
		return false;
	}
	return true;
}


function check_email(obj,email){
	if (!obj.value.match(/[!#-9A-~]+@+[a-z0-9]+.+[^.]$/i)) {
		alert( 'メールアドレスを正しく入力してください。' );
		obj.focus();
		return false;
	}
	return true;
}

