//------------------ 플래시에서 호출하는 gotoPage ------------------//
function gotoPageGnb(d1,d2,d3){
	
	try
	{
		var url = "";
		var loginCheck = "";
		
		if (myClassType == "Middle")     
		    var link_value = "link_m";
		if (myClassType == "Primary")    
		    var link_value = "link_p";
		if (myClassType == "Speciality") 
		    var link_value = "link_s";
		    
		if(d1) { 
		    link_value += "_" + d1; 
		}
		if(d2) { 
		    link_value += "_" + d2;
		 }
		if(d3) { 
		    link_value += "_" + d3; 
		}
		
		loginCheck = eval(link_value)[0];
		url = eval(link_value)[1];
		
		if(loginCheck.length > 0 )
		{
			if(LoginCheck())
			{
				if(url=="") {
				    alert("준비중입니다.");
				}
				else {
				    document.location.href = url;
				}
			}
		}
		else
		{
			if(url=="") {
			    alert("준비중입니다.");
			}
			else {
			    document.location.href = url;	
			}
		}
	}
	catch (e)
	{
		alert(e.message);
	}
}

//------------------ LNB 플래시 링크 호출함수 ------------------// 
function gotoClsPage(cls,d1,d2,d3){
	try
	{
		var url = "";
		var loginCheck = "";
		
		if (cls == "Middle")     var link_value = "link_m";
		if (cls == "Primary")    var link_value = "link_p";
		if (cls == "Speciality") var link_value = "link_s";
		if (cls == "Common")     var link_value = "link_c";
		
		if(d1) { link_value += "_" + d1; }
		if(d2) { link_value += "_" + d2; }
		if(d3) { link_value += "_" + d3; }
		
		loginCheck = eval(link_value)[0];
		url = eval(link_value)[1];
		
		if(loginCheck.length > 0 )
		{
			if(LoginChcek())
			{
				if(url=="") {alert("준비중입니다.");}
				else {document.location.href = url;	}
			}
		}
		else
		{
			if(url=="") {alert("준비중입니다.");}
			else {document.location.href = url;	}
		}
	}
	catch (e)
	{
		alert(e.message);
	}
}
function gotoPage(d1,d2,d3){
	try
	{
		var url = "";
		var loginCheck = "";
		
		if (myClass == "Middle")     var link_value = "link_m";
		if (myClass == "Primary")    var link_value = "link_p";
		if (myClass == "Speciality") var link_value = "link_s";
		if (myClass == "Common")     var link_value = "link_c";
		
		if(d1) { link_value += "_" + d1; }
		if(d2) { link_value += "_" + d2; }
		if(d3) { link_value += "_" + d3; }
		
		loginCheck = eval(link_value)[0];
		url = eval(link_value)[1];
		
		if(loginCheck.length > 0 )
		{
			if(LoginChcek())
			{
				if(url=="") {alert("준비중입니다.");}
				else {document.location.href = url;	}
			}
		}
		else
		{
			if(url=="") {alert("준비중입니다.");}
			else {document.location.href = url;	}
		}
	}
	catch (e)
	{
		alert(e.message);
	}
}

function gotoCommonPage(d1){

	try
	{
		var url = "";
		var loginCheck = "";
			
		var url = "";
		var link_value = "link_c";
		if(d1) { link_value += "_" + d1; }
		
		loginCheck = eval(link_value)[0];
		url = eval(link_value)[1];
		
		if(loginCheck.length > 0 )
		{
			if(LoginChcek())
			{
				if(url=="") {alert("준비중입니다.");}
				else {document.location.href = url;	}
			}
		}
		else
		{
			if(url=="") {alert("준비중입니다.");}
			else {document.location.href = url;	}
		}
	}
	catch (e)
	{
		alert(e.message);
	}
}
// 플래시 사이즈 조절 
function flashResize(n, w, h){
	getObject(n).width = w;
	getObject(n).height = h;
}

function getObject(objectId) { 

	if(document.getElementById && document.getElementById(objectId)) 
	{ 
		return document.getElementById(objectId); // 대부분의브라우저
	}
	else if (document.all && document.all(objectId))
	{ 
		return document.all(objectId); // IE4와5.0 
	} 
	else if (document.layers && document.layers[objectId]) 
	{ 
		return document.layers[objectId]; // Netscape 4.x 
	} 
	else 
	{ 
		return false; 
	}
 }
