// 통합검색
function fsearchbox_submit(f)
{
	if (f.stx.value == '')
	{
		alert("검색어를 입력하세요.");
		f.stx.select();
		f.stx.focus();
		return false;
	}
f.submit();
}

// 통합검색 input 배경 처리 
function hideBg(f){
	f.style.backgroundImage = "";
}

function showBg(f){
	if(f.value == ""){
		f.style.backgroundImage = "url(/images/main/searchbg.gif)";
	}
}

// 플래시 라인 없애기
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);
}

// Top Menu
function initNavigation(seq) {
	var 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) {			
						if( seq != 0)
						this.current.parentNode.className = this.current.parentNode.className.replace(" over","");						
						if (nav.current.submenu){						
							nav.current.submenu.style.display = "none";
						}
						nav.current = null;					
					}
				}
			}, 1000);
		}
	}

	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("div").item(0);
		
		navAnchor.onmouseover = navAnchor.onfocus = function () {
			if (nav.current) {		
				if(seq !=0)
				nav.current.parentNode.className = nav.current.parentNode.className.replace(" over","");
				if (nav.current.submenu){
					nav.current.submenu.style.display = "none";
				}
				nav.current = null;
			}
			
			if (nav.current != this) {
				if( seq != 0)
				this.submenu.parentNode.className +=" over";
				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] != ""){
		nav.menu[seq].onmouseover();
	}
}


// Adjust Layout
window.onload = function() {
	window.setInterval(function() {
		bodyEl = document.getElementById("body");
		subEl = document.getElementById("sub");
		if (!bodyEl || !subEl)
			return;
		if (bodyEl.offsetHeight < subEl.offsetHeight +  25) {
			bodyEl.style.height = subEl.offsetHeight + "px";
		}
	}, 200);
}

function initBoardList() {
	boardPager = document.getElementById("board-pager");
	if (boardPager)
		boardPager.getElementsByTagName("li").item(2).style.borderStyle = "none";
}
function initBoardViewPhoto() {
	imageContainer = document.getElementById("attach-photo");
	if (imageContainer) {
		imgEl = imageContainer.getElementsByTagName("img");
		for (i = 0; i < imgEl.length; i++) {
			if (imageContainer.offsetWidth < imgEl.item(i).offsetWidth) {
				imgEl.item(i).style.width = imageContainer.offsetWidth;
			}
		}
	}
}

//따라다니는 배너
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)
}

// 화면확대축소
	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 goPoint(point){
	if(document.getElementById(point).className != "listNone"){
		document.getElementById(point).className = "listNone";
	} else {
		document.getElementById(point).className = "listBlock";
	}
}
