﻿
/************************************************************
*
*  JavaScript
*
************************************************************/

var mainWinW = 0;
var mainWinH = 0;
function mainFlashX(src, swfid) {
    document.write(flashHtml(src, "100%", "100%", swfid));
    mainWinW = $(window).width();
    mainWinH = $(window).height();
    if(mainWinW < 980) mainWinW = 980;
    if(mainWinH < 750) mainWinH = 750;
    //$("div.mainWrap").html(flashHtml(src, mainWinW, mainWinH, swfid));
    $("div.mainWrap").css("width", (mainWinW + "px")).css("height", (mainWinH + "px"));
	
	$(window).resize(function() {
  	  var newMainWinW = $(window).width();
      var newMainWinH = $(window).height();
      if(newMainWinW < 980) newMainWinW = 980;
      if(newMainWinH < 750) newMainWinH = 750;
      if(mainWinW == newMainWinW || mainWinH == newMainWinH) {
        return;
      }
      mainWinW = newMainWinW;
      mainWinH = newMainWinH;
      
	    //$("div.mainWrap").html(flashHtml(src, mainWinW, mainWinH, swfid));
	    $("div.mainWrap").css("width", (mainWinW + "px")).css("height", (mainWinH + "px"));
	    //alert(mainWinW, mainWinH);
	});

}

function flashHtml(src, w, h, swfid) {
    swf_html = '';
    swf_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="' + w + '" height="' + h + '" id="' + swfid + '">';
    swf_html += '<param name="allowScriptAccess" value="sameDomain">';
    swf_html += '<param name="movie" value="' + src + '">';
    swf_html += '<param name="quality" value="high">';
    swf_html += '<param name="bgcolor" value="#FFFFFF">';
    swf_html += '<PARAM NAME="wmode" VALUE="transparent">';
    swf_html += '<embed src="' + src + '" quality="high" bgcolor="#FFFFFF" width="' + w + '" height="' + h + '" name="' + swfid + '" allowScriptAccess="always" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">';
    swf_html += '</object>';
    return swf_html;
}

//ex)<script type="text/javascript">flashX('slide.swf','462','495','slide');</script> <== html 사용시
function flashX(src, w, h, swfid) {
    swf_html = '';
    swf_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="' + w + '" height="' + h + '" id="' + swfid + '">';
    swf_html += '<param name="allowScriptAccess" value="sameDomain">';
    swf_html += '<param name="movie" value="' + src + '">';
    swf_html += '<param name="quality" value="high">';
    swf_html += '<param name="bgcolor" value="#FFFFFF">';
    swf_html += '<PARAM NAME="wmode" VALUE="transparent">';
    swf_html += '<embed src="' + src + '" quality="high" bgcolor="#FFFFFF" width="' + w + '" height="' + h + '" name="' + swfid + '" allowScriptAccess="always" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">';
    swf_html += '</object>';
    document.write(swf_html);
}


//ex)<script type="text/javascript">playflash('/kt08/fla/KTmain.swf','100%','720','#ffffff','high','main_Index','');</script> <== html 사용시
function playflash(swf, width, height, bgcolor, quality, id, flashvars) {

    var strFlashTag = new String();


    if (navigator.appName.indexOf("Microsoft") != -1) {

        strFlashTag += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';

        strFlashTag += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=version=8,0,0,0" ';
        strFlashTag += 'id="' + id + '" width="' + width + '" height="' + height + '">';
        strFlashTag += '<param name="movie" value="' + swf + '"/>';

        if (flashvars != null) { strFlashTag += '<param name="flashvars" value="' + flashvars + '"/>' };
        strFlashTag += '<param name="quality" value="' + quality + '"/>';
        strFlashTag += '<param name="bgcolor" value="' + bgcolor + '"/>';
        strFlashTag += '<param name="menu" value="false"/>';
        strFlashTag += '<param name="salign" value="LT"/>';
        strFlashTag += '<param name="scale" value="noscale"/>';
        strFlashTag += '<param name="wmode" value="transparent"/>';
        strFlashTag += '<param name="allowScriptAccess" value="always"/>';
        strFlashTag += '</object>';
    }
    else {
        strFlashTag += '<embed src="' + swf + '" ';
        strFlashTag += 'quality="' + quality + '" ';
        strFlashTag += 'bgcolor="' + bgcolor + '" ';
        strFlashTag += 'width="' + width + '" ';
        strFlashTag += 'height="' + height + '" ';
        strFlashTag += 'menu="false" ';
        strFlashTag += 'scale="noscale" ';
        strFlashTag += 'id="' + id + '" ';
        strFlashTag += 'salign="LT" ';
        strFlashTag += 'wmode="transparent" ';
        strFlashTag += 'allowScriptAccess="always" ';
        if (flashvars != null) { strFlashTag += 'flashvars="' + flashvars + '" ' };
        strFlashTag += 'type="application/x-shockwave-flash" ';
        strFlashTag += 'pluginspage="http://www.macromedia.com/go/getflashplayer">';
        strFlashTag += '</embed>';
    }

    document.write(strFlashTag);
}