//------------------ GNB 출력함수 ------------------//
//아래 파라미터 입력 중 loginFlag 값은 true , false 로 설정 
function gongbuwaracGNB() {
    var path = "";

    if(loginFlag == "True")
    {
        path = "xmlPath=/Common/Navigation/Swf/Widget/widget_logout_test.xml";
    }
    else
    {
        path = "xmlPath=/Common/Navigation/Swf/Widget/widget_logout_test.xml";
    }

	Flash('GNB_SWF','/Common/Navigation/Swf/gongbuwarac_gnb.swf','908','125', path + '&menuPath=/Common/Navigation/Swf/&myClass='+myClass+'&myGlobal='+myGlobal+'&myMenu='+myMenu+'&login='+loginFlag + '&myClassType=' + myClassType,'','transparent');
}

//------------------ LNB 출력함수 ------------------//
function gongbuwaracLNB() {
	Flash('LNB_SWF','/Common/Navigation/Swf/gongbuwarac_lnb.swf','172','570','menuPath=/Common/Navigation/Swf/&myClass='+myClass+'&myGlobal='+myGlobal+'&myMenu='+myMenu,'','opaque');
}

// flash(출력영역ID및NAME,플래시파일경로,WIDTH,HEIGHT,FLASHVARS,BackgroundColor,WMOD) 
function Flash(fid,fnm,wid,hei,fvs,bgc,wmd) {
	var flash_tag = "";
	flash_tag = '<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="'+wid+'" height="'+hei+'" id="'+fid+'" align="middle">';
	flash_tag +='<param name="allowScriptAccess" value="always" />';
	flash_tag +='<param name="allowFullScreen" value="false" />';
	flash_tag +='<param name="movie" value="'+fnm+'" />';
	flash_tag +='<param name="FlashVars" value="'+fvs+'" />';
	flash_tag +='<param name="quality" value="high" />';
	flash_tag +='<param name="bgcolor" value="'+bgc+'" />';
	flash_tag +='<param name="wmode" value="'+wmd+'" />';
	flash_tag +='<embed src="'+fnm+'" quality="high" bgcolor="'+bgc+'" FlashVars="'+fvs+'" wmode="'+wmd+'" width="'+wid+'" height="'+hei+'" name="'+fid+'" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	flash_tag +='</object>';
	
	document.write(flash_tag);
}
/*********************************************** //스타와락 플래시 함수 *********************************/
function innerHTMLSwf_Call(a,b,c,d,e)//경로,폭,높이,IDName
 {
	var idName="";
	if (! isNaN(d)) idName=" id='" +d+ "'";
    var tempInHtml = "";
	tempInHtml = "<object" + idName + " classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='" + b + "' height='" + c + "' VIEWASTEXT>";
	tempInHtml += "<param name=movie value='" + a + "'>";
	tempInHtml += "<param name=quality value=high>";
	tempInHtml += "<param name='wmode' value='transparent'>";
	tempInHtml += "<param name='allowScriptAccess' value='always' />";
	tempInHtml += "<embed" + idName + "  src='" + a + "' quality=high pluginspage='http://www.macromedia.com/go/getflashplayer' allowScriptAccess='always' type='application/x-shockwave-flash' width='" + b + "' height='" + c + "'></embed> ";
	tempInHtml += "</object>";	
	document.getElementById(e).innerHTML = tempInHtml;	
} 
/*********************************************** //플래시 함수 *********************************/
/********************************************************************
개발시 화면 처리 ASPX가 클라이언트에 Load된 후 실행해야 될 로직 처리
********************************************************************/
function g_WindowDevOnLoad()
{
	//에러 메시지가 있는 경우 팝업 출력
	var objError = eval("document.all.errorMessage");
	
	if (objError.value.length > 0)
	{	g_OpenScriptAlert(objError.value);}
	
	//Information이 있는 경우 팝업 출력
	var objInfo = eval("document.all.informationMessage");
	if (objInfo.value.length > 0)
	{	g_OpenScriptAlert(objInfo.value);}
	
	//confirm이 있는 경우 팝업 출력
	var objConfirm = eval("document.all.confirmMessage");
	if (objConfirm.value.length > 0)
	{	return g_OpenScriptConfirm(objConfirm.value);}
	
	try
	{
		eval("FormLoad")();
	}
	catch (exception)
	{
	}

	// 상태바 Text 변경
	window.status = "";
}

