//따라다니는 배너
function initMoving(target, position, topLimit, btmLimit) {
	if (!target)
		return false;

	var obj = target;
	obj.initTop = position;
	obj.topLimit = topLimit;
	obj.bottomLimit = document.documentElement.scrollHeight - btmLimit;

	obj.style.position = "absolute";
	obj.top = obj.initTop;
	obj.left = obj.initLeft;

	if (typeof(window.pageYOffset) == "number") {
		obj.getTop = function() {
			return window.pageYOffset;
		}
	} else if (typeof(document.documentElement.scrollTop) == "number") {
		obj.getTop = function() {
			return document.documentElement.scrollTop;
		}
	} else {
		obj.getTop = function() {
			return 0;
		}
	}

	if (self.innerHeight) {
		obj.getHeight = function() {
			return self.innerHeight;
		}
	} else if(document.documentElement.clientHeight) {
		obj.getHeight = function() {
			return document.documentElement.clientHeight;
		}
	} else {
		obj.getHeight = function() {
			return 500;
		}
	}

	obj.move = setInterval(function() {
		if (obj.initTop > 0) {
			pos = obj.getTop() + obj.initTop;
		} else {
			pos = obj.getTop() + obj.getHeight() + obj.initTop;
			//pos = obj.getTop() + obj.getHeight() / 2 - 15;
		}

		if (pos > obj.bottomLimit)
			pos = obj.bottomLimit;
		if (pos < obj.topLimit)
			pos = obj.topLimit;

		interval = obj.top - pos;
		obj.top = obj.top - interval / 3;
		obj.style.top = obj.top + "px";
	}, 30)
}

//png투명하게
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 '';
}

// Top Menu
function initNavigation(seq) {
	nav = document.getElementById("topmenu");
	nav.menu = new Array();
	nav.current = null;
	nav.menuseq = 0;
	navLen = nav.childNodes.length;
	
	allA = nav.getElementsByTagName("a")
	for(k = 0; k < allA.length; k++) {
		allA.item(k).onmouseover = allA.item(k).onfocus = function () {
			nav.isOver = true;
		}
		allA.item(k).onmouseout = allA.item(k).onblur = function () {
			nav.isOver = false;
			setTimeout(function () {
				if (nav.isOver == false) {
					if (nav.menu[seq])
						nav.menu[seq].onmouseover();
					else if(nav.current) {
						menuImg = nav.current.childNodes.item(0);
						menuImg.src = menuImg.src.replace("_on.gif", ".gif");
						if (nav.current.submenu)
							nav.current.submenu.style.display = "none";
						nav.current = null;
					}
				}
			}, 500);
		}
	}

	for (i = 0; i < navLen; i++) {
		navItem = nav.childNodes.item(i);
		if (navItem.tagName != "LI")
			continue;

		navAnchor = navItem.getElementsByTagName("a").item(0);
		navAnchor.submenu = navItem.getElementsByTagName("ul").item(0);
		
		navAnchor.onmouseover = navAnchor.onfocus = function () {
			if (nav.current) {
				menuImg = nav.current.childNodes.item(0);
				menuImg.src = menuImg.src.replace("_on.gif", ".gif");
				if (nav.current.submenu)
					nav.current.submenu.style.display = "none";
				nav.current = null;
			}
			if (nav.current != this) {
				menuImg = this.childNodes.item(0);
				menuImg.src = menuImg.src.replace(".gif", "_on.gif");
				if (this.submenu)
					this.submenu.style.display = "block";
				nav.current = this;
			}
			nav.isOver = true;
		}
		nav.menuseq++;
		nav.menu[nav.menuseq] = navAnchor;
	}
	if (nav.menu[seq])
		nav.menu[seq].onmouseover();
}

