/* --------------------------------
	전체메뉴 펼치기
-------------------------------- */
function showBx(id)
{
    var bx = document.getElementById(id);
    if (bx.style.display == 'block')
    	bx.style.display='none';
    else
        bx.style.display='block';
}

/** 마우스오버아웃
* author: myshin
* update: 2008.06.16
* desc: 아웃이미지가 img.gif 이면 오버이미지는 imgon.gif
* .gif 에 국한된 확장자를 범용으로 수정함.
* _imgtype 를 전역변수로 지정해서 내장함수(obj.src.replace)에서도 사용가능.
* ex) 상황별로 다른 함수 사용.
*/
function imgOver(imgEl){//ex) oneEl.onmouseover = imgOver("이미지id");
	if(imgEl){
		_imgtype = imgEl.src.substr(imgEl.src.length-3,imgEl.src.length-1);
		var where = imgEl.src.indexOf("on."+_imgtype,0);
		if(where==-1) imgEl.src = imgEl.src.replace("."+_imgtype,"on."+_imgtype);
	}
}
function imgOut(imgEl){//ex) oneEl.onmouseover = imgOut("이미지id");
	if(imgEl){
		_imgtype = imgEl.src.substr(imgEl.src.length-3,imgEl.src.length-1);
		var where = imgEl.src.indexOf("on."+_imgtype,0);
		if(where!=-1) imgEl.src = imgEl.src.replace("on."+_imgtype,"."+_imgtype);
	}
}
function menuOver(){//ex) imgEl.onmouseover = menuOver; aEl.onfocus = menuOver;
	var imgEl = (this.src)? this: this.getElementsByTagName("img")[0];
	if(imgEl) {
		_imgtype = imgEl.src.substr(imgEl.src.length-3,imgEl.src.length-1);
		var where = imgEl.src.indexOf("on."+_imgtype,0);
		if(where==-1) imgEl.src = imgEl.src.replace("."+_imgtype,"on."+_imgtype);
	}
}
function menuOut(){//ex) imgEl.onmouseout = menuOver; aEl.onblur = menuOut;
	var imgEl = (this.src)? this: this.getElementsByTagName("img")[0];
	if(imgEl) {
		_imgtype = imgEl.src.substr(imgEl.src.length-3,imgEl.src.length-1);
		var where = imgEl.src.indexOf("on."+_imgtype,0);
		if(where!=-1) imgEl.src = imgEl.src.replace("on."+_imgtype,"."+_imgtype);
	}
}
/** 이미지롤오버함수할당
* author: myshin
* update: 2008.06.16
* desc: 콘테이너 안의 모든 img 요소에 롤오버 함수를 할당한다.
* .gif 에 국한된 확장자를 범용으로 수정함.
* _imgtype 를 전역변수로 지정해서 내장함수(obj.src.replace)에서도 사용가능.
* ex) initImgRoll("이미지그룹id");
*/
function initImgRoll(containerId) { 
 	var imgEl = document.getElementById(containerId).getElementsByTagName("img");
	if(imgEl){
		for(var i=0; i<imgEl.length; i++){
			var objImg = imgEl[i];
			_imgtype = objImg.src.substr(objImg.src.length-3,objImg.src.length-1);
			var where = objImg.src.indexOf("on."+_imgtype,0);
			if (where==-1){ objImg.onmouseover = menuOver; objImg.onmouseout = menuOut; }
		}
	}
}
/** 글자크기
* amender : myshin
* update : 2008.07.16
* desc : 글자크기확대축소, 최대최소값고정.
* 확대축소영역 지정 추가. 이벤트는 스크립트에서 처리, 기본 크기 추가.
* ex) initFontZoom(document.getElementById("container")); setFontSize(+1); setFontSize(-1); setFontSize(0);
*/
function setFontSize(a,zoomArea){
	var defaultFontSize = 1;//em
	var minFontSize = 1;//em
	var maxFontSize = 2;//em
	if(!zoomArea){//확대축소영역 지정 없으면
		zoomArea = document.getElementById("pagebody");//기본 확대축소영역은 서브 본문
		if(!zoomArea) zoomArea = document.getElementById("body");//메인일 경우
	}
	if(zoomArea){
		if(!a) zoomArea.style.fontSize = parseFloat(defaultFontSize)+"em";//기본값
		else {
			var objFontSize = zoomArea.style.fontSize;
			if (!objFontSize) objFontSize = parseFloat(defaultFontSize)+"em";
			var checkFontSize = (Math.round(12*parseFloat(objFontSize))+(a*2))/12;
			if (checkFontSize > maxFontSize) { checkFontSize = maxFontSize; zoomArea.style.fontSize = checkFontSize+"em"; alert("더 늘릴 수 없습니다."); }
			else if (checkFontSize < minFontSize) { checkFontSize = minFontSize; zoomArea.style.fontSize = checkFontSize+"em"; alert("더 줄일 수 없습니다."); }
			else { zoomArea.style.fontSize = checkFontSize+"em"; }
		}
	}
}
function initFontZoom(zoomArea){
	zoomArea = (zoomArea)? zoomArea: null;//전역변수로지정
	var fzoomIn = document.getElementById("fontsize-larger");
	var fzoomOut = document.getElementById("fontsize-smaller");
	var fzoom0 = document.getElementById("fontsize-default");
	if(fzoomIn) fzoomIn.onclick = function(){ setFontSize(+1,zoomArea); return false; }
	if(fzoomOut) fzoomOut.onclick = function(){ setFontSize(-1,zoomArea); return false; }
	if(fzoom0) fzoom0.onclick = function(){ setFontSize(0,zoomArea);	 return false; }
}

