/**********개발자 추가 :S*********/
function alertReady(){
	alert("준비중입니다..");
}

function slide(Id, interval, to)
{
var obj = document.getElementById(Id);
var H, step = 5;

if (obj == null) return;
if (to == undefined) { // user clicking
if (obj._slideStart == true) return;
if (obj._expand == true) {
to = 0;
obj.style.overflow = "hidden";
} else {
slide.addId(Id);
for(var i=0; i < slide.objects.length; i++) {
if (slide.objects[i].id != Id && slide.objects[i]._expand == true) {
slide(slide.objects[i].id);
}
}


obj.style.height = "";
obj.style.overflow = "";
obj.style.display = "block";
to = obj.offsetHeight;
obj.style.overflow = "hidden";
obj.style.height = "1px";
}
obj._slideStart = true;
}

step = ((to > 0) ? 1:-1) * step;
interval = ((interval==undefined)?1:interval);
obj.style.height = (H=((H=(isNaN(H=parseInt(obj.style.height))?0:H))+step<0)?0:H+step)+"px";
obj.style.offsetheight = (H=((H=(isNaN(H=parseInt(obj.style.height))?0:H))+step<0)?0:H+step)+"px";

if (H <= 0) {
obj.style.display = "none";
obj.style.overflow = "hidden";
obj._expand = false;
obj._slideStart = false;
} else if (to > 0 && H >= to) {
obj.style.display = "block";
obj.style.overflow = "visible";
obj.style.height = H + "px";
obj._expand = true;
obj._slideStart = false;
} else {
setTimeout("slide('"+Id+"' , "+interval+", "+to+");", interval);
}
}
slide.objects = new Array();
slide.addId = function(Id)
{
for (var i=0; i < slide.objects.length; i++) {
if (slide.objects[i].id == Id) return true;
}
slide.objects[slide.objects.length] = document.getElementById(Id);
}
/**********개발자 추가 :E*********/

function addevent(target,eventname,functionname){
	if(target.attachEvent){
		target.attachEvent('on'+eventname,functionname);
	}else{
		target.addEventListener(eventname,functionname,false);
	}
}


/* 플래시 삽입 */
function embedFlash1(id, url, width, height, altText, flashVars, wmode) {
	if (!flashVars) flashVars = '';
	if (!wmode) wmode = 'window';
	if (!altText) altText = '<p style="padding-right: 8px;">플래시 플러그인이 설치되어 있지 않습니다.<br />아래 링크를 클릭하시면 플러그인 다운로드 페이지로 이동합니다.<br /><a href="https://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=shockwaveFlash">플래시 플러그인 다운로드 페이지</a></p>';

	var str = '' +
	'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0" width="' + width + '" height="' + height + '" id="' + id + '">' +
		'<param name="movie" value="' + url + '" />' +
		'<param name="wmode" value="' + wmode + '" />' +
		'<param name="FlashVars" value="' + flashVars + '" />' +
		'<!--[if !IE]>-->' +
		'<object type="application/x-shockwave-flash" data="' + url + '" width="' + width + '" height="' + height + '">' +
			'<param name="wmode" value="' + wmode + '" />' +
			'<param name="FlashVars" value="' + flashVars + '" />' +
		'<!--<![endif]-->' +
			'<div class="alt-content">' + altText + '</div>' +
		'<!--[if !IE]>-->' +
		'</object>' +
		'<!--<![endif]-->' +
	'</object>';
	document.write(str);
}


// check browser
	var isie=navigator.userAgent.toLowerCase().indexOf('msie')!=-1; //ie

