﻿
/****** 플래쉬링크 링크 **************************************************************/

// new GNB
function GoSwfUrl01() { location.href = "/lgeri/about/about.asp"; }
function GoSwfUrl02() { location.href = "/lgeri/message/message.asp"; }
function GoSwfUrl03() { location.href = "/lgeri/group/group01.asp"; }
function GoSwfUrl04() { location.href = "/lgeri/recruit/recruit.asp"; }

// 홈 링크
function goHome() { location.href = "/"; }

// Economy
function goLink1() { location.href = "javascript:goLink1_1()"; }
function goLink1_1() { location.href = "/economy/domestic/listBoard.asp?grouping=02010100"; }
function goLink1_2() { location.href = "/economy/finance/listBoard.asp?grouping=02010200"; }
function goLink1_3() { location.href = "/economy/overseas/listBoard.asp?grouping=02010300"; }
function goLink1_4() { location.href = "/economy/expert/listBoard.asp?grouping=02050300"; }

// Industry
function goLink2() { location.href = "javascript:goLink2_1()"; }
function goLink2_1() { location.href = "/industry/general/listBoard.asp?grouping=02020100"; }
function goLink2_2() { location.href = "/industry/electronic/listBoard.asp?grouping=02020200"; }
function goLink2_3() { location.href = "/industry/chemical/listBoard.asp?grouping=02020300"; }
function goLink2_4() { location.href = "/industry/etc/listBoard.asp?grouping=02020400"; }

// Economic Outlook
function goLink3() { location.href = "/outlook/listBoard.asp?grouping=02030000"; }

// Publications
function goLink4() { location.href = "javascript:goLink4_1()"; }
function goLink4_1() { location.href = "/publication/keb/kebstop.asp"; }
function goLink4_2() { location.href = "/publication/report/list.asp"; }

// Indicators
function goIndicator() { location.href = "javascript:goIndicator_1()"; }
function goIndicator_1() { location.href = "/indicator/daily/daily.asp"; }
function goIndicator_2() { location.href = "/indicator/economic/list01.asp"; }
function goIndicator_3() { location.href = "/indicator/forecast/korea.asp"; }

// 국문사이트
function goKorean() { //location.href = "http://www.lgeri.com"; 
    location.href = "/login/other_login.asp";
}

// 이용안내
function goUseinfo() { location.href = "/useinfo/useinfo.asp"; }

// 사이트맵
function goSitemap() { location.href = "/sitemap/sitemap.asp"; }
function goCopyright() { location.href = "/policy/copyright/copyright.asp"; }
function goSiteLink() { location.href = "/siteLink/economy/list01.asp"; }
function goCopyrightE() { location.href = "/policy/private/private.asp"; }




/****** 아크로벳 리더 다운로드 링크 **************************************************************/
function getAcrobat() {
    window.open("http://www.korea.adobe.com/products/acrobat/readstep2.html", "", "");
}

/****** 좌측메뉴 관련 함수 **************************************************************/
function setLeftMenu(thisId) {
    var nowMenuObj = document.getElementById(thisId);
    if (nowMenuObj) {
        nowMenuObj.thisOnOff = "false";
        nowMenuObj.src = getThisSrc(nowMenuObj.src, "on");
    }
}

function LeftOnOff(flag) {
    var source = event.srcElement;
    if (document.images && source.tagName == "IMG") {
        if (typeof (source.thisOnOff) == "undefined") return;
        if (source.thisOnOff == "false") return;
        imgPath = source.src;
        source.src = getThisSrc(imgPath, flag);
    }
}

function getThisSrc(imgPath, flag) {
    var imgPathLen = imgPath.length;
    var imgPathFlag = imgPath.lastIndexOf("/");
    var imgName = imgPath.substring(0, imgPathFlag + 1);
    var fileType = imgPath.substring(imgPath.lastIndexOf("."), imgPathLen);
    var fileName = imgPath.substring(imgPathFlag + 1, imgPath.lastIndexOf("_"));
    var nowImgUrl = imgName + fileName + "_" + flag + fileType;
    return nowImgUrl;
}


/****** 좌측 마이페이지 More 버튼 액션 **************************************************************/
function showMoreList() {
    setDisplay("myPageMoreBtn", "none");
    setDisplay("myPageMoreMenu", "");
}

function hiddenMoreList() {
    setDisplay("myPageMoreBtn", "");
    setDisplay("myPageMoreMenu", "none");
}

