function addLoadEvent(func){ //Add Onload-function which does not conflict with other scripts

	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
		window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}
	
}

var setBodySize={
	largeClasses:["largeItem","dat_xx","dat","IMF_specTable"], 
	wrapperObj:{},gmenuObj:{},mainObj:{},maximumItemwidth:0,columnsWidth:340,
	BORDER_WIDTHMIN:966,
	BORDER_WIDTHMAX:1106,
	columns:["NF-sub","NF-ActionArea"],adjustIntervavl:100,
	ifIe6:false,ifIe7:false,
	getMainInnerHeight:{},	
	ifRightColumnIsEmpty:false,
	ifNoColumns:false,
	
	IDS:{
		WRAPPER:"NF-TypeLEVEL2",
		GLOBALNAVI:"NF-GlobalNavArea",
		CONTENTAREA:"NF-ContentArea",
		SUBNAVI:"SubNaviArea",
		MAIN:"NF-main",
		SUB:"NF-sub",
		ACTIONAREA:"NF-ActionArea",
		FOOT:"NF-FootArea"
	},
	IDNAMES:[],
	setStyle:{},
	getStyle:{},
	getProperty:{},
	
	initialize:function(){ 
		var _columns=[];
		setBodySize.columns.each(function(val){
				if($(val)) 	_columns.push(val);
		});
		setBodySize.columns=_columns;delete _columns;
	
		setBodySize.ifIe6=(agent.browser=="MSIE" && agent.version <= 6);
		setBodySize.ifIe7=(agent.browser=="MSIE" && agent.version >= 7);
		setBodySize.ifMoz=(agent.browser=="Mozilla");
		
		setBodySize.setStyle["FOOT"]=($(setBodySize.IDS["FOOT"])) ? 
					function(prop,value){
						$(setBodySize.IDS["FOOT"]).style[prop]=value;
					}:
					function(){return false};
		setBodySize.getStyle["FOOT"]=($(setBodySize.IDS["FOOT"])) ? 
					function(prop){
						return $(setBodySize.IDS["FOOT"]).style[prop];
					}:
					function(){return 0};
		setBodySize.getProperty["FOOT"]=($(setBodySize.IDS["FOOT"])) ? 
					function(prop){
						return ($(setBodySize.IDS["FOOT"])[prop]) ? $(setBodySize.IDS["FOOT"])[prop]:0;
					}:
					function(){return 0};
									
		if(setBodySize.ifNoColumns) {
			setBodySize.setStyle.WRAPPER=function(prop,value){	$("NF-TypeLEVEL2_noColumn").style[prop]=value;		}
			setBodySize.getStyle.WRAPPER=function(prop){return $("NF-TypeLEVEL2_noColumn").style[prop];}
			setBodySize.getProperty.WRAPPER=function(prop){return $("NF-TypeLEVEL2_noColumn")[prop];}
		}
		if($("NF-ContentArea_noColumn")) {
			
			/*setBodySize.setStyle.WRAPPER=function(prop,value){	$("NF-ContentArea_noColumn").style[prop]=value;		}
			setBodySize.getStyle.WRAPPER=function(prop){return $("NF-ContentArea_noColumn").style[prop];}
			setBodySize.getProperty.WRAPPER=function(prop){return $("NF-ContentArea_noColumn")[prop];}*/
			setBodySize.setStyle.CONTENTAREA=function(prop,value){	$("NF-ContentArea_noColumn").style[prop]=value;		}
			setBodySize.getStyle.CONTENTAREA=function(prop){return $("NF-ContentArea_noColumn").style[prop];}
			setBodySize.getProperty.CONTENTAREA=function(prop){return $("NF-ContentArea_noColumn")[prop];}
			setBodySize.IDS.CONTENTAREA="NF-ContentArea_noColumn";
		}
		
		//main program (switch by browser)
		if(setBodySize.ifIe6){
			
			//setting height of body
			if($(setBodySize.IDS.SUB)){ 
				var func=function(){
					var sh = setBodySize.getProperty.SUB("clientHeight");
					var ah = setBodySize.getProperty.ACTIONAREA("clientHeight");
					var mh = (sh > ah) ? sh : ah;
					setBodySize.setStyle.MAIN("height",mh+"px");
					setBodySize.setStyle.CONTENTAREA("height",mh+"px");
					setBodySize.setStyle.FOOT("display","block");
					if(	agent.windowsize() < setBodySize.BORDER_WIDTHMIN){				
						setBodySize.setStyle.WRAPPER("width",setBodySize.BORDER_WIDTHMIN-6+"px");
					} else {
						setBodySize.setStyle.WRAPPER("width","100%");					
					}
				}
			} else {
				var func=function(){
					setBodySize.setStyle.FOOT("display","block");
					if(	agent.windowsize() < setBodySize.BORDER_WIDTHMIN){				
						setBodySize.setStyle.WRAPPER("width",setBodySize.BORDER_WIDTHMIN-6+"px");
					} else {
						setBodySize.setStyle.WRAPPER("width","100%");					
					}
				}
			}
			window.onresize =function(){
				func();
			}
			func();
			
			
		} else if(setBodySize.ifMoz || setBodySize.ifIe7){ // IE7,Firefox
			
			var func=function(){ return false};
			
			setBodySize.getMainInnerHeight=function(){return 1};
			if($(setBodySize.IDS.MAIN)){
				setBodySize.getMainInnerHeight=(setBodySize.getProperty.MAIN("clientHeight")!=0) ?
				function(){return setBodySize.getProperty.MAIN("clientHeight")} :
				function(){return $(setBodySize.IDS.MAIN).getElementsByTagName("div")[0].clientHeight;}
			}				
			
			if(setBodySize.ifIe7) {
				if($(setBodySize.IDS.MAIN)){
					func=function(){
						var maxheight=0;var maxObj;
						setBodySize.columns.each(function(val){
							if(maxheight <= $(val).clientHeight){
								maxheight =	$(val).clientHeight;
								maxObj = $(val);
							} 
						});
						setBodySize.setStyle.WRAPPER("height",(setBodySize.getProperty.MAIN("clientHeight")+126)+"px");
						
						if(maxheight!=0 && setBodySize.getMainInnerHeight() <= maxheight){
							setBodySize.setStyle.MAIN("height",maxObj.clientHeight+"px");
							setBodySize.setStyle.CONTENTAREA("height",(maxObj.clientHeight/*+100*/)+"px");
						} else {
							setBodySize.setStyle.MAIN("height","auto");
							setBodySize.setStyle.CONTENTAREA("height","auto");
						}
					}
				}
			} else {
				func=function(){
					var maxheight=0;var maxObj;
					setBodySize.columns.each(function(val){
						if(maxheight <= $(val).clientHeight){
							maxheight =	$(val).clientHeight;
							maxObj = $(val);
						} 
					});
					if(maxheight!=0 && setBodySize.getMainInnerHeight() <= maxheight){
					
						setBodySize.setStyle.MAIN("height",maxObj.clientHeight+"px");
						setBodySize.setStyle.CONTENTAREA("height",(maxObj.clientHeight/*+100*/)+"px");
					} else{
						setBodySize.setStyle.MAIN("height","auto");
						setBodySize.setStyle.CONTENTAREA("height","auto");
					}
				}
			}
			
			func();
			setBodySize.setStyle.FOOT("display","block");			
			setInterval(func,setBodySize.adjustIntervavl);
			
		}//->main program

		// patch for fixed-width design with large contents
		var maxItem=null;
		var maxwidth=0;var largeitems=[];
		if($(setBodySize.IDS.MAIN)){
			for(var i=0,L=setBodySize.largeClasses.length;i<L;i++){
				var larges=$(setBodySize.IDS.MAIN).getElementsByClassName(setBodySize.largeClasses[i]);
				if(larges.length>0) {
					
					for(var j=0,jL=larges.length;j<jL;j++){;
					  if(620 < larges[j].clientWidth){
						largeitems.push(larges[j]);
						if(maxwidth<larges[j].clientWidth ) {
							maxwidth=larges[j].clientWidth;
							maxItem=larges[j];
						}
					  }
					}
					
				}
			}
		}
		if($(maxItem) && $(setBodySize.IDS.CONTENTAREA)) {
			
			setBodySize.setStyle.CONTENTAREA("background","none");
			setBodySize.setStyle.CONTENTAREA("width","960px");
			if(setBodySize.ifRightColumnIsEmpty){
				setBodySize.setStyle.ACTIONAREA("display","none");
				setBodySize.setStyle.MAIN("marginRight","0px");
			}
			
			var maxmod=(setBodySize.ifNoColumns) ? 40 : 180;
			var maxplus=((maxwidth + maxmod) > 960) ? maxwidth + maxmod : 960;
			
			if(setBodySize.ifIe6){
				var ie6resize=function(){
					if(document.documentElement.clientWidth < maxplus) {
						setBodySize.setStyle.WRAPPER("width",maxplus+"px");
					}else {
						setBodySize.setStyle.WRAPPER("width","100%");
					}
				}
				Event.observe(window,"resize",ie6resize,false);
				ie6resize();
				
			} else {
				setBodySize.setStyle.WRAPPER("minWidth",maxplus+"px");
			}
			if(setBodySize.ifIe6){
				
				largeitems.each(function(largeitem){
				  if(largeitem.nodeName!="TH" && largeitem.nodeName!="TD"){
					largeitem.style.width=largeitem.clientWidth+"px";
					largeitem.style.position="absolute";
					var itemheight=largeitem.clientHeight;
					var divObj=document.createElement("div");
					if(largeitem.nextSibling){
						largeitem.parentNode.insertBefore(divObj,largeitem.nextSibling);
					} else {
						largeitem.parentNode.appendChild(divObj);
					}
					divObj.className="subtablebox";
					divObj.style.cssText='width:1px; height:'+itemheight+'px';
				  }
				});
				
				setBodySize.setStyle.ACTIONAREA("top","0px");
				
			}
		}
	}//->initialize
	
	,checkRightcolumn:function(){
			//define functions for set style/get style/get property
			//*to avoide error ,function returns 'false' if 'area' is absent, 
			//Usage
			// setBodySize.setStyle.[name of area]([property name],[value]) -> set style
			// setBodySize.getStyle.[name of area]([property name]) -> get style
			// setBodySize.getProperty.[name of area]([property name]) -> get property
			// 
			for(var areaName in setBodySize.IDS){
				setBodySize.IDNAMES.push(areaName);
			}
			setBodySize.IDNAMES.each(function(areaName){
					setBodySize.setStyle[areaName]=($(setBodySize.IDS[areaName])) ? 
						function(prop,value){
							$(setBodySize.IDS[areaName]).style[prop]=value;
						}:
						function(){return false};
					setBodySize.getStyle[areaName]=($(setBodySize.IDS[areaName])) ? 
						function(prop){
							return $(setBodySize.IDS[areaName]).style[prop];
						}:
						function(){return 0};
					setBodySize.getProperty[areaName]=($(setBodySize.IDS[areaName])) ? 
						function(prop){
							return ($(setBodySize.IDS[areaName])[prop]) ? $(setBodySize.IDS[areaName])[prop]:0;
						}:
						function(){return 0};
	
				}
			);
			
			if($("NF-TypeLEVEL2_noColumn")){
				setBodySize.IDS.WRAPPER="NF-TypeLEVEL2_noColumn";
				setBodySize.ifNoColumns=true;
			} else {
				setBodySize.ifNoColumns=false;
			}
			

			if(!$(setBodySize.IDS.ACTIONAREA)) {
				setBodySize.setStyle.CONTENTAREA("background","none");
				var bg_image =( setBodySize.ifNoColumns ) ? "mi_back.gif":"subnavi_back_clear.gif";
				setBodySize.setStyle.SUBNAVI("background","url(/common/images/"+bg_image+") 0 0 repeat-x");
				setBodySize.ifRightColumnIsEmpty=true;
				return false;
			}
			
			var isempty=true;
			var reg_space=new RegExp(/\S/);
			var rinner=$(setBodySize.IDS.ACTIONAREA).getElementsByTagName("div")[0];
			
			(function (array){
				for(var i=0,L=array.length;i<L;i++){
					var ndname=array[i].nodeName;
					if(ndname=="#text"){
						if(reg_space.exec(array[i].nodeValue)){ //element that contains characters except spaces,line-feeds,carriage-returns ,and tabs
								isempty=false;
								break;
						}
					} else if(ndname=="IMG" || ndname=="INPUT"){ //Any replaced element 
						isempty=false;
						break;
					} else {
						if(array[i].hasChildNodes()) {
							arguments.callee($A(array[i].childNodes));
						}
					}
					
				}
			})($A(rinner.childNodes));


			if(isempty){
				setBodySize.setStyle.ACTIONAREA("backgroundColor","transparent");
				setBodySize.setStyle.CONTENTAREA("background","none");
				//if($("SubNaviArea")) $("SubNaviArea").style.background="url(/common/images/subnavi_back_clear.gif) 0 0 no-repeat";
				
				setBodySize.ifRightColumnIsEmpty=true;
			}
	}
}
//setBodySize.checkRightcolumn();