// 마이무비업에서 영상을 불러오기 위한 태그 생성
function myMovieUp(key, w, h, movieid, divid)
{
    var src = "http://asp.mymovieup.com/player/" + key;
    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="' + w + '" height="' + h + '" id="' + movieid + '">';
    html += '<param name="allowScriptAccess" value="always">';
    html += '<param name="movie" value="' + src + '">';
    html += '<param name="quality" value="high">';
    html += '<param name="bgcolor" value="#FFFFFF">';
    html += '<param name="wmode" value="transparent">';
    html += '<param name="flashvars" value="autoPlay=true&amp;skinID=1">';
    html += '<embed src="' + src + '" quality="high" bgcolor="#FFFFFF" width="' + w + '" height="' + h + '" name="' + movieid + '" flashvars="autoPlay=true&amp;skinID=1" allowScriptAccess="always" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">';
    html += '</object>';
    
    if(typeof(divid) == "undefined")
        document.write(html);
    else
        document.getElementById(divid).innerHTML = html;
}

/**
 * myMovieUp 을 vimeo 로 변경함
 * 작성: xerson
 * 일자: 2010.09.30
 * TO DO: 일단 embed 만 적용함. objec 코드 적용시킬 것.
 */
function myMovieUp2(key, w, h, movieid, divid)
{
	var src = "http://vimeo.com/moogaloop.swf?clip_id=" + key;
	var html = '<object>';
	html += '<embed src="' + src + "&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=1&amp;color=00adef&amp;fullscreen=0&amp;autoplay=1&amp;loop=0" + '" quality="high" bgcolor="#FFFFFF" width="' + w + '" height="' + h + '" name="' + movieid + '" flashvars="autoPlay=true&amp;skinID=1" allowScriptAccess="always" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">';
	html += '</object>';

	if(typeof(divid) == "undefined") {
		document.write(html);
	} else {
		document.getElementById(divid).innerHTML = html;
	}

}


//  화면 정중앙에 POPUP WINODOW OPEN
function popCwin(url, name, w, h, scroll) {

    var wl = (window.screen.width / 2) - ((w / 2) + 10);
    var wt = (window.screen.height / 2) - ((h / 2) + 50);

    var option = "height=" + h + ",width=" + w + ",left=" + wl + ",top=" + wt + ",screenX=" + wl + ",screenY=" + wt + ",scrollbars=" + scroll + ", status=yes";

    commonPopWin = window.open(url, name, option);
    commonPopWin.focus();
}

// 원하는 위치에 POPUP WINODOW OPEN
function popUwin(url, name, w, h, wl, wt, scroll) {

    var option = "status=no,height=" + h + ",width=" + w + ",resizable=no,left=" + wl + ",top=" + wt + ",screenX=" + wl + ",screenY=" + wt + ",scrollbars=" + scroll;

    commonPopWin = window.open(url, name, option);
    commonPopWin.focus();
}

/************************************************************
* GoTop
************************************************************/
function GoTop() {
    window.scrollTo(0, 0);
}



// scrolling layer
var stmnLEFT = 968; // 왼쪽 여백
var stmnGAP1 = 0; // 위쪽 여백
var stmnGAP2 = 200; // 스크롤시 브라우저 위쪽과 떨어지는 거리
var stmnBASE = 200; // 스크롤 시작위치
var stmnActivateSpeed = 35;
var stmnScrollSpeed = 20;
var stmnTimer;

function RefreshStaticMenu() {
    var stmnStartPoint, stmnEndPoint;
    stmnStartPoint = parseInt(document.getElementById('STATICMENU').style.top, 10);
    stmnEndPoint = Math.max(document.documentElement.scrollTop, document.body.scrollTop) + stmnGAP2;
    if (stmnEndPoint < stmnGAP1) stmnEndPoint = stmnGAP1;
    if (stmnStartPoint != stmnEndPoint) {
        stmnScrollAmount = Math.ceil(Math.abs(stmnEndPoint - stmnStartPoint) / 15);
        document.getElementById('STATICMENU').style.top = parseInt(document.getElementById('STATICMENU').style.top, 10) + ((stmnEndPoint < stmnStartPoint) ? -stmnScrollAmount : stmnScrollAmount) + 'px';
        stmnRefreshTimer = stmnScrollSpeed;
    }
    stmnTimer = setTimeout("RefreshStaticMenu();", stmnActivateSpeed);
}
function InitializeStaticMenu() {
    document.getElementById('STATICMENU').style.left = stmnLEFT + 'px';
    document.getElementById('STATICMENU').style.top = document.body.scrollTop + stmnBASE + 'px';
    RefreshStaticMenu();
}

