﻿// 채용페이지
// 채용시 URL : /lgeri/recruit/recruit.asp
// 미채용시 URL : /lgeri/recruit/noRecruit.asp
function goRecruit() { location.href = "/lgeri/recruit/list.asp"; }
//function goRecruit_1() { location.href = "/lgeri/recruit/Recruit_ing.asp"; }


/****** 플래쉬링크 링크 **************************************************************/

// 홈 링크
function goHome() { location.href = "/"; }

// 경제정보
function goLink1() { location.href = "javascript:goLink1_1()"; }
function goLink1_1() { location.href = "http://www.lgeri.com/economy/domestic/listWebzine.asp?grouping=01010100"; }
function goLink1_2() { location.href = "http://www.lgeri.com/economy/overseas/listWebzine.asp?grouping=01010200"; }
function goLink1_3() { location.href = "http://www.lgeri.com/economy/finance/listWebzine.asp?grouping=01010300"; }

// 경영정보
function goLink2() { location.href = "javascript:goLink2_1()"; }
function goLink2_1() { location.href = "http://www.lgeri.com/management/strategy/listWebzine.asp?grouping=01020100"; }
function goLink2_2() { location.href = "http://www.lgeri.com/management/organization/listWebzine.asp?grouping=01020200"; }
function goLink2_3() { location.href = "http://www.lgeri.com/management/marketing/listWebzine.asp?grouping=01020300"; }
function goLink2_4() { location.href = "http://www.lgeri.com/management/finance/listWebzine.asp?grouping=01020400"; }
function goLink2_5() { location.href = "http://www.lgeri.com/management/general/listWebzine.asp?grouping=01020500"; }

// 산업정보
function goLink3() { location.href = "javascript:goLink3_1()"; }
function goLink3_1() { location.href = "http://www.lgeri.com/industry/general/listWebzine.asp?grouping=01030100"; }
function goLink3_2() { location.href = "http://www.lgeri.com/industry/electronic/listWebzine.asp?grouping=01030200"; }
function goLink3_3() { location.href = "http://www.lgeri.com/industry/chemical/listWebzine.asp?grouping=01030300"; }
function goLink3_4() { location.href = "http://www.lgeri.com/industry/etc/listWebzine.asp?grouping=01030400"; }

// 발간물
function goLink4() { location.href = "javascript:goLink4_1()"; }
function goLink4_1() { location.href = "http://www.lgeri.com/publication/businessInsight/list.asp"; }
function goLink4_2() { location.href = "http://www.lgeri.com/publication/report/list.asp"; }
function goLink4_3() { location.href = "http://www.lgeri.com/publication/prospect/list.asp"; }
function goLink4_4() { location.href = "http://www.lgeri.com/publication/book/contents.asp"; }
function goLink4_5() { location.href = "http://www.lgeri.com/publication/application/appForm.asp"; }
function goLink4_6() { location.href = "http://www.lgeri.com/publication/weekly/list.asp"; }
function goLink4_7() { location.href = "http://www.lgeri.com/publication/summary/list.asp"; }

// 경제동향지표
function goTrend() { location.href = "javascript:goTrend_1()"; }
function goTrend_1() { location.href = "http://www.lgeri.com/trend/daily/daily.asp"; }
function goTrend_2() { location.href = "http://www.lgeri.com/trend/korea/korea.asp"; }
function goTrend_3() { location.href = "http://www.lgeri.com/trend/world/world.asp"; }
function goTrend_4() { location.href = "http://www.lgeri.com/trend/indicator/list01.asp"; }

// 영문사이트
function goEnglish() { //location.href = "http://english.lgeri.co.kr/?a"; 
    location.href = "http://www.lgeri.com/login/other_login.asp";
}

// 이용안내
function goUseinfo() { location.href = "http://www.lgeri.com/useinfo/useinfo.asp"; }

// 사이트맵
function goSitemap() { location.href = "http://www.lgeri.com/sitemap/sitemap.asp"; }

// 이메일 수집 거부
function winOpen() {
    window.open('http://www.lgeri.com/common/popup/no_email.asp', 'email', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
}


function winOpenphone() {
    window.open('http://www.lgeri.com/common/popup/phone.asp', 'phone', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
}

// 오시는 길
function winOpenmap() {
    window.open('http://www.lgeri.com/common/popup/popup_map.asp', 'phone', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
}

/****** 아크로벳 리더 다운로드 링크 **************************************************************/
function getAcrobat() {
    window.open("http://www.korea.adobe.com/products/acrobat/readstep2.html", "", "");
}

/****** 2011.08.08. 라이프스타일보고서 신청추가  **************************************************************/
function getAppFormLife() {
   // window.open("http://www.korea.adobe.com/products/acrobat/readstep2.html", "", "");
   window.open('/publication/application/AppFormLife.asp', 'FormLife', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
}

/****** 좌측메뉴 관련 함수 **************************************************************/
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;
    }
}

/****** 체크박스 체크**************************************************************/
function checkCheckbox(thisId, mode) {
    var thisObj = document.all[thisId];

    for (i = 0; i < thisObj.length; i++) {
        thisObj[i].checked = mode;
    }
}

/****** 체크박스 설명문구 비활성화 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 popOpen2(url, width, height, toolbar, scrollbars, resize) {
    var positionX = (screen.width - 400) / 2;
    var positionY = (screen.height - 250) / 2;
    window.open(url, "", "left=" + positionX + ",top=" + positionY + ",width=" + width + ",height=" + height + ",toolbar=" + toolbar + ",scrollbars=" + scrollbars + ",resizable=" + resize);
}

/****** 팝업창 리사이즈 **************************************************************/
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 (isSP2()) marginY += 25	// XP SP2일 경우, 팝업창에 강제로나오는 상태바영역만큼 더해준다
    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);
}