/* --------------------------------
	MM_Behavior
-------------------------------- */

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


/********************************************************************
  Flash
*********************************************************************/
function flash(value, width, height){	//???
	document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+width+'" height="'+height+'">');
	document.writeln('<param name="movie" value="'+value+'">');
	document.writeln('<param name="quality" value="high">');
	document.writeln('<param name="wmode" value="transparent">');
	document.writeln('<param name="menu" value="false">');
	document.writeln('<embed src="'+value+'" width="'+width+'" height="'+height+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" menu="false"></embed>');
	document.writeln('</object>');
}
function flash2(value, width, height){	//???
	document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+width+'" height="'+height+'">');
	document.writeln('<param name="movie" value="'+value+'">');
	document.writeln('<param name="quality" value="high">');
	document.writeln('<param name="menu" value="false">');
	document.writeln('<embed src="'+value+'" width="'+width+'" height="'+height+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" menu="false"></embed>');
	document.writeln('</object>');
}


function movie(value, width, height){	//???
	document.writeln('<object id="WMP" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" standby="Loading Microsoft Windows Media Player..." width="'+width+'" height="'+height+'">');
	document.writeln('<param name="FileName" value="'+value+'">');
	document.writeln('<param name="AutoStart" value="true">');
	document.writeln('<param name="AutoSize" value="false">');
	document.writeln('<param name="transparentAtStart" value="True">');
	document.writeln('<param name="transparentAtStop" value="True">');
	document.writeln('<param name="ShowControls" value="false">');
	document.writeln('<param name="ShowStatusBar" value="false">');
	document.writeln('<param name="loop" value="-1">');
	document.writeln('<param name="Volume" value="-600">');
	document.writeln('<param name="PLUGINSPAGE" value="http://www.microsoft.com/korea/windows/windowsmedia/">');
	document.writeln('<embed src="'+value+'" width="'+width+'" height="'+height+'" autostart="False" loop="-1" filename="'+value+'" autosize="false" showcontrols="false" showstatusbar="false" volume="-600" pluginspage="http://www.microsoft.com/korea/windows/windowsmedia/"></embed>');
	document.writeln('</object>');
}

/////popup
function MM_openBrWindow(url,title,opt) { //v3.0
  var popup=window.open(url,title, "toolbar=no, location=no, directories=no, status=no, fullscreen=no, menubar=no, scrollbars=no, resizable=no, " + opt);
}

/////popup-scrollOK
function MM_openBrWindow2(url,title,opt) { //v3.0
  var popup=window.open(url,title, "toolbar=no, location=no, directories=no, status=no, fullscreen=no, menubar=no, scrollbars=yes, resizable=yes, " + opt);
}

/* --------------------------------
	 Scroll
-------------------------------- */

function scroller(i){
		scroller_up(i,1000);
}
	
function scroller_up(i,y){
	y = y + (i - y)*.1;
	window.scroll(0,y);
	if (((i - y) <= .6)&&((i - y) >= -.6))
	{					
		y = i;
	}else{
		setTimeout("scroller_up("+i+","+y+")",1);
	}
}

function scroller_e(i){
	y = 1;
	kyoukai = i*.6;
	while(y <= kyoukai)
	{
		window.scroll(0,y);
		y = y + (y*.08);
    }
	while(y != i)
	{
		window.scroll(0,y);
		y = y + (i-y)*.08;
		if (((i - y) <= .6)&&((i - y) >= -.6))
		{
			y = i;
		}
	}
}
