﻿
var iep_vs = 6;
if (navigator.userAgent.indexOf("MSIE") != -1)
    iep_vs = parseFloat(navigator.appVersion.split("MSIE")[1]);


//콤마 입력
function commaset(oo)
{ 
      oo.value=number_format(oo.value);
}
// 숫자형으로 변경 (',' 포함)
function number_format(numstr)
{
  numstr = String(numstr);
  numstr= numstr.replace(/,/gi,"");
  var re0 = /(\d+)(\d{3})($|\..*)/;
  if (re0.test(numstr))
    return numstr.replace(re0,function(str,p1,p2,p3) { return number_format(p1) + "," + p2 + p3; });
  else
    return numstr;
}

//숫자만 입력가능
function KD_NumberCheck()  
{ 
   k=event.keyCode;
   if (k == 9 || k== 13 || k== 46 || k== 8 || k==37 || k ==39 || ( k>=48 && k<= 57) ||( k>=96 && k<= 105) )   
    // 189- ,46 del, 8 back, 190 . ,37 L, 39 R,38 u,40 D,191 / ,0 tab
        event.returnValue = true;
   else
        event.returnValue = false;

}  
//숫자 - 포함입력가능
function KD_NumberPlusCheck()  
{ 
   k=event.keyCode;
   if (k == 9 || k== 13 || k== 189 || k== 190 || k== 46 || k== 8 || k==37 || k ==39 || ( k>=48 && k<= 57) ||( k>=96 && k<= 105) )   
    // 189- ,46 del, 8 back, 190 . ,37 L, 39 R,38 u,40 D,191 / ,0 tab
        event.returnValue = true;
   else
        event.returnValue = false;
   
}  

function ftConfirm(mode)
{       
    msg =mode;
	if(mode=="write"){
		msg = "등록 하시겠습니까?";
	}else if(mode=="modify"){
		msg = "수정 하시겠습니까?";
	}else if(mode=="reply"){
		msg = "답변을 등록 하시겠습니까?";
	}else if(mode=="delete"){
		msg = "삭제하시겠습니까?";
	}
    if (confirm(msg) == false) 
    {
       try {
              event.returnValue = false; 
         }catch(e){}
       return false;
    }
    return true;
}

//메세지를 받아서 확인창 DP
function ConfMessage(Message)
{
    if(confirm(Message) == false)
        return false;
    else
        return true;
}


function ftValidate(objname, msg, len) {
    var obj = document.getElementById(objname);
    if (obj.value == "" ) {
        alert(msg);
        obj.focus();
        return false;
    }
    if ( len != null && obj.value.length < len) {
        alert(msg+"(글자수 부족)");
        obj.focus();
        return false;
    }
    return true;
}

//trim
String.prototype.trim = function()
{ 
   return this.replace(/(^\s*)|(\s*$)/g, "");
}


//이메일 체크
function isValidEmail(itemValue)
{
	try
	{
		if (!(/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test(itemValue))) 
		{
			return false;
		}
		else 
		{
			return true;
		}
	} 
	catch (exception)
	{
		return false;	
	}
}