//scrolling layer end


/*************************************
** SELECT SHOW / HIDE
*************************************/
// Hide select boxes as they will 'peek' through the image in IE
function hideSelect() {
    selects = document.getElementsByTagName("select");
    for (i = 0; i != selects.length; i++) {
        selects[i].style.visibility = "hidden";
    }
}
// make select boxes visible
function showSelect() {
    selects = document.getElementsByTagName("select");
    for (i = 0; i != selects.length; i++) {
        selects[i].style.visibility = "visible";
    }
}


/* tab show hide */
function changeDivStyle(bid, id, total) {
    for (var i = 1; i <= total; i++) {
        document.getElementById(bid + 'Tab_' + i).style.display = 'none';
        document.getElementById(bid + 'Cont_' + i).style.display = 'none';
    }
    document.getElementById(bid + 'Tab_' + id).style.display = 'block';
    document.getElementById(bid + 'Cont_' + id).style.display = 'block';
}

// div show/hide
function changeDivStyle2(bid, id, total) {
    if (id) {
        for (var i = 1; i <= total; i++) {
            document.getElementById(bid + "_Cont_" + i).style.display = 'none';
        }

        document.getElementById(bid + "_Cont_" + id).style.display = 'block';
    }
}

// 2Tab
function changeDivStyle3(bid, id, total) {
    for (var i = 1; i <= total; i++) {
        document.getElementById(bid + "_Cont_" + i).style.display = 'none';
        document.getElementById(bid + "_Tab_" + i).className = '';
    }
    document.getElementById(bid + "_Cont_" + id).style.display = 'block';
    document.getElementById(bid + "_Tab_" + id).className = 'on';
}

// 3Tab
function changeDivStyle4(bid, id, total) {
    var offNum;
    for (var i = 1; i <= total; i++) {
        document.getElementById(bid + "_Cont_" + i).style.display = 'none';
        document.getElementById(bid + "_Tab_" + i).className = '';
    }

    if (id != 1) {
        offNum = id - 1;
        document.getElementById(bid + "_Tab_" + offNum).className = 'off';
        if (id > 2) {
            document.getElementById(bid + "_Tab_1").className = 'off1';
        } else {
            document.getElementById(bid + "_Tab_1").className = 'off2';
        }
    }

    document.getElementById(bid + "_Cont_" + id).style.display = 'block';
    document.getElementById(bid + "_Tab_" + id).className = 'on';
    /*
    var offNum;
    for(var i = 1; i <= total; i++)
    {
    document.getElementById(bid+"_Cont_"+i).style.display = 'none';
    document.getElementById(bid+"_Tab_"+i).className = '';
    }

		if (id != 1){
    offNum = id - 1;
    document.getElementById(bid+"_Tab_"+offNum).className = 'off2'
    }

	document.getElementById(bid+"_Cont_"+id).style.display = 'block';
    document.getElementById(bid+"_Tab_"+id).className = 'on';
    */
}

// div 위치안내
function changeDivStyle5(bid, id, total) {
    for (var i = 1; i <= total; i++) {
        document.getElementById(bid + "_Cont_" + i).style.display = 'none';
        document.getElementById(bid + "_Btn_" + i).src = document.getElementById(bid + "_Btn_" + i).src.replace("_.gif", ".gif");
    }

    document.getElementById(bid + "_Cont_" + id).style.display = 'block';
    document.getElementById(bid + "_Btn_" + id).src = document.getElementById(bid + "_Btn_" + id).src.replace(".gif", "_.gif");
}

// KT 아트홀소개 이미지변경
function changeImg(bid, id, total) {
    for (var i = 1; i <= total; i++) {
        document.getElementById(bid).src = document.getElementById(bid).src.replace(i + ".jpg", id + ".jpg");
    }
}


// 이용약관 이전내용보기
function agreement(bid, id, total) {

}

// imgSWAP
function swapImg(bid, id) {
    document.getElementById(bid + "_Btn_" + id).src = document.getElementById(bid + "_Btn_" + id).src.replace(".gif", "_.gif");
}
function restoreImg(bid, id) {
    document.getElementById(bid + "_Btn_" + id).src = document.getElementById(bid + "_Btn_" + id).src.replace("_.gif", ".gif");
}