function setDisplay(objId, mode) {
    var obj = document.getElementById(objId);
    if (obj) obj.style.display = mode;
}


/****** Footer Family Site **************************************************************/
function goSelectedLink(thisURL) {
    if (thisURL == "list") {
        location.href = "/familySite/list.asp";
        return;
    }
    else if (thisURL != null && thisURL != "") {
        window.open(thisURL, "", "");
        return;
    }
}

/****** 셀렉트박스 비활성화 On Off**************************************************************/
function changeSelectbox(thisId, mode) {
    var thisObj = document.all[thisId];
    var nowMode = false;
    if (mode == "off") nowMode = true;
    thisObj.disabled = nowMode;
}


/****** 체크박스 비활성화 On Off**************************************************************/
function changeCheckbox(thisId, mode) {
    var thisObj = document.all[thisId];
    var nowMode = false;
    if (mode == "off") nowMode = true;
    for (i = 0; i < thisObj.length; i++) {
        thisObj[i].disabled = nowMode;
    }
}


/****** 체크박스 설명문구 비활성화 On Off**************************************************************/
function changeTextColor(thisId, mode) {
    var i = 1;
    var textColor = "#666666";
    if (mode == "off") textColor = "#A6A6A3";
    while (document.getElementById(thisId + i)) {
        document.getElementById(thisId + i).style.color = textColor;
        i = i + 1;
    }
}


/****** 이미지 롤오버 **************************************************************/
function EImgChg(flag) {
    source = event.srcElement;
    if (document.images && source.tagName == "IMG") {
        if (source.name == '') return;
        imgElement = source.name;
        imgPath = source.src;
        imgPathLen = imgPath.length;
        imgPathFlag = imgPath.lastIndexOf("/");
        imgName = imgPath.substring(0, imgPathFlag + 1);
        fileType = imgPath.substring(imgPath.lastIndexOf("."), imgPathLen);
        document.images[imgElement].src = imgName + imgElement + "_" + flag + fileType;
    }
}


/****** 팝업창 **************************************************************/
function popOpen(url) {
    var positionX = (screen.width - 400) / 2;
    var positionY = (screen.height - 250) / 2;
    window.open(url, "", "left=" + positionX + ",top=" + positionY + ",width=400,height=250,toolbar=no,scrollbars=no");
}


/****** 팝업창 리사이즈 **************************************************************/
function popResize() {
    var thisX = document.getElementById("offsetTable").offsetWidth;
    var thisY = document.getElementById("offsetTable").offsetHeight;
    var maxThisX = screen.width - 50;
    var maxThisY = screen.height - 80;
    var marginY = 99; //템플릿의 헤더와 풋터 높이 + 알파
    if (thisX > maxThisX) {
        window.document.body.scroll = "yes";
        thisX = maxThisX;
    }
    if (thisY > maxThisY - marginY) {
        window.document.body.scroll = "yes";
        thisX += 19;
        thisY = maxThisY - marginY;
    }
    window.resizeTo(thisX + 10, thisY + marginY);

    var windowX = (screen.width - (thisX + 10)) / 2;
    var windowY = (screen.height - (thisY + marginY)) / 2 - 20;
    window.moveTo(windowX, windowY);
}


function _pdfview(grouping, seq, filename) {
    window.open("/common/popup/pdfview.asp?grouping=" + grouping + "&seq=" + seq + "&filename=" + filename, "pdfview" + seq + grouping, "left=100, top=50, width=700, height=600, scrollbars=yes, toolbars=yes, resizable=yes")
}


////////////////////////////////
//	enter 키 처리
////////////////////////////////
function _keyEnter(doThat) {
    if (event.keyCode == 13) {
        location.href = doThat;
    }
}


/* gnb control */

function clearPnode(el) {
	var liarr = [];
	var wrap = document.getElementById(el);
	for (var i=0;i<el.childNodes.length;i++) {
		if (el.childNodes[i].nodeType == '1') {
			liarr.push(el.childNodes[i]);
		}
	}
	return liarr;
}
function gnbMain(obj) {
	var wrap = document.getElementById(obj),
		item = clearPnode(wrap);
	for (var i=0;i<item.length;i++) {
		item[i].onmouseover = function() {
			this.className = 'hover';
		}
		item[i].onmouseout = function() {
			this.className = this.className.replace('hover','');
		}
	}
}
function imgrollControl(obj) {
	var wrap = document.getElementById(obj),
		item = wrap.getElementsByTagName('img');
	for (var i=0;i<item.length;i++)	{
		item[i].onmouseover = function() {
			if (!this.className) {
				this.src = this.src.replace('_off','_on')
			}
		}
		item[i].onmouseout = function() {
			if (!this.className) {
				this.src = this.src.replace('_on','_off')
			}
		}
	}
}
/* //gnb control */