//전화번호 유효성 체크
function isValidPhoneNumber(itemValue)
{
	try
	{
		if (!(/^\d{2,3}-\d{3,4}-\d{4,4}$/.test(itemValue))) 
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	catch (exception)
	{
		return false;		
	}
}

// 기능   : 엑셀저장

function SaveExcel()
{
	//저장할 내용 불러오기
	var contentsText = document.body.innerHTML;
	var PrnStart   = contentsText.toLowerCase().indexOf("<!-- print start -->");
	var PrnEnd     = contentsText.toLowerCase().indexOf("<!-- print end -->");
	var PrnContent = contentsText.substring(PrnStart, PrnEnd);

	PrnContent = PrnContent.replace("<!-- print start -->", "");
	PrnContent = PrnContent.replace("<!-- print end -->", "");
	
	ContentsText = PrnContent;
	
	//Hidden객체에 저장 후 페이지 전송
	document.getElementById("hdnExcelBody").value = ContentsText;
	document.forms("frmExcel").submit();
}

//영문자와 숫자만의 조합인지 체크
function check_char(input_str)
{
	var alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
	var numeric = '1234567890';
	var nonkorean = alpha+numeric; 
	
	for (var i=0; i < input_str.length; i++ )  {
		if( nonkorean.indexOf(input_str.substring(i,i+1)) < 0) {
			break ; 
		}
	}
	
	if ( i != input_str.length ) {
		return false ; 
	}
	else{
		return true ;
	} 
	
	return true;
}

// 주민번호 유효성 체크
function JuminCheck(no1, no2)   
{   
    if (no1.length != 6)   
    {   
        return false;    
    }   

    else if (no2.length != 7)   
    {   
        return false;       
    }   

    else 
    {
        var str_serial1 = no1;   
        var str_serial2 = no2;   
        
        var digit=0   
        for (var i=0;i<str_serial1.length;i++)
        {   
            var str_dig=str_serial1.substring(i,i+1);   
            if (str_dig<'0' || str_dig>'9')
            {
                digit=digit+1    
            }   
        }   
        
        if ((str_serial1 == '') || ( digit != 0 ))   
        {   
            return false;       
        }   
        
        var digit1=0   
        for ( i=0;i<str_serial2.length;i++)
        {
            var str_dig1=str_serial2.substring(i,i+1);   
            if (str_dig1<'0' || str_dig1>'9')
            {
                digit1=digit1+1    
            }   
        }   

        if ((str_serial2 == '') || ( digit1 != 0 ))   
        {   
            return false;      
        }   

        if (str_serial1.substring(2,3) > 1)   
        {   
            return false;      
        }   

        if (str_serial1.substring(4,5) > 3)   
        {   
            return false;       
        }    

        if (str_serial2.substring(0,1) > 4 || str_serial2.substring(0,1) == 0)   
        {   
            return false;       
        }   

        var a1=str_serial1.substring(0,1)   
        var a2=str_serial1.substring(1,2)   
        var a3=str_serial1.substring(2,3)   
        var a4=str_serial1.substring(3,4)   
        var a5=str_serial1.substring(4,5)   
        var a6=str_serial1.substring(5,6)
        
        var check_digit=a1*2+a2*3+a3*4+a4*5+a5*6+a6*7   

        var b1=str_serial2.substring(0,1)   
        var b2=str_serial2.substring(1,2)   
        var b3=str_serial2.substring(2,3)   
        var b4=str_serial2.substring(3,4)   
        var b5=str_serial2.substring(4,5)   
        var b6=str_serial2.substring(5,6)   
        var b7=str_serial2.substring(6,7)   

        check_digit=check_digit+b1*8+b2*9+b3*2+b4*3+b5*4+b6*5    

        check_digit = check_digit%11   
        check_digit = 11 - check_digit   
        check_digit = check_digit%10   

        if (check_digit != b7)   
        {   
            return false;       
        }           
        else  
        {   
            return true;       
        }   
    }
}
// 재외국인 번호 체크
function check_fgnno(fgnno) {
    var sum = 0;
    var odd = 0;
    buf = new Array(13);
    for (i = 0; i < 13; i++) { buf[i] = parseInt(fgnno.charAt(i)); }
    odd = buf[7] * 10 + buf[8];
    if (odd % 2 != 0) { return false; }
    if ((buf[11] != 6) && (buf[11] != 7) && (buf[11] != 8) && (buf[11] != 9)) {
        return false;
    }
    multipliers = [2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5];
    for (i = 0, sum = 0; i < 12; i++) { sum += (buf[i] *= multipliers[i]); }
    sum = 11 - (sum % 11);
    if (sum >= 10) { sum -= 10; }
    sum += 2;
    if (sum >= 10) { sum -= 10; }
    if (sum != buf[12]) { return false }
    return true;
}
// 사업자등록번호 체크
function check_busino(vencod) {
    var sum = 0;
    var getlist = new Array(10);
    var chkvalue = new Array("1", "3", "7", "1", "3", "7", "1", "3", "5");
    for (var i = 0; i < 10; i++) { getlist[i] = vencod.substring(i, i + 1); }
    for (var i = 0; i < 9; i++) { sum += getlist[i] * chkvalue[i]; }
    sum = sum + parseInt((getlist[8] * 5) / 10);
    sidliy = sum % 10;
    sidchk = 0;
    if (sidliy != 0) { sidchk = 10 - sidliy; }
    else { sidchk = 0; }
    if (sidchk != getlist[9]) { return false; }
    return true;
}

//새창
function winOpen(pUrl, pName, pW, pH, sb, rs, etc, pL, pT) {

        if (typeof (pName) == "undefined") {
            pName = "_blank";
        }
        if (typeof (sb) == "undefined") {
            sb = "yes";
        }
        if (typeof (rs) == "undefined") {
            rs = "yes";
        }
        if (typeof (pL) == "undefined") {
            var winWidth = window.screen.width;    //해상도가로
            pL = parseInt((winWidth - pW) / 2);
        }
        if (typeof (pT) == "undefined") {
            var winHeight = window.screen.height;     //해상도세로
            pT = parseInt((winHeight - pH) / 2);
        }
        if (typeof (etc) == "undefined")
            etc = "directories = yes, status = yes, menubar = yes ,location=yes ,titlebar=yes ,toolbar=yes";

        if (typeof (pW) == "undefined") {
            var newWin = window.open(pUrl, pName);
            newWin.focus();
        }
        else {
            var newWin = window.open(pUrl, pName, "width=" + pW + ",height=" + pH + ",scrollbars=" + sb + ",resizable=" + rs + ",left=" + pL + ",top=" + pT + "," + etc);
            newWin.focus();
        }


    }
    function winPopup(pUrl, pName, pW, pH, pL, pT) {
        winOpen(pUrl, pName, pW, pH, "no", "no", "directories = no, status = no, menubar =no", pL, pT);
    }

  
    function setPng24(obj) {
             if (obj.className.indexOf('png24') < 0  || iep_vs != 6) {
                 return '';
             }
             obj.width = obj.height = 1;
             obj.className = obj.className.replace(/\bpng24\b/i, '');
             obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + obj.src + "', sizingMethod='image');";
             obj.src = 'about:blank';
             
             return '';
         }



    /* ie 6.0 background 사용시 flicker 현상 방지 */
    try {
        document.execCommand('BackgroundImageCache', false, true);
    } catch (e) { }



    //게시물에서 내용 이미지 리사이즈 시키기
    function ftImg_resize(imgname, wsize) {

        var obj = document.getElementsByName(imgname);
        for (i = 0; i < obj.length; i++) {
            try {
                var newImg = new Image();
                newImg.src = obj[i].src;
                //            if (newImg.complete == true) {
                imgw = newImg.width;
                imgh = newImg.height;
                if (imgw > wsize) {
                    obj[i].height = parseInt((wsize * imgh) / imgw);
                    obj[i].width = wsize;
                    //                }
                }
            } catch (ex) { }

        }
    }


    var imgrepeatcommon = 0;

    function ftImg_resizeXY(imgid, wsize, hsize) {

        try {
            var obj = document.getElementById(imgid);
            var newImg = new Image();
            newImg.src = obj.src;
            if (newImg.complete == true) {
                imgw = newImg.width;
                imgh = newImg.height;
                if (imgh / imgw >= hsize / wsize) {
                    obj.height = parseInt((wsize * imgh) / imgw);
                    obj.width = wsize;

                }
                else {
                    obj.width = parseInt((hsize * imgw) / imgh);
                    obj.height = hsize;

                }
                imgrepeatcommon = 0;
            }
            else {
                if (++imgrepeatcommon < 5)
                    setTimeout("ftImg_resizeXY('" + imgid + "'," + wsize + "," + hsize + ")", 200);
                else
                    imgrepeatcommon = 0;
            }
        } catch (ex) { }


    }


    //아이프레임 리사이즈
    function frResizeiFrame(Id) {
        var obj = document.getElementById(Id);
        try {
            var contentObj;
            if (obj.contentWindow) contentObj = obj.contentWindow.document;
            else contentObj = eval(Id + ".document");

            var Body;
            if (obj.contentWindow) {
                Body = contentObj.getElementsByTagName('BODY');
                Body = Body[0];
            }
            else
                Body = contentObj.body;

            obj.style.height = Body.scrollHeight;

        } catch (e) {
        }

        setTimeout("resizeiFrame('" + Id + "')", 200);
    }

    /**
    * 쿠키 셋팅
    * @param name 쿠키이름
    * @param value 쿠키값
    * @param expiredays 날짜 ( 1:하루 )
    *
    * setCookie( "Notice", "done" , 1); 하루동안 쿠키 저장
    */
    function setCookie(CookieName, CookieValue, CookieDay) {
        var objCookieTime = new Date();
        objCookieTime.setTime(objCookieTime.getTime() + (CookieDay * 86400 * 1000));
        if (CookieDay) CookieDay = "expires=" + objCookieTime.toGMTString() + ";";
        else CookieDay = "";
        document.cookie = CookieName + "=" + CookieValue + "; " + CookieDay;
    }

    function SetCookie(name, value, expires, path, domain, secure) {
        document.cookie = name + "=" + escape(value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "");
    }
    /**
    * 쿠키값 가져오기
    * @param name 쿠키이름
    * @return String 쿠키값
    *
    * getCookie(쿠키이름)
    */
    function getCookie(name) {
        var prefix = name + "=";
        var cookieStartIndex = document.cookie.indexOf(prefix);
        if (cookieStartIndex == -1)
            return "";
        var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length);
        if (cookieEndIndex == -1)
            cookieEndIndex = document.cookie.length;
        return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex));
    }
    /**
    * 쿠키 소멸
    * @param name 쿠키이름
    */
    function clearCookie(name) {
        var today = new Date();
        //어제 날짜를 쿠키 소멸 날짜로 설정한다.
        var expire_date = new Date(today.getDate() - 1);
        document.cookie = name + "= " + "; path=/; expires=" + expire_date.toGMTString();
    }






    /**
    * 플래시 쓰기
    * @param fSrc 플래시경로
    * @param sWidth 넓이
    * @param sHeight 높이
    * @param fVars 값들
    * @param fId 아이디
    * @param fName 이름
    * @param fBgcolor 배경색
    * @param fWmode wmode
    */
    function ShowFlash(fSrc, sWidth, sHeight, fVars, fId, fName, fBgcolor, fWmode) {

        if (!fVars) fVars = "";
        if (!fId) fId = "";
        if (!fName) fName = "";

        if (!fBgcolor) fBgcolor = "#ffffff";
        //transparent | notransparent
        if (!fWmode) fWmode = "transparent";

        var _protocol = location.protocol;
        var str = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" '
		+ 'codebase="' + _protocol + '//fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,24,0"'
		+ ' id="' + fId + '" name="' + fName + '"'
		+ ' width="' + sWidth + '" height="' + sHeight + '" align="middle">'
		+ '<param name="allowScriptAccess" value="always" />'
		+ '<param name="FlashVars" value="' + fVars + '">'
		+ '<param name="movie" value="' + fSrc + '">'
		+ '<param name="wmode" value="' + fWmode + '">'
		+ '<param name="bgcolor" value="' + fBgcolor + '">'
		+ '<param name="quality" value="high">'
		+ '<param name="menu" value="false">'
		+ '<embed src="' + fSrc + '" pluginspage="' + _protocol + '//www.macromedia.com/go/getflashplayer"'
		+ ' type="application/x-shockwave-flash"'
		+ ' id="' + fId + '" name="' + fName + '"'
		+ ' FlashVars="' + fVars + '" wmode="' + fWmode + '" '
		+ ' menu="false" quality="high" bgcolor="' + fBgcolor + '" align="middle" allowScriptAccess="always" '
		+ ' width="' + sWidth + '" height="' + sHeight + '">'
		+ '</embed></object>'
		+ '';
        document.write(str);
    }

    /**
    * 이미지 확대보기
    * @param imgSrc 이미지 경로
    * @param pW
    * @param pH
    * @param pL
    * @param pT
    */
    var popupImg;
    function popImgWin(imgSrc, pW, pH, pL, pT) {


        var viewSrc;
        var src1, src2;
        if (imgSrc.lastIndexOf("/") > -1) {
            src1 = imgSrc.substring(0, imgSrc.lastIndexOf("/") + 1);
            src2 = imgSrc.slice(imgSrc.lastIndexOf("/") + 1);
        } else {
            src1 = "";
            src2 = imgSrc;
        }
        viewSrc = src1 + escape(decodeURI(src2)); //이미지명 인코딩 한글 파일명일경우 에러
        popupImg = new Image();
        popupImg.src = viewSrc;
        popImgWin0(viewSrc, pW, pH, pL, pT);
    }
    function popImgWin0(imgSrc, pW, pH, pL, pT) {


        if (popupImg.complete == false) {
            setTimeout("popImgWin0('" + imgSrc + "'," + pW + "," + pH + "," + pL + "," + pT + ")", 200);
            return;
        }
        pW = popupImg.width + 16;
        pH = popupImg.height + 2;

        viewSrc = imgSrc;

        var swfPattern = /\.(swf|wmv)$/ig; //확장자 플래시 패턴
        var imgPattern = /\.(jpg|gif|bmp|png)$/ig; //이미지 확장자 패턴

        var strhtml = "";



        //이미지 파일 이라면
        if (imgPattern.test(imgSrc)) {

            strhtml += "<html><head><title>이미지확대보기</title><style>body{margin:0;}</style>";
            strhtml += "<s" + "cript language=\"JavaScript\">";
            strhtml += "function win_resize(){";
            strhtml += "var imgWidth  = parseInt(document.content_img.offsetWidth);";
            strhtml += "var imgHeight = parseInt(document.content_img.offsetHeight);";
            strhtml += "var winWidth  = window.screen.width;";
            strhtml += "var winHeight  = window.screen.height;";
            strhtml += "var reWidth,reHeight;";
            strhtml += "if(imgWidth>winWidth-26){";
            strhtml += "reWidth  = winWidth-26;";
            strhtml += "}else{";
            strhtml += "reWidth = imgWidth+26;";
            strhtml += "}";
            strhtml += "if(imgHeight>winHeight-26){";
            strhtml += "reHeight = winHeight-26;";
            strhtml += "}else{";
            strhtml += "reHeight = imgHeight+26;";
            strhtml += "}";
            //       strhtml += "window.resizeTo(reWidth,reHeight);";
            strhtml += "window.moveTo(parseInt((winWidth-reWidth)/2),parseInt((winHeight-reHeight)/2));";
            strhtml += "window.focus();";
            strhtml += "}";
            strhtml += "</s" + "cript>";
            strhtml += "</head><body onload='win_resize()'>";
            strhtml += "<table width='100%' height='100%' cellspacing='0' cellpadding='0'><tr>";
            strhtml += "<td align='center' valign='center'>";
            strhtml += "<img src='" + viewSrc + "' name='content_img' id='content_img' border=0 onclick='window.close();' style='cursor:hand;'>";
            strhtml += "</td></tr></table></body></html>";
        } else {
            if (pW == 100) pW = 400;
            if (pH == 100) pH = 300;

            strhtml += "<html><head><title>확대보기</title><style>body{margin:0;}</style>";
            strhtml += "</head><body>";
            strhtml += "<table width='100%' height='100%' cellspacing='0' cellpadding='0'><tr>";
            strhtml += "<td align='center' valign='center'>";
            strhtml += "<embed src='" + viewSrc + "' width='100%' height='100%'>";
            strhtml += "</td></tr></table></body></html>";
        }

        if (typeof (pL) == "undefined") pL = parseInt((window.screen.width - pW) / 2); //해상도가로
        if (typeof (pT) == "undefined") pT = parseInt((window.screen.height - pH) / 2); //해상도세로

        var imageWin = window.open('', "imageWin", "width=" + pW + ",height=" + pH + ",left=" + pL + ",top=" + pT + ",scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,location=no,directories=no");
        imageWin.document.open();
        imageWin.document.write(strhtml);
        imageWin.document.close();
        imageWin.focus();
    }

 
 
    function memberin() {

        if (document.getElementById('btn_member').outerHTML.indexOf("top_icon04", 0) != -1)
            location.href = "memberReg.aspx";
        else
            location.href = "memberReg1.aspx?mode=1";
    }

    function loginon() {

        if (document.getElementById('btn_login').outerHTML.indexOf("icon03", 0) != -1) {  //login

            if (document.getElementById('login_div').style.display == "") {
                document.getElementById('login_div').style.display = "none";
                document.getElementById('logintb').style.display = "none";
            }
            else {
                document.getElementById('login_div').style.display = "";
                document.getElementById('logintb').style.display = "";
            }
        }
        else //logout
        {
            ftLogOut();
        }

    }
    function Loginclose() {
        document.getElementById('login_div').style.display = "none";
        document.getElementById('logintb').style.display = "none";
    }
    function ftLogin() {
        var id = document.getElementById('login_id').value;
        var pw = document.getElementById('login_pw').value;
        if (id == "") {
            alert("아이디를 입력하십시오.");
            document.getElementById('login_id').focus();
            return;
        }
        if (pw == "") {
            alert("비밀번호를 입력하십시오.");
            document.getElementById('login_pw').focus();
            return;
        }

        var ctext = id + "|" + pw;
        $.ajax({
            type: "POST",
            url: "ajax.aspx",
            data: { "type": "login", "cText": ctext },
            dataType: "text",
            timeout: 10000,
            error: function() {
                //alert("error");
            },
            success: function(rt) {
                if (rt != "") {
                    if (rt == "FnoID") {
                        alert("등록되지않은 아이디입니다.")
                        document.getElementById("login_id").focus();
                    }
                    else if (rt == "FnoPW") {
                        alert("비밀번호가 틀립니다.")
                        document.getElementById("login_pw").focus();
                    }
                    else if (rt.length > 30) {
                        alert("로그인 실패했습니다.  다시해주세요")
                    }
                    else {

                        //id 저장
                        if (document.getElementById('chk_idsave').value == "1")
                            setCookie("ToinseId", id, 30);
                        else {
                            clearCookie("ToinseId");
                            document.getElementById("login_id").value = "";

                        }
                        document.getElementById('login_div').style.display = "none"
                        document.getElementById('logintb').style.display = "none"
                        if (topctrl == "")
                            document.getElementById("btn_login").src = "./images/main/top_icon05.png";
                        else
                            document.getElementById("btn_login").src = "./images/sub/top/top_icon05.png";

                        document.getElementById("btn_login").style.width = '43px';
                        document.getElementById("btn_login").className = "png24";

                        if (topctrl == "")
                            document.getElementById("btn_member").src = "./images/main/top_icon06.png";
                        else
                            document.getElementById("btn_member").src = "./images/sub/top/top_icon06.png";
                        document.getElementById("btn_member").className = "png24";
                        document.getElementById("login_pw").value = "";
                        //   document.getElementById("btn_mylink").style.display = "";
                        //   document.getElementById("btn_mylink1").style.display = "";
                        alert(rt + "님 환영합니다.");
                        try{
                        init();
                        }catch(e){}
                    }

                }
            }
        });

    }
    function ftLogOut() {
        $.ajax({
            type: "POST",
            url: "ajax.aspx",
            data: { "type": "logout" },
            dataType: "text",
            timeout: 10000,
            error: function() {
                //alert("error");
            },
            success: function(rt) {
                if (topctrl == "")
                    document.getElementById("btn_login").src = "./images/main/top_icon03.png";
                else
                    document.getElementById("btn_login").src = "./images/sub/top/top_icon03.png";
                document.getElementById("btn_login").style.width = '34px';
                document.getElementById("btn_login").className = "png24";

                if (topctrl == "")
                    document.getElementById("btn_member").src = "./images/main/top_icon04.png";
                else
                    document.getElementById("btn_member").src = "./images/sub/top/top_icon04.png";
                document.getElementById("btn_member").className = "png24";
             //   document.getElementById("btn_mylink").style.display = "none";
             //   document.getElementById("btn_mylink1").style.display = "none";
            }
        });
    }

    function load_cookie_id() {
        try {
            var memid = getCookie("ToinseId");
            if (memid != "") {
                document.getElementById("login_id").value = memid;
                document.getElementById("chk_idsave").checked = true;

            }
        } catch (e) { }
    }


    var topctrl = "";

    function ftSessionck() {
        var obj = document.getElementById("query");
        if (obj == null)
            topctrl = "TopControl1$";
        else
            topctrl = "";
        load_cookie_id();
        $.ajax({
            type: "POST",
            url: "ajax.aspx",
            data: { "type": "sessionck" },
            dataType: "text",
            timeout: 10000,
            error: function() {
                //alert("error");
            },
            success: function(rt) {
                var art = rt.split("|");
                if (art[0] == "") {
                    if (topctrl == "")
                        document.getElementById("btn_login").src = "./images/main/top_icon03.png";
                    else
                        document.getElementById("btn_login").src = "./images/sub/top/top_icon03.png";
                    document.getElementById("btn_login").style.width = '34px';
                    document.getElementById("btn_login").className = "png24";
                    
                    if (topctrl == "")
                        document.getElementById("btn_member").src = "./images/main/top_icon04.png";
                    else
                        document.getElementById("btn_member").src = "./images/sub/top/top_icon04.png";
                    document.getElementById("btn_member").className = "png24";


                }
                else {

                    if (topctrl == "")
                        document.getElementById("btn_login").src = "./images/main/top_icon05.png";
                    else
                        document.getElementById("btn_login").src = "./images/sub/top/top_icon05.png";

                    document.getElementById("btn_login").style.width = '43px';
                    document.getElementById("btn_login").className = "png24";

                    if (topctrl == "")
                        document.getElementById("btn_member").src = "./images/main/top_icon06.png";
                    else
                        document.getElementById("btn_member").src = "./images/sub/top/top_icon06.png";
                    document.getElementById("btn_member").className = "png24";

               //     document.getElementById("btn_mylink").style.display = "";
               //     document.getElementById("btn_mylink1").style.display = "";
                }

            }
        });
//        if (iep_vs == 6)
//            document.getElementById("mylinkclose").style.display = '';
//        
        
    }


