//------------------- SWF 제어함수 시작
/**
 *	version 1.4
 *	최종수정일 : 2008. 11. 04
 *
 *	-- 플래시로더 객체생성 기본사용방법 ---
 *	<script language="javascript" type="Text/JavaScript">
 *		var setFlash = new SWFLoader();
 *		setFlash.init( '넓이', '높이', '파일경로', 총 매개변수값);
 *		setFlash.parameter('파람이름','값'); //이미 기본옵션 사용중
 *		setFlash.wmode('window'); //이미 기본옵션('transparent') 사용중
 *		setFlash.id('아이디이름'); //예) ID_SWF파일이름
 *		setFlash.alt('값');	// 플래시 대체 텍스트 값 입력
 *		setFlash.layer('div 아이디 이름')  //예) <div id='SWF파일명Layer'></div> 
 *		setFlash.show( );
 *	</script>
 *
 *	SWF파일 아이디 표준화 사용방법 : ID_파일명(대소문자구분) 예제 : 파일명이 navi.swf 인경우 --> 'ID_navi'
 *
 *	-- setFlash.layer() 사용시 방법 - 기본사용방법을 showSWFLayer() 함수로
 *     객체를 감싸주고 메서드호출 시 인자로 Div 아이디 값을 넘겨준다.
 *	
 *	<script language="javascript" type="Text/JavaScript">
 *		function showSWFLayer( layername) {
 *			var setFlash = new SWFLoader();
 *			setFlash.init( '넓이', '높이', '파일경로', 총 매개변수값);
 *			setFlash.parameter('파람이름','값'); //이미 기본옵션 사용중
 *			setFlash.id('아이디이름'); //예) ID_SWF파일이름
 *			setFlash.layer(layername)  //예) <div id='SWF파일명Layer'></div>
 *			setFlash.show();
 *		}
 *  </script>
 *
 *	<a href="javascript:showSWFLayer('siteMapLayer')">열기</a>
 */

function SWFLoader() {
	var obj = new String;
	var parameter = new String;
	var embed = new String;
	
	var classId = new String;
    var codeBase = new String;
	var pluginSpage = new String;
	var embedType = new String;	
	var allParameter = new String;	
	
	var src = new String;
	var width = new String;
	var height = new String;
	var id = new String;
	var layer = new String;
	var arg = new String;
	var altText = new String;
	var wmode = new String;

	this.init = function ( w, h, s, a ) {
		width = w; //넓이
		height = h; //높이
		src = s; //파일경로
		arg = a; // 매개변수
		wmode = 'transparent'; //모드설정

		classId = 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000';
		codeBase = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0';
		pluginSpage = 'http://www.macromedia.com/go/getflashplayer';
		embedType = 'application/x-shockwave-flash';

		parameter += "<param name='allowScriptAccess' value='always'>\n";
		parameter += "<param name='allowFullScreen' value='false'\n>";
		parameter += "<param name='movie' value='"+ s + "'>\n";
		parameter += "<param name='quality' value='high'>\n";
		parameter += "<param name='base' value='.'>\n";
		parameter += "<param name=FlashVars value='arg="+a+"'>\n";		
	}
	
	//플래시 오브젝트 옵션설정
	this.parameter = function ( param, value ) {
		 parameter += "<param name='"+param +"' value='"+ value + "'>\n";
	}

	// 플래시 wmode 설정 setFlash.wmode('window')
	this.wmode = function ( value ) {
		wmode = value;
	}

	// 플래시 아이디 설정
	this.id = function ( value ) {
		id = value;
	}
	
	// 플래시 대체텍스트 설정
	this.alt = function ( value ) {
		altText = value;
	}

	// 플래시 삽입 레이어 설정
	this.layer = function ( value ) {
		if(value == undefined) {
			layer = "";
		} else {
			layer = value;
		}
	}

	this.show = function () {
		obj = '<object id="'+id+'" width="'+width+'" height="'+height+'" classid="'+classId+'" codebase="'+codeBase+'">\n'+
			parameter +
			'<param name="wmode" value="'+wmode+'">\n'+
			'<!--[if !IE]>-->\n' +
			'<object type="application/x-shockwave-flash" data="' + src + '" width="' + width + '" height="' + height + '" name="' + id + '">\n' +
				parameter +
				'<param name="wmode" value="'+wmode+'">\n'+
			'<!--<![endif]-->\n' +
				'<div class="alt-content alt-' + id + '">' + altText + '</div>\n' +
			'<!--[if !IE]>-->\n' +
			'</object>\n' +
			'<!--<![endif]-->\n' +
		'</object>';

		if(layer == "") {
			document.write(obj);
		}else{
			var div = document.getElementById( layer);
			div.style.display = "";
			div.innerHTML = obj;
		}
	}
}

function hideSWFLayer( div) {
	var div = document.getElementById( div);
	div.style.display = "";
	div.innerHTML = "";
}

function thisMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	}
	else {
		return document[movieName];
	}
 }

 function callExternalInterface(movieId) {
    thisMovie(movieId).moveMc();	
}
//------------------- SWF 제어함수 끝


