﻿//-----------------------------------------------------
/*****         GNB          *****/
//-----------------------------------------------------
//주제별 강의 , 분야별강의 2Depth 갯수따른 박스 조절

function gnb_box_control(obj) {
	//obj = "3";
	obj1 = document.getElementById('submenu'+obj+'_type_1');
	obj2 = document.getElementById('submenu'+obj);
	
	Item = obj1.getElementsByTagName("p"); 
	Item2 = obj2.getElementsByTagName("img");
	items = Item.length;
	
	if(items == 2){
		obj2.style.left = "375px";
		Item2[0].style.marginLeft ="-210px";
	}
	if(items == 3){
		obj2.style.left = "270px";
		Item2[0].style.marginLeft ="-105px";
	}
	if(items == 4){
		obj2.style.left = "220px";
		Item2[0].style.marginLeft ="-55px";
	}	
	if(items == 7){
		obj2.style.left = "50px";
		Item2[0].style.marginLeft ="115px";
	}
	if(items == 8){
		obj2.style.left = "0px";
		obj2.style.width = "898px";
		Item2[0].style.marginLeft ="165px";
	}
}


function show_submenu2(obj) {
	
	for(var i = 1; i < 5; i++) {
		obj1 = document.getElementById('submenu'+i);
		img = document.getElementById('menu'+i);
		img.onmouseover=function(){
				imgchange_N(this);
		}
		if ( obj == i ) {
			obj1.style.display = "inline";
			img.onmouseover=null;
			img.onmouseout=null;
			if(img.src.indexOf('on.gif')==-1){
				img.src=img.src.replace('.gif','on.gif');
			}
		} else {
			obj1.style.display = "none";
			img.src=img.src.replace('on.gif','.gif');
			
		}
	}
}

function hide_submenu2(obj) {
	for(var i = 1; i < 5; i++) {
        obj1 = document.getElementById('submenu'+i);
        img = document.getElementById('menu'+i);
		
        if ( obj == i ) {
            obj1.style.display = "none";			
			img.src=img.src.replace('on.gif','.gif');
			img.onmouseover=function(){
				imgchange_N(this);
			}
        } 
    }
	
}

//**   img change **//
//사용예 onmouseover="imgchange(this);" style="CURSOR: pointer;"
function imgchange_N(imgobj){
	if(imgobj.src.indexOf('on.gif')==-1){
		imgobj.src=imgobj.src.replace('.gif','on.gif');
		imgobj.onmouseout=function(){if(this.src.indexOf('on.gif')!=-1) this.src=this.src.replace('on.gif','.gif');}
	}
}


// PNG 용
function imgchangeP(imgobj){
	imgobj.style.marginTop = '-50px';
	imgobj.onmouseout=function(){imgobj.style.marginTop = '0px';}
}

//-------------------------------------------------------
/****  복수의 레이어를 동시에 보이기 / 숨기기 -  메인 탭 메뉴 ****/
//-------------------------------------------------------
function event_change(n) {
    for(var i = 1; i <= 5; i++) {
        obj1 = document.getElementById('Heder2_con'+i);
		//obj2 = document.getElementById('list_change'+i);
		//obj3 = document.getElementById('event_more'+i);
        //img = document.getElementById('event_change_button'+i);
        if ( n == i ) {
            obj1.style.display = "block";
			//obj2.style.display = "block";
			//obj3.style.display = "block";
            //img.height = 14;
        } else {
            obj1.style.display = "none";
			//obj2.style.display = "none";
			//obj3.style.display = "none";
            //img.height = 14;
        }
    }
}

//-----------------------------------------------------
/*****         INPUT 배경이미지          *****/
//-----------------------------------------------------
/* 상세검색 */
function clrImg(obj){
        obj.className="detailSearchon";
		obj.onkeydown=obj.onmousedown=null;
    }
function returnImg(obj){
		if (obj.value=="")
        obj.className ="detailSearch";
    }
/* 뉴스레터 신청 */
function clrImg(obj){
        obj.className="input_newsletteron";
		obj.onkeydown=obj.onmousedown=null;
    }
function returnImg(obj){
		if (obj.value=="")
        obj.className ="input_newsletter";
    }


/***********************************************
 스크롤 (뉴스티커)
***********************************************/