/********************************************************************
운영시 화면 처리 ASPX가 클라이언트에 Load된 후 실행해야 될 로직 처리
********************************************************************/
function g_WindowOnLoad()
{
	//에러 메시지가 있는 경우 팝업 출력
	var objError = eval("document.all.errorMessage");
	
	if (objError.value.length > 0)
	{
		g_MovePage(ERRORPAGE);
	    //g_OpenScriptAlert(objError.value);
	}
	//Information이 있는 경우 팝업 출력
	var objInfo = eval("document.all.informationMessage");
	if (objInfo.value.length > 0)
	{	g_OpenScriptAlert(objInfo.value);}
	
	//confirm이 있는 경우 팝업 출력
	var objConfirm = eval("document.all.confirmMessage");
	if (objConfirm.value.length > 0)
	{	return g_OpenScriptConfirm(objConfirm.value);}
	
	try
	{
		eval("FormLoad")();
	}
	catch (exception)
	{
	}

	// 상태바 Text 변경

	window.status = "";
}
/********************************************************************
linkURL : 링크 URL
********************************************************************/
function g_MovePage(linkURL)
{
	self.location.href = linkURL;
}
//------------------ 강좌 직접검색!!! ----------------//
function SearchGo(obj)
{
    var url = "frmseq=1&word=" + encodeURL(obj.value);
    document.location.href = "/Global/LecureSearch/Default.aspx?" + url;
}
//------------------ 강좌 직접검색!!! ----------------//	
//------------------ 교육/시험뉴스 !!! ----------------//	
function fnOpenUrl(turl,seq,flag) 
{
    var pop = window.open("MiddlePopup.aspx?turl= " + turl + "&mseq= " + seq + "&flag=" + flag, "NewsOriginalLink", "toolbar=yes,scrollbars=yes,resizable=yes,status=yes,width=800,height=600"); 
    pop.focus();		
}
// iframe 사이즈 조절 (height) //
function resizeIFrame()
{ 
	var ifr = document.getElementById('ifrGW');
	var iframeWin = ifr.contentWindow;
	var scrollbarWidth = 4; 
	var iframeWinBody = iframeWin.document.getElementsByTagName('BODY')[0];
	var diffHeight = iframeWinBody.scrollHeight - ifr.style.height; 
	ifr.style.height  = iframeWinBody.scrollHeight + scrollbarWidth + "px";
} 
//------------------ 교육/시험뉴스 !!! ----------------//	
// 풋터 Family Site 롤링......
function initScrollHorizon(container, content, left, right, strType) {
	var containerObj = document.getElementById(container);
	var contentObj = document.getElementById(content);
	var leftObj = document.getElementById(left);
	var rightObj = document.getElementById(right);
	if(strType == "EVENT")
	{
	var viewCnt = 4;
	var itemCnt = 4;
	}
	else
	{
	var viewCnt = 3;
	var itemCnt = 9;
	}
	var currentNo = 1;
	var moveWidth = 76;
	if (containerObj.offsetWidth > contentObj.offsetWidth)
	{
		return;
	}
	contentObj.innerHTML = contentObj.innerHTML + contentObj.innerHTML;
	function moveLeft() {
		currentNo++;
		if (currentNo == itemCnt + 1 || currentNo == 1) {
			currentNo = 1;
			contentObj.style.marginLeft = 0;
		} else {
			contentObj.style.marginLeft = (parseInt(contentObj.style.marginLeft) - moveWidth) + "px";
		}
	}
	function moveRight() {
		currentNo--;
		if (currentNo == 0) {
			contentObj.style.marginLeft = -(moveWidth * (itemCnt - 1)) + "px";
		} else if (currentNo == 1 - viewCnt) {
			currentNo = itemCnt - viewCnt + 1;
			contentObj.style.marginLeft = -((currentNo - 1) * moveWidth) + "px";
		} else {
			contentObj.style.marginLeft = (parseInt(contentObj.style.marginLeft) + moveWidth) + "px";
		}
	}
	leftObj.onclick = function() {
		moveLeft();
	}
	rightObj.onclick = function() {
		moveRight();
	}
}