// familysite
function famlistAction1() {	
	var target = document.getElementById('familyList1');
	target.style.display = (target.style.display=='block' ? 'none':'block');
}
function famlistAction2() {	
	var target = document.getElementById('familyList2');
	target.style.display = (target.style.display=='block' ? 'none':'block');
}

//* image rollover *//
function overRoll( obj ) {
    obj.src = obj.src.replace( 'off.gif', 'on.gif' );
}
function outRoll( obj ) {
    obj.src = obj.src.replace( 'on.gif', 'off.gif' );
}

//메인 메뉴전체보기 스크립트 정의서
//아이디명은 파일명과 동일 예) siteMap
function viewSWFLayer( _id, _wd, _ht, _dir, _xmlurl) {
	var id = _id;
	var width = _wd;
	var height = _ht;
	var dir = _dir;
	var xmlurl = _xmlurl;
	var html;

	html = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' width='"+width+"' height='"+height+"'>";
	html += "<param name='allowScriptAccess' value='always'>";
	html += "<param name='allowFullScreen' value='false'>";
	html += "<param name='movie' value='"+dir+"'>";
	html += "<param name='quality' value='high'>";
	html += "<param name='wmode' value='transparent'>";
	html += "<param name='base' value='.'>";
	html += "<param name=FlashVars value='url1="+xmlurl+"'/>";
	html += "<embed base='.' src='"+dir+"' FlashVars='url1="+xmlurl+"' quality='high' width='"+width+"' height='"+height+"' align='middle' allowScriptAccess='sameDomain' allowFullScreen='false' wmode ='transparent' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'>";
	html += "</object>";

	var layername = document.getElementById( id);
	layername.style.display = "";
	layername.innerHTML = html;
	
}

function hideSWFLayer( _id) {
	var id = _id;
	var layername = document.getElementById( id);
	var hidetarget = document.getElementById('top-sitemap');
	layername.style.display = "none";
	layername.innerHTML = "";
	hidetarget.className = ''
}

// top sitemap layer (height - 0/100%)
function sitmapLayer() {
	var target = document.getElementById('top-sitemap');
	target.className = (target.className=='' ? 'top-sitemap-open':'');
}

// 프린트 하기
function Printing() {
	var txts = "/language/eng/common/jsp/print.jsp?dep="+mmenu
	window.open(txts,'print','width=658,height=600,scrollbars=yes');void(0);
}


//viewer download
document.writeln("<form name='down' method='get' action='/common/kep_download.jsp'>");//=>
document.writeln("<input type='hidden' name='FileName3'>");
document.writeln("<input type='hidden' name='FileName2' >");
document.writeln("<input type='hidden' name='FileName1' >");

document.writeln("</form>");
function getDown(sFile1,sFile2) {
	down.FileName1.value=sFile1;
	down.FileName2.value=sFile2;
	down.submit();
}


//fontSize change ----------------------------------------------
// cookie 등록
function setCookie(name, value, expires, path, domain, secure) {
  document.cookie = name + "=" + escape(value) +
  ((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
  ((path == null) ? "" : "; path=" + path) +
  ((domain == null) ? "" : "; domain=" + domain) +
  ((secure == null) ? "" : "; secure");
}

// cookie 삭제
function delCookie (name,path,domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path == null) ? "" : "; path=" + path) +
    ((domain == null) ? "" : "; domain=" + domain) + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
  //페이지 리로드
  document.location.reload();
}
var firstCall = true;
function changeFontsize(fSize, increment) {
	if (firstCall) {
		firstCall = false;
		if (increment != "") {
			changeFontsize('12', '');
		}
	}
	if (document.getElementsByTagName) {
	var getElement = document.getElementsByTagName("*");
	var eachElement, currentFontSize, fontIncrease, newFontSize;
	for (i=0; i<getElement.length; i++) {
		eachElement = getElement[i];
		if (increment != "") {
			currentFontSize = parseInt(eachElement.style.fontSize);
			fontIncrease = parseInt(increment);
			newFontSize = currentFontSize + fontIncrease;
		}
		else if (fSize != "") {
			newFontSize = parseInt(fSize);
		}
		if (getElement[i].tagName == "LI") {
			eachElement.style.lineHeight = Math.round(newFontSize*1.2) + "px";
		} else {
			eachElement.style.lineHeight = Math.round(newFontSize*1.5) + "px";
		}
		if (fSize != "") {
			switch(getElement[i].tagName) {
				case "H2": newFontSize += 3; break;
				case "H3": newFontSize += 2; break;
				case "H4": newFontSize += 1; break;
				case "H5": newFontSize += 1; break;
				case "H6": newFontSize += 1;
			}
		}
		eachElement.style.fontSize = newFontSize + "px";
		setCookie('fontSize', newFontSize);
	}
}
}
//---- fontSize change ----------------------------------------------]

// popup
function popup(Fn,Win, X, Y, Scroll){
l = (screen.width) ?	(screen.width- X) / 2	: 0;
t = (screen.height) ?	(screen.height- Y) / 2 : 0;	
	NewWindow=window.open(Fn,Win,'width='+X+',height='+Y+',top='+t+',left='+l+',scrollbars='+Scroll+',toolbar=no,location=no,directories=no,status=no,resizable=no,menubar=no');
}