// write flash
function writeflash(containerid,swfid,src,w,h,flashvars,winmode,bgcolor){
	if(!winmode) var winmode='transparent';
	if(!bgcolor) var bgcolor='none';
	var html='';
	if(isie){
		html+='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+w+'" height="'+h+'" id="'+swfid+'">';
		html+='<param name="allowScriptAccess" value="always" />';
		html+='<param name="allowFullScreen" value="true" />';
		html+='<param name="quality" value="high" />';
		html+='<param name="movie" value="'+src+'" />';
		html+='<param name="wmode" value="'+winmode+'" />';
		html+='<param name="bgcolor" value="'+bgcolor+'" />';
		html+='<param name="flashvars" value="'+flashvars+'"/>';
		html+='</object>';
	}else{
		html+='<embed src="'+src+'" quality="high" wmode="'+winmode+'" bgcolor="'+bgcolor+'" width="'+w+'" height="'+h+'" id="'+ swfid+'" flashvars="'+flashvars+'" allowScriptAccess="always" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/go/getflashplayer"></embed>';
	}
	document.getElementById(containerid).innerHTML=html;
}


/* 팝업 */
function popGuide(url, popName, w, h) {
	var positionT = (screen.width - w) / 2;
	var positionL = (screen.height - h) / 2;
	var feat = "width=" + w + ", height=" + h +", top=" + positionT + ", left=" + positionL + ", resizable=no, scrollbars=no, status=no"
	window.open(url, popName, feat);
}


/* 메인 네비게이션 확장 */
function navHeader() {
	var nav = document.getElementById("nav");
	if(!document.getElementById("nav")) return false;

	nav.onmouseover = function() {
		this.style.height = "602px" ;
	}

	nav.onmouseout = function() {
			this.style.height = "370px" ;
		}
}
addevent(window,'load',navHeader);


/* 컨텐츠 창 열기*/
function slideOpen() {
	if (!document.getElementById("slide")) return false;
	var slide = document.getElementById("slide");

	slide.timer = null;
	clearTimeout(slide.timer);
	slide.className = "cntFlashOn" ;
}

/* 컨텐츠 창 닫기*/
function slideClose() {
	if (!document.getElementById("slide")) return false;
	var slide = document.getElementById("slide");

	slide.timer = null;
	slide.timer=setTimeout(function(){ document.getElementById("slide").className = "cntFlash" ;},400);
}

/* 서브 메뉴 */
function snb() {

	var menu = document.getElementById("menuL");
	if(!document.getElementById("menuL")) return false;

	var tith = menu.getElementsByTagName("h3");
	var list = menu.getElementsByTagName("ul");
	var listLi = menu.getElementsByTagName("li");

	var max = tith.length;

	for (var i = 0; i < max; i++) {
		tith[i].no = i;
		tith[i].style.cursor = "pointer";


		list[i].style.display = "none";
		list[0].style.display = "block";

		tith[i].onmouseover = function() {
			menuShow(this.no);
		}
	}

	function menuShow(r) {
		for (var i = 0; i < max; i++) {
			if (i == r) {
				list[i].style.display = "block";
				tith[i].className = "on"
			} else {
				list[i].style.display = "none";
				tith[i].className = ""
			}
		}
	}
}

addevent(window,'load',snb);


/* 서브 메뉴
function snb() {

	var menu = document.getElementById("menuL");
	if(!document.getElementById("menuL")) return false;

	var tith = menu.getElementsByTagName("h3");
	var list = menu.getElementsByTagName("ul");
	var listLi = menu.getElementsByTagName("li");

	var max = tith.length;
	var maxA = listLi.length;


	for (var i = 0; i < max; i++) {
		tith[i].no = i;
		tith[i].style.cursor = "pointer";
		tith[i].open = false;

		list[i].style.display = "none";
		list[0].style.display = "block";

		tith[i].onmouseover = function() {
			menuShow(this.no);
		}
	}

	function menuShow(r) {
		for (var i = 0; i < max; i++) {
			if (i == r && tith[i].open==false) {
				list[i].style.display = "block";
				tith[i].className = "on"
				tith[i].open = true;

			} else {
				list[i].style.display = "none";
				tith[i].className = ""
				tith[i].open = false;
			}
		}
	}

	for (var j = 0; j < maxA; j++) {
		listLi[j].no = j;
		listLi[j].style.cursor = "pointer";

		listLi[j].onclick = function() {
			active(this.no);
		}
	}

	function active(ac) {
		for (var j = 0; j < maxA; j++) {
			if (j == ac) {
				listLi[j].className = "on"
			} else {
				listLi[j].className = ""
			}
		}
	}
}

addevent(window,'load',snb);
*/