// 우측 스카이 퀵 메뉴 
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 / 5;
		obj.style.top = obj.top + "px";
		
	}, 30)
}
/*********************************************** 인기수강신청 동작 함수 *********************************/
function initPopularLecture(n) {
    var Container = document.getElementById(n);
    var contObjs = new Array();
    var contCount;
    var listObjs;
    var tmpTdObjs = Container.getElementsByTagName('TD');
    var snapWrapObj;
    var listWrapObj;
    var tmpChildNodes;
    var cIdx = 0;
    var speed = 5000;
    /* 스냅영역, 리스트영역 추출 */
    for (var a = 0 ; a < tmpTdObjs.length ; a++ )
    {
        if (tmpTdObjs[a].className == "snap") { snapWrapObj = tmpTdObjs[a]; }
        else if (tmpTdObjs[a].className == "list") { listWrapObj = tmpTdObjs[a]; }
    }
    tmpChildNodes = snapWrapObj.childNodes;
    listObjs = listWrapObj.getElementsByTagName('A');
    /* 롤링 컨텐츠 추출 */
    for (var b = 0 ; b < tmpChildNodes.length ;  b++)
    {
        if (tmpChildNodes[b].tagName == "TABLE") { contObjs.push(tmpChildNodes[b]); }
    }
    contCount = contObjs.length;
    /* 리스트 링크 onclick 설정 */
    for (var c = 0 ; c < listObjs.length ; c++ )
    {
		listObjs[c].idx = c;
		listObjs[c].onmouseover = function () {
			ContHidden(cIdx);
			ContView(this.idx);
			cIdx = this.idx;
			return false;
		}
    }

    /* 마우스가 영역으로 들어오면 자동롤링 중지 */
    Container.onmouseover = function () {
        stopInterval();
    }
    /* 마우스가 영역에서 벗어나면 자동롤링 시작 */
    Container.onmouseout = function () {
        startInterval(speed);
    }

    /* 자동롤링 시작 */
    function startInterval(speed) {
        if (Container.rolling) { return; }
        Container.interval = setInterval(function() {
            Container.rolling = true;
            nextContView();
        }, speed);
    }
    /* 자동롤링 중지 */
    function stopInterval() {
        Container.rolling = false;
        clearInterval(Container.interval);
    }
    /* 다음 컨텐츠 Display */
    function nextContView() {
        ContHidden(cIdx);
        if (cIdx == contCount - 1) { ContView(0); cIdx = 0;}
        else { ContView(cIdx + 1); cIdx++;}
    }
    /* 컨텐츠 숨김 */
    function ContHidden(i) {
        contObjs[i].style.display = "none";
        listObjs[i].style.fontWeight = "normal";
    }
    /* 컨텐츠 보임 */
    function ContView(i) {
        contObjs[i].style.display = "block";
        listObjs[i].style.fontWeight = "bold";
        listObjs[i].style.color = "#222";
    }

    listObjs[cIdx].style.fontWeight = "bold";
    listObjs[cIdx].style.color = "#222";
    startInterval(speed);
}
/*********************************************** //인기수강신청 동작 함수 *********************************/       
/*********************************************** //셈플동영상 플레이어 함수 *********************************/

function View_VodSample(quality, prodCD, vodSeq, site)
{
    if(site != null && site == "0001")
    {
        window.open("./Lms/VodPlayer/PlayerSample.aspx?quality=" + quality + "&prodcd=" + prodCD + "&vodseq=" + vodSeq, "VOD", "left=0px, top=0,width=800px, height=500px");
    }
    else
    {
        window.open("./Common/Lms/VodPlayer/PlayerSample.aspx?quality=" + quality + "&prodcd=" + prodCD + "&vodseq=" + vodSeq, "VOD", "left=0px, top=0,width=800px, height=500px");
    }
}
/*********************************************** //셈플동영상 플레이어 함수 *********************************/                                                                                                                                
// 대교조직원 인증 팝업 오픈(08/11/28 pcj)
function OpenDaekyoMemberAuth(iMode)
{
    var url = "";
    var iWidth = 0;
    var iHeight = 0;
    if(iMode == 1)      // 소개회원
    {
	    url = "PopIntroMemberMain3.aspx";
	    iWidth = 500;   
	    iHeight = 320;  
    }
    else if(iMode == 2) // 조직원
    {	
	    url = "PopFamilyMemberMain.aspx";
	    iWidth = 520;
	    iHeight = 366;
    }
    window.open(WEB_PATH + "/Global/B2B/BU/" + url, "__DAEKYOMEMBER__", "menubar=no,status=no,toolbar=no,resizable=no,scrollbars=no,location=no,width=" + iWidth + ",height=" + iHeight).focus();
} 
/********************************************************************
입력값에 스페이스 이외의 의미있는 값이 있는지 체크
********************************************************************/
function g_isEmpty(obj) {
	var str = ((typeof obj == "object") ? obj.value : obj);
	
	if (str == null || str.replace(/ /gi,"") == "") {
		return true;
	}
	return false;
}

/*******************************************************************
썸네일 배너 롤링
********************************************************************/
function initThumbnailBanner(mode)
{   
    if(document.getElementById("thumbnail_0") != null)
    {
        if(thumbFlag)
        {
            var curView = 0;
            var totalView = 0;

            for(var i=0; ; i++)
            {
                var ob = document.getElementById("thumbnail_" + i);
            
                if(ob == null)
                {      
                    totalView = i-1;
                    break;
                }
                else
                {
                    if(ob.style.display == "block")
                    {
                        curView = i;
                        ob.style.display = "none";
                    }
                }
            }        
            
            if(mode == 'start' || totalView == curView)  //시작 || (1개뿐 또는 마지막)
            {
                document.getElementById("thumbnail_0").style.display = "block";           
            }
            else
            {
                document.getElementById("thumbnail_" + (curView+1)).style.display = "block";
            }	
        }
        
        setTimeout("initThumbnailBanner('')", 5000);
    }
}