﻿var Common =
{

    //el: 'LimitLayerArea',
    LayerOpen: function (path, width, height) {

        //        var ifmback = document.createElement('iframe');
        //        ifmback.src = '/Background.htm';
        //        ifmback.id = 'ifmBack';
        //        ifmback.style.position = 'absolute';
        //        ifmback.src
        //        ifmback.style.left = '0';
        //        ifmback.style.top = '0';
        //        ifmback.style.filter = 'alpha(opacity=50)';
        //        ifmback.style.MozOpacity = '0.5';
        //        ifmback.style.backgroundColor = '#000';
        //        ifmback.frameBorder = '0';
        //        ifmback.width = parseInt(document.body.clientWidth) + 'px';
        //        ifmback.height = parseInt(document.body.scrollHeight) + 'px';
        //        ifmback.style.margin = '0';
        //        document.body.appendChild(ifmback);
        var ifmlimit = document.createElement('iframe');
        ifmlimit.src = path;
        ifmlimit.id = 'ifmLimit';
        ifmlimit.style.position = 'absolute';
        ifmlimit.style.left = (parseInt(document.body.clientWidth) / 2) - (parseInt(width) / 2) + 'px';
        ifmlimit.style.top = ((parseInt(document.documentElement.clientHeight) / 2) + (parseInt(document.documentElement.scrollTop))) - (parseInt(height) / 2) + 'px';
        ifmlimit.zIndex = 5000;
        ifmlimit.allowTransparency = 'true';
        ifmlimit.style.backgroundColor = 'transparent';
        ifmlimit.frameBorder = '0';
        ifmlimit.scrolling = 'no';
        ifmlimit.width = width + 'px';
        ifmlimit.height = height + 'px';
        ifmlimit.style.margin = '0';

        document.body.appendChild(ifmlimit);
    },
    LayerClose: function () {
        //document.body.removeChild(document.getElementById('ifmBack'));
        document.body.removeChild(document.getElementById('ifmLimit'));

    },

    LayerOpen2: function (path, width, height, scroll) {

        var ifmLimit2 = document.createElement('iframe');
        ifmLimit2.src = path;
        ifmLimit2.id = 'ifmLimit2';
        ifmLimit2.style.position = 'absolute';
        ifmLimit2.style.left = '20px';
        ifmLimit2.style.top = '10px';
        ifmLimit2.zIndex = 5000;
        ifmLimit2.allowTransparency = 'true';
        ifmLimit2.style.backgroundColor = 'transparent';
        ifmLimit2.frameBorder = '0';
        ifmLimit2.scrolling = "yes";
        ifmLimit2.width = width + 'px';
        ifmLimit2.height = height + 'px';
        ifmLimit2.style.margin = '0';

        document.body.appendChild(ifmLimit2);
    },
    LayerClose2: function () {
        //document.body.removeChild(document.getElementById('ifmBack'));
        document.body.removeChild(document.getElementById('ifmLimit2'));

    },




    CheckAll: function (object) {
        bChecked = (object.checked) ? true : false
        for (i = 0; i < document.frmMain.elements.length; i++) {
            document.frmMain.elements[i].checked = bChecked;
        }
    },

    CheckCommnet: function () {
        var frm = document.frmMain;
        if (!NTO.isValidateEmpty(frm.txtComment, "코멘트 내용을 입력하세요.")) return false;

    },

    CheckContentLen: function () {

        var intLimit = 400;


        var frm = document.frmMain;

        if (NTO.intStrLen(frm.txtComment.value) > intLimit) {
            //alert("덧글은 한글 기준" + intLimit + "자를 넘을수 없습니다.");
            alert("더 이상 덧글을 입력할 수 없습니다.");
            frm.txtComment.value = NTO.substringKor(frm.txtComment.value, intLimit);

        }
    },

    setEditorImageResize: function (intLimit, intSize) {
        var oImg = document.frmMain.EditorImage;

        if (typeof (oImg) == "object") {
            if (oImg.length == undefined) {
                if (oImg.width > intLimit)
                    oImg.width = intSize;
            }
            else {
                for (var i = 0; i < oImg.length; i++) {

                    if (oImg[i].width > intLimit)
                        oImg[i].width = intSize;
                }
            }
        }
    },

    SetImageSize: function (num) {
        var oImg = eval("document.getElementById('ImgUserUpload" + num + "')");

        if (oImg.width > 678)
            oImg.width = 678;
    },

    ImageViewOriginal: function (simg) {

        window.open(Http.Content + 'Common/PopImageView.aspx?fu=' + simg, 'ImageView', 'scrollbars=auto, resizable=yes,width=10,height=10, top=100, left=100');
    },

    LoginDirect: function () {
        document.location.href = Http.Member + '/Login.aspx';
    },

    LoginReferer: function () {

        var strQuerystring = document.location.search;
        if (strQuerystring != '') {
            strQuerystring = strQuerystring.substring(1, strQuerystring.length);
            strQuerystring = escape(strQuerystring);
        }

        var strUrl = document.location.href;
        strUrl = strUrl.split("://");

        if (strQuerystring == '')
            strTransfer = strUrl[1].substring(strUrl[1].indexOf('/'));
        else
            strTransfer = strUrl[1].substring(strUrl[1].indexOf('/'), strUrl[1].indexOf('?'));

        document.location.href = Http.Member + '/Login.aspx?t=' + strTransfer + '&qs=' + strQuerystring;

    },

    LoginConfirm: function () {
        if (confirm('로그인 후 이용가능 합니다.\n\n로그인 페이지로 이동하시겠습니까?')) {
            var strQuerystring = document.location.search;
            if (strQuerystring != '') {
                strQuerystring = strQuerystring.substring(1, strQuerystring.length);
                strQuerystring = escape(strQuerystring);
            }

            var strUrl = document.location.href;
            strUrl = strUrl.split("://");

            if (strQuerystring == '')
                strTransfer = strUrl[1].substring(strUrl[1].indexOf('/'));
            else
                strTransfer = strUrl[1].substring(strUrl[1].indexOf('/'), strUrl[1].indexOf('?'));

            document.location.href = Http.Member + '/Login.aspx?t=' + strTransfer + '&qs=' + strQuerystring;
        }
        else {
            document.body.focus();
        }
    },

    GoLogout: function () {
        document.location.href = Http.Member + "/Login/Logout.aspx";
    },

    isLogin: function () {

        var rtn = false;
        var ckLogin = NTO.fnGetStrCookie("cafemoriidea");
        if (ckLogin == "" || ckLogin == "undefined" || ckLogin == null) {
            rtn = false
        }
        else
            rtn = true;

        return rtn;
    },

    Flash: function (strParamPath, intWidth, intHight) {
        var strObject;
        strObject = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='" + intWidth + "' height='" + intHight + "'  id='sub_navi' align='middle' />" +
					"<param name='allowScriptAccess' value='sameDomain' />" +
					"<param name='movie' value='" + strParamPath + "'/>" +
					"<param name='quality' value='high'/>" +
					"<param name='wmode' value='transparent'>" +
					"<embed src='" + strParamPath + "' quality='high' bgcolor='#000000' width='" + intWidth + "' height='" + intHight + "' name='sub_navi' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />" +
				"</object>"
        document.write(strObject);
    }


}
function popup(url, w, h, scroll, resize) {
    if (scroll) w = w + 17;
    if (!scroll) scroll = 'no'; if (!resize) resize = 'no';
    var winl = (screen.width - w) / 2; var wint = (screen.height - h) / 2;

    var winnameset = url.split('/');
    var winname = winnameset[winnameset.length - 1].split('.')[0];
    winname = winname.replace("(", "_");
    winname = winname.replace(")", "");
    window.open(url, winname, 'width=' + w + ',height=' + h + ',top=' + wint + ',left=' + winl + ',resizable=' + resize + ',scrollbars=' + scroll + ',toolbars=no,status=yes,menu=no');
}