/* 폰트사이즈 조절 */
function zoom() {
	if (!document.getElementById("zoom")) return false;
	var zoom = document.getElementById("zoom");
	var zBtn = zoom.getElementsByTagName("a");
	var contents = document.getElementById("contents");

	for(var i = 0; i < zBtn.length; i++) {
		var basic  = 12;
		var add = 2;

		zBtn[0].onclick = function() {
			if (basic < 20) {
				basic += add;
				contents.style.fontSize = basic + "px";
				return false;
			}
		}

		zBtn[1].onclick = function() {
			if (basic > 12) {
				basic -= add;
				contents.style.fontSize = basic + "px";
				return false;
			}
		}
	}
}

window.onload = function() {
	zoom();
}


 /* faq */
 function faq() {
	if(!document.getElementById("faq")) return false;;
	var faq = document.getElementById("faq");
	var dt = faq.getElementsByTagName("dt");
	var dd = faq.getElementsByTagName("dd");
	var max = dt.length;

	for (var i = 0; i < max; i++) {
		dt[i].no = i;
		dt[i].open = false;
		dt[i].style.cursor = "pointer";
		dd[i].style.display = "none";
		dd[0].style.display = "block";

		dt[i].onclick = function() {
			question(this.no);
		}
	}

	function question(no) {
		for (var i = 0; i < max; i++) {
			if(i==no && dt[i].open==false) {
				dd[i].style.display = "block";
				dt[i].open = true;

			} else {
				dd[i].style.display = "none";
				dt[i].open = false;
			}
		}
	}
}

addevent(window,'load',faq);


 function tab() {
	if(!document.getElementById("tab")) return false;
	if(!document.getElementById("contents")) return false;

	var tab = document.getElementById("tab");
	var tabList = tab.getElementsByTagName("li");


	var contents = document.getElementById("contents");
	var conList = contents.getElementsByTagName("div");

	var max = tabList.length;

	for (var i = 0; i < max; i++) {
		tabList[i].no = i;
		tabList[i].style.cursor = "pointer";
		tabList[0].className = "liColor";

		conList[i].style.display = "none";
		conList[0].style.display = "block";

		tabList[i].onclick = function() {
			show(this.no);
		}
	}

	function show(num) {
		for (var i = 0; i < max; i++) {
			if (i == num) {
				tabList[i].className = "liColor"
				conList[i].style.display = "block";
				conList[i].style.fontWeight = "bold";
			} else {
				tabList[i].className = ""
				conList[i].style.display = "none";
			}
		}
	}
}

addevent(window,'load',tab);


/* 공지사항, 뉴스, 열린공간 */
function information() {
	if (!document.getElementById("information")) return false;
	if (!document.getElementById("newsTab")) return false;

	var information = document.getElementById("information");
	var dlList = information.getElementsByTagName("dl");

	var newsTab = document.getElementById("newsTab");
	var newsTabBtn = newsTab.getElementsByTagName("area");
	var newsMore = newsTab.getElementsByTagName("a");

	var max = newsTabBtn.length;

	for (var i = 0; i < max; i++) {
		newsTabBtn[i].no = i;
		newsMore[i].style.display = "none";
		newsMore[0].style.display = "block";

		dlList[i].style.display = "none";
		dlList[0].style.display = "block";

		newsTabBtn[i].onclick = function() {
			show(this.no);
			tab(this); return false;
		}
	}

	function show(no) {
		for (var i = 0; i < max; i++) {
			if (i == no) {
				newsMore[i].style.display = "block";
				dlList[i].style.display = "block";
			} else {
				newsMore[i].style.display = "none";
				dlList[i].style.display = "none";
			}
		}
	}

	function tab(img) {
		newsTab.getElementsByTagName("img")[0].src = img.href;
	}
}

addevent(window,'load',information);


