document.onkeydown = EnterKeyCodeChanger;
function EnterKeyCodeChanger(){
	//if(window.event.srcElement.tagName != "INPUT"){
	//	return;
	//}
	if(window.event.srcElement.className != "EnterToTab"){
		return;
	}
	if(event.keyCode == 13){
		event.keyCode = 9;
	}
}
var lastColor;
var customFocasElement;
function Init(){
	var element = document.forms(0).all;
	if(element != null){
		var firstElement = true;
		for(i = 0; i < element.length; i++){
			if(element.item(i).className == "EnterToTab" && element.item(i).disabled == false){
				element.item(i).onfocus = changeBgColorOrangeRed;
				element.item(i).onblur = changeLastColor;
				if(firstElement){
					if(typeof(FocusElement) == "undefined" || FocusElement == element.item(i).name){
						element.item(i).focus();
						firstElement = false;
					}
				}
			}
			if(element.item(i).className == "ActiveButton" && element.item(i).disabled == false){
				element.item(i).onfocus = changeBgColorOrangeRed;
				element.item(i).onblur = changeLastColor;
				if(firstElement){
					if(typeof(FocusElement) == "undefined" || FocusElement == element.item(i).name){
						element.item(i).focus();
						firstElement = false;
					}
				}
			}
			if(firstElement){
				if(typeof(FocusElement) != "undefined" && FocusElement == element.item(i).name){
						element.item(i).focus();
						firstElement = false;
				}
			}
		}
	}
	//bootstarapより受け付けるカスタムフォーカスエレメント
	if(typeof(customFocasElement) != "undefined"){
		customFocasElement.focus();
		customFocasElement = null;
	}
	
}

function changeBgColorOrangeRed(){
	lastColor = window.event.srcElement.style.backgroundColor;
	window.event.srcElement.style.backgroundColor='OrangeRed';
}

function changeLastColor(){
	window.event.srcElement.style.backgroundColor=lastColor;
}

function SetCustomFocasElement(element){
	customFocasElement = element;
}