/****** 윈도우 XP 서비스팩 설치여부 체크 **************************************************************/
function isSP2() { // 결과가 true이면 XP서비스팩2가 설치된 것임.
    return (window.navigator.userAgent.indexOf("SV1") != -1);
}


function _pdfview(grouping, seq, filename) {
    window.open("http://www.lgeri.com/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")
}


function _sempdfview(idx, filename) {
    window.open("http://www.lgeri.com/common/popup/sempdfview.asp?idx=" + idx + "&filename=" + filename, "sempdfview", "left=100, top=50, width=700, height=600, scrollbars=yes, toolbars=yes, resizable=yes")
}


////////////////////////////////
//	마이폴더에 담기...
////////////////////////////////
function _myFolder(grouping_seq, typ) {
    if (grouping_seq == '') {
    } else {
        popOpen('/common/popup/inputMyfolder.asp?grouping_seq=' + grouping_seq + '&typ=' + typ);
        /*
        document.frm.myfolders.value = "1";
        document.frm.method="post";
        document.frm.target="_blank";
        document.frm.action = "http://www.lgeri.com/common/_include/inputMyfolder.asp?grouping_seq="+grouping_seq;
        document.frm.submit();
        */
    }
}


////////////////////////////////
//	enter 키 처리
////////////////////////////////
function _keyEnter(doThat) {
    if (event.keyCode == 13) {
        location.href = doThat;
    }
}


//!!!!!!!!!!!!!!!!!!!!!!!!!!	오른쪽 마우스 막음
//document.onselectstart = function() {return false}
//document.oncontextmenu = function() {return false}

/* 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 wraper = document.documentElement;
	var wrap = document.getElementById(obj);
	wrap.style.top = '4px';
	var targetNode = null;
	var hook = document.getElementById(child);

	wraper.onclick = function(e) {
		var targ;
		if (!e) var e = window.event;
		if (e.target) targ = e.target;
		else if (e.srcElement) targ = e.srcElement;

		if (targ.nodeType == 3) // defeat Safari bug
			targ = targ.parentNode;

		targetNode = targ;
		while(targetNode != wrap && targetNode != null)
			targetNode = targetNode.parentNode;

		if (targetNode != null) {	
			wrap.style.top = (wrap.style.top == '4px') ? '-191px' : '4px';
			hook.style.display = (hook.style.display == 'block') ? 'none' : 'block';
		} else {
			wrap.style.top = '4px';
			hook.style.display = 'none';
		}
	};
}
/* //tabmenu */


/* search */

function _leftsearchit(srchword) {
    var srchpath, srchType;

    document.all["topSrchword"].value = srchword;
	srchType = "A";
    
//	if (document.all["leftsrchtype"].value == "A") {
        srchpath = "M";
//    }
//    else {
//        srchpath = "C";
//    }

    if (srchword == "- 검색어입력" || srchword == "" || srchword.substr(0, 1) == " ") {
        alert("검색어를 입력해 주세요.");
        document.all["topSrchword"].value = "";
        document.all["topSrchword"].focus();
    } else {
        location.href = "http://www.lgeri.com/search/all/list.asp?srchtype=" + srchType + "&srchpath=" + srchpath + "&srchword=" + srchword;
    }
}

function _leftkeyEnter(doThat) {
    if (event.keyCode == 13) {
        _leftsearchit(document.all["topSrchword"].value);
    }
}

/*
function _leftsearchit__(srchword) {
    var srchpath;

    document.all["leftsrchword"].value = srchword;

    if (document.all["leftsrchtype"].value == "A") {
        srchpath = "M";
    }
    else {
        srchpath = "C";
    }

    if (srchword == "- 검색어입력" || srchword == "" || srchword.substr(0, 1) == " ") {
        alert("검색어를 입력해 주세요.");
        document.all["leftsrchword"].value = "";
        document.all["leftsrchword"].focus();
    } else {
        location.href = "http://www.lgeri.com/search/all/list.asp?srchtype=" + document.all["leftsrchtype"].value + "&srchpath=" + srchpath + "&srchword=" + srchword;
    }
}

function _leftkeyEnter__(doThat) {
    if (event.keyCode == 13) {
        _leftsearchit(document.all["leftsrchword"].value);
    }
}
*/

function _topSearchit() {
    var srchpath, srcType;

    srchword = document.all["topSrchword"].value;
    srcType = "A";
    srchpath = "M";
    

    if (srchword == "- 검색어입력" || srchword == "" || srchword.substr(0, 1) == " ") {
        alert("검색어를 입력해 주세요.");
        document.all["topSrchword"].value = "";
        document.all["topSrchword"].focus();
    } else {
       var str = srchword ;
       var count=0;
       for (var i=0; i < str.length; i++) { 
           ch_char = str.charAt(i);
           ch = ch_char.charCodeAt();
           if( (ch >= 33 && ch <= 47) || (ch >= 58 && ch <= 64) || (ch >= 91 && ch <= 96) || (ch >= 123 && ch <= 126) ) {
              count++;
           }
       }    
       if(count!=0){
             alert("검색시 특수문자는 사용할 수 없습니다.");
             document.all["topSrchword"].value = "";
             document.all["topSrchword"].focus();
           
       }else{
             location.href = "http://www.lgeri.com/search/all/list.asp?srchtype=" + srcType + "&srchpath=" + srchpath + "&srchword=" + srchword;
       }
    }
}

function _topKeyEnter(doThat) {
    if (event.keyCode == 13) {
        _topSearchit();
    }
}

/* 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");
}
