if (typeof C2 == 'undefined') C2 = {};
if (typeof C2.page == 'undefined') C2.page = {
    c1: {
        openMiniHP:
            function (pStrId) {
                document.cookie = 'MINIHP=tid' + '=; path=/;domain=cyworld.com';
                return window.open('http://minihp.cyworld.com/pims/main/pims_main.asp?tid='+pStrId, 'person_info', 'height=538,width=932,scrollbars=no,resizable=yes');
            },
        openTownHP:
            function (pStrId) {
                document.cookie = 'MINIHP=tid' + '=; path=/;domain=cyworld.com';
                return window.open('http://town.cyworld.com/pims/main/pims_main.asp?tid='+pStrId, 'person_info', 'height=538,width=932,scrollbars=no,resizable=yes');
            },
        // 사진첩
        openImgBBS:
            function (pStrId, pIntBoardNo, pIntItemSeq) {
                return C2.page.c1.openBBS(pStrId, '2', pIntBoardNo, pIntItemSeq);
            },
        // 게시판
        openBBS:
            function (pStrId, pStrBoardType, pIntBoardNo, pIntItemSeq) {
                document.cookie = 'MINIHP=tid' + '=; path=/;domain=cyworld.com';
                return window.open('http://cyworld.com/common/pims_hub.asp?boardtype=' + pStrBoardType + '&tid=' +pStrId+'&board_no='+pIntBoardNo+'&search_type=&search_keyword=&item_seq='+pIntItemSeq,'person_info_i','height=538,width=932,scrollbars=no,resizable=yes');
            },
        openDiary:
            function (pStrId, pStrDday) {
                document.cookie = 'MINIHP=tid' + '=; path=/;domain=cyworld.com';
                return window.open('http://minihp.cyworld.com/pims/main/pims_diary.asp?tid='+pStrId+'&urlstr=diar&urlstrsub=schedule&toyearmonday='+pStrDday, 'diary', 'height=538,width=932,scrollbars=no,resizable=yes');
            }
    },
    openHome:
        function (pStrId) {
            return window.open("http://cyhome.cyworld.com/?home_id=" + pStrId + '&mf=', '_new');
        },
    openDocument:
        function (pStrId, pIntPostSeq) {
            return window.open('http://cyhome.cyworld.com/myhompy/index.php?home_id='+pStrId+'&postSeq='+pIntPostSeq, 'myhome');
        },
    getMemberType:
        function (pStrId) {
            if (pStrId.substr(0, 1) >= '1' && pStrId.substr(0, 1) <= '6')
                return 'c1';
            else if (pStrId.substr(0, 1) >= '7' && pStrId.substr(0, 1) <= '8')
                return 'town';
            else if (pStrId.substr(0, 1) >= 'a' && pStrId.substr(0, 1) <= 't')
                return 'c2';
            else
                return 'c1';
        },
    openUserHome:
        function (pStrId) {
            switch (C2.page.getMemberType(pStrId)) {
                case 'c1':
                    C2.page.c1.openMiniHP(pStrId);
                    break;
                case 'town':
                    C2.page.c1.openTownHP(pStrId);
                    break;
                case 'c2':
                    var win = C2.page.openHome(pStrId);
                    win.focus();
            }
            return;
        },

    openMainHome:
        function (pStrId) {
            var mainId = C2.page.getMainID(pStrId);
            C2.page.openUserHome(mainId);
        },
    getMainID:
        function (pStrId) {
            var strType = C2.page.getMemberType(pStrId);
            if(strType == 'c2' || strType == 'town')
                return pStrId;

            var strAjaxUrl = "/common/interfaceICacheAjax.php";
            var arrParameter = { id: pStrId }; 
            var res = Swaf.Ajax.ajaxSyncRequest(strAjaxUrl, 'get', 'JSON', arrParameter);

            if(res.isSuccess())
                return res.value.id;	
            
            return pStrId;
        }
};