//    var mylinkTrCnt = 0; 
//    function mylink(bdip) {
//        var obj = document.getElementById('mylink');
//        if (bdip == null || bdip == 'undefined') {
//            if (obj.style.display == "none") {
//                obj.style.display = "";
//            }
//            else {
//                obj.style.display = "none"
//                return;

//            }
//        }

//        $.ajax({
//            type: "POST",
//            url: "ajax.aspx",
//            data: { "type": "mylink" },
//            dataType: "text",
//            timeout: 10000,
//            error: function() {
//                //alert("error");
//            },
//            success: function(rt) {
//                var idx = 1;
//                mylinkTrCnt = 0;
//                var memo = "<table id='tb_mylink' style='table-layout : fixed;width:150px;'>";
//                if (rt != "") {

//                    var arr = rt.split("|")
//                    for (i = 0; i < arr.length - 1; i++) {
//                        if (arr[i] == "")
//                            continue;
//                        var vals = arr[i].split("^");

//                        memo += "<tr onclick='mylinkclick(this)'><td class='ellipsis' style='width:150px;'>" + vals[1] + "</td><td style='display:none;width:0px'>" + vals[0] + "</td></tr>";
//                        ++mylinkTrCnt;
//                        if (newmylinkTrIdx == vals[0])
//                            idx = i;
//                    }
//                }
//                memo += " </table>";
//                obj = document.getElementById("mylinkGroup");
//                obj.innerHTML = memo;
//                try {
//                    obj = obj.children[0].children[0].children[idx];