/* 베스트 프로그램 10 */
function list() {
	if(!document.getElementById("best10")) return false;

	var list = document.getElementById("bestList");
	var listLink = list.getElementsByTagName("li");
	var listUrl = list.getElementsByTagName("a");

	var inputArea = document.getElementById("inputArea");

	var max = listLink.length;

	list.style.display = "block";

	list.onmouseout = function() {
		list.style.display = "none";
	}

	list.onmouseover = function() {
		list.style.display = "block";
	}

	for (var i = 0; i < max; i++) {
		listLink[i].num = i;
		listLink[i].style.cursor = "pointer"

		listUrl[i].onclick = function() {
			list.style.display = "none";
			//window.open(this.href);
			//return false;
		}
	}
}


/* 패밀리 사이트 */
function family() {
	if (!document.getElementById("family")) return false;
	if (!document.getElementById("btnF")) return false;
	if (!document.getElementById("listF")) return false;

	var family = document.getElementById("family");
	var btnF = document.getElementById("btnF");
	var listF = document.getElementById("listF");
	var listF_li = listF.getElementsByTagName("li");
	var listF_link = listF.getElementsByTagName("a");
	var max = listF_li.length;

	btnF.onclick = function() {
		listF.style.display = "block";
	}

	listF.onmouseover = function() {
		this.style.display = "block";
	}

	listF.onmouseout = function() {
		this.style.display = "none";
	}

	for (var i = 0; i < max; i++) {
		listF_li[i].no = i;

		listF_li[i].onmouseover = function() {
			over(this.no);
		}

		listF_link[i].onclick = function() {
			window.open(this.href);
			return false;
		}
	}

	function over(no) {
		for (var i = 0; i < max; i++) {
			if (i == no) {
				listF_li[i].className = "over";
			} else {
				listF_li[i].className = "";
			}
		}
	}
}

addevent(window,'load',family);


/* 지식창고 */
 function newsTab() {
	if(!document.getElementById("tabNews")) return false;
	if(!document.getElementById("newsList")) return false;

	var tab = document.getElementById("tabNews");
	var tabList = tab.getElementsByTagName("li");

	var contents = document.getElementById("newsList");
	var conList = contents.getElementsByTagName("div");

	var max = tabList.length;

	for (var i = 0; i < max; i++) {
		tabList[i].no = i;
		tabList[i].style.cursor = "pointer";
		tabList[0].className = "on";

		conList[i].style.display = "none";
		conList[0].style.display = "block";

		tabList[i].onclick = function() {
			show(this.no);
		}
	}

	function show(num) {
		for (var i = 0; i < max; i++) {
			if (i == num) {
				tabList[i].className = "on"
				conList[i].style.display = "block";
			} else {
				tabList[i].className = ""
				conList[i].style.display = "none";
			}
		}
	}
}

addevent(window,'load',newsTab);
/* //지식창고 */


/* 오늘의 북모닝 ceo */
/*
 function bookMorning() {
	if(!document.getElementById("tabbm")) return false;
	if(!document.getElementById("bmList")) return false;
	if(!document.getElementById("bmThum")) return false;

	var tab = document.getElementById("tabbm");
	var tabList = tab.getElementsByTagName("li");

	var contents = document.getElementById("bmList");
	var conList = contents.getElementsByTagName("dl");

	var thum = document.getElementById("bmThum");
	var thumList = thum.getElementsByTagName("a");

	var max = tabList.length;

	for (var i = 0; i < max; i++) {
		tabList[i].no = i;
		tabList[i].style.cursor = "pointer";
		tabList[0].className = "on";

		conList[i].style.display = "none";
		conList[0].style.display = "block";

		thumList[i].style.display = "none";
		thumList[0].style.display = "block";

		tabList[i].onclick = function() {
			show(this.no);
		}
	}

	function show(num) {
		for (var i = 0; i < max; i++) {
			if (i == num) {
				tabList[i].className = "on"
				conList[i].style.display = "block";
				thumList[i].style.display = "block";
			} else {
				tabList[i].className = ""
				conList[i].style.display = "none";
				thumList[i].style.display = "none";
			}
		}
	}
}
addevent(window,'load',bookMorning);
*/
/* //오늘의 북모닝 ceo */


