﻿// JavaScript for OecBody

// イベントハンドラ ------------------------------------------------------------- //


// ローカルメソッド ------------------------------------------------------------- //
// 初期フォーカス位置
function InitFocus() {
    minObj = null;  // min-tabindex obj
    topObj = null;  // top obj
    cnt = document.getElementsByTagName("input").length;
    for(i=0; i<cnt; i++) {
        curObj = document.getElementsByTagName("input")[i];
        if((curObj.getAttribute("type") != "text") && 
           (curObj.getAttribute("type") != "submit") &&
           (curObj.getAttribute("type") != "password")) {
            continue;
        }
        
        if(curObj.getAttribute("disabled") == true ) {
            continue;
        }
        
        if(topObj == null) topObj = curObj;
        if(curObj.getAttribute("tabindex") > 0) {
            if(minObj == null) minObj = curObj;
            else {
                if(minObj.getAttribute("tabindex") > curObj.getAttribute("tabindex"))
                    minObj = curObj;
            }
        }
    }
    if      (minObj != null) minObj.focus();
    else if (topObj != null) topObj.focus();    
}

// 初期フォーカス位置(LinkButton)
// LinkButtonしかない画面で、一番にフォーカスを当てる //
function InitFocusLinkButton() {
    minObj = null;  // min-tabindex obj
    topObj = null;  // top obj
    cnt = document.getElementsByTagName("a").length;
    for(i=0; i<cnt; i++) {
        curObj = document.getElementsByTagName("a")[i];
        if(curObj.getAttribute("href") == ""){
            continue;
        }
        
        if(curObj.getAttribute("disabled") == true){
            continue;
        }
        
        if(topObj == null) topObj = curObj;
        if(curObj.getAttribute("tabindex") > 0){
            if(minObj == null) minObj = curObj;
            else {
                if(minObj.getAttribute("tabindex") > curObj.getAttribute("tabindex"))
                    minObj = curObj;
            }
        }
    }
    if(minObj != null)            minObj.focus();
    else if(topObj != null)        topObj.focus();    
}
// 動作を無効にしたい場合は、以下のコメントアウトをはずす
//function InitFocus()
//{
//}

// ２重送信判定
var click_flg = 0;
function Double_ClickCheck() {
    
    if (click_flg == 0) {
        click_flg = 1;
        return true;
    } else {
        return false;
    }
}