//                } catch (e) { obj = null; };
//                newmylinkTrIdx = "0";
//                mylinkclick(obj);

//            }
//        });
//    }




//    var mylinkTrS = null;
//    function mylinkclickS(obj) {
//        if (mylinkTrS != null)
//            mylinkTrS.style.backgroundColor = "#ffffff";
//        obj.style.backgroundColor = "#dddddd";
//        mylinkTrS = obj;
//        document.getElementById(topctrl+"txtmlsite").value = obj.children[0].innerText; ;
//        document.getElementById(topctrl + "txtmlurl").value = obj.children[1].innerText; ;
//        document.getElementById(topctrl + "txtmlcomment").value = obj.children[2].innerText; ;
//    }

//   var newmylinkTrIdx = "0";   
//   var mylinkTr = null;
//   function mylinkclick(obj) {
//        ctext = "";
//        if (obj != null)
//            ctext = obj.children[1].innerText;


//        $.ajax({
//            type: "POST",
//            url: "ajax.aspx",
//            data: { "type": "mylinkSite", "cText": ctext },
//            dataType: "text",
//            timeout: 10000,
//            error: function() {
//                //alert("error");
//            },
//            success: function(rt) {
//                var memo = "<table id='tb_mylinkS' style='table-layout : fixed;width:736px;'>";
//                cnt = 1;
//                if (rt != "") {