function pausescroller(content, divId, divClass, delay){
this.content=content //message array content
this.tickerid=divId //ID of ticker div to display information
this.delay=delay //Delay between msg change, in miliseconds.
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
this.hiddendivpointer=1 //index of message array for hidden div
document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden" id="'+divId+'2">'+content[1]+'</div></div>')
var scrollerinstance=this
if (window.addEventListener) //run onload in DOM2 browsers
window.addEventListener("load", function(){scrollerinstance.initialize()}, false)

else if (window.attachEvent) //run onload in IE5.5+
window.attachEvent("onload", function(){scrollerinstance.initialize()})
else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec
setTimeout(function(){scrollerinstance.initialize()}, 500)
}

// -------------------------------------------------------------------
// initialize()- Initialize scroller method.
// -Get div objects, set initial positions, start up down animation
// -------------------------------------------------------------------

pausescroller.prototype.initialize=function(){
this.tickerdiv=document.getElementById(this.tickerid)
this.visiblediv=document.getElementById(this.tickerid+"1")
this.hiddendiv=document.getElementById(this.tickerid+"2")
this.visibledivtop=parseInt(pausescroller.getCSSpadding(this.tickerdiv))
//set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
this.getinline(this.visiblediv, this.hiddendiv)
this.hiddendiv.style.visibility="visible"
var scrollerinstance=this
document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}
if (window.attachEvent) //Clean up loose references in IE
window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
setTimeout(function(){scrollerinstance.animateup()}, this.delay)
}


// -------------------------------------------------------------------
// animateup()- Move the two inner divs of the scroller up and in sync
// -------------------------------------------------------------------

pausescroller.prototype.animateup=function(){
var scrollerinstance=this
if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+1)){
this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-1+"px"
this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-1+"px"
setTimeout(function(){scrollerinstance.animateup()}, 50)
}
else{
this.getinline(this.hiddendiv, this.visiblediv)
this.swapdivs()
setTimeout(function(){scrollerinstance.setmessage()}, this.delay)
}
}

// -------------------------------------------------------------------
// swapdivs()- Swap between which is the visible and which is the hidden div
// -------------------------------------------------------------------

pausescroller.prototype.swapdivs=function(){
var tempcontainer=this.visiblediv
this.visiblediv=this.hiddendiv
this.hiddendiv=tempcontainer
}

pausescroller.prototype.getinline=function(div1, div2){
div1.style.top=this.visibledivtop+"px"
div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px"
}

// -------------------------------------------------------------------
// setmessage()- Populate the hidden div with the next message before it's visible
// -------------------------------------------------------------------

pausescroller.prototype.setmessage=function(){
var scrollerinstance=this
if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
setTimeout(function(){scrollerinstance.setmessage()}, 100)
else{
var i=this.hiddendivpointer
var ceiling=this.content.length
this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1
this.hiddendiv.innerHTML=this.content[this.hiddendivpointer]
this.animateup()
}
}

pausescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
if (tickerobj.currentStyle)
return tickerobj.currentStyle["paddingTop"]
else if (window.getComputedStyle) //if DOM2
return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
else
return 0
}

//PNG Ie6
function setPng24_bikzo(obj) { 
	 
	obj.width=obj.height=1; 
	obj.className=obj.className.replace(/\bpng24_bikzo\b/i,''); 
	obj.style.filter = 
	"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');" 
	obj.src='../../images/common/blank.gif';
	return ''; 

}

//-----------------------------------------------------
/*****         레프트 메뉴          *****/
//-----------------------------------------------------

var enablepersist="off" // 쿠키를 적용하여 위치기억시키기 설정 (on/off)
var collapseprevious="yes" // 이전 열었던 항목 유지여부 (yes/no)

// var contractsymbol='- ' // 축소버튼 이미지로 사용할 경우 <img src="whatever.gif"> 처럼 설정해 줍니다
// var expandsymbol='+ ' // 확장버튼


if (document.getElementById){
document.write('<style type="text/css">')
document.write('.switchcontent{display:none;}')
document.write('.switchcontent2{display:none;}')
document.write('</style>')
}

function getElementbyClass(rootobj, classname){
var temparray=new Array()
var inc=0
var rootlength=rootobj.length
for (i=0; i<rootlength; i++){
if (rootobj[i].className==classname)
temparray[inc++]=rootobj[i]
}
return temparray
}


