<!--


// 文字列が空白だけの場合、真を返す
function isblank(s)
{
    for(var i = 0; i < s.length; i++) {
        var c = s.charAt(i);
        if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
    }
    return true;
}

//フォームの検証
//
function verify(f)
{
    var msg;
    var empty_fields = "";
    var errors = "";

    // Loop through the elements of the form, looking for all 
    // text and textarea elements that don't have an "indispensable" property
    // defined.  Then, check for fields that are empty and make a list of them.
    // Also, if any of these elements have a "min" or a "max" property defined,
    // then verify that they are numbers and that they are in the right range.
    // Put together error messages for fields that are wrong.
    for(var i = 0; i < f.length; i++) {
        var e = f.elements[i];
        if ( e.Kname ) {
            // first check if the field is empty
            if (e.indispensable && isNullorUndefined(e.value)) {
                empty_fields += "\n          " + e.Kname;
                continue;
            }

            // Now check for fields that are supposed to be numeric.
            if ( !isNullorUndefined(e.value) && ( e.numeric || !isNullorUndefined(e.min) || !isNullorUndefined(e.max) )) { 
                var regstr = /[^0-9.]/;
                var b = regstr.test(e.value);
                var v = parseFloat(e.value);
                if ( b || 
                    (!isNullorUndefined(e.min) && (v < e.min)) || 
                    (!isNullorUndefined(e.max) && (v > e.max))) {
                    errors += "- " + e.Kname + " は数値(半角)を入力してください。";
                    if (!isNullorUndefined(e.min)) 
                        errors += " 入力できる最小値は " + e.min;
                    if (!isNullorUndefined(e.min) && !isNullorUndefined(e.max)) 
                        errors += " 最大値は " + e.max;
                    else if (!isNullorUndefined(e.max))
                        errors += " 入力できる最大値は " + e.max;
                    errors += "です。\n";
                }
            }
            if(!isNullorUndefined(e.ConditionName)){
							if( e.ConditionName == 'GeocodeFlagAndAddress2'){
								errors += ChkGeocodeFlagAndAddress2(f);
							}
						}
        }
    }

    // Now, if there were any errors, then display the messages, and
    // return true to prevent the form from being submitted.  Otherwise
    // return false
    if (!empty_fields && !errors) return true;

    msg  = "＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿　　\n\n"
    msg += "入力に以下の不備が見つかりました。\n";
    msg += "必須項目が空白になっているか、または、数値項目(半角)に\n";
    msg += "数値以外の文字が入力されています。\n";
    msg += "エラーを確認して再度入力してください。\n";
    msg += "＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿　　\n\n"

    if (empty_fields) {
        msg += "- 次の項目は必須項目です。:" 
                + empty_fields + "\n";
        if (errors) msg += "\n";
    }
    msg += errors;
    alert(msg);
    return false;
}

function ChkGeocodeFlagAndAddress2(f){
	var w_err = "";
	if((f.address2.value == null || f.address2.value == "") ){
		if(( f.GeocodeFlag.type == 'checkbox' && f.GeocodeFlag.checked ) || ( f.GeocodeFlag.type == 'hidden' && f.GeocodeFlag.value==1 )){
			w_err = "- 所在地の番地が空白の場合、地図検索対象にすることはできません。\n";
			w_err += "  所在地の番地を入力するか、または地図設定で地図検索対象をOFFにしてください。\n";
		}
	}
	return(w_err)
}


function isNullorUndefined(v){
	var ret = false;
	ret = (( v == null) || ( v === "" ) || ( v == undefined ) );
	return ret;
}

// -->