/* tabmenu */
function tab(obj) {
	var wrap = document.getElementById(obj),
		anc = wrap.getElementsByTagName('a');
		wrap.tmp = 0;
	for (var i=0;i<anc.length;i++) {
		anc[i].num = i;
		anc[i].onmouseover = function() {
			var visible = document.getElementById(anc[this.num].href.split('#')[1]);
			var hidden = document.getElementById(anc[wrap.tmp].href.split('#')[1]);
			anc[this.num].parentNode.className = 'on';
			visible.style.display = 'block';
			if (wrap.tmp != this.num) {
				anc[wrap.tmp].parentNode.className = '';
				hidden.style.display = 'none';
			}
			wrap.tmp = this.num;
		}
	}
	anc[wrap.tmp].parentNode.className = 'on';
	document.getElementById(anc[wrap.tmp].href.split('#')[1]).style.display = 'block';
}
function rankShow(obj) {
	var target = document.getElementById(obj);
	target.onmouseover = function() {this.className = 'add_bg';} 
	target.onmouseout = function() {this.className = '';} 
}
/*
function familyShow(obj,child) {
	var wrap = document.getElementById(obj);
	wrap.style.top = '4px';
	var target = document.getElementById(child);
	wrap.onclick = function() {
		wrap.style.top = (wrap.style.top == '4px') ? '-191px' : '4px';
		target.style.display = (target.style.display == '') ? 'block' : '';
	}
	wrap.onblur = function() {
		wrap.style.top = (wrap.style.top == '4px') ? '-191px' : '4px';
		target.style.display = (target.style.display == '') ? 'block' : '';
	}
}
*/
function familyShow(obj,child) {
	var wrap = document.getElementById(obj);
	wrap.style.top = '4px';
	var target = document.getElementById(child);
	wrap.onblur = function() {
		wrap.style.top = '4px';
		target.style.display = '';
	}
	wrap.onclick = function() {
		wrap.style.top = (wrap.style.top == '4px') ? '-191px' : '4px';
		target.style.display = (target.style.display == '') ? 'block' : '';
	}
}
function inpBoxFocus(obj) {
	var target = document.getElementById(obj);
	target.onclick = function() {this.className = 'txt';}
	target.onblur = function() {
		if (target.value == null || target.value =="" ) {
			this.className = 'txt bg';
		} else {
			this.className = 'txt';
		}
	}
}
/* //tabmenu */


/* search */

function _leftsearchit(srchword) {
    var srchpath, srchtype;

    document.getElementsByName("leftsrchword").value = srchword;

    if (document.getElementById("leftsrchtype").value == "A")
        srchpath = "M";
    else
        srchpath = "C";

    //if (document.getElementsByName("leftsrchtype").value == "undefined")
        srchtype = "";
    
    if (srchword == "- 검색어입력" || srchword == "" || srchword.substr(0, 1) == " ") {
        alert("검색어를 입력해 주세요.");
        document.getElementsByName("leftsrchword").value = "";
        document.getElementsByName("leftsrchword").focus();
    }
    else
        location.href = "/search/all/list.asp?srchtype=" + srchtype + "&srchpath=" + srchpath + "&srchword=" + escape(srchword);
}

function _leftkeyEnter(doThat) {
    if (event.keyCode == 13) {
        _leftsearchit(document.getElementsByName("leftsrchword").value);
    }
}


/* search */

/*******************************************************************************
SNS로 퍼가기
type : 1(Twitter), 2(FaceBook), 3(me2Day)    
*******************************************************************************/
function goSNS(type, url, title) {

    var actionURL;

    switch (type) {

        case 1:
            actionURL = "http://twitter.com/home/?status=" + title + url;
            break;

        case 2:
            actionURL = "http://www.facebook.com/sharer.php?u=" + url + "&t=" + title;

            break;

        case 3:
            actionURL = "http://me2day.net/posts/new?new_post[body]=" + title + " - \"내용자세히 보기\":" + url + "&new_post[tags]=";
            break;
    }

    window.open(actionURL, "_blank");
}