function CollectW(){


	return false;


	//properties
	this.COOKIEENABLE=false; //enable/disable cookie
	this.EXPIREDAY=1; //span of cookie valid
	this.SENDTO="/common/scripts/window_size/collector.php";	//URL of collecting program
	
	this.COOKIENAME="Collected";
	//functions
	this.ifCollectable=function(){
		if(!this.COOKIEENABLE) return true;
		var li = document.cookie.split(';');
		var isCollected=true;
		for(var i=0;i < li.length;i++) {
			var value = li[i];
			if (value.indexOf(this.COOKIENAME) != -1) {
				isCollected=false;
			}
			if (isCollected==false) break;
		}
		return isCollected;
	}

	this.collect=function(stats,sendto){
		
		var width=agent.windowsize();
		var url=location.href;
		var string="cache="+(new Date()).getTime();
		string += "&width="+width;
		string += "&url="+url;
		string += "&stats="+stats;
		new Ajax.Request(sendto, {
				method: "post",
				parameters: string
		});
	}
	
	
	//constructor
	if(!Ajax || !agent || !Event) return false;
	if(this.ifCollectable()){
		var collect=this.collect;
		var sendto=this.SENDTO;
		Event.observe(window, "load", function(){collect("open",sendto);}, false);
		Event.observe(window, "unload", function(){collect("close",sendto);}, false);
		
		if(this.COOKIEENABLE){
			var _expires=(this.EXPIREDAY*24*60*60*1000);
			var date = new Date();
			date.setTime(date.getTime()+_expires);
			var expires = "; expires="+date.toGMTString();
			document.cookie=this.COOKIENAME+"=1"+expires+"; path=/";
		}
	}
}


