//-----for NN4-----
function resizeCheck(){
	if (document.layers){
		location.reload();	//for NN
	}
}

window.onresize = resizeCheck;
//-----for NN4-----

//<======	Event handler array	======>
	//任意のイベントが発生した場合に、登録したメソッドをすべて実行する
	function EventFunction(e){
		if ((e) && (e.type) && (EventFunction[e.type])){	//for Moz
			var etype = e.type;
			for (var i = 0; i < EventFunction[etype].length; i++){
				EventFunction[etype][i]();
			}
		}else if ((typeof(event) == "object") && (event) && (event.type) && (EventFunction[event.type])){	//for IE			
			var etype = event.type;	//for Mac IE 5
			for (var i = 0; i < EventFunction[etype].length; i++){
				EventFunction[etype][i]();
			}
		}

		//配列の最後に任意のイベントのメソッドを追加登録する。
		//eventType = ["load" | "focus" | "click" ...]
		//例：EventFunction.addFunc("load",onloadInit);
		//例：EventFunction.addFunc("click",clickEvent);
		EventFunction.addFunc = function (eventType,funcName){
			if (! EventFunction[eventType]){
				EventFunction[eventType] = new Array();
			}

			EventFunction[eventType][EventFunction[eventType].length] = funcName;
		}

		return this;
	}

		new EventFunction();
		
		/*	memo
			window.onclick = EventFunction;	//moz OK , IE6 NG
			document.onclick = EventFunction;	//moz OK , IE6 OK
		*/
		window.onload = EventFunction;
//</======	onload	======>

EventFunction.addFunc("load",onloadInit);


function onloadInit(){
	//setDefaultFontSize();
}


//標準モード以外ならば、body{font-size:small;}にセットする。
function setDefaultFontSize(){
	if (navigator.appName == "Microsoft Internet Explorer"){
		if (navigator.userAgent.match(/MSIE [45]/i) && (navigator.userAgent.match(/Windows/i))){
			document.body.style.fontSize = "small";	//for Win IE4 , Win IE 5
			return;
		}
	}

	if (! document.getElementById){return;}
	var body = (document.getElementsByTagName("body"))[0];
	if (! body){return;}
	if (! body.style){return;}

	if (document.compatMode){
		var mode = document.compatMode;	//"CSS1Compat" | "BackCompat" | "QuirksMode" (Opera7)

		if ((mode) && (mode != "CSS1Compat")){	// !DOCTYPEスイッチ：標準モード以外ならば
				body.style.fontSize = "small";	//xml宣言をすると、IE6が互換モードになるバグ対策。
		}
	}

	//var feature = document.implementation.hasFeature('HTML','1.0');
}

//別窓オープン
function openWin(obj,w,h,winName){
	var attr = "resizable=1,scrollbars=1,location=1,status=1,toolbar=1,directories=1,menubar=1";
	if(w){
		attr += ",width=" + w;
	}

	if(h){
		attr += ",height=" + h;
	}

	if (! winName){
		winName = "_blank";
	}
	var win=window.open(obj.href,winName,attr);
	win.focus();
	return false;
}


//定型ウインドウをオープン (未使用)
function _openWin(obj,w,h,noFocusFlg){

	if (! obj.defHref){obj.defHref = obj.href;}
	obj.href ="javascript:void(0)";
	
	w = (w)?(w):(700);
	h = (h)?(h):(700);

	//低解像度モニタ対策
	var wLimit,hLimit,minSize=100,offset = 50;
	if(screen){
		wLimit = (screen.availWidth)?(screen.availWidth -offset):(null);
		hLimit = (screen.availHeight)?(screen.availHeight -offset):(null);
		
		if (wLimit){w = (w > wLimit)?(wLimit):(w);}
		if (hLimit){h = (h > hLimit)?(hLimit):(h);}
		w = (w < minSize)?(minSize):(w);
		h = (h < minSize)?(minSize):(h);
	}

	var attr = "width=" + w + ",height=" + h + ",resizable=1,scrollbars=1,location=1,status=1,toolbar=1,directories=1,menubar=1";
	
	var winName = obj.defHref.replace(/^.+\//,"");	//URLからファイル名だけ抜き出す
	winName = winName.replace(/\./g,"_");	//ファイル名の"."(ドット)を"_"アンスコに置換
	
	//Mac IE 5.1.4 (OS X) でハイフンがあるとスクリプトエラー発生のため回避
	winName = winName.replace(/-/g,"_");	//ファイル名の"-"(ハイフン)を"_"アンスコに置換
	var win=window.open(obj.defHref,winName,attr);

	//"resizable=1,scrollbars=1,directories=1,location=1,menubar=1,toolbar=1,status=1";	//オプションメモ

	if(noFocusFlg){return;}	//mac IE5 keypress対策
	win.opener=self; //NN2x対策
	if(navigator.appVersion.charAt(0)>=3){win.focus();}//NN3.0x フォーカス対策

	return false;
}

function resetHref(obj){
	if (obj.defHref){obj.href = obj.defHref;}
}

//sent Keypress 別窓リンク
function openWinfromKey(e,obj){
	resetHref(obj);

	var code = (e.which)?(e.which):((e.keyCode)?(e.keyCode):(null));
	if(!(code == 13 || code == 14 || code == 3)){return;}	//RETURN key or ENTER key
	openWin(obj,null,null,true);
}

//--------------------------------------------------------------
//id stringsからオブジェクトを返す
function getObjFromID(id){
	if (document.getElementById){		//IE5.x IE6 NN6
		return document.getElementById(id);
	}else if ((document.all) && (document.all(id).style)){	//IE 4.x
		return document.all(id);
	}else{
		return false;
	}
}



//roll over image
//Ex : <img src="1.gif" onmouseover="swapImg(this,'2.gif')" width="80" height="80" alt="">
function swapImg(obj,path){
	if(this.defSrc){
		(this.src == this.defSrc)?(this.src=this.swapSrc):(this.src =this.defSrc);
	}else if((! obj.defSrc) && (obj.src)){
		obj.defSrc = obj.src;
		obj.swapSrc = obj.src = path;
		obj.onmouseout = obj.onmouseover = swapImg;
	}
}

//--------debug用---------------------------------------------
//オブジェクトの全てのプロパティを表示する。(for debug) Ex : showAllProp(document);
function showAllProp(obj){
	var str = "";

	for(var i in obj){
		str += i + " : " + obj[i] + "<br>\n";
	}

	//alert(str);
	var win=window.open("",'newwin');
	win.document.write(str);
}