// 화면확대축소
	var zoomRate = 10;			//확대/축소시 증감률
	//var maxRate = 300;			//최대확대률
	var maxRate = 160;			//최대확대률
	var minRate = 100;			//최소축소률

	function zoomInOut(contentid, how) {

		if(GetCookie("zoomVal") != null && GetCookie("zoomVal") != ""){
			//document.all[contentid].style.zoom = GetCookie("zoomVal");
			document.body.style.zoom = GetCookie("zoomVal");
			currZoom=GetCookie("zoomVal");
		}
		else{
			//document.all[contentid].style.zoom = '100%'; 
			document.body.style.zoom = '100%'; 
			currZoom = '100%';
		}
		
		if (((how == "in") && (parseInt(currZoom) >= maxRate)) || ((how == "out") && (parseInt(currZoom) <= minRate)) ) {
			return; 
		}
		if (how == "in") {
			//document.all[contentid].style.zoom = parseInt(document.all[contentid].style.zoom)+zoomRate+'%'
			document.body.style.zoom = parseInt(document.body.style.zoom)+zoomRate+'%'
		}
		else {
			//document.all[contentid].style.zoom = parseInt(document.all[contentid].style.zoom)-zoomRate+'%'
			document.body.style.zoom = parseInt(document.body.style.zoom)-zoomRate+'%'
		}
		SetCookie("zoomVal",document.body.style.zoom, 1);
	}

	function SetCookie( name, value, expiredays ){
		var todayDate = new Date();
		todayDate.setDate( todayDate.getDate() + expiredays );
		document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";" ;
	}
	
	function GetCookie( name )
	{
	        var nameOfCookie = name + "=";
	        var x = 0;
	        while ( x <= document.cookie.length )
	        {
	                var y = (x+nameOfCookie.length);
	                if ( document.cookie.substring( x, y ) == nameOfCookie ) {
	                        if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
	                                endOfCookie = document.cookie.length;
	                        return unescape( document.cookie.substring( y, endOfCookie ) );
	                }
	                x = document.cookie.indexOf( " ", x ) + 1;
	                if ( x == 0 )
	                        break;
	        }
	        return "";
	}
	
	function GoZoom(contentid){
		if(GetCookie("zoomVal") != null && GetCookie("zoomVal") != ""){
			//document.all[contentid].style.zoom = GetCookie("zoomVal");
			document.body.style.zoom = GetCookie("zoomVal");
			currZoom=GetCookie("zoomVal");
		}
		else{
			//document.all[contentid].style.zoom = '100%'; 
			document.body.style.zoom = '100%'; 
			currZoom = '100%';
		}
	}
	
	function initZoomDisplay(){
		var currZoom = "100%" ;
		if(GetCookie("zoomVal") != null && GetCookie("zoomVal") != ""){
			currZoom=GetCookie("zoomVal");
		}
		//document.body.style.zoom = currZoom ;
	}

	function basicZoom(){
		var currZoom = "100%" ;
		document.body.style.zoom = currZoom ;
		SetCookie("zoomVal",document.body.style.zoom, 1);
	}

// 플래시 라인 없애기
function flashWrite(url,w,h,id,bg,win)
{
	// 플래시 코드 출력
	var flashStr=
	"<div id='__"+id+"__' style='z-index:100;'>"+
	"<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='"+w+"' height='"+h+"' id='"+id+"' align='middle'>"+
	"<param name='movie' value='"+url+"' />"+
	"<param name='wmode' value='"+win+"' />"+
	"<param name='menu' value='false' />"+
	"<param name='quality' value='high' />"+
	"<param name='bgcolor' value='"+bg+"' />"+
	"<embed src='"+url+"' wmode='"+win+"' menu='false' quality='high' bgcolor='"+bg+"' width='"+w+"' height='"+h+"' name='"+id+"' align='middle' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"+
	"</object></div>";
	document.write(flashStr);
}

// 이미지 크게보기 팝업
var popbackground="white" //팝업 배경색상
var windowtitle="Image Window"  //팝업윈도우 제목

function detectexist(obj){ return (typeof obj !="undefined")
}

function jkpopimage(imgpath, popwidth, popheight, textdescription){

function getpos(){
    leftpos=(detectexist(window.screenLeft))? screenLeft+document.body.clientWidth/2-popwidth/2 : detectexist(window.screenX)? screenX+innerWidth/2-popwidth/2 : 0
    toppos=(detectexist(window.screenTop))? screenTop+document.body.clientHeight/2-popheight/2 : detectexist(window.screenY)? screenY+innerHeight/2-popheight/2 : 0
        if (window.opera){
            leftpos-=screenLeft
            toppos-=screenTop
        }
    }
getpos()

var winattributes='width='+popwidth+',height='+popheight+',resizable=yes,left='+leftpos+',top='+toppos
var bodyattribute=(popbackground.indexOf(".")!=-1)? 'background="'+popbackground+'"' : 'bgcolor="'+popbackground+'"'

    if (typeof jkpopwin=="undefined" || jkpopwin.closed)
        jkpopwin=window.open("","",winattributes)
    else {
        jkpopwin.resizeTo(popwidth, popheight+30)
    }
    jkpopwin.document.open()
    jkpopwin.document.write('<html><title>'+textdescription+'</title><body style="margin:0;" '+bodyattribute+'><a href="#" onclick="window.close();"><img src="'+imgpath+'" style="margin-bottom: 0.5em; border:0;"></a></body></html>')
    jkpopwin.document.close()
    jkpopwin.focus()
}