/*
function sweeptoggle(ec){
var thestate=(ec=="expand")? "block" : "none"
var inc=0
while (ccollect[inc]){
ccollect[inc].style.display=thestate
inc++
}
revivestatus()
}
*/

function contractcontent(omit){
var inc=0
while (ccollect[inc]){
if (ccollect[inc].id!=omit)
ccollect[inc].style.display="none"
inc++
}
}

function contractcontent2(omit){
var inc=0
while (ccollect2[inc]){
if (ccollect2[inc].id!=omit)
ccollect2[inc].style.display="none"
inc++
}
}

/* depth2 */
function expandcontent(curobj, cid ){
var Ptags=curobj.getElementsByTagName("P")
var showstateobj=getElementbyClass(Ptags, "showstate")

if (ccollect.length>0){
if (collapseprevious=="yes")
contractcontent(cid)
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
if (showstateobj.length>0){ 
if (collapseprevious=="no")
showstateobj[0].innerHTML=(document.getElementById(cid).style.display=="block")? contractsymbol : expandsymbol
else
revivestatus()
}
}
}

/* depth3 */
function expandcontent2(curobj2, cid2){
var divtags=curobj2.getElementsByTagName("DIV")
var bul_arrow1obj=getElementbyClass(divtags, "bul_arrow1")
if (ccollect2.length>0){
if (collapseprevious=="yes")
contractcontent2(cid2)
document.getElementById(cid2).style.display=(document.getElementById(cid2).style.display!="block")? "block" : "none"
if (bul_arrow1obj.length>0){ 
if (collapseprevious=="no")
bul_arrow1[0].innerHTML=(document.getElementById(cid2).style.display=="block")? contractsymbol : expandsymbol
else
revivestatus2()
}
}
}

function revivecontent(){
contractcontent("omitnothing")
selectedItem=getselectedItem()
selectedComponents=selectedItem.split("|")
for (i=0; i<selectedComponents.length-1; i++)
document.getElementById(selectedComponents[i]).style.display="block"
}

/* depth2 */
function revivestatus(){
var inc=0
while (statecollect[inc]){
if (ccollect[inc].style.display=="block")
statecollect[inc].innerHTML=contractsymbol
else
// statecollect[inc].innerHTML=expandsymbol
inc++
}
}

/* depth3 */
function revivestatus2(){
var inc=0
while (statecollect2[inc]){
if (ccollect2[inc].style.display=="block")
statecollect2[inc].innerHTML=contractsymbol
else
// statecollect2[inc].innerHTML=expandsymbol
inc++
}
}

function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function getselectedItem(){
if (get_cookie(window.location.pathname) != ""){
selectedItem=get_cookie(window.location.pathname)
return selectedItem
}
else
return ""
}

function saveswitchstate(){
var inc=0, selectedItem=""
while (ccollect[inc]){
if (ccollect[inc].style.display=="block")
selectedItem+=ccollect[inc].id+"|"
inc++
}

document.cookie=window.location.pathname+"="+selectedItem
}

function do_onload(){
uniqueidn=window.location.pathname+"firsttimeload"
uniqueidn2=window.location.pathname+"firsttimeload2"
var alltags=document.all? document.all : document.getElementsByTagName("*")
ccollect=getElementbyClass(alltags, "switchcontent")
ccollect2=getElementbyClass(alltags, "switchcontent2")

/* depth2 */
statecollect=getElementbyClass(alltags, "showstate")
if (enablepersist=="on" && ccollect.length>0){
document.cookie=(get_cookie(uniqueidn)=="")? uniqueidn+"=1" : uniqueidn+"=0" 
firsttimeload=(get_cookie(uniqueidn)==1)? 1 : 0

if (!firsttimeload)
revivecontent()
}
if (ccollect.length>0 && statecollect.length>0)
revivestatus()
}

/* depth3
statecollect2=getElementbyClass(alltags, "bul_arrow1")
if (enablepersist=="on" && ccollect2.length>0){
document.cookie=(get_cookie(uniqueidn2)=="")? uniqueidn2+"=1" : uniqueidn2+"=0" 
firsttimeload2=(get_cookie(uniqueidn2)==1)? 1 : 0

if (!firsttimeload2)
revivecontent()
}
if (ccollect2.length>0 && statecollect2.length>0)
revivestatus2()
} */


if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload

if (enablepersist=="on" && document.getElementById)
window.onunload=saveswitchstate