/* Scrolling Wing */
function initMoving() {
	if (!document.getElementById("quickMenu")) return false;

	var obj = document.getElementById("quickMenu");
	obj.initTop = 290;
	obj.topLimit = 0;
	obj.bottomLimit = document.documentElement.scrollHeight  - obj.topLimit;

	obj.style.position = "absolute";
	obj.top = obj.initTop;
	obj.left = obj.initLeft;
	obj.style.top = obj.top + "px";

	obj.getTop = function() {
		if (document.documentElement.scrollTop) {
			return document.documentElement.scrollTop;
		} else if (window.pageYOffset) {
			return window.pageYOffset;
		} else {
			return 0;
		}
	}
	obj.getHeight = function() {
		if (self.innerHeight) {
			return self.innerHeight;
		} else if(document.documentElement.clientHeight) {
			return document.documentElement.clientHeight;
		} else {
			return 500;
		}
	}
	obj.move = setInterval(function() {
		//pos = obj.getTop() + obj.getHeight() / 2 - 15;
		pos = obj.getTop() + obj.initTop;

		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)
}

addevent(window,'load',initMoving);


/* 퀵메뉴 열고 닫기 */
function quickOpen() {
	var qOpen = document.getElementById("qOpen");
	if(!document.getElementById("qOpen")) return false;

	var quickLink = document.getElementById("quickLink");
	if(!document.getElementById("quickLink")) return false;

	qOpen.onclick = function() {

		if (quickLink.style.display == "block") {
			quickLink.style.display = "none";
		} else {
			quickLink.style.display = "block";
		}
	}
}
addevent(window,'load',quickOpen);


function tabPocket() {
	if (!document.getElementById("tabPocket")) return false;
	if (!document.getElementById("listPocket")) return false;

	var tabPocket = document.getElementById("tabPocket");
	var tabPL = tabPocket.getElementsByTagName("li");

	var listPocket = document.getElementById("listPocket");
	var listPL =  listPocket.getElementsByTagName("ul");

	var max = tabPL.length;

	for (var i = 0; i < max; i++) {
		tabPL[i].no = i;
		listPL[i].style.display = "none";
		listPL[0].style.display = "block";

		tabPL[i].onclick = function() {
			show(this.no);
		}
	}

	function show(no) {
		for (var i = 0; i < max; i++) {
			if(i == no) {
				tabPL[i].className = "on"
				listPL[i].style.display = "block";
			} else {
				tabPL[i].className = ""
				listPL[i].style.display = "none";
			}
		}
	}
}



/**
 * 인쇄 영역  함수 호출 ex) pageprint ()  이치도  2010. 05. 20
 */
var initBody 

/*
function pageprint() {
	alert("1");
	 window.onbeforeprint = beforePrint; 
	 window.onafterprint = afterPrint; 
	 window.print();
} 
*/
function beforePrint(){
 initBody = document.body.innerHTML; 
 document.body.innerHTML = print_page.innerHTML;
} 

function afterPrint(){
 document.body.innerHTML = initBody; 
}


/** 
 * 새창 띄우기 인쇄     pagePrint(document.getElementById('print_page'))
 */

function pagePrint(Obj) { 
	
    var W = Obj.offsetWidth;        //screen.availWidth;    Obj.clientWidth     Obj.offsetWidth;   
    var H = Obj.offsetHeight;        //screen.availHeight;  Obj.clientHeight    Obj.offsetHeight; 
 
    
    var features = "menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,width=" + W + ",height=" + H + ",left=0,top=0"; 
    
    var PrintPage = window.open("about:blank",Obj.id,features); 
    
    PrintPage.document.open(); 
    PrintPage.document.write("<html><head><title></title><style type='text/css'>body, tr, td, input, textarea { font-family:굴림; font-size:12px; }</style>\n </head>\n<body>" + Obj.innerHTML + "\n</body></html>"); 
    PrintPage.document.close(); 

    PrintPage.document.title = document.domain; 
    PrintPage.print(PrintPage.location.reload()); 
} 


/**
 * top 의 url을 이동시킨다.
 */
function fnGoUrlOnTop(url) {
	top.location.href = url;
}

// 2011. 12. 23 
function fnGoTopUrlSSL(url){
	top.location.href = url;
}


addevent(window,'load',tabPocket);
