if (typeof(POPUP_BASIC_NONE_SKIN_JS) == 'undefined') // 한번만 실행
{
    var POPUP_BASIC_NONE_SKIN_JS = true;

    $.clientCoords = function() {
         var dimensions = {width: 0, height: 0};
         if (document.documentElement) {
             dimensions.width = document.documentElement.offsetWidth;
             dimensions.height = document.documentElement.offsetHeight;
         } else if (window.innerWidth && window.innerHeight) {
             dimensions.width = window.innerWidth;
             dimensions.height = window.innerHeight;
         }
         return dimensions;
    }

    $(document).ready(function() {
        $('div[id^=popup-basic-window-]').each(function() {
            var popup_name = $(this).attr('id');
            var popid = popup_name.replace('popup-basic-window-', '');

            if (get_cookie(popup_name) == '') {
                $.get(g4_popup_skin_path + '/get_popup.php', { 'popid': popid }, function(data) {
                    if (data != '') {
                        var popup = eval('(' + data + ')');
                        if (popup['style'] == 'Layer') {
                            if (popup['center']) {
                                popup['left'] = Math.round((coord.width - parseInt(popup['width'])) / 2);
                                popup['top'] = Math.round((coord.height - parseInt(popup['height'])) / 2);
                            }
                            $('#popup-basic-window-' + popup['popid'])
                                   .css('padding', '0')
                                   .html(popup['content'])
                                   .dialog({ position: [parseInt(popup['left']), parseInt(popup['top'])],
                                             width: parseInt(popup['width']),
                                             height: parseInt(popup['height']) + 36,
                                             resizable: false,
                                             title: popup['subject'] })
                                   .find('input[name=close_check]').click(function() {
                                       var popup_name = 'popup-basic-window-' + $(this).val();
                                       if ($(this).attr('checked'))
                                           set_cookie(popup_name, '1', 24, g4_cookie_domain);
                                       $('#' + popup_name).dialog('close');
                                   });
                        }
                        else {
                            if (popup['center']) {
                                popup['left'] = Math.round((screen.width - parseInt(popup['width'])) / 2);
                                popup['top'] = Math.round((screen.height - parseInt(popup['height'])) / 2);
                            }
                            var win = window.open('', popup_name.split('-').join('_'),
                                                  'width=' + popup['width'] + ',height=' + popup['height'] +
                                                  ',left=' + popup['left'] + ',top=' + popup['top'] +
                                                  ',location=no,menubar=no,status=no,toolbar=no' +
                                                  ',resizable=no,scrollbars=no');
                            eval('var ' + popup_name.split('-').join('_') + ' = win;');

                            if (win) {
                                win.document.open();
                                win.document.write(popup['content']);
                                win.document.body.style.margin = 0;
                                win.document.title = popup['subject'];
                                win.document.close();

                                if (typeof(win.document.fcheck.close_check) != 'undefined') {
                                    win.document.fcheck.close_check.onclick = function() {
                                        var popup_name = 'popup-basic-window-' + this.value;
                                        if (this.checked)
                                            set_cookie(popup_name, '1', 24, g4_cookie_domain);
                                        eval(popup_name.split('-').join('_') + '.close();');
                                    }
                                }

                                win.focus();
                            }
                        }
                    }
                });
            }
        });
    });
}