//                    var arr = rt.split("|")
//                    for (i = 0; i < arr.length - 1; i++) {
//                        if (arr[i] == "")
//                            continue;
//                        var vals = arr[i].split("^");
//                        var url = vals[2];
//                        url = url.toLowerCase();
//                        if (url.substr(0, 7) != "http://" && url.substr(0, 6) != "ftp://")
//                            url = "http://" + vals[2];
//                        else
//                            url = vals[2];

//                        memo += "<tr onclick='mylinkclickS(this)'>";
//                        memo += "<td style='width:109px;padding-left:1px;padding-right:3px' class='ellipsis'>" + vals[1] + "</td>";
//                        memo += "<td style='width:309px;padding-right:3px;' class='ellipsis'><a href='" + url + "' target='_blank' >" + vals[2] + "</a></td>";
//                        memo += "<td style='width:300px;' class='ellipsis'><div class='ellipsis' style='width:300px'>" + vals[3] + "</div></td>";
//                        memo += "<td style='display:none;width:0px'>" + vals[0] + "</td></tr>";

//                    }
//                    cnt = arr.length;
//                }

//                if (mylinkTrCnt > cnt) {

//                    while (cnt <= mylinkTrCnt) {
//                        memo += "<tr><td colspan='4'>&nbsp;</td></tr>"
//                        ++cnt;
//                    }

