// ExtのBasicDialogをHTMLのプレビューウィンドウにします
// 2007/09/05 t-koshikawa

//Ext用インラインフレーム高さ自動調整
function getHeight(id, name) {
    document.getElementById(id).height = parent.frames[name].document.body.scrollHeight;
}

var PopupWindow = function(){
    // dialog:ポップアップウィンドウ本体
    // showBtn:ポップアップウィンドウを表示するためのボタン
    var dialog, showBtn;
    return {
        init : function(){
            showBtn = Ext.get('show-dialog-btn');
            showBtn.on('click', this.showDialog, this);
        },
        // ポップアップウィンドウの設定と処理
        showDialog : function(){
            if (!dialog) {
                dialog = new Ext.BasicDialog("preview-dlg", { 
                        autoTabs:true,
                        width:640,
                        height:600,
                        shadow:true,
                        minWidth:30,
                        minHeight:20,
                        proxyDrag:true
                });
                dialog.addKeyListener(27, dialog.hide, dialog);
                // dialog.addButton('最小化', dialog.collapse, dialog);
                dialog.addButton('閉じる', dialog.hide, dialog);
            }
            dialog.show(showBtn.dom);
        }
    };
}();
Ext.onReady(PopupWindow.init, PopupWindow, true);