var agent={
	browser:"",
	version:"",
	windowsize:function(){return false},
	create:function(){
		var ua = navigator.userAgent;
		iest = ua.indexOf("MSIE");
		if(iest == -1) {
		  var nsst = ua.indexOf("Mozilla/",0);
		  var opst = ua.indexOf("Opera");
		  if (nsst!= -1){
			 agent.browser="Mozilla";
			 nsed = ua.indexOf(" ",nsst);
			 nsnum = Number(ua.substring(nsst+8,nsed));
			 agent.version=eval(nsnum);
		  } else if (opst!=-1){
			agent.browser="MSIE";
			agent.version=7;
		  }
		}  else {
			agent.browser="MSIE";
			ieed = ua.indexOf(";",iest);
			ienum = Number(ua.substring(iest+5,ieed));
			agent.version=eval(ienum);
		}
	},
	getReady:function(){
		addLoadEvent(setBodySize.initialize);

		//prepare for resizing & zooming
		document.write('<style>#NF-FootArea{ display:none}<\/style>');
		
		//Load script
		document.write('<script type="text/javascript" src="/common/scripts/prototype.js"><\/script><script type="text/javascript" src="/common/scripts/menupopup.js"><\/script>');
	}
}



agent.create();
if(agent.browser=="MSIE"){
	
	if(agent.version <= 5.5){
		agent.windowsize=function (){return document.body.clientWidth;}
	} else {
		agent.windowsize=function (){return document.documentElement.clientWidth;}
	}
	
	if(agent.version >= 5.5){		
		agent.getReady();
	} 
} else if(agent.browser=="Mozilla" && agent.version >= 5){
	agent.windowsize=function (){return document.body.clientWidth;}
	agent.getReady();

	//Adjust header position
	var ffAdjuster={
		divs:["header","headerNav","NF-GlobalNavArea"],
		initialize:function(){
			if(!document.getElementById("headerNav")) return false;
			for(var i=0,L=ffAdjuster.divs.length;i<L;i++){
				if(!document.getElementById(ffAdjuster.divs[i])) continue;
				var targetObj=document.getElementById(ffAdjuster.divs[i]);
				targetObj.style.position="relative";
				targetObj.style.top="1px";
			}
			setTimeout(function(){
				for(var i=0,L=ffAdjuster.divs.length;i<L;i++){
					if(!document.getElementById(ffAdjuster.divs[i])) continue;
					document.getElementById(ffAdjuster.divs[i]).style.position="static";
				}
			},3000);
		}
		
	}
	addLoadEvent(ffAdjuster.initialize);
}

// add by NECEL CC div.
function disp_popup(url, t, w, h) {
	window.open(url, t, "width=" + w + ",height=" + h + ",scrollbars=yes,resizable=yes");
}