//                }
//                memo += " </table>";
//                document.getElementById("mylinkSite").innerHTML = memo;



//            }
//        });
//        if (obj != null) {
//            if (mylinkTr != null)
//                mylinkTr.style.backgroundColor = "#ffffff";
//            obj.style.backgroundColor = "#dddddd";
//            mylinkTr = obj;

//            document.getElementById(topctrl + "txtmlgroup").value = obj.children[0].innerText; 
//        }
//        mylinkTrS = null;
//        document.getElementById(topctrl + "txtmlsite").value = "";
//        document.getElementById(topctrl + "txtmlurl").value = "";
//        document.getElementById(topctrl + "txtmlcomment").value = "";
//   
//    }


//    function mylinkadd() {
//        ctext = document.getElementById(topctrl + "txtmlgroup").value;
//        ctext.trim();
//        if (ctext == "")
//            return;
//        $.ajax({
//            type: "POST",
//            url: "ajax.aspx",
//            data: { "type": "mylinkadd", "cText": ctext },
//            dataType: "text",
//            timeout: 10000,
//            error: function() {
//                //alert("error");
//            },
//            success: function(rt) {

//                if (rt != "") {
//                    newmylinkTrIdx = rt;
//                    mylink(1);
//                    document.getElementById(topctrl + "txtmlgroup").value = "";
//                }

