// 数値のみを入力可能にする
function numOnly(keyCode) {
  var inputkeys = [8,9,13,16,37,39,46,48,49,50,51,52,53,54,55,56,57,96,97,98,99,100,101,102,103,104,105];
  if(getIndex(inputkeys,keyCode) < 0) return false;
  return true;
}

// 自動フォーカス移動(次のコントロール指定)
function f_checkTabMoveTo(keyCode,obj, nextobj){
	var movekeys = [9,16,37,39];
	if(getIndex(movekeys,keyCode) >= 0) return true;
    if(obj.value.length == obj.getAttribute('maxlength')){
        nextobj.focus();
    }
}


// フォーカス取得時に背景色変更
function f_onFocus(textObj){
	textObj.style.backgroundColor = '#fff';
}

// フォーカス喪失時に背景色変更
function f_onBlur(obj){
	if("text" == obj.type){
		// テキスト
		if(obj.value.length > 0){
			obj.style.backgroundColor = '#fff';
		}else{
			obj.style.backgroundColor = '#FFCC99';
		}
	}else if("select-one" == obj.type){
		// コンボボックス
		if(obj.selectedIndex > 0){
			obj.style.backgroundColor = '#fff';
		}else{
			obj.style.backgroundColor = '#FFCC99';
		}
	}
}

// 配列内の要素を検索
function getIndex(ar,srh){
	for(i=0;i < ar.length;i++){
		if(ar[i] == srh){
			return i;
		}
	}
	return -1;
}

function f_ChangeInputColor(){
    if(document.forms != 'undefined'){
	var frmcount = document.forms.length;
	var cnt;
	for(cnt = 0; cnt < frmcount; cnt++){
	    if(document.forms[cnt].name == "frm_eventno" || document.forms[cnt].name == "frm_area" || document.forms[cnt].name == "frm_thema" || document.forms[cnt].name == "frm_keyword"){continue;}
	    var max = document.forms[cnt].elements.length;
	    var i;
	    for(i = 0; i < max; i++){
	    var obj = document.forms[cnt].elements[i];
		if ("text" == obj.type){
		    // テキスト
		    if(obj.value.length > 0){
			  obj.style.backgroundColor = '#fff';
		    }else{
			  obj.style.backgroundColor = '#FFCC99';
		}
		}else if("select-one" == obj.type){
		    // コンボボックス
		    if(obj.selectedIndex > 0){
			  obj.style.backgroundColor = '#fff';
		    }else{
			  obj.style.backgroundColor = '#FFCC99';
		    }
		}
	    }
	}
    }
}