// quick -----------------------------------------------------------
function getPosition(){
	var start, end, scale, term;
	start = parseInt (document.getElementById('quicktop').style.top, 0);
	end = document.documentElement.scrollTop + 0;
	term = 5;

	if ( start != end ) {
	scale = Math.ceil( Math.abs( end - start ) / 20 );
		if ( end < start )	scale = -scale;
		document.getElementById('quicktop').style.top = parseInt (document.getElementById('quicktop').style.top, 0)+ scale + "px";
		term = 1;
	}
	setTimeout ("getPosition()", term);
}
function moveBanner() {
	document.getElementById('quicktop').style.top = document.documentElement.scrollTop + 0 + "px"; //숫자가 같으면 슬라이드 없다.
	getPosition();
	return true;
}

// tab over -------------------------------------------------------
//<![CDATA[
	function chgHeadingTab(el) {
		if (!document.getElementsByTagName) return false;
		var tabtag = el;
		var headings = new RegExp("[h1-6]","i");
		while (!headings.test(tabtag.tagName)) {
			tabtag = tabtag.parentNode;
		}
		if (!headings.test(tabtag.tagName)) return false;
		var tabparent = tabtag.parentNode;
		tabtag = tabtag.tagName;
		var clickedtab = el;
		while (clickedtab.tagName != tabtag) {
			clickedtab = clickedtab.parentNode;
		}
		var tabitems = tabparent.getElementsByTagName(tabtag);
		for (var i=0; i<tabitems.length; i++) {
			var tabimg = tabitems[i].getElementsByTagName("IMG")[0];
			var tabcont = tabitems[i].nextSibling;
			while (tabcont.nodeType != 1) {
				tabcont = tabcont.nextSibling;
			}
			if (tabitems[i] == clickedtab) {
				tabimg.src = tabimg.src.replace("_off.gif","_on.gif");
				tabcont.style.display = "block";
			} else if (tabitems[i] != clickedtab) {
				if (tabimg.src.indexOf("_on.gif") != -1) {
					tabimg.src = tabimg.src.replace("_on.gif","_off.gif");
				}
				tabcont.style.display = "none";
			}
		}
		return false;
	}

	function overImg(obj) {
		obj.src = obj.src.replace( 'off.gif', 'on.gif' );
	}
	function outImg(obj) {
		if (chkContOn(obj)) return false;
		obj.src = obj.src.replace( 'on.gif', 'off.gif' );
	}
	function chkContOn(el) {
		var tab = el;
		var headings = new RegExp("[h1-6]","i");
		while (!headings.test(tab.tagName)) {
			tab = tab.parentNode;
		}
		if (!headings.test(tab.tagName)) return false;
		var tabcont = tab.nextSibling;
		while (tabcont.nodeType != 1) {
			tabcont = tabcont.nextSibling;
		}
		return tabcont.style.display != "none" ? true : false;
	}
//]]>
/* */
function menuMouseOver(idx){
	try{
		for(i=1 ; i<=7 ; i++){
			
			objImage = document.getElementById("menu"+i);
			objLayer = document.getElementById("tab_0"+i);
			if(i == idx){
				objImage.src = objImage.src.replace(i+"_off.gif", i+"_on.gif");
				objLayer.style.display = "block";
			}else{
				objImage.src = objImage.src.replace(i+"_on.gif", i+"_off.gif");
				objLayer.style.display = "none";
			}
		}
	}catch(err){
	
	}
}

// [[ Image Rollover ]]
function menuOn(imgEl) {
	var isrc = imgEl.src;
	if( isrc.indexOf("_on.gif") < 0){
		imgEl.src = imgEl.src.replace("_off.gif", "_on.gif");
	}
}
function menuOut(imgEl) {
	var isrc = imgEl.src;
	if( isrc.indexOf("_on.gif") > -1){
		imgEl.src = imgEl.src.replace("_on.gif", "_off.gif");
	}
}// [[ END Image Rollover ]]

// [[ Image Rollover ]]
function png_menuOn(imgEl) {
	var isrc = imgEl.src;
	if( isrc.indexOf("_on.gif") < 0){
		imgEl.src = imgEl.src.replace("_off.png", "_on.png");
	}
}
function png_menuOut(imgEl) {
	var isrc = imgEl.src;
	if( isrc.indexOf("_on.gif") > -1){
		imgEl.src = imgEl.src.replace("_on.png", "_off.png");
	}
}// [[ END Image Rollover ]]

/* png 이미지 투명 적용 script */
function setPng24(obj) { 
 obj.width=obj.height=1; 
 obj.className=obj.className.replace(/\bpng24\b/i,''); 
 obj.style.filter = 
 "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');" 
 obj.src='';
 return '';
}

/* left menu */
var old='';

function LeftMenu(name){
	submenu=eval("Leftmenu_"+name+".style");
		if(old!=submenu)
		{
			if(old!='')
			{
			old.display='none';
			}
				submenu.display='block';
				old=submenu;
        }
        else
        {
			submenu.display='none';
			old='';
		}
}

/* main gallery js  */