function showDiv(what, lpw, lph) {
    var ns = (navigator.appName.indexOf("Netscape") != -1);

    var CH = document.documentElement.clientHeight; //보이는화면Height
    var CW = document.documentElement.clientWidth; //보이는화면Width
    var ST = ns ? pageYOffset : document.documentElement.scrollTop;

    hideSelect()
    document.getElementById(what).style.display = "";
    document.getElementById(what).style.left = ((CW - lpw) / 2) + "px";
    document.getElementById(what).style.top = (ST + (CH - lph) / 2) + "px";
}
function hideDiv(what) {
    document.getElementById(what).style.display = "none";
}


function openFooter() {
    hideSelect()
    document.getElementById("footerIn").className = "open";
    document.getElementById("footerIn2").style.display = "block";
}

function closeFooter() {
    showSelect();
    document.getElementById("footerIn").style.display = "block";
    document.getElementById("footerIn2").style.display = "none";
}


// 구성체제
function systemTab(no) {
    var num = 7;   // 상위메뉴 개수(서브메뉴 아님)
    for (i = 1; i <= num; i++) {
        document.getElementById('cont_' + i).style.display = "none";
        document.getElementById('system' + i).src = "/static/images/changbi/sy_navi_0" + i + ".gif";
    }
    document.getElementById('cont_' + no).style.display = "block";
    document.getElementById('system' + no).src = "/static/images/changbi/sy_navi_0" + no + "_.gif";
}
function systemTab2(no) {
    var num = 5;   // 상위메뉴 개수(서브메뉴 아님)
    for (i = 1; i <= num; i++) {
        document.getElementById('cont_' + i).style.display = "none";
        document.getElementById('system' + i).src = "/static/images/changbi/sy_navi_0" + i + ".gif";
    }
    document.getElementById('cont_' + no).style.display = "block";
    document.getElementById('system' + no).src = "/static/images/changbi/sy_navi_0" + no + "_.gif";
}

function systemTab3(no) {
    var num = 8;   // 상위메뉴 개수(서브메뉴 아님)
    for (i = 1; i <= num; i++) {
        document.getElementById('cont_' + i).style.display = "none";
        document.getElementById('system' + i).src = "/static/images/changbi/sy_navi_0" + i + ".gif";
    }
    document.getElementById('cont_' + no).style.display = "block";
    document.getElementById('system' + no).src = "/static/images/changbi/sy_navi_0" + no + "_.gif";
}


// 12문 12답
function qnaCnt(no) {
    var num = 10;   // 상위메뉴 개수(서브메뉴 아님)
    for (i = 1; i <= num; i++) {
        document.getElementById('cont_' + i).style.display = "none";
        document.getElementById('stit' + i).src = "/static/images/changbi/qna_stit_" + i + ".gif";
    }
    document.getElementById('cont_' + no).style.display = "block";
    document.getElementById('stit' + no).src = "/static/images/changbi/qna_stit_" + no + "_.gif";
}

// 교과서맛보기
function avTab(no) {
    var num = 2;   // 상위메뉴 개수(서브메뉴 아님)
    for (i = 1; i <= num; i++) {
//        document.getElementById('cont_' + i).style.display = "none";
        document.getElementById('stit' + i).src = "/static/images/changbi/tb_tab0" + i + ".gif";
    }
//    document.getElementById('cont_' + no).style.display = "block";
    document.getElementById('stit' + no).src = "/static/images/changbi/tb_tab0" + no + "_.gif";
}


// 집필진
function writerTab(no) {
    var num = 2;   // 상위메뉴 개수(서브메뉴 아님)
    for (i = 1; i <= num; i++) {
        document.getElementById('cont_' + i).style.display = "none";
        document.getElementById('writer' + i).src = "/static/images/changbi/pr1_tab_0" + i + ".gif";
    }
    document.getElementById('cont_' + no).style.display = "block";
    document.getElementById('writer' + no).src = "/static/images/changbi/pr1_tab_0" + no + "_.gif";
}

function resultList(str) {
    document.getElementById(str).style.display = "block";
}
function resultList2(str) {
    document.getElementById(str).style.display = "none";
}

function studyTab1(no) {
    var num = 7;   // 상위메뉴 개수(서브메뉴 아님)
    for (i = 1; i <= num; i++) {
        document.getElementById('cont_0' + i).style.display = "none";
        document.getElementById('stit_0' + i).src = "/static/images/changbi/st1_tab_0" + i + ".gif";
    }
    document.getElementById('cont_0' + no).style.display = "block";
    document.getElementById('stit_0' + no).src = "/static/images/changbi/st1_tab_0" + no + "_.gif";
}