//            }
//        });
//    }
//    function mylinkSadd() {


//        obj = document.getElementById(topctrl + "txtmlsite");
//        if (obj.value == "") {
//            alert("사이트명을 입력하세요");
//            obj.focus();
//            return;
//        }
//        ctext = obj.value + "|";
//        obj = document.getElementById(topctrl + "txtmlurl");
//        if (obj.value == "") {
//            alert("URL을 입력하세요");
//            obj.focus();
//            return;
//        }
//        ctext += obj.value + "|" + document.getElementById(topctrl + "txtmlcomment").value + "|" + mylinkTr.children[1].innerText;
//        $.ajax({
//            type: "POST",
//            url: "ajax.aspx",
//            data: { "type": "mylinkSadd", "cText": ctext },
//            dataType: "text",
//            timeout: 10000,
//            error: function() {
//                //alert("error");
//            },
//            success: function(rt) {

//                if (rt != "") {
//                    mylinkclick(mylinkTr);
//                    document.getElementById(topctrl + "txtmlsite").value = "";
//                    document.getElementById(topctrl + "txtmlurl").value = "";
//                    document.getElementById(topctrl + "txtmlcomment").value = "";
//                    mylinkTrS = null;
//                } 
//            }
//        });
//    }

//    function mylinkmodi() {

