﻿    var strImageDefaultPath = "/_home_/_design_/";

    function jgUserLogin( )
    {
        window.open( "http://www.justgo.kr/TestLogin.aspx?ReturnUrl="+encodeURIComponent("http://fnlnetworks.testnet.co.kr/SSO/loginLink.aspx?ReturnUrl="+document.location.href), "", "width=300, height=400" );
        //window.open( "https://www.justgo.kr/Member/SignIn.aspx?LoginType=default&ReturnUrl="+encodeURIComponent("http://fnlnetworks.testnet.co.kr/SSO/loginLink.aspx?ReturnUrl="+document.location.href), "", "width=500, height=500" );
        //document.location.href = "http://fnlnetworks.testnet.co.kr/sso/loginTemp.aspx?ReturnUrl="+document.location.href;
    }
    function jgUserLogout( )
    {
        //alert( "logout" );
        document.location.href = "http://fnlnetworks.testnet.co.kr/sso/logoutTemp.aspx";
    }
    function jgUserJoin( )
    {
        alert( "회원가입" );
    }
    function jgUserModify( )
    {
        alert( "정보수정" );
    }

    //검색기 2010.07.22 신장순 1. justgo 통합검색에 팝업//링크
    function GoSearch() {
        var SWord = document.getElementById("top_search");
        
        //document.location.href = "http://www.justgo.kr/UnitySearch/Default.aspx?KeyWord=" + encodeURIComponent(SWord.value);
        window.open('http://www.justgo.kr/UnitySearch/Default.aspx?KeyWord=' + encodeURIComponent(SWord.value), 'JustGoSearch');
    }

    //시작페이지 구현 2010.07.22 신장순
    function goSetHomepage() {
        document.body.style.behavior = 'url(#default#homepage)';
        document.body.setHomePage('http://www.justgotravelguide.com'); 
    }
    
    //즐겨찾기 추가 구현 2010.07.22 신장순
    function goSetBookmark( )
    {
        window.external.AddFavorite('http://www.justgotravelguide.com', '여행인 - JustGo')
    }

    function pop_jgGoLocationInfo(lid, addString) {
        opener.location.href = "/default.aspx?lid=" + lid + addString;
        self.close();
    }

    function jgGoLocationInfo( lid, addString )
    {
        document.location.href = "/default.aspx?lid="+lid+addString;
    }

    function pop_jgGoLocationInfo_Ifr(lid, addString) {
        opener.location.href = "/Ifr_Default.aspx?lid=" + lid + addString + "&ifr=y";
        self.close();
    }

    function jgGoLocationInfo_Ifr(lid, addString) {
        document.location.href = "/Ifr_Default.aspx?lid=" + lid + addString + "&ifr=y";
    }

    function jgGoGallery( lid, uid )
    {
        alert( "갤러리" );
    }

    function jgMapOnOff( type )
    {
        switch ( type ) {
            case 1: {
                if ( document.getElementById("main_search_1").style.display != "" ) {
                    document.getElementById("main_search_1").style.display = "";
                    //document.getElementById("main_search_2").style.display = "none";
                    document.getElementById("main_search_3").style.display = "none";
                }
                else {
                    document.getElementById("main_search_1").style.display = "none";
                    //document.getElementById("main_search_2").style.display = "none";
                    document.getElementById("main_search_3").style.display = "";
                }
                break;
            }
            case 2: {
                alert("빠른검색");
                //if ( document.getElementById("main_search_1").style.display != "" ) {
                //    document.getElementById("main_search_1").style.display = "none";
                //    //document.getElementById("main_search_2").style.display = "";
                //    document.getElementById("main_search_3").style.display = "none";
                //}
                //else {
                //    document.getElementById("main_search_1").style.display = "none";
                //    //document.getElementById("main_search_2").style.display = "none";
                //    document.getElementById("main_search_3").style.display = "";
                //}
                break;
            }
            case 3:
                {
                    document.getElementById("main_search_1").style.display = "";
                    document.getElementById("main_search_3").style.display = "none";
                    break;
                }
        }
    }

    function goAirReservation( type )
    {
        var strURL = new Array();

        strURL[0] = "";
        strURL[1] = "전세계 저가 항공권 예약";
        strURL[2] = "전세계 비즈니스 항공권 예약";
        strURL[3] = "전세계 퍼스트클래스 항공권 예약";

        alert( strURL[type] );
    }

  // 게시물 Comment 달기(동적생성)
    function insertCommentForm4Location( comment_uid )
    {
        var string_innerHTML = "";
            string_innerHTML = "    <li class=\"reply\">                                                                                           \n"
                             + "        <form id=\"frmComment\" name=\"frmComment\" onSubmit=\"return checkFormComment(this);\">                   \n"
                             + "            <input type=\"hidden\" id=\"lid\"   name=\"lid\"   value=\"" + pLid         + "\">                     \n"
                             + "            <input type=\"hidden\" id=\"hUid\"  name=\"hUid\"  value=\"" + pHotplaceUid + "\">                     \n"
                             + "            <input type=\"hidden\" id=\"eUid\"  name=\"eUid\"  value=\"" + pEtcUid      + "\">                     \n"
                             + "            <input type=\"hidden\" id=\"eMode\" name=\"eMode\" value=\"reply\">                                    \n"
                             + "            <input type=\"hidden\" id=\"bUid\"  name=\"bUid\"  value=\"" + pBoardUid    + "\">                     \n"
                             + "            <input type=\"hidden\" id=\"userId\" name=\"userId\" value=\""+ pUserId    +  "\">                     \n"
                             + "            <input type=\"hidden\" id=\"pCommentUid\" name=\"pCommentUid\" value=\""+ comment_uid    +  "\">       \n"
                             + "        <dl>                                                                                                       \n"
                             + "            <dt class=\"comment_reply_name\">작성자 : "+ pUserId +"</dt>                                                  \n"
                             + "            <dd class=\"comment_reply_con\">                                                                       \n"
                             + "                <textarea id=\"comment\" name=\"comment\" class=\"input_comment_write\"></textarea>                \n"
                             + "            </dd>                                                                                                  \n"
                             + "            <dd class=\"comment_reply_btn\">                                                                       \n"
                             + "                <input type=image src=\""+strImageDefaultPath+"/images/btn_spot_comment.gif\" alt=\"답글등록\">    \n"
                             + "            </dd>                                                                                                  \n"
                             + "        </dl>                                                                                                      \n"
                             + "        </form>                                                                                                    \n"
                             + "    </li>                                                                                                          \n"
                             ;

            document.getElementById("locationComment_"+comment_uid).innerHTML = string_innerHTML;
            document.getElementById("locationComment_"+comment_uid).style.display = "";

    }

    function getCookie( name )
    {
        var nameOfCookie = name + "=";
        var x            = 0;
        var y            = 0;

        while ( x <= document.cookie.length ) {
            y = (x+nameOfCookie.length);
            if ( document.cookie.substring( x, y ) == nameOfCookie ) {
                if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
                    endOfCookie = document.cookie.length;
                return unescape( document.cookie.substring( y, endOfCookie ) );
            }
            x = document.cookie.indexOf( " ", x ) + 1;
            if ( x == 0 )
                break;
        }
        return "";
    }

    //alert( getCookie("MMIF_MEID") );


    function showChangeImage( smallObject )
    {
        var bigObject   = document.getElementById("bigImage");
        var smallObject = smallObject;

        bigObject.src = smallObject.src;
    }
    function showChangeImageURL(ImageURL) {
        var bigObject = document.getElementById("bigImage");
        var smallObject = ImageURL;
        
        bigObject.src = smallObject;
    }

    /* ================================================================
    이미지 보여주기 위한 function .. //실이미지와 설정이미지 크기를 조절 (현재 필요 없음)
    ===================================================================*/
    function showChangeImageURL_2(ImageURL, re_W, re_H) {
        var time;
        var imgFile = new Image();
        var bigObject = document.getElementById("bigImage");

        imgFile.src = ImageURL;
        
        //리사이징이 안되는경우가 있음.. 아예이미지가 안나옴.
        //이미지 로드가 되기전에 리사이징으로 인해 폭과 높이를 못가져온상태서 해서 그런것 같음.그래서 setTimeout 사용
        if (imgFile.width == 0 || imgFile.height == 0) {
            time = setTimeout("showChangeImageURL_2('" + ImageURL + "', '" + re_W + "', '" + re_H + "')", 500);
        }
        else {
            clearTimeout(time);
        }
        bigObject.src = imgFile.src;
        bigObject.width = imgFile.width;
        bigObject.height = imgFile.height;

        //alert(bigObject.width + ', ' + bigObject.height);
        //썸네일 이미지를 설정된 폭과 높이에 맞는 비율로 변환한다.
        imgcheck(bigObject, true, re_W, re_H);
    }
    
    //targetImg : 객체명, bool값 
    //이미지 함수를 처리 한다. 이미지 자동으로 줄여줌
    function imgcheck(imgObj, bool, re_W, re_H) {
        //alert("imgcheck : " + imgObj.width + ',' + imgObj.height);
        //time = setTimeout("", 1000);
        var imgWidth = re_W; //설정 이미지 폭값
        var imgHeight = re_H; //설정 이미지 높이값

        if (bool) {
            var O_Width = imgObj.width; //이미지의 실제 폭
            var O_Height = imgObj.height; //이미지의 실제 높이
            var ReWidth = O_Width; //변화된 폭 저장 변수
            var ReHeight = O_Height; //변화된 높이 저장 변수
            
            if (O_Width >= O_Height) {
                if (ReWidth > imgWidth) {
                    ReWidth = imgWidth;
                    ReHeight = (O_Height * ReWidth) / O_Width;
                }

                if (ReHeight > imgHeight) {
                    ReWidth = (ReWidth * imgHeight) / ReHeight;
                    ReHeight = imgHeight;
                }
            }
            else {
                if (ReHeight > imgHeight) {
                    ReHeight = imgHeight;
                    ReWidth = (O_Width * ReHeight) / O_Height;
                }
                
                if (ReWidth > imgWidth) {
                    ReHeight = (ReHeight * imgWidth) / ReWidth;
                    ReWidth = imgWidth;
                }                
            }
            //alert("Result : " + ReWidth + '=' + ReHeight);
            imgObj.width = ReWidth;
            imgObj.height = ReHeight;
            //alert(ReWidth + ',' + ReHeight);
            imgObj.alt = ReWidth + ',' + ReHeight;
            
        }
        else {
            //이미지 에러 있을경우 
            //안보이게 스타일 시트로 처리
            //imgObj.style.display = 'none';
        }
        //clearTimeout(time);
    }

    function imgcheck_2(imgObj, bool, re_W, re_H) {
        alert("imgcheck : " + imgObj.width + ',' + imgObj.height);
        //time = setTimeout("", 1000);
        var imgWidth = re_W; //설정 이미지 폭값
        var imgHeight = re_H; //설정 이미지 높이값

        if (bool) {
            var O_Width = imgObj.width; //이미지의 실제 폭
            var O_Height = imgObj.height; //이미지의 실제 높이
            var ReWidth = O_Width; //변화된 폭 저장 변수
            var ReHeight = O_Height; //변화된 높이 저장 변수

            if (O_Width >= O_Height) {
                if (ReWidth > imgWidth) {
                    ReWidth = imgWidth;
                    ReHeight = (O_Height * ReWidth) / O_Width;
                }

                if (ReHeight > imgHeight) {
                    ReWidth = (ReWidth * imgHeight) / ReHeight;
                    ReHeight = imgHeight;
                }
            }
            else {
                if (ReHeight > imgHeight) {
                    ReHeight = imgHeight;
                    ReWidth = (O_Width * ReHeight) / O_Height;
                }

                if (ReWidth > imgWidth) {
                    ReHeight = (ReHeight * imgWidth) / ReWidth;
                    ReWidth = imgWidth;
                }
            }
            //alert("Result : " + ReWidth + '=' + ReHeight);
            imgObj.width = ReWidth;
            imgObj.height = ReHeight;
            alert(ReWidth + ',' + ReHeight);
            imgObj.alt = ReWidth + ',' + ReHeight;

        }
        else {
            //이미지 에러 있을경우 
            //안보이게 스타일 시트로 처리
            //imgObj.style.display = 'none';
        }
        //clearTimeout(time);
    }