//        if (mylinkTr == null)
//            return;
//        ctext = document.getElementById(topctrl + "txtmlgroup").value;
//        ctext.trim();
//        if (ctext == "")
//            return;
//        $.ajax({
//            type: "POST",
//            url: "ajax.aspx",
//            data: { "type": "mylinkmodi", "cText": ctext + "|" + mylinkTr.children[1].innerText },
//            dataType: "text",
//            timeout: 10000,
//            error: function() {
//                //alert("error");
//            },
//            success: function(rt) {

//                if (rt != "") {

//                    mylinkTr.children[0].innerText = ctext;
//                }

//            }
//        });
//    }

//    function mylinkSmodi() {

//        if (mylinkTrS == null)
//            return;
//        obj = document.getElementById(topctrl + "txtmlsite");
//        if (obj.value == "") {
//            alert("사이트명을 입력하세요");
//            obj.focus();
//            return;
//        }
//        ctext = obj.value + "|";
//        obj = document.getElementById(topctrl + "txtmlurl");
//        if (obj.value == "") {
//            alert("URL을 입력하세요");
//            obj.focus();
//            return;
//        }
//        ctext += obj.value + "|" + document.getElementById(topctrl + "txtmlcomment").value + "|" + mylinkTrS.children[3].innerText;
//        $.ajax({
//            type: "POST",
//            url: "ajax.aspx",
//            data: { "type": "mylinkSmodi", "cText": ctext },
//            dataType: "text",
//            timeout: 10000,
//            error: function() {
//                //alert("error");
//            },
//            success: function(rt) {

//                if (rt != "") {

//                    mylinkTrS.children[0].innerText = document.getElementById(topctrl + "txtmlsite").value;
//                    url = document.getElementById(topctrl + "txtmlurl").value;
//                    url1 = url.toLowerCase(); ;
//                    if (url1.substr(0, 7) != "http://" && url1.substr(0, 6) != "ftp://")
//                        url1 = "http://" + url;
//                    else
//                        url1 = url;
//                    mylinkTrS.children[1].innerHTML = "<a href='" + url1 + "' target='_blank' >" + url + "</a>";
//                    mylinkTrS.children[2].innerText = document.getElementById(topctrl + "txtmlcomment").value;
//                }

//            }
//        });
//    }

//    function mylinkdel() {

//        if (mylinkTr == null)
//            return;

//        if (ftConfirm("delete") == false)
//            return;

//        ctext = mylinkTr.children[1].innerText;
//        $.ajax({
//            type: "POST",
//            url: "ajax.aspx",
//            data: { "type": "mylinkdel", "cText": ctext },
//            dataType: "text",
//            timeout: 10000,
//            error: function() {
//                //alert("error");
//            },
//            success: function(rt) {

//                if (rt != "") {

//                    mylink(1);
//                }

//            }
//        });
//    }
//    function mylinkSdel() {

//        if (mylinkTrS == null)
//            return;
//        if (ftConfirm("delete") == false)
//            return;
//        ctext = mylinkTrS.children[3].innerText;
//        $.ajax({
//            type: "POST",
//            url: "ajax.aspx",
//            data: { "type": "mylinkSdel", "cText": ctext },
//            dataType: "text",
//            timeout: 10000,
//            error: function() {
//                //alert("error");
//            },
//            success: function(rt) {

//                if (rt != "") {

//                    mylinkclick(mylinkTr)
//                    mylinkTrS = null;
//                }

//            }
//        });
//    }
//    function mylinkedit() {

//        if (document.getElementById('btn_login').outerHTML.indexOf("icon03", 0) != -1) {  //login
//            alert("로그인 해야 등록할수 있습니다.");
//            return;
//        }

//        obj = document.getElementById("mylinkbtnexpand");
//        if (obj.outerHTML.indexOf("collapse", 0) == -1) {
//            obj.src = "./images/main/btn_collapse.gif";
//            document.getElementById("mylinkedit").style.display = "";
//            document.getElementById("mylinkeditbtn").style.display = "";
//            document.getElementById("mylinkeditbtn1").style.display = "";
//            
//        }
//        else {
//            obj.src = "./images/main/btn_expand.gif";
//            document.getElementById("mylinkedit").style.display = "none";
//            document.getElementById("mylinkeditbtn").style.display = "none";
//            document.getElementById("mylinkeditbtn1").style.display = "none";
//        }
//   